Asked to retrieve element 0, but the Sequence has length 0

Hi DeepLearningAI,

I got a response in “Cats vs Dogs” assignment.

the response is shown as below.
Failed test case: your model could not be used for inference. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
Asked to retrieve element 0, but the Sequence has length 0.

May I know the further detail of this response ?

How to make this error ?
( I couldn’t get this error in colab )

thanks for helps.

Please click my name and message your notebook as an attachment.

I understand that the grader feedback isn’t informative. The staff have now been notified to address this.

Here are few things in the notebook that require your attention:

Please ensure that your model meets this criteria:

To pass this assignment, your model should achieve a training accuracy of at least 95% and a validation accuracy of at least 80%

Your submission has less than 80% for validation accuracy.
`Epoch 15/15

[details removed] loss: 0.0454 - accuracy: 0.9869 - val_loss: 1.6095 - val_accuracy: 0.7623`

Output of split_data doesn’t match.

Expected Output:

666.jpg is zero length, so ignoring.
11702.jpg is zero length, so ignoring.
There are 11250 images of cats for training
There are 11250 images of dogs for training
There are 1250 images of cats for validation
There are 1250 images of dogs for validation

Yours

There are 11250 images of cats for training
There are 11250 images of dogs for training
There are 1250 images of cats for validation
There are 1250 images of dogs for validation

thanks

i will modify my code and upload it

[code removed - moderator]
Hi balaji.ambresh,

I still got the same response.

is there any thing i could improve ?

[code removed - moderator]

  1. I think the model accuracy is meat the criteria

Epoch 15/15
180/180 [==============================] - 79s 438ms/step - loss: 0.0743 - accuracy: 0.9824 - val_loss: 1.0935 - val_accuracy: 0.8160

  1. I print the zero length file information

666.jpg is zero length, so ignoring.
11702.jpg is zero length, so ignoring.

There are 11250 images of cats for training
There are 11250 images of dogs for training
There are 1250 images of cats for validation
There are 1250 images of dogs for validation

thanks for your help

Please don’t post code in public. Click my name and message your notebook as an attachment.

Hi @dynaxchen, it took me a while to figure out what was causing the bug. In your split_data function you are moving the files instead of copying them into the target directory. This causes that the folder that contains the images of cats and dogs to be empty when it is used to perform inference with your model.

By changing shutil.move to shutil.copy you should get full score!

Hi a-zarta.

Thanks for your explanation.

great review