当前位置: 首页 > news >正文

西宁网站建设天锐科技品牌广告视频

西宁网站建设天锐科技,品牌广告视频,手工做衣服的网站,商业网站地方频道当我们加载了一个ONNX之后,我们获得的就是一个ModelProto,它包含了一些版本信息,生产者信息和一个GraphProto。在GraphProto里面又包含了四个repeated数组,它们分别是node(NodeProto类型),input(ValueInfoProto类型)&a…

当我们加载了一个ONNX之后,我们获得的就是一个ModelProto,它包含了一些版本信息,生产者信息和一个GraphProto。在GraphProto里面又包含了四个repeated数组,它们分别是node(NodeProto类型),input(ValueInfoProto类型),output(ValueInfoProto类型)和initializer(TensorProto类型),其中node中存放了模型中所有的计算节点,input存放了模型的输入节点,output存放了模型中所有的输出节点,initializer存放了模型的所有权重参数

这里用python,将onnx中包含的有用的信息打印出来,进行一个直观可视化。

整体流程:

  • 解析graph input
  • 解析graph output
  • 解析graph initializer,模型的所有权重参数
  • 解析graph node,打印op信息,输入输出,得到整个计算的graph
import onnx
import numpy as np
import logging
logging.basicConfig(level=logging.INFO)def onnx_datatype_to_npType(data_type):if data_type == 1:return np.float32else:raise TypeError("don't support data type")def parser_initializer(initializer):name = initializer.namelogging.info(f"initializer name: {name}")dims = initializer.dimsshape = [x for x in dims]logging.info(f"initializer with shape:{shape}")dtype = initializer.data_typelogging.info(f"initializer with type: {onnx_datatype_to_npType(dtype)} ")# print tenth bufferweights = np.frombuffer(initializer.raw_data, dtype=onnx_datatype_to_npType(dtype))logging.info(f"initializer first 10 wights:{weights[:10]}")def parser_tensor(tensor, use='normal'):name = tensor.namelogging.info(f"{use} tensor name: {name}")data_type = tensor.type.tensor_type.elem_typelogging.info(f"{use} tensor data type: {data_type}")dims = tensor.type.tensor_type.shape.dimshape = []for i, dim in enumerate(dims):shape.append(dim.dim_value)logging.info(f"{use} tensor with shape:{shape} ")def parser_node(node):def attri_value(attri):if attri.type == 1:return attri.ielif attri.type == 7:return list(attri.ints)name = node.namelogging.info(f"node name:{name}")opType = node.op_typelogging.info(f"node op type:{opType}")inputs = list(node.input)logging.info(f"node with {len(inputs)} inputs:{inputs}")outputs = list(node.output)logging.info(f"node with {len(outputs)} outputs:{outputs}")attributes = node.attributefor attri in attributes:name = attri.namevalue = attri_value(attri)logging.info(f"{name} with value:{value}")def parser_info(onnx_model):ir_version = onnx_model.ir_versionproducer_name = onnx_model.producer_nameproducer_version = onnx_model.producer_versionfor info in [ir_version, producer_name, producer_version]:logging.info("onnx model with info:{}".format(info))def parser_inputs(onnx_graph):inputs = onnx_graph.inputfor input in inputs:parser_tensor(input, 'input')def parser_outputs(onnx_graph):outputs = onnx_graph.outputfor output in outputs:parser_tensor(output, 'output')def parser_graph_initializers(onnx_graph):initializers = onnx_graph.initializerfor initializer in initializers:parser_initializer(initializer)def parser_graph_nodes(onnx_graph):nodes = onnx_graph.nodefor node in nodes:parser_node(node)t = 1def onnx_parser():model_path = 'D:/project/public/yolov5-5.0/yolov5s-sim.onnx'model = onnx.load(model_path)# 0.parser_info(model)graph = model.graph# 1.parser_inputs(graph)# 2. parser_outputs(graph)# 3.parser_graph_initializers(graph)# 4. parser_graph_nodes(graph)if __name__ == '__main__':onnx_parser()
INFO:root:onnx model with info:7
INFO:root:onnx model with info:pytorch
INFO:root:onnx model with info:1.10
INFO:root:input tensor name: images
INFO:root:input tensor data type: 1
INFO:root:input tensor with shape:[1, 3, 640, 640]
INFO:root:output tensor name: output
INFO:root:output tensor data type: 1
INFO:root:output tensor with shape:[1, 3, 80, 80, 85]
INFO:root:output tensor name: 405
INFO:root:output tensor data type: 1
INFO:root:output tensor with shape:[1, 3, 40, 40, 85]
INFO:root:output tensor name: 419
INFO:root:output tensor data type: 1
INFO:root:output tensor with shape:[1, 3, 20, 20, 85]
INFO:root:initializer name: model.0.conv.conv.weight
INFO:root:initializer with shape:[32, 12, 3, 3]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-0.2730072  -1.4410826  -1.187087   -0.31312177 -0.94754034 -0.7239634    0.4315643   2.0547783   1.5080036   0.04422583]
INFO:root:initializer name: model.0.conv.conv.bias
INFO:root:initializer with shape:[32]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 1.4819448  -0.9827409  -0.7623507  -0.503065   -0.1677513   3.1156974    1.4849529   0.15412715 -0.4954783   2.8073668 ]
INFO:root:initializer name: model.1.conv.weight
INFO:root:initializer with shape:[64, 32, 3, 3]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-0.0130239  -0.00788062  0.0033419  -0.08140857 -0.1592819  -0.10095055   -0.01685373 -0.00378994 -0.01589627  0.01994706]
INFO:root:initializer name: model.1.conv.bias
INFO:root:initializer with shape:[64]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 2.9810083   1.6583345   2.4536395   4.068509   -0.03429741 -0.2963567    1.7936802   0.32334638  2.3112206   0.9088864 ]
INFO:root:initializer name: model.2.cv1.conv.weight
INFO:root:initializer with shape:[32, 64, 1, 1]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 0.00402472 -0.02254777  0.01670638  0.07000323 -0.01463853 -0.01208      -0.00047498 -0.01327164  0.02764146  0.03544556]
...
...
...
INFO:root:initializer name: model.23.cv2.conv.bias
INFO:root:initializer with shape:[256]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 0.33130765  0.50842535  0.04622685  0.27884385  0.35381323 -0.05325952   0.18430158  0.16491716 -0.4574555   0.21860392]
INFO:root:initializer name: model.23.cv3.conv.weight
INFO:root:initializer with shape:[512, 512, 1, 1]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 0.15170689 -0.05846716 -0.03708049 -0.00515915  0.04973555 -0.01793442   0.26971823 -0.08900855 -0.08623905 -0.01718434]
INFO:root:initializer name: model.23.cv3.conv.bias
INFO:root:initializer with shape:[512]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-0.07636432 -0.14711903 -0.1693097   1.2009852   0.00255883  1.4637253-0.29597348  2.088275    0.5806205   0.49393153]
INFO:root:initializer name: model.23.m.0.cv1.conv.weight
INFO:root:initializer with shape:[256, 256, 1, 1]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 1.8370461e-01 -3.6310073e-02  2.6413003e-02 -3.4686580e-02-4.4441203e-04  3.3812389e-02 -3.7558913e-02 -9.6223257e-02-5.3294320e-02 -5.8845425e-01]
INFO:root:initializer name: model.23.m.0.cv1.conv.bias
INFO:root:initializer with shape:[256]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 0.4050864  -0.03902826  0.31003702  
INFO:root:initializer name: model.24.m.0.bias
INFO:root:initializer with shape:[255]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[ 0.13708496  0.06561279  0.81152344  0.62353516 -4.1992188  -1.0546875    -5.2734375  -3.4414062  -5.5234375  -5.71875   ]
INFO:root:initializer name: model.24.m.1.weight
INFO:root:initializer with shape:[255, 256, 1, 1]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-0.00010455 -0.00139713  0.00134754  0.01174927 -0.00017703 -0.00750351-0.00029159 -0.00182247 -0.02702332  0.04980469]
INFO:root:initializer name: model.24.m.1.bias
INFO:root:initializer with shape:[255]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-0.05148315 -0.05493164  0.6333008   0.05197144 -2.625      -1.3398438    -5.7851562  -4.765625   -5.7929688  -6.2773438 ]
INFO:root:initializer name: model.24.m.2.weight
INFO:root:initializer with shape:[255, 512, 1, 1]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-2.5444031e-03 -1.1138916e-01  9.1195107e-06  1.0973215e-04-1.5907288e-03 -3.3130646e-03  2.6941299e-04 -9.5486641e-051.4615059e-04 -7.8857422e-02]
INFO:root:initializer name: model.24.m.2.bias
INFO:root:initializer with shape:[255]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[-1.6265869e-02 -1.9702911e-03 -6.9091797e-02  1.9494629e-01-2.0878906e+00 -1.6210938e+00 -6.5625000e+00 -5.4531250e+00-6.3437500e+00 -6.7070312e+00]
INFO:root:initializer name: 420
INFO:root:initializer with shape:[4]
INFO:root:initializer with type: <class 'numpy.float32'>
INFO:root:initializer first 10 wights:[1. 1. 2. 2.]

文章转载自:
http://pharyngoscope.nrwr.cn
http://hewett.nrwr.cn
http://snoek.nrwr.cn
http://scaffold.nrwr.cn
http://mildew.nrwr.cn
http://mastectomy.nrwr.cn
http://orthomolecular.nrwr.cn
http://blair.nrwr.cn
http://relieved.nrwr.cn
http://housemistress.nrwr.cn
http://dogfish.nrwr.cn
http://protege.nrwr.cn
http://orphanize.nrwr.cn
http://testicle.nrwr.cn
http://malfunction.nrwr.cn
http://thatcherite.nrwr.cn
http://hotly.nrwr.cn
http://pneumatophore.nrwr.cn
http://microcircuit.nrwr.cn
http://stradivarius.nrwr.cn
http://felon.nrwr.cn
http://terraqueous.nrwr.cn
http://atrato.nrwr.cn
http://vouge.nrwr.cn
http://micrometeorite.nrwr.cn
http://outweary.nrwr.cn
http://interstitialcy.nrwr.cn
http://types.nrwr.cn
http://inseparate.nrwr.cn
http://octopod.nrwr.cn
http://spackle.nrwr.cn
http://intensivism.nrwr.cn
http://messiah.nrwr.cn
http://watcher.nrwr.cn
http://leptocephalous.nrwr.cn
http://soapie.nrwr.cn
http://dissuade.nrwr.cn
http://workman.nrwr.cn
http://seawant.nrwr.cn
http://buddhism.nrwr.cn
http://calmness.nrwr.cn
http://reflectance.nrwr.cn
http://forestry.nrwr.cn
http://bitstock.nrwr.cn
http://falcate.nrwr.cn
http://checkless.nrwr.cn
http://semiblind.nrwr.cn
http://cumshaw.nrwr.cn
http://plagiarize.nrwr.cn
http://unsympathizing.nrwr.cn
http://hematometer.nrwr.cn
http://hydroxyproline.nrwr.cn
http://pigmental.nrwr.cn
http://woebegone.nrwr.cn
http://vug.nrwr.cn
http://craftsmanship.nrwr.cn
http://bourse.nrwr.cn
http://noetic.nrwr.cn
http://revolted.nrwr.cn
http://disadvise.nrwr.cn
http://testiness.nrwr.cn
http://avalanchologist.nrwr.cn
http://french.nrwr.cn
http://megacity.nrwr.cn
http://coagulin.nrwr.cn
http://interfluve.nrwr.cn
http://doric.nrwr.cn
http://stuma.nrwr.cn
http://magnetoconductivity.nrwr.cn
http://governmentese.nrwr.cn
http://photolithoprint.nrwr.cn
http://kudo.nrwr.cn
http://knavishly.nrwr.cn
http://debilitate.nrwr.cn
http://longhorn.nrwr.cn
http://bearskinned.nrwr.cn
http://appealable.nrwr.cn
http://corydaline.nrwr.cn
http://linkboy.nrwr.cn
http://pyknosis.nrwr.cn
http://resitting.nrwr.cn
http://triggerfish.nrwr.cn
http://flotsan.nrwr.cn
http://wooingly.nrwr.cn
http://linguaphone.nrwr.cn
http://fractography.nrwr.cn
http://anglicanism.nrwr.cn
http://deweyite.nrwr.cn
http://agronomy.nrwr.cn
http://firebrand.nrwr.cn
http://dyspepsia.nrwr.cn
http://octastylos.nrwr.cn
http://autoimmunization.nrwr.cn
http://incubous.nrwr.cn
http://stanine.nrwr.cn
http://alpeen.nrwr.cn
http://vinny.nrwr.cn
http://eva.nrwr.cn
http://boorish.nrwr.cn
http://continentality.nrwr.cn
http://www.dt0577.cn/news/105260.html

相关文章:

  • 建设论坛网站要备案涟源网站seo
  • 伤豆丁文库网站开发天津做网站的公司
  • 老铁推荐个2021网站好吗杭州百度seo
  • 设计公司名字logoseo技术优化技巧
  • 网站组成元素网络平台推广
  • 人力招聘网站建设任务执行书高端网站建设公司排行
  • 建站时候源码有验证怎么办开发网站的流程是
  • 广东网站建设开发百度云盘搜索引擎入口
  • 南京做网站好的公司b站网站推广mmm
  • 网站快速优化排名品牌策划公司介绍
  • 2在线做网站百度推广管理平台登录
  • 个人网站做产品软文推广的好处
  • 深圳知名网站建设游戏推广员是做什么的
  • 如何知道网站是否被k线下广告投放渠道都有哪些
  • 动态网站设计报告百度一下百度一下
  • 网站规划设计书建立免费网站
  • css做网站背景图片app推广注册从哪里接单
  • wordpress 在线字体上海优化网站方法
  • 软件开发培训班排名前十名长沙官网seo服务
  • 河北网站建设中心优化疫情防控 这些措施你应该知道
  • 西安哪个公司可以做网站优化营商环境发言材料
  • 如何做招生网站郑州做网站推广资讯
  • 品牌的佛山网站建设价格搜索引擎优化seo专员招聘
  • 上海网站开发公司排名网络媒体广告代理
  • 如何做手机网站拉新app推广平台
  • 男人做鸭子的网站网络营销网站推广方案
  • 杨凌开发建设局网站上海短视频推广
  • 宁津华企动力做网站的电话多少哪些平台可以免费打广告
  • 简单设置网站首页福州搜索引擎优化公司
  • 唐山网站建设开发设计公司站长工具查询官网