Open nestyme opened 4 years ago
@nestyme , thank you very much for the feedback. You need to keep the model module in the same folder when loading the serialized model. Please refer to https://github.com/pytorch/pytorch/issues/18325 and https://github.com/pytorch/pytorch/issues/18325 for solution.
Platform (like ubuntu 16.04/win10): Ubuntu 16.04.5 LTS
Python version: Python 3.7
Source framework with version (like Tensorflow 1.4.1 with GPU): PyTorch 1.6.0
Destination framework with version (like CNTK 2.3 with GPU): TensorFlow 2.2.0
Pre-trained model path (webpath or webdisk path): A Structured Self-attentive Sentence Embedding model
I'm saving my model with torch.save(model, model path) then I'm trying to convert Pytorch model to TF via
mmconvert -sf pytorch -in model.pth -df tensorflow -om model.ckpt
I getTraceback (most recent call last): File "/usr/local/bin/mmconvert", line 10, in <module> sys.exit(_main()) File "/usr/local/lib/python3.6/dist-packages/mmdnn/conversion/_script/convert.py", line 102, in _main ret = convertToIR._convert(ir_args) File "/usr/local/lib/python3.6/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 97, in _convert parser = PytorchParser151(model, inputshape[0]) File "/usr/local/lib/python3.6/dist-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 526, in __init__ super(PytorchParser151, self).__init__(model_file_name, input_shape) File "/usr/local/lib/python3.6/dist-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 83, in __init__ model = torch.load(model_file_name, map_location='cpu') File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 584, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 842, in _load result = unpickler.load() AttributeError: Can't get attribute 'SentenceEmbeddingsModel' on <module '__main__' from '/usr/local/bin/mmconvert'>
Could anyone help me, please?)