The problem was with reading data function tf.keras.preprocessing.image_dataset_from_directory
, which has got its shuffle
argument set to True
.
When I reload the data again and set shuffle=False
like this:
>>> val_ds = tf.keras.preprocessing.image_dataset_from_directory(
... 'PetImages',
... shuffle=False,
... validation_split=0.2,
... subset="validation",
... seed=1337,
... image_size=image_size,
... batch_size=batch_size,
... )
>>> for i in range(5):
... predictions = model.predict(val_ds)
... predictions_list = [round(pred[0], 3) for pred in predictions]
... print(predictions_list[:10])
then the result looks as I expected:
[0.998, 0.994, 1.0, 1.0, 0.885, 1.0, 0.998, 1.0, 0.979, 1.0]
[0.998, 0.994, 1.0, 1.0, 0.885, 1.0, 0.998, 1.0, 0.979, 1.0]
[0.998, 0.994, 1.0, 1.0, 0.885, 1.0, 0.998, 1.0, 0.979, 1.0]
[0.998, 0.994, 1.0, 1.0, 0.885, 1.0, 0.998, 1.0, 0.979, 1.0]
[0.998, 0.994, 1.0, 1.0, 0.885, 1.0, 0.998, 1.0, 0.979, 1.0]
CLICK HERE to find out more related problems solutions.