当前位置:网站首页>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
边栏推荐
- 带低压报警的51单片机太阳能充电宝设计与制作(完整代码资料)
- EasyUI combobox determines whether the input item exists in the drop-down list
- 传输层重要知识(面试,复试,期末)
- PyTorch 18. torch.backends.cudnn
- Systrace 解析
- torch. mm() torch. sparse. mm() torch. bmm() torch. Mul () torch The difference between matmul()
- [point cloud series] pnp-3d: a plug and play for 3D point clouds
- 【点云系列】Pointfilter: Point Cloud Filtering via Encoder-Decoder Modeling
- imx6ull-qemu 裸机教程2:USDHC SD卡
- 如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
猜你喜欢
Raspberry Pie: two color LED lamp experiment
Use originpro express for free
【點雲系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation
ArcGIS license server administrator cannot start the workaround
x86架构初探之8086
GIS实战应用案例100篇(五十三)-制作三维影像图用以作为城市空间格局分析的底图
Mysql database installation and configuration details
【点云系列】 A Rotation-Invariant Framework for Deep Point Cloud Analysis
Device Tree 详解
Chapter 2 pytoch foundation 1
随机推荐
Compression and acceleration technology of deep learning model (I): parameter pruning
多机多卡训练时的错误
Use originpro express for free
STM32多路测温无线传输报警系统设计(工业定时测温/机舱温度定时检测等)
基于51单片机的三路超声波测距系统(定时器方式测距)
Solution to slow compilation speed of Xcode
使用proteus仿真STM32超声波SRF04测距!Code+Proteus
GIS实战应用案例100篇(三十四)-拼接2020globeland30
Systrace 解析
Thanos. SH kill bully script, easily delete half of the files in the system at random
【点云系列】PnP-3D: A Plug-and-Play for 3D Point Clouds
美摄科技云剪辑,助力哔哩哔哩使用体验再升级
GIS实战应用案例100篇(五十二)-ArcGIS中用栅格裁剪栅格,如何保持行列数量一致并且对齐?
unhandled system error, NCCL version 2.7.8
Pymysql connection database
WinForm scroll bar beautification
Visual studio 2019 installation and use
swin transformer 转 onnx
Chapter 4 pytoch data processing toolbox
关于短视频平台框架搭建与技术选型探讨