快捷方式

torch.Tensor.module_load

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

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

get_swap_module_params_on_conversion()True 时使用。

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

注意

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

参数

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源