TFLITE model Input Tensor Update

I have created tflite model it was conerted succesfully and che cking the netron output it seems ok but input tensor shape is 1 x 3 x height x width . What I need is to have 1 x height x width x 3. Does anyone know if it was possible to convert it to the desired shape or not?


Welcome to the Tensorflow Forum,

We can only change the model input details while building the tflite model by specifying the input shape.

Please take look at sample code snippet below

img = tf.keras.Input(shape=(64, 64, 3), name="img")
const = tf.constant([1., 2., 3.]) + tf.constant([1., 4., 4.])
val = img + const
out = tf.identity(val, name="out")

# Convert to TF Lite format
converter = tf.lite.TFLiteConverter.from_keras_model(tf.keras.models.Model(inputs=[img], outputs=[out]))
tflite_model = converter.convert()

Thank you!