import onnx # 加载ONNX模型 model_path = "model.onnx" model = onnx.load(model_path) # 遍历模型的图结构,获取每一层的节点属性 for node in model.graph.node: # 输出节点名称和类型 print(f"Node Name: {node.name}") print(f"Node Type: {node.op_type}") # 遍历节点的属性,输出属性名称和值 for attr in node.attribute: print(f" Attribute Name: {attr.name}") #print(f" Attribute Value: {attr.ints or attr.floats or attr.strings or attr.graph or attr.sparse_tensor or attr.tensor}")
标签:node,attr,onnx,获取,print,model,属性 From: https://www.cnblogs.com/LuckCoder/p/17247325.html