Skip to content

Commit b4f4daf

Browse files
committed
[Doc] Fix links in doc (#2151)
(cherry picked from commit 5b9cb44)
1 parent 78ce8b5 commit b4f4daf

File tree

7 files changed

+27
-21
lines changed

7 files changed

+27
-21
lines changed

docs/source/reference/data.rst

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ widely used replay buffers:
2424
Composable Replay Buffers
2525
-------------------------
2626

27+
.. _ref_buffers:
28+
2729
We also give users the ability to compose a replay buffer.
2830
We provide a wide panel of solutions for replay buffer usage, including support for
2931
almost any data type; storage in memory, on device or on physical memory;
@@ -796,6 +798,8 @@ such that they can be stacked together during sampling.
796798
TensorSpec
797799
----------
798800

801+
.. _ref_specs:
802+
799803
The `TensorSpec` parent class and subclasses define the basic properties of observations and actions in TorchRL, such
800804
as shape, device, dtype and domain.
801805
It is important that your environment specs match the input and output that it sends and receives, as

docs/source/reference/envs.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function.
133133
transform.
134134

135135

136-
Our environment `tutorial <https://pytorch.org/rl/tutorials/pendulum.html>`_
136+
Our environment :ref:`tutorial <pendulum_tuto>`
137137
provides more information on how to design a custom environment from scratch.
138138

139139
.. autosummary::
@@ -559,7 +559,7 @@ Transforms
559559
In most cases, the raw output of an environment must be treated before being passed to another object (such as a
560560
policy or a value operator). To do this, TorchRL provides a set of transforms that aim at reproducing the transform
561561
logic of `torch.distributions.Transform` and `torchvision.transforms`.
562-
Our environment `tutorial <https://pytorch.org/rl/tutorials/pendulum.html>`_
562+
Our environment :ref:`tutorial <pendulum_tuto>`
563563
provides more information on how to design a custom transform.
564564

565565
Transformed environments are build using the :class:`TransformedEnv` primitive.

docs/source/reference/trainers.rst

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
torchrl.trainers package
44
========================
55

6+
.. _ref_trainers:
7+
68
The trainer package provides utilities to write re-usable training scripts. The core idea is to use a
79
trainer that implements a nested loop, where the outer loop runs the data collection steps and the inner
810
loop the optimization steps. We believe this fits multiple RL training schemes, such as

tutorials/sphinx-tutorials/coding_dqn.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# - how to build an environment in TorchRL, including transforms (e.g. data
3636
# normalization, frame concatenation, resizing and turning to grayscale)
3737
# and parallel execution. Unlike what we did in the
38-
# `DDPG tutorial <https://pytorch.org/rl/tutorials/coding_ddpg.html>`_, we
38+
# :ref:`DDPG tutorial <coding_ddpg>`, we
3939
# will normalize the pixels and not the state vector.
4040
# - how to design a :class:`~torchrl.modules.QValueActor` object, i.e. an actor
4141
# that estimates the action values and picks up the action with the highest
@@ -46,7 +46,7 @@
4646
# - and finally how to evaluate your model.
4747
#
4848
# **Prerequisites**: We encourage you to get familiar with torchrl through the
49-
# `PPO tutorial <https://pytorch.org/rl/tutorials/coding_ppo.html>`_ first.
49+
# :ref:`PPO tutorial <coding_ppo>` first.
5050
#
5151
# DQN
5252
# ---
@@ -393,8 +393,8 @@ def get_replay_buffer(buffer_size, n_optim, batch_size):
393393
# Data collector
394394
# ~~~~~~~~~~~~~~
395395
#
396-
# As in `PPO <https://pytorch.org/rl/tutorials/coding_ppo.html>`_ and
397-
# `DDPG <https://pytorch.org/rl/tutorials/coding_ddpg.html>`_, we will be using
396+
# As in :ref:`PPO <coding_ppo>` and
397+
# :ref:`DDPG <coding_ddpg>`, we will be using
398398
# a data collector as a dataloader in the outer loop.
399399
#
400400
# We choose the following configuration: we will be running a series of
@@ -691,7 +691,7 @@ def get_loss_module(actor, gamma):
691691
# In this case, a location must be explicitly passed (). This method gives
692692
# more control over the location of the hook but it also requires more
693693
# understanding of the Trainer mechanism.
694-
# Check the `trainer documentation <https://pytorch.org/rl/reference/trainers.html>`_
694+
# Check the :ref:`trainer documentation <ref_trainers>`
695695
# for a detailed description of the trainer hooks.
696696
#
697697
trainer.register_op("post_optim", target_net_updater.step)
@@ -768,7 +768,7 @@ def print_csv_files_in_folder(folder_path):
768768
# - A prioritized replay buffer could also be used. This will give a
769769
# higher priority to samples that have the worst value accuracy.
770770
# Learn more on the
771-
# `replay buffer section <https://pytorch.org/rl/reference/data.html#composable-replay-buffers>`_
771+
# :ref:`replay buffer section <ref_buffers>`
772772
# of the documentation.
773773
# - A distributional loss (see :class:`~torchrl.objectives.DistributionalDQNLoss`
774774
# for more information).

tutorials/sphinx-tutorials/coding_ppo.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
2727
We will cover six crucial components of TorchRL:
2828
29-
* `environments <https://pytorch.org/rl/reference/envs.html>`__
30-
* `transforms <https://pytorch.org/rl/reference/envs.html#transforms>`__
31-
* `models (policy and value function) <https://pytorch.org/rl/reference/modules.html>`__
32-
* `loss modules <https://pytorch.org/rl/reference/objectives.html>`__
33-
* `data collectors <https://pytorch.org/rl/reference/collectors.html>`__
34-
* `replay buffers <https://pytorch.org/rl/reference/data.html#replay-buffers>`__
29+
* :ref:`environments <Environment-API>`
30+
* :ref:`transforms <transforms>`
31+
* :ref:`models <ref_modules>`
32+
* :ref:`loss modules <ref_objectives>`
33+
* :ref:`data collectors <ref_collectors>`
34+
* :ref:`replay buffers <ref_buffers>`
3535
3636
"""
3737

@@ -478,7 +478,7 @@
478478
# Data collector
479479
# --------------
480480
#
481-
# TorchRL provides a set of `DataCollector classes <https://pytorch.org/rl/reference/collectors.html>`__.
481+
# TorchRL provides a set of :ref:`DataCollector classes <ref_collectors>`.
482482
# Briefly, these classes execute three operations: reset an environment,
483483
# compute an action given the latest observation, execute a step in the environment,
484484
# and repeat the last two steps until the environment signals a stop (or reaches

tutorials/sphinx-tutorials/multiagent_ppo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
# TorchRL API allows integrating various types of multi-agent environment flavours.
184184
# Some examples include environments with shared or individual agent rewards, done flags, and observations.
185185
# For more information on how the multi-agent environments API works in TorchRL, you can check out the dedicated
186-
# `doc section <https://pytorch.org/rl/reference/envs.html#multi-agent-environments>`_.
186+
# :ref:`doc section <MARL-environment-API>`.
187187
#
188188
# The VMAS simulator, in particular, models agents with individual rewards, info, observations, and actions, but
189189
# with a collective done flag.
@@ -784,7 +784,7 @@
784784
#
785785
# If you are interested in creating or wrapping your own multi-agent environments in TorchRL,
786786
# you can check out the dedicated
787-
# `doc section <https://pytorch.org/rl/reference/envs.html#multi-agent-environments>`_.
787+
# :ref:`doc section <MARL-environment-API>`.
788788
#
789789
# Finally, you can modify the parameters of this tutorial to try many other configurations and scenarios
790790
# to become a MARL master.

tutorials/sphinx-tutorials/pendulum.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
3434
In the process, we will touch three crucial components of TorchRL:
3535
36-
* `environments <https://pytorch.org/rl/reference/envs.html>`__
37-
* `transforms <https://pytorch.org/rl/reference/envs.html#transforms>`__
38-
* `models (policy and value function) <https://pytorch.org/rl/reference/modules.html>`__
36+
* :ref:`environments <Environment-API>`
37+
* :ref:`transforms <transforms>`
38+
* :ref:`models <ref_modules>`
3939
4040
"""
4141

@@ -389,7 +389,7 @@ def _reset(self, tensordict):
389389
# convenient shortcuts to the content of the output and input spec containers.
390390
#
391391
# TorchRL offers multiple :class:`~torchrl.data.TensorSpec`
392-
# `subclasses <https://pytorch.org/rl/reference/data.html#tensorspec>`_ to
392+
# :ref:`subclasses <ref_specs>` to
393393
# encode the environment's input and output characteristics.
394394
#
395395
# Specs shape

0 commit comments

Comments
 (0)