File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -9225,6 +9225,7 @@ def test_transform_compose(self):
9225
9225
)
9226
9226
def test_transform_env (self , out_key ):
9227
9227
base_env = self .envclass ()
9228
+ torch .manual_seed (0 )
9228
9229
actor = self ._make_actor ()
9229
9230
# we need to patch the env and create a sample_log_prob spec to make check_env_specs happy
9230
9231
env = TransformedEnv (
@@ -9234,6 +9235,7 @@ def test_transform_env(self, out_key):
9234
9235
KLRewardTransform (actor , out_keys = out_key ),
9235
9236
),
9236
9237
)
9238
+ torch .manual_seed (0 )
9237
9239
actor = self ._make_actor ()
9238
9240
td1 = env .rollout (3 , actor )
9239
9241
tdparams = TensorDict (dict (actor .named_parameters ()), []).unflatten_keys ("." )
Original file line number Diff line number Diff line change @@ -1877,8 +1877,7 @@ def look_for_cuda(tensor, has_cuda=has_cuda):
1877
1877
if cmd == "seed" :
1878
1878
if not initialized :
1879
1879
raise RuntimeError ("call 'init' before closing" )
1880
- # torch.manual_seed(data)
1881
- # np.random.seed(data)
1880
+ torch .manual_seed (data [0 ])
1882
1881
new_seed = env .set_seed (data [0 ], static_seed = data [1 ])
1883
1882
child_pipe .send (("seeded" , new_seed ))
1884
1883
Original file line number Diff line number Diff line change @@ -2218,17 +2218,16 @@ def set_seed(
2218
2218
"""Sets the seed of the environment and returns the next seed to be used (which is the input seed if a single environment is present).
2219
2219
2220
2220
Args:
2221
- seed (int): seed to be set
2221
+ seed (int): seed to be set. The seed is set only locally in the environment. To handle the global seed,
2222
+ see :func:`~torch.manual_seed`.
2222
2223
static_seed (bool, optional): if ``True``, the seed is not incremented.
2223
2224
Defaults to False
2224
2225
2225
2226
Returns:
2226
2227
integer representing the "next seed": i.e. the seed that should be
2227
- used for another environment if created concomittently to this environment.
2228
+ used for another environment if created concomitantly to this environment.
2228
2229
2229
2230
"""
2230
- if seed is not None :
2231
- torch .manual_seed (seed )
2232
2231
self ._set_seed (seed )
2233
2232
if seed is not None and not static_seed :
2234
2233
new_seed = seed_generator (seed )
You can’t perform that action at this time.
0 commit comments