Not getting consistent results on different machines with h5 and TFLite models

Hey there everyone,

I, along with my team were having some issues in getting consistent results from a MobileNet V3 based model (both .h5 and .tflite models) on different machines. The model architecture and the compilation details:

base_model = tf.keras.applications.MobileNetV3Small(input_shape=(256, 256, 3),
                                               include_top=False,
                                               weights='imagenet',
                                               minimalistic=True)

base_model.trainable = True
    
model = tf.keras.Sequential([
        base_model,
        #pretrained_model,
        tf.keras.layers.GlobalAveragePooling2D(),
        tf.keras.layers.Dense(2, dtype=tf.float32)
    ])

model.compile(
        loss = tf.keras.losses.MeanAbsoluteError(),
        optimizer = tf.keras.optimizers.Adam(),
        metrics = [tf.keras.metrics.MeanAbsoluteError(), tf.keras.metrics.MeanSquaredError()],
        steps_per_execution=64
    )

It is an image regression model and we have noticed that the outputs vary by about ~0.2 when the ground truth labels’ range was [0, 3] which makes it difficult to determine thresholds. For additional context, we tested them on the Intel Mac, Mac M1 as well as windows machines with the exact same TF, Keras, numpy and opencv versions and different results were obtained on every system.

Any idea why it might be happening and how it can be dealt with, would mean a lot.

Thanks!

@Rohan_Mishra,

Welcome to the Tensorflow Forum!

Sorry for the late response. We should expect consistent results on all machines.

Can you tell us how you installed tensorflow and which version is it? Meanwhile can you try with the latest version and let us know?

Thank you!