Buffer¶
- class torch.nn.parameter.Buffer(data=None, *, persistent=True)[source]¶
A kind of Tensor that should not be considered a model parameter. For example, BatchNorm’s
running_mean
is not a parameter, but is part of the module’s state.Buffers are
Tensor
subclasses, that have a very special property when used withModule
s – when they’re assigned as Module attributes they are automatically added to the list of its 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 using theregister_buffer()
function.