pytorch加载模型torch.load() 遇到问题ModuleNotFoundError: No module named 'models'

希望完整保存模型之后,可以在另外一个地方进行测试使用,但是加载模型时遇到问题

    
 File "/home/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 426, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "/home/anaconda3/lib/python3.7/site-packages/torch/serialization.py", line 613, in _load
    result = unpickler.load()
ModuleNotFoundError: No module named 'models.TextCNN'

 

看到一个github上的解决办法,供参考

https://github.com/pytorch/pytorch/issues/18325

你可能感兴趣的:(pytorch)