Skip to content

Commit fedf01f

Browse files
committed
Automatically set test_step_num_episodes to num_test_envs by default
1 parent b7e8b93 commit fedf01f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tianshou/highlevel/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ class TrainingConfig(ToStringMixin):
5252
num_test_envs: int = 1
5353
"""the number of test environments to use"""
5454

55-
test_step_num_episodes: int = 1
55+
test_step_num_episodes: int = -1
5656
"""the total number of episodes to collect in each test step (across all test environments).
57+
58+
-1 means this will be set to the number of test environments, i.e. each test environment
59+
will run exactly one episode per test step.
5760
"""
5861

5962
buffer_size: int = 4096
@@ -147,7 +150,9 @@ def __post_init__(self) -> None:
147150
f"but number of test environments is ({self.num_test_envs}). "
148151
f"This can cause unnecessary memory usage.",
149152
)
150-
153+
if self.test_step_num_episodes == -1:
154+
log.debug(f"Setting test_step_num_episodes to num_test_envs ({self.num_test_envs}) since it was -1.")
155+
self.test_step_num_episodes = self.num_test_envs
151156
if (
152157
self.test_step_num_episodes != 0
153158
and self.test_step_num_episodes % self.num_test_envs != 0

0 commit comments

Comments
 (0)