Parameter#
- classtorch.nn.parameter.Parameter(data=None,requires_grad=True)[source]#
A kind of Tensor that is to be considered a module parameter.
Parameters are
Tensorsubclasses, that have avery special property when used withModules - when they’reassigned as Module attributes they are automatically added to the list ofits parameters, and will appear e.g. inparameters()iterator.Assigning a Tensor doesn’t have such effect. This is because one mightwant to cache some temporary state, like last hidden state of the RNN, inthe model. If there was no such class asParameter, thesetemporaries would get registered too.- Parameters
data (Tensor) – parameter tensor.
requires_grad (bool,optional) – if the parameter requires gradient. Note thatthe torch.no_grad() context does NOT affect the default behavior ofParameter creation–the Parameter will still haverequires_grad=True in
no_gradmode. SeeLocally disabling gradient computation for moredetails. Default:True