当前位置:网站首页>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
边栏推荐
- Gephi教程【1】安装
- Mysql database installation and configuration details
- 机器视觉系列(02)---TensorFlow2.3 + win10 + GPU安装
- x86架构初探之8086
- scons 搭建嵌入式arm编译
- rearrange 和 einsum 真的优雅吗
- Chapter 3 pytoch neural network toolbox
- C language, a number guessing game
- torch. mm() torch. sparse. mm() torch. bmm() torch. Mul () torch The difference between matmul()
- 【技术规范】:如何写好技术文档?
猜你喜欢
![Gephi tutorial [1] installation](/img/f7/a37be7ac1af3216b7491e500760ad6.png)
Gephi tutorial [1] installation

基于51单片机的体脂检测系统设计(51+oled+hx711+us100)

美摄科技云剪辑,助力哔哩哔哩使用体验再升级

Detailed explanation of unwind stack backtracking

Visual studio 2019 installation and use

带低压报警的51单片机太阳能充电宝设计与制作(完整代码资料)

Chapter 1 numpy Foundation

1.1 pytorch and neural network

【点云系列】Unsupervised Multi-Task Feature Learning on Point Clouds

网络层重要知识(面试、复试、期末)
随机推荐
[3D shape reconstruction series] implicit functions in feature space for 3D shape reconstruction and completion
imx6ull-qemu 裸机教程2:USDHC SD卡
Machine learning II: logistic regression classification based on Iris data set
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
【期刊会议系列】IEEE系列模板下载指南
【點雲系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation
AUTOSAR从入门到精通100讲(八十三)-BootLoader自我刷新
AUTOSAR从入门到精通100讲(八十六)-UDS服务基础篇之2F
Detailed explanation of unwind stack backtracking
Thanos. SH kill bully script, easily delete half of the files in the system at random
Five methods are used to obtain the parameters and calculation of torch network model
美摄科技推出桌面端专业视频编辑解决方案——美映PC版
基于51单片机的温湿度监测+定时报警系统(c51源码)
MySQL数据库安装与配置详解
Device Tree 详解
【点云系列】点云隐式表达相关论文概要
F.pad 的妙用
面试总结之特征工程
Machine learning III: classification prediction based on logistic regression
PyTorch 17. GPU并发