Platform : ubuntu 16.04
Python version: 3.5.2
mmdnn version : 0.2.5
Source framework with version : Tensorflow 1.14.0 with GPU
Destination framework with version : Pytorch 1.1.0预训练模型路径:
初始resnet v2模型(Tensorflow)(来自https://github.com/tensorflow/models/tree/master/research/slim)
运行脚本:
mmconvert -sf tensorflow -iw inception_resnet_v2_jsy.pb --inNodeName input --inputShape 299,299,3 --dstNodeName InceptionResnetV2/Logits/Logits/BiasAdd -df pytorch -om tf_to_pytorch_inception_resnet_v2.pth你好,
我尝试将tensorflow模型(初始resnet v2的pb文件)转换为使用mmdnn的py呼啸模型。
我在pb文件(resnet_v1_50,inception_v3)的两个模型中获得了成功的结果,但是当我试图转换inception_resnet_v2时,我得到了以下错误。
有没有人有一些想法来解决这些问题或解释这些问题?
Error logs.
IR network structure is saved as [09db48a5839944eeb4492ee2a0959097.json].
IR network structure is saved as [09db48a5839944eeb4492ee2a0959097.pb].
IR weights are saved as [09db48a5839944eeb4492ee2a0959097.npy].
Parse file [09db48a5839944eeb4492ee2a0959097.pb] with binary format successfully.
Target network code snippet is saved as [tf_to_pytorch_inception_resnet_v2.py].
Target weights are saved as [09db48a5839944eeb4492ee2a0959097.npy].
Traceback (most recent call last):
File "/usr/local/bin/mmconvert", line 11, in
sys.exit(_main())
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convert.py", line 112, in _main
dump_code(args.dstFramework, network_filename + '.py', temp_filename + '.npy', args.outputModel, args.dump_tag)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/dump_code.py", line 32, in dump_code
save_model(MainModel, network_filepath, weight_filepath, dump_filepath)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/pytorch/saver.py", line 5, in save_model
model = MainModel.KitModel(weight_filepath)
File "tf_to_pytorch_inception_resnet_v2.py", line 476, in init
self.InceptionResnetV2_Logits_Logits_MatMul = self.__dense(name = 'InceptionResnetV2/Logits/Logits/MatMul', in_features = -1, out_features = 1001, bias = True)
File "tf_to_pytorch_inception_resnet_v2.py", line 1444, in __dense
layer = nn.Linear(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/linear.py", line 76, in init
self.weight = Parameter(torch.Tensor(out_features, in_features))
RuntimeError: Trying to create tensor with negative dimension -1: [1001, -1]发布于 2019-11-19 10:23:43
相反,mmconvert可以使用tf2onnx包将Tensorflow转换为ONNX。然后可以加载.onnx模型并将其保存为.pth。
https://stackoverflow.com/questions/57193146
复制相似问题