Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Protocol buffers 如何读取各个层';重量及重量;ONNX模型的偏差值?_Protocol Buffers_Onnx - Fatal编程技术网

Protocol buffers 如何读取各个层';重量及重量;ONNX模型的偏差值?

Protocol buffers 如何读取各个层';重量及重量;ONNX模型的偏差值?,protocol-buffers,onnx,Protocol Buffers,Onnx,如何从ONNX模型中获取权重/偏差矩阵值,我目前可以从model.ONNX中获取输入、内核大小、步幅和垫值。我加载模型,然后读取图形节点以获得相同的结果: import onnx m = onnx.load('model.onnx') print(m.graph.node) 在官方git回购上发布了一个问题后,我得到了问题的答案。我们可以从m.graph中的初始值设定项访问权重值 weights = m.graph.initializer 要获取权重矩阵,需要使用numpy\u helper

如何从ONNX模型中获取权重/偏差矩阵值,我目前可以从
model.ONNX
中获取输入、内核大小、步幅和垫值。我加载模型,然后读取图形节点以获得相同的结果:

import onnx
m = onnx.load('model.onnx')
print(m.graph.node)

在官方git回购上发布了一个问题后,我得到了问题的答案。我们可以从
m.graph
中的初始值设定项访问权重值

weights = m.graph.initializer
要获取权重矩阵,需要使用
numpy\u helper
fromonnx

from onnx import numpy_helper
w1 = numpy_helper.to_array(weights[0])

在官方git回购上发布了一个问题后,我得到了问题的答案。我们可以从
m.graph
中的初始值设定项访问权重值

weights = m.graph.initializer
要获取权重矩阵,需要使用
numpy\u helper
fromonnx

from onnx import numpy_helper
w1 = numpy_helper.to_array(weights[0])

下面的代码帮助您从onnx模型创建状态字典

import onnx
from onnx import numpy_helper
onnx_model   = onnx.load("model.onnx")
INTIALIZERS  = onnx_model.graph.initializer
onnx_weights = {}
for initializer in INTIALIZERS:
    W = numpy_helper.to_array(initializer)
    onnx_weights[initializer.name] = W

下面的代码帮助您从onnx模型创建状态字典

import onnx
from onnx import numpy_helper
onnx_model   = onnx.load("model.onnx")
INTIALIZERS  = onnx_model.graph.initializer
onnx_weights = {}
for initializer in INTIALIZERS:
    W = numpy_helper.to_array(initializer)
    onnx_weights[initializer.name] = W

我仍在研究如何将原始数据转换为权重矩阵。我仍在研究如何将原始数据转换为权重矩阵。请为您的答案添加一些解释。_model.graph.initializer将给出所有模型初始值设定项的列表,以及权重和偏差。请为您的答案添加一些解释回答。_model.graph.initializer将给出所有模型初始值设定项的列表,以及权重和偏差。