当前位置:网站首页>被 onnx.checker.check_model 检查出的常见错误
被 onnx.checker.check_model 检查出的常见错误
2022-04-23 06:12:00 【wujpbb7】
错误1:“Field 'name' of graph is required to be non-empty.”
解决:对 model.graph.name 赋值。
错误2:“Nodes in a graph must be topologically sorted, however input ...”
解决:调整节点顺序,保证每个节点的输入都先于它存在。
参考代码如下:
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))
# 目前只考虑这个错误“ Nodes in a graph must be topologically sorted, however input ...”,
# 就是模型的节点顺序有问题,onnxruntime 是可以推断的,为了其他引擎比如 trt可以推断,调整一下节点顺序。
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
# 只考虑模型是单输入单输出的情况。
# 这里不需要 copy.deepcopy(model.graph.input[0]), python 是写时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://blog.csdn.net/blueblood7/article/details/121253178
边栏推荐
- 扫雷小游戏
- 给女朋友写个微信双开小工具
- 【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
- C# EF mysql更新datetime字段报错Modifying a column with the ‘Identity‘ pattern is not supported
- 【点云系列】Multi-view Neural Human Rendering (NHR)
- 第4章 Pytorch数据处理工具箱
- [3D shape reconstruction series] implicit functions in feature space for 3D shape reconstruction and completion
- Android interview Online Economic encyclopedia [constantly updating...]
- PyTorch 11.正则化
- 素数求解的n种境界
猜你喜欢

【点云系列】PnP-3D: A Plug-and-Play for 3D Point Clouds

WebView displays a blank due to a certificate problem
![[point cloud series] pnp-3d: a plug and play for 3D point clouds](/img/83/3662bc668602110236e43ee0b9d7ac.png)
[point cloud series] pnp-3d: a plug and play for 3D point clouds

【期刊会议系列】IEEE系列模板下载指南

Record WebView shows another empty pit

【指标】Precision、Recall

机器学习笔记 一:学习思路

MySQL数据库安装与配置详解

【點雲系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation

第1章 NumPy基础
随机推荐
Android interview Online Economic encyclopedia [constantly updating...]
PyMySQL连接数据库
Summary of image classification white box anti attack technology
C language, a number guessing game
Machine learning II: logistic regression classification based on Iris data set
Project, how to package
Binder mechanism principle
[2021 book recommendation] kubernetes in production best practices
【動態規劃】不同路徑2
Android exposed components - ignored component security
How to standardize multidimensional matrix (based on numpy)
Gobang games
Pytorch best practices and coding style guide
torch_ Geometric learning 1, messagepassing
The Cora dataset was trained and tested using the official torch GCN
How keras saves and loads the keras model
【 planification dynamique】 différentes voies 2
[point cloud series] pnp-3d: a plug and play for 3D point clouds
【点云系列】Multi-view Neural Human Rendering (NHR)
Google AdMob advertising learning