pytorch torch.nn.Module.register

tech2024-04-22  45

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 nametensor (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

最新回复(0)