sách gpt4 ai đã đi

python - 如何使用 mmconvert 将 tensorflow 模型(InceptionResnetV2 pb 文件)转换为 pytorch 模型?

In lại 作者:行者123 更新时间:2023-12-01 05:49:07 39 4
mua khóa gpt4 Nike

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 模型(inception resnet v2 的 pb 文件)转换为 pytorch 模型以使用 mmdnn。

我使用 pb 文件 (resnet_v1_50, inception_v3) 获得了 2 个模型的成功结果,但是当我尝试转换 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].
Theo dõi (cuộc gọi gần đây nhất là cuộc gọi cuối cùng):
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]

1 Câu trả lời

而是 mmconvertBạn có thể sử dụng tf2onnx将 Tensorflow 转换为 ONNX 的包。然后你可以加载 .onnx模型并将其另存为 .pth .

关于python - 如何使用 mmconvert 将 tensorflow 模型(InceptionResnetV2 pb 文件)转换为 pytorch 模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57193146/

39 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com