我将 TF 模型转换为 ONNX,然后将 ONNX 模型转换为 Caffe2。转换成功发生。但是,尝试从获得的模型加载和推断时出现运行时错误。
这是我收到的错误。如何将属性“is_true”添加到 SpatialBN 节点?
我浏览了 pytorch repo 并看到了这个问题,但是,它没有得到解决。在 ONNX here的代码库中,它添加is_test
了 opset >=7 的属性,我使用的是 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 }