UninitializedParameter

class torch.nn.parameter.UninitializedParameter [source]

A parameter that is not initialized.

Unitialized Parameters are a a special case of torch.nn.Parameter where the shape of the data is still unknown.

Unlikely a torch.nn.Parameter, uninitialized parameters hold no data and attempting to access some properties, like their shape, will throw a runtime error. The only operations that can be performed on a uninitialized parameter are changing its datatype, moving it to a different device and converting it to a regular torch.nn.Parameter.

materialize(shape, device=None, dtype=None) [source]

Create a Parameter with the same properties of the uninitialized one. Given a shape, it materializes a parameter in the same device and with the same dtype as the current one or the specified ones in the arguments.

Parameters
  • shape – (tuple): the shape for the materialized tensor.
  • device (torch.device) – the desired device of the parameters and buffers in this module. Optional.
  • dtype (torch.dtype) – the desired floating point type of the floating point parameters and buffers in this module. Optional.

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.nn.parameter.UninitializedParameter.html