I have the following problem: I'm trying to fit a deep learning CNN model in google colab with a dataset of cats and dogs, it is very popular in Kaggle, i've cleaned the dataset of none images with a method, and the model train well for a few iterations but in a moment the code throw the following error: Error description

And here a picture where the code works well in the first iterations, how i can solve this? I'm thinking it's a dataset problem but i'm not sure. I am a student of Deep Learning with Tensorflow

Here it's my colab notebook: https://colab.research.google.com/drive/1GzLma_-DMHOe1-injn4d_2KiI6kcwasZ?usp=sharing Prove of good behavior

  • 1
    $\begingroup$ It seems like some of the pictures have a different size. Have you checked? $\endgroup$
    – noe
    Commented Jul 26, 2022 at 18:14

2 Answers 2


There are 2 things you can do.

  1. Verify that there are no corrupted images, and all files in the directories are actual images.

If you do not fix this before training you will get errors regarding these issues and training will fail once these files are reached.

Running the following bash commands in the base directory will resolve these issues:

find /tmp/data/ -size 0 -exec rm {} +
find /tmp/data/ -type f ! -name "*.jpg" -exec rm {} +
  1. You should add a Resizing layer in your model such that you are sure that any image will be passed to the model in the right format.


There could be a problem of corrupt files in one of the directories. Please refer to the link where a sample code helps to check for potential corrupt files.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.