pytorch torch.nn.Module.register_buffer

API

register_buffer(name: str, tensor: Optional[torch.Tensor], persistent: bool = True)None

注册buffer,表名不是权重参数。比如BatchNorm的running_mean不是parameter,但是他是模型的state。
buffers,是持久的和parameters一起保存的。

参数 描述
name (string) name of the buffer. The buffer can be accessed from this module using the given name
tensor (Tensor) buffer to be registered.
persistent (bool) whether the buffer is part of this module’s state_dict.

参考:
https://pytorch.org/docs/master/generated/torch.nn.Module.html#torch.nn.Module.register_buffer

你可能感兴趣的:(Python,python)