本文整理汇总了Python中onnx.numpy_helper方法的典型用法代码示例。如果您正苦于以下问题:Python onnx.numpy_helper方法的具体用法?Python onnx.numpy_helper怎么用?Python onnx.numpy_helper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onnx
的用法示例。
在下文中一共展示了onnx.numpy_helper方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _onnx_initializer_to_input_dict_items
# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import numpy_helper [as 别名]
def _onnx_initializer_to_input_dict_items(initializer):
""" Convert ONNX graph initializer to input dict items.
:param initializer: ONNX graph initializer, list of TensorProto.
:return: List of input dict items.
"""
def tensor2list(onnx_tensor):
# Use the onnx.numpy_helper because the data may be raw
return numpy_helper.to_array(onnx_tensor).flatten().tolist()
return [(init.name,
tf.constant(
tensor2list(init),
shape=init.dims,
dtype=onnx2tf(init.data_type)))
for init in initializer]
示例2: to_array
# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import numpy_helper [as 别名]
def to_array(self): # type: () -> numpy.ndarray
"""Get the value of this tensor as a Numpy array."""
return onnx.numpy_helper.to_array(self._proto)
示例3: onnx_tensor_to_list
# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import numpy_helper [as 别名]
def onnx_tensor_to_list(tensor):
return onnx.numpy_helper.to_array(tensor).flatten().tolist()
示例4: get_numpy
# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import numpy_helper [as 别名]
def get_numpy(tensor_proto):
"""Grab data in TensorProto and convert to numpy array."""
try:
from onnx.numpy_helper import to_array
except ImportError as e:
raise ImportError(
"Unable to import onnx which is required {}".format(e))
return to_array(tensor_proto)