修改onnx输入输出维度

import onnx
model = onnx.load("end2end.onnx")

print(model.graph.input)
print(model.graph.output)

model.graph.input[0].type.tensor_type.shape.dim[0].dim_value=1
model.graph.output[0].type.tensor_type.shape.dim[0].dim_value=1
model.graph.output[1].type.tensor_type.shape.dim[0].dim_value=1
#若onnx输入输出为fp16,可以修改elem_type=1,变成fp32

onnx.checker.check_model(model)
onnx.save(model,"out.onnx")


你可能感兴趣的:(python,开发语言)