快捷方式

torch.Tensor.module_load

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

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

get_swap_module_params_on_conversion()True 时使用。

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

注意

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

参数

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源