当前位置:网站首页>By onnx checker. check_ Common errors detected by model
By onnx checker. check_ Common errors detected by model
2022-04-23 07:28:00 【wujpbb7】
error 1:“Field 'name' of graph is required to be non-empty.”
solve : Yes model.graph.name assignment .
error 2:“Nodes in a graph must be topologically sorted, however input ...”
solve : Adjust node order , Ensure that the input of each node exists before it .
The reference codes are as follows :
def check_update_model(model):
if (model.graph.name == ''):
model.graph.name = 'tackle_checker_error'
try:
onnx.checker.check_model(model)
except onnx.checker.ValidationError as e:
print("model is invalid: %s"%(e))
# At present, only this error is considered “ Nodes in a graph must be topologically sorted, however input ...”,
# There is a problem with the node order of the model ,onnxruntime It can be inferred , For other engines like trt It can be inferred , Adjust the node order .
else:
return model
print('update model ...')
new_model = onnx.ModelProto(ir_version=model.ir_version,
producer_name=model.producer_name,
producer_version=model.producer_version,
opset_import=model.opset_import)
new_model.graph.name = model.graph.name
# Only consider the case that the model is single input and single output .
# There is no need for copy.deepcopy(model.graph.input[0]), python It's written time copy.
new_model.graph.input.append(model.graph.input[0])
new_model.graph.output.append(model.graph.output[0])
list_total_input_name = [model.graph.input[0].name]
for weight in model.graph.initializer:
new_model.graph.initializer.append(weight)
list_total_input_name.append(weight.name)
list_nodes_invalid = []
for node in model.graph.node:
node_invalid = False
for node_input_name in node.input:
if (list_total_input_name.count(node_input_name) == 0):
list_nodes_invalid.append(node)
node_invalid = True
break
if (node_invalid):
continue
for node_output_name in node.output:
list_total_input_name.append(node_output_name)
new_model.graph.node.append(node)
for node in list_nodes_invalid:
for node_input_name in node.input:
assert list_total_input_name.count(node_input_name) > 0
for node_output_name in node.output:
list_total_input_name.append(node_output_name)
new_model.graph.node.append(node)
return new_model
版权声明
本文为[wujpbb7]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230611550414.html
边栏推荐
- [point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation
- Proteus 8.10安装问题(亲测稳定不闪退!)
- Chapter 1 numpy Foundation
- EMMC/SD学习小记
- 基于Labview上位机的51单片机步进电机控制系统(上位机代码+下位机源码+ad原理图+51完整开发环境)
- “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
- N states of prime number solution
- 【点云系列】点云隐式表达相关论文概要
- PyTorch 21. PyTorch中nn.Embedding模块
- Chapter 5 fundamentals of machine learning
猜你喜欢
随机推荐
MySQL的安装与配置——详细教程
Chapter 5 fundamentals of machine learning
ECDSA 签名验证原理及C语言实现
Machine learning III: classification prediction based on logistic regression
《Multi-modal Visual Tracking:Review and Experimental Comparison》翻译
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
AUTOSAR从入门到精通100讲(八十七)-高级EEA的关键利器-AUTOSAR与DDS
【51单片机交通灯仿真】
The Cora dataset was trained and tested using the official torch GCN
x509解析
【期刊会议系列】IEEE系列模板下载指南
pth 转 onnx 时出现的 gather、unsqueeze 等算子
Detailed explanation of device tree
关于短视频技术轮廓探讨
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
. net encountered failed to decode downloaded font while loading font:
【点云系列】Learning Representations and Generative Models for 3D pointclouds
【点云系列】Multi-view Neural Human Rendering (NHR)
【3D形状重建系列】Implicit Functions in Feature Space for 3D Shape Reconstruction and Completion
画 ArcFace 中的 margin 曲线