Table of Contents
Shortcuts

# ParameterList

class torch.nn.ParameterList(values=None)

  Holds parameters in a list.

  `ParameterList` can be used like a regular Python list, but Tensors that are `Parameter` are properly registered, and will be visible by all `Module` methods.

  Note that the constructor, assigning an element of the list, the `append()` method and the `extend()` method will convert any `Tensor` into `Parameter`.

  Parameters:

    parameters (iterable, optional) – an iterable of elements to add to the list.

  Example:

      class MyModule(nn.Module):
          def __init__(self):
              super().__init__()
              self.params = nn.ParameterList([nn.Parameter(torch.randn(10, 10)) for i in range(10)])

          def forward(self, x):
              # ParameterList can act as an iterable, or be indexed using ints
              for i, p in enumerate(self.params):
                  x = self.params[i // 2].mm(x) + p.mm(x)
              return x

  append(value)

    Appends a given value at the end of the list.

    Parameters:

      value (Any) – value to append

    Return type:

      ParameterList

  extend(values)

    Appends values from a Python iterable to the end of the list.

    Parameters:

      values (iterable) – iterable of values to append

    Return type:

      ParameterList

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.