Skip to content

Commit

Permalink
[Doc] Minor fixes to comments and docstrings (#2443)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasbbrunner authored Sep 30, 2024
1 parent a0dfddc commit c94d07f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sota-implementations/impala/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def make_ppo_modules_pixels(proof_environment):
out_keys=["common_features"],
)

# Define on head for the policy
# Define one head for the policy
policy_net = MLP(
in_features=common_mlp_output.shape[-1],
out_features=num_outputs,
Expand Down
6 changes: 3 additions & 3 deletions torchrl/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,9 +2136,9 @@ def reset(
self._assert_tensordict_shape(tensordict)

tensordict_reset = self._reset(tensordict, **kwargs)
# We assume that this is done properly
# if reset.device != self.device:
# reset = reset.to(self.device, non_blocking=True)
# We assume that this is done properly
# if reset.device != self.device:
# reset = reset.to(self.device, non_blocking=True)
if tensordict_reset is tensordict:
raise RuntimeError(
"EnvBase._reset should return outplace changes to the input "
Expand Down
2 changes: 1 addition & 1 deletion torchrl/envs/libs/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ class GymEnv(GymWrapper):
pixels_only (bool, optional): if ``True``, only the pixel observations will
be returned (by default under the ``"pixels"`` entry in the output tensordict).
If ``False``, observations (eg, states) and pixels will be returned
whenever ``from_pixels=True``. Defaults to ``True``.
whenever ``from_pixels=True``. Defaults to ``False``.
frame_skip (int, optional): if provided, indicates for how many steps the
same action is to be repeated. The observation returned will be the
last observation of the sequence, whereas the reward will be the sum
Expand Down
12 changes: 6 additions & 6 deletions torchrl/envs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@


ACTION_MASK_ERROR = RuntimeError(
"An out-of-bounds actions has been provided to an env with an 'action_mask' output."
" If you are using a custom policy, make sure to take the action mask into account when computing the output."
" If you are using a default policy, please add the torchrl.envs.transforms.ActionMask transform to your environment."
"An out-of-bounds actions has been provided to an env with an 'action_mask' output. "
"If you are using a custom policy, make sure to take the action mask into account when computing the output. "
"If you are using a default policy, please add the torchrl.envs.transforms.ActionMask transform to your environment. "
"If you are using a ParallelEnv or another batched inventor, "
"make sure to add the transform to the ParallelEnv (and not to the sub-environments)."
" For more info on using action masks, see the docs at: "
"https://pytorch.org/rl/reference/envs.html#environments-with-masked-actions"
"make sure to add the transform to the ParallelEnv (and not to the sub-environments). "
"For more info on using action masks, see the docs at: "
"https://pytorch.org/rl/main/reference/envs.html#environments-with-masked-actions"
)


Expand Down
4 changes: 2 additions & 2 deletions torchrl/modules/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ class TanhNormal(FasterTransformedDistribution):
.. math::
loc = tanh(loc / upscale) * upscale.
min (torch.Tensor or number, optional): minimum value of the distribution. Default is -1.0;
max (torch.Tensor or number, optional): maximum value of the distribution. Default is 1.0;
low (torch.Tensor or number, optional): minimum value of the distribution. Default is -1.0;
high (torch.Tensor or number, optional): maximum value of the distribution. Default is 1.0;
event_dims (int, optional): number of dimensions describing the action.
Default is 1. Setting ``event_dims`` to ``0`` will result in a log-probability that has the same shape
as the input, ``1`` will reduce (sum over) the last dimension, ``2`` the last two etc.
Expand Down
2 changes: 1 addition & 1 deletion torchrl/objectives/value/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _fast_vec_gae(
``[*Batch x TimeSteps x F]``, with ``F`` feature dimensions.
"""
# _gen_num_per_traj and _split_and_pad_sequence need
# _get_num_per_traj and _split_and_pad_sequence need
# time dimension at last position
done = done.transpose(-2, -1)
terminated = terminated.transpose(-2, -1)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/sphinx-tutorials/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
# * :meth:`EnvBase._reset`, which codes for the resetting of the simulator
# at a (potentially random) initial state;
# * :meth:`EnvBase._step` which codes for the state transition dynamic;
# * :meth:`EnvBase._set_seed`` which implements the seeding mechanism;
# * :meth:`EnvBase._set_seed` which implements the seeding mechanism;
# * the environment specs.
#
# Let us first describe the problem at hand: we would like to model a simple
Expand Down
2 changes: 1 addition & 1 deletion tutorials/sphinx-tutorials/torchrl_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def env_make(env_name):
###############################################################################
# Transforming parallel environments
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# There are two equivalent ways of transforming parallen environments: in each
# There are two equivalent ways of transforming parallel environments: in each
# process separately, or on the main process. It is even possible to do both.
# One can therefore think carefully about the transform design to leverage the
# device capabilities (e.g. transforms on cuda devices) and vectorizing
Expand Down

1 comment on commit c94d07f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'CPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: c94d07f Previous: a0dfddc Ratio
benchmarks/test_replaybuffer_benchmark.py::test_rb_sample[TensorDictPrioritizedReplayBuffer-LazyMemmapStorage-None-10000] 707.1265808426921 iter/sec (stddev: 0.028300047483102594) 1625.4706835210693 iter/sec (stddev: 0.000047963200007486906) 2.30

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.