前言
半路接手项目,阅读代码,解决bug,优化速度。
part one
- 1050 Ti加载模型时OOM
model.load_state_dict(torch.load(path))
Copies parameters and buffers from :attr:
state_dict
into
this module and its descendants. If :attr:strict
isTrue
, then
the keys of :attr:state_dict
must exactly match the keys returned
by this module’s :meth:~torch.nn.Module.state_dict
function.
Arguments:
state_dict (dict): a dict containing parameters and
persistent buffers.
strict (bool, optional): whether to strictly enforce that the keys
in :attr:state_dict
match the keys returned by this module’s
:meth:~torch.nn.Module.state_dict
function. Default:True
2019/1/16补:
其实问题是出在main函数,当时一直没考虑到(因为Java中必须得主函数作为运行入口,Python不强求,所以写Python代码没养成好习惯)。
所以,尽量写