ONNX修改节点的值
作者:互联网
#新节点
conv1_node = onnx.helper.make_node(
name="Conv_40", # Name is optional.
op_type="Conv",
# Must follow the order of input and output definitions.
# https://github.com/onnx/onnx/blob/rel-1.9.0/docs/Operators.md#inputs-2---3
inputs=["input", "backbone.patch_embed.proj.weight", "backbone.patch_embed.proj.bias"],
outputs=["268"],
# The following arguments are attributes.
kernel_shape=[4,4,4],
strides=[4,4,4],
dilations=[4,4,4],
group=1,
pads=[0,0,0,0,0,0]
)
onnx_model = onnx.load(onnxfile)
graph = onnx_model.graph
graph.node.remove(node)
graph.node.insert(584, conv1_node)
onnx.checker.check_model(onnx_model)
onnx.save(onnx_model, onnxfile)
参考文章:
https://leimao.github.io/blog/ONNX-Python-API/
https://github.com/onnx/onnx/issues/2259
标签:node,github,ONNX,修改,graph,https,onnx,model,节点 来源: https://blog.csdn.net/sinat_26253653/article/details/122733641