Shortcuts

torch.Tensor.module_load

Tensor.module_load(other, assign=False)[源代码]

定义了在加载到self时如何转换other,在load_state_dict()中。

get_swap_module_params_on_conversion()True 时使用。

预计selfnn.Module中的一个参数或缓冲区,而other是状态字典中具有相应键的值,此方法定义了在通过swap_tensors`()self交换之前如何重新映射other,在module.load_state_dict()中。

注意

此方法应始终返回一个新对象,该对象不是 selfother。 例如,默认实现返回 self.copy_(other).detach() 如果 assignFalseother.detach() 如果 assignTrue

Parameters