Skip to content

Commit 2f3b4cd

Browse files
author
Vincent Moens
committed
[Doc] Fix tutorials
ghstack-source-id: 6c91143 Pull Request resolved: #2560
1 parent 7051238 commit 2f3b4cd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tutorials/sphinx-tutorials/torchrl_demo.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,9 @@
415415
TransformedEnv,
416416
)
417417

418-
base_env = GymEnv("Pendulum-v1", frame_skip=3, from_pixels=True, pixels_only=False)
418+
base_env = GymEnv("HalfCheetah-v4", frame_skip=3, from_pixels=True, pixels_only=False)
419419
env = TransformedEnv(base_env, Compose(NoopResetEnv(3), ToTensorImage()))
420-
env.append_transform(ObservationNorm(in_keys=["pixels"], loc=2, scale=1))
421-
422-
###############################################################################
420+
env = env.append_transform(ObservationNorm(in_keys=["pixels"], loc=2, scale=1))
423421

424422
env.reset()
425423

tutorials/sphinx-tutorials/torchrl_envs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,11 @@ def env_make(env_name):
694694

695695
make_env = EnvCreator(lambda: TransformedEnv(GymEnv("CartPole-v1"), VecNorm(decay=1.0)))
696696
env = ParallelEnv(3, make_env)
697-
make_env.state_dict()["_extra_state"]["td"]["observation_count"].fill_(0.0)
698-
make_env.state_dict()["_extra_state"]["td"]["observation_ssq"].fill_(0.0)
699-
make_env.state_dict()["_extra_state"]["td"]["observation_sum"].fill_(0.0)
697+
print("env state dict:")
698+
sd = TensorDict(make_env.state_dict())
699+
print(sd)
700+
# Zeroes all tensors
701+
sd *= 0
700702

701703
tensordict = env.rollout(max_steps=5)
702704

0 commit comments

Comments
 (0)