model = VGGish() # vgg model class
model.train(False)
x = torch.randn(10, 1, 64, 96, requires_grad=True)
# Export the model
torch_out = torch.onnx._export(model, # model being run`enter code here`
x, # model input (or a tuple for multiple inputs)
"super_resolution.onnx", # where to save the model (can be a file or file-like object)
export_params=True) # store the trained parameter weights inside the model file
model = onnx.load("modelsVGGish_conv.onnx")
onnx.checker.check_model(model)
onnx.helper.printable_graph(model.graph)
rep = backend.prepare(model, device="CPU") # or "CPU"
当程序运行到这段代码
rep = backend.prepare(model, device="CPU") # or "CPU"
发生错误:
Traceback (most recent call last):
File "C:/Users/xxx/Desktop/python/新建文件夹/onnx_to_caffe2.py", line 159, in <module>
rep = backend.prepare(model, device="CPU") # or "CPU"
File "D:\environment\Anaconda\lib\site-packages\caffe2\python\onnx\backend.py", line 713, in prepare
init_net, predict_net = cls._onnx_model_to_caffe2_net(model, device, opset_version, False)
File "D:\environment\Anaconda\lib\site-packages\caffe2\python\onnx\backend.py", line 876, in _onnx_model_to_caffe2_net
onnx_model = onnx.utils.polish_model(onnx_model)
File "D:\environment\Anaconda\lib\site-packages\onnx\utils.py", line 21, in polish_model
model = onnx.optimizer.optimize(model)
File "D:\environment\Anaconda\lib\site-packages\onnx\optimizer.py", line 55, in optimize
optimized_model_str = C.optimize(model_str, passes)
IndexError: invalid unordered_map<K, T> key
简直让我抓狂!</p>
任何人都可以帮助我吗?