Skip to content Skip to sidebar Skip to footer

Tensorflow Prediction Always Zero

I am Tensorflow newbie. I have model generated using convNetKerasLarge.py and saved as tflite model. I am trying to test this saved model as follows import tensorflow as tf import

Solution 1:

The script you linked normalize the data before the training by subtracting the mean (here 0.5) and dividing by the standard deviation (here 1):

mean = np.array([0.5,0.5,0.5])
std = np.array([1,1,1])
X_train = X_train.astype('float')
X_test = X_test.astype('float')
for i in range(3):
    X_train[:,:,:,i] = (X_train[:,:,:,i]- mean[i]) / std[i]
    X_test[:,:,:,i] = (X_test[:,:,:,i]- mean[i]) / std[i]

If you don't repeat the same operations before doing a prediction with the model, the input you are passing to the model will not have the same characteristics as the that you trained with.

You could fix it by subtracting the mean (0.5) to the image when preparing the data, i.e:

    np_val_images = np.array(val_images) - 0.5

Post a Comment for "Tensorflow Prediction Always Zero"