Buffer#
- classtorch.nn.parameter.Buffer(data=None,*,persistent=True)[source]#
A kind of Tensor that should not be considered a modelparameter. For example, BatchNorm’s
running_meanis not a parameter, but is part of the module’s state.Buffers are
Tensorsubclasses, that have avery special property when used withModules – when they’reassigned as Module attributes they are automatically added to the list ofits buffers, and will appear e.g. inbuffers()iterator.Assigning a Tensor doesn’t have such effect. One can still assign a Tensor as explicitly by usingtheregister_buffer()function.