Compare commits

...

1 Commits

Author SHA1 Message Date
b1abd9ec11 Test myst-markdown in docstrings 2025-07-23 09:32:38 -07:00

View File

@ -19,13 +19,13 @@ class _ParameterMeta(torch._C._TensorMeta):
class Parameter(torch.Tensor, metaclass=_ParameterMeta): class Parameter(torch.Tensor, metaclass=_ParameterMeta):
r"""A kind of Tensor that is to be considered a module parameter. r"""A kind of Tensor that is to be considered a module parameter.
Parameters are :class:`~torch.Tensor` subclasses, that have a Parameters are {class}`~torch.Tensor` subclasses, that have a
very special property when used with :class:`Module` s - when they're very special property when used with {class}`Module` s - when they're
assigned as Module attributes they are automatically added to the list of assigned as Module attributes they are automatically added to the list of
its parameters, and will appear e.g. in :meth:`~Module.parameters` iterator. its parameters, and will appear e.g. in {meth}`~Module.parameters` iterator.
Assigning a Tensor doesn't have such effect. This is because one might Assigning a Tensor doesn't have such effect. This is because one might
want to cache some temporary state, like last hidden state of the RNN, in want to cache some temporary state, like last hidden state of the RNN, in
the model. If there was no such class as :class:`Parameter`, these the model. If there was no such class as {class}`Parameter`, these
temporaries would get registered too. temporaries would get registered too.
Args: Args:
@ -33,7 +33,7 @@ class Parameter(torch.Tensor, metaclass=_ParameterMeta):
requires_grad (bool, optional): if the parameter requires gradient. Note that requires_grad (bool, optional): if the parameter requires gradient. Note that
the torch.no_grad() context does NOT affect the default behavior of the torch.no_grad() context does NOT affect the default behavior of
Parameter creation--the Parameter will still have `requires_grad=True` in Parameter creation--the Parameter will still have `requires_grad=True` in
:class:`~no_grad` mode. See :ref:`locally-disable-grad-doc` for more {class}`~no_grad` mode. See {ref}`locally-disable-grad-doc` for more
details. Default: `True` details. Default: `True`
""" """