torch.Tensor.module_load¶
- Tensor.module_load(other, assign=False)[source][source]¶
定义如何在
load_state_dict()中加载other时将其转换为self。当
get_swap_module_params_on_conversion()是True时使用。预期
self是一个参数或缓冲区,nn.Module和other是状态字典中对应键的值,此方法定义了在通过swap_tensors()与self交换之前如何重映射other。注意
此方法应始终返回一个新对象,该对象不是
self或other。例如,默认实现返回self.copy_(other).detach()如果assign是False,或者返回other.detach()如果assign是True。- 参数:
其他(Tensor)- 状态字典中与
self键对应的值assign(布尔值)- 传递给
nn.Module.load_state_dict()的 assign 参数