When I converter keras model to tflite model,why the output of two models are different?

the code as follows:

converter = tf.lite.TFLiteConverter.from_keras_model(dpcrn_tf)
tflite_model = converter.convert()

# Save the model.
with open('DPCRN_ULSTM.tflite', 'wb') as f:
  f.write(tflite_model)

tf_model_path="./DPCRN_ULSTM.tflite"
interpreter=tf.lite.Interpreter(tf_model_path)
interpreter.allocate_tensors()

#模型输入和输出细节
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

input_tf=input.numpy()
with tf.device('/cpu:0'):
    #input=tf.ones((1,2,65,1))
    for i in range(10):
        keras_out=dpcrn_tf(input_tf[:,:,i:i+1,:])  #keras model
        
        #tflite model
        interpreter.set_tensor(input_details[0]['index'],input_tf[:,:,i:i+1,:])
        interpreter.invoke()
        tflite_out = interpreter.get_tensor(output_details[0]['index'])
        diff = np.mean(abs(keras_out - tflite_out))
        print("diff:",diff)

the output is:
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
diff: 7.7362637e-07
diff: 0.24605547
diff: 0.22020927
diff: 0.3136428
diff: 0.2653234
diff: 0.26636368
diff: 0.33740526
diff: 0.2464747
diff: 0.33185515
diff: 0.34733117
Why the output error is so big?

Hi @YinDi

Please create a Colab notebook so we can debug the above. From my experience you cannot observe differences that much with the same input in Python and not having quantized the model during conversion.

Regards