InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. In Node, ("Conv_0", Conv, "", -1) : ("x": tensor(float),"conv2d_68.tmp_0Weights": tensor(float),"conv2d_68.tmp_0Bias": tensor(float),) -> ("batch_norm_0.tmp_2": tensor(float),) , Error Unrecognized attribute: output_tensor_shape for operator Conv
unrecognized attribute,用netron 查看模型:
那么我们可以用以下代码对这类属性进行移除:
model = onnx.load('old.onnx')
nodes = model.graph.node
for node in nodes:
attrs=node.attribute
for attr in attrs[:]:
if attr.name in ['excutor','output_tensor_type','output_tensor_shape']:
attrs.remove(attr)
onnx.save(model,'new.onnx')