Python onnx.numpy_helper() Examples
The following are 4
code examples of onnx.numpy_helper().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
onnx
, or try the search function
.
Example #1
Source File: onnx.py From utensor_cgen with Apache License 2.0 | 6 votes |
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]
Example #2
Source File: model_wrappers.py From ngraph-python with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: onnx_helper.py From minionn with Apache License 2.0 | 5 votes |
def onnx_tensor_to_list(tensor): return onnx.numpy_helper.to_array(tensor).flatten().tolist()
Example #4
Source File: onnx.py From incubator-tvm with Apache License 2.0 | 5 votes |
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)