torch.Tensor.module_load¶
- Tensor.module_load(other, assign=False)[源代码]¶
定义了在加载到
self时如何转换other,在load_state_dict()中。当
get_swap_module_params_on_conversion()为True时使用。预计
self是nn.Module中的一个参数或缓冲区,而other是状态字典中具有相应键的值,此方法定义了在通过swap_tensors`()与self交换之前如何重新映射other,在module.load_state_dict()中。注意
此方法应始终返回一个新对象,该对象不是
self或other。 例如,默认实现返回self.copy_(other).detach()如果assign是False或other.detach()如果assign是True。- Parameters
其他 (张量) – 状态字典中与键对应于
self的值分配 (布尔值) – 传递给
nn.Module.load_state_dict()的分配参数