Skip to content Skip to sidebar Skip to footer

Keras Predict_classes Method Returns "list Index Out Of Range" Error

I am new to CNN and machine learning in general and have been trying to follow Image Classification tutorial of TensorFlow. Now, the Google Colab can be found here. I've followed t

Solution 1:

All the predict functions in Keras expect batch of inputs. Therefore, since you are doing prediction on one single image, you need to add an axis at the beginning of image tensor to represent the batch axis:

image = tf.expand_dims(image, axis=0)   # the shape would be (1, 224, 224, 3)
print(model.predict_classes(image)[0])

Post a Comment for "Keras Predict_classes Method Returns "list Index Out Of Range" Error"