【发布时间】:2020-11-23 17:15:21
【问题描述】:
我将一个 TF 模型转换为 ONNX,然后将 ONNX 模型转换为 Caffe2。转换成功发生。但是,在尝试从获得的模型中加载和推断时,我遇到了运行时错误。
这是我收到的错误。如何将属性“is_true”添加到 SpatialBN 节点?
我浏览了 pytorch repo 并看到了这个 issue,但是,它尚未解决。
在 ONNX here 的代码库中,它为 opset >=7 添加了is_test 属性,我使用的是 8。但是,它仍然给出错误。
[W common_gpu.cc:35] Insufficient cuda driver. Cannot use cuda.
[W init.h:137] Caffe2 GlobalInit should be run before any other API calls.
[W init.h:137] Caffe2 GlobalInit should be run before any other API calls.
[W predictor_config.cc:90] Caffe2 is compiled without optimization passes.
[E operator_schema.cc:101] Argument 'is_test' is required for Operator 'SpatialBN'.
Traceback (most recent call last):
File "main.py", line 91, in <module>
test_caffe("mod-caffe-net.pb", "mod-caffe-init-net.pb", "../data/mouth")
File "main.py", line 70, in test_caffe
predictor = workspace.Predictor(param_values, model_net)
File "/home/ubuntu/.local/lib/python3.6/site-packages/caffe2/python/workspace.py", line 187, in Predictor
return C.Predictor(StringifyProto(init_net), StringifyProto(predict_net))
RuntimeError: [enforce fail at operator.cc:199] schema->Verify(operator_def). Operator def did not pass schema checking: input: "conv1/Relu:0" input: "batchNorm1/gamma/read/_1__cf__1:0" input: "batchNorm1/beta/read/_0__cf__0:0" input: "batchNorm2/moving_mean/read/_6__cf__6:0" input: "batchNorm1/moving_variance/read/_3__cf__3:0" output: "batchNorm1/FusedBatchNorm:0" name: "batchNorm1/FusedBatchNorm" type: "SpatialBN" arg { name: "epsilon" f: 0.001 } device_option { device_type: 0 device_id: 0 }
【问题讨论】:
-
有什么理由不使用较新的 opset,例如 12?
-
这是默认设置,因此,坚持这一点。我尝试了 9 和 10。但是,我面临一个不同的错误。
op Conv: Source for input conv1/kernel/read/_17__cf__17:0 is unknown for net tf2onnx, operator input: "conv1/BiasAdd__8:0"
标签: inference onnx caffe2 onnxruntime