onnx-tensorflow | Tensorflow Backend for ONNX | Machine Learning library
kandi X-RAY | onnx-tensorflow Summary
kandi X-RAY | onnx-tensorflow Summary
Open Neural Network Exchange (ONNX) is an open standard format for representing machine learning models. ONNX is supported by a community of partners who have implemented it in many frameworks and tools. TensorFlow Backend for ONNX makes it possible to use ONNX models as input for TensorFlow. The ONNX model is first converted to a TensorFlow model and then delegated for execution on TensorFlow to produce the output.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate the support status file
- Parse command line arguments
- Train onnx model
- Run the graph
- Returns the train and test dataset
- Update onnx model
- Maximum pooling op
- Calculate argmax
- Calculate the argmax without padding
- Get list of permissions from formats
- Parse docstring
- Train TF model
- Generate API documentation
- Converts a given file to Tensorflow graph
- Convert onnx graph to Tensorflow ops
- Creates Variables
- Run onnx
- Make a graph - like object
- Calculate the coverage of the backend
- Generate the cli script
- Generate tensorflow dict
- Load a tf node
- Convert a graph definition to a tensorflow repos
- Create TensorFlowNode
- Create a dictionary of handler variables
- Common method for common operator
onnx-tensorflow Key Features
onnx-tensorflow Examples and Code Snippets
---------- onnx coverage: ----------
Operators (passed/loaded/total): 21/21/70
------------------------------------
╒════════════════════╤════════════════════╕
│ Operator │ Attributes │
│ │ (name: #values) │
╞═
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
$ ./convert_tool -h
[Convert Tools Info]: optional arguments:
-h help show this help message and exit
-f input type path to input float32 tmfile
-p input structure path to the network structure of inpu
Community Discussions
Trending Discussions on onnx-tensorflow
QUESTION
I am converting efficientnet from onnx to tensorflow for further conversion to tflite. The conversion from onnx to tensorflow yields strange results
Onnx has 1 conv2d operator
And after converting to tensorflow and later tflite model I get this stack of convs(All of them couldn't fit in the picture, there are 32 of the in total, as the number of kernels in onnx)
I suspect the issue is with onnx-tf
conversion. It seems like the conv2d output are split into 32 separate outputs, then they are processed individually on separate conv2d operator and then concatenated together.
There are 2 connected issues on their github.
First has a fix for depthwise convs but it can't be applied in my case
https://github.com/onnx/onnx-tensorflow/issues/473
https://github.com/onnx/onnx-tensorflow/issues/754
Looking at the source of https://github.com/onnx/onnx-tensorflow/blob/master/onnx_tf/handlers/backend/conv_mixin.py They do indeed split the output produce separate convolutions and later concatenate them.
Can this split to multiple convolutions be avoided?
...ANSWER
Answered 2021-Mar-19 at 20:58After some additional digging I've found the following
- My convs were depthwise(conv2d is depthwise in pytorch and onnx if it has groups parameter > 1)
- This bunch of convs is an inefficient way of doing a depthwise conv. To do it efficiently we need to use tf.depthwiseconv
To fix this in onnx-tf
v1.7.0 you should apply a patch to onnx-tf
source code posted here https://github.com/onnx/onnx-tensorflow/issues/473#issuecomment-533522917
In current master branch there is an attempt to fix the issue by detecting depthwise convs but it currently contains a bug. To fix the bug in master branch you can apply a fix I posted here https://github.com/onnx/onnx-tensorflow/issues/754#issuecomment-801775203 I've used the master branch and the fix above resulting in a small graph with depthwise conv
I've also created a fork with the fix above, so you can do
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install onnx-tensorflow
Install ONNX master branch from source.
Install TensorFlow >= 2.6.0 and tensorflow-addons. (Note TensorFlow 1.x is no longer supported)
Run git clone https://github.com/onnx/onnx-tensorflow.git && cd onnx-tensorflow.
Run pip install -e ..
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page