Reputation: 49
I was able to find out each Conv2D's input/output tensor shape inside tflite model with below code.
import tensorflow as tf
SAVED_MODEL_PATH = "TFLITEMODEL_PATH.tflite"
interpreter = tf.lite.Interpreter(model_path=SAVED_MODEL_PATH)
ops = interpreter._get_ops_details()
for op_index, op in enumerate(ops):
if op['op_name'] == "CONV_2D":
cnt += 1
for tensor_idx in op['inputs']:
tensor = interpreter2._get_tensor_details(tensor_idx)
tensor_shape = tensor['shape']
print(tensor['name'], "\t", tensor['shape'])
print("----")
And Below is the output.
Placeholder [ 1 224 224 3]
conv2d/kernel [64 7 7 3]
conv2d/Conv2D_bias [64]
----
block-0/denseblock-0-0/Relu [ 1 56 56 64]
block-0/denseblock-0-0/conv2d/kernel [32 3 3 64]
block-0/denseblock-0-0/conv2d/Conv2D_bias [32]
----
block-0/denseblock-0-1/Relu [ 1 56 56 96]
block-0/denseblock-0-1/conv2d/kernel [32 3 3 96]
block-0/denseblock-0-1/conv2d/Conv2D_bias [32]
----
But I wonder how can I know its Conv2D parameters(like padding, stride, dilation, etc) with python code. I want to those information like netron.app. It shows all layers and its info like name, padding, stride, etc.
Upvotes: 0
Views: 675
Reputation: 4875
There is no official way to do that. _get_ops_details
isn't a public API and isn't guaranteed to be stable.
May I know what you're trying to achieve?
Technically it's possible to go into the detail, and parse the TFLite FlatBuffer model by your own. However it's not a official path either.
Upvotes: 1