评价此页

torch.Tensor.module_load#

Tensor.module_load(other, assign=False)[source]#

定义了在 load_state_dict() 中加载 otherself 时如何转换 other

get_swap_module_params_on_conversion()True 时使用。

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

注意

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

参数