mindspore.nn.Buffer
- class mindspore.nn.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 Cell's state.
Buffers are
Tensor
subclasses, that have a very special property when used withCell
s: when they're assigned as Cell attributes they are automatically added to the list of its buffers, and will appear e.g. inmindspore.nn.Cell.buffers()
iterator. Assigning a tensor doesn't have such effect. One can still assign a tensor as a buffer explicitly by using themindspore.nn.Cell.register_buffer()
function.