Self-Created Tools to convert ONNX files (NCHW) to TensorFlow/TFLite/Keras format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf). I don't need a Star, but give me a pull request.
MIT License
662
stars
65
forks
source link
Bring constant layers unconnected to the model into the model #628
1. Content and background
Constant
Constant
layers unconnected to the model into the model.-nuo
option is specified because runningonnxsim
will remove constants from the ONNX file.Lambda
layer and force them into the model.interpreter = tf.lite.Interpreter(model_path="saved_model/toy_with_constant_float32.tflite") interpreter.allocate_tensors()
input_details = interpreter.get_input_details() output_details = interpreter.get_output_details()
interpreter.set_tensor( tensor_index=input_details[0]['index'], value=np.ones(tuple(input_details[0]['shape']), dtype=np.float32) ) interpreter.invoke()
variable_output = interpreter.get_tensor(output_details[0]['index']) constant_output = interpreter.get_tensor(output_details[1]['index'])
print("=================") print("Variable Output:") pprint(variable_output) print("=================") print("Constant Output:") pprint(constant_output)
================= Variable Output: array([[-0.02787317, -0.05505124, 0.05421712, 0.03526559, -0.14131774, 0.0019211 , 0.08399964, 0.00433664, -0.00984338, -0.03370604]], dtype=float32)
Constant Output: array([1., 2., 3., 4., 5.], dtype=float32)
2. Summary of corrections
3. Before/After (If there is an operating log that can be used as a reference)
4. Issue number (only if there is a related issue)