torch.Tensor.module_load
- Tensor.module_load(other, assign=False)[源代码]
-
定义了在调用
load_state_dict()将other加载到self时,如何转换other。当
get_swap_module_params_on_conversion()为True时使用。预期
self是nn.Module中的一个参数或缓冲区,而other是在状态字典中与之对应的值。此方法定义了在load_state_dict()调用swap_tensors()之前,如何重新映射other并与self进行交换。注意
此方法应始终返回一个新的对象,该对象既不是
self也不是other。例如,默认实现当assign为False时返回self.copy_(other).detach(),而当assign为True时则返回other.detach()。