Grader output
Failed test case: incorrect number of (training, testing) images when using a split of 0.5 and 12 images (6 are zero-sized).
Expected:
(3, 3),
but got:
(4, 4).
Why is this? I tried rounding up and down when calculating the training-testing partition
You filed this question under DLS Course 2 (Deep Learning Specialization). I am pretty familiar with the material there, but I do not recognize which quiz or assignment you are working on. Are you sure you filed this in the right category?
If you decide you need to move it, you can do that by clicking the little “edit pencil” by the title of the post. Or if you have trouble doing that, just let me know the correct category and I can do the “move” for you.
Hi @damf.383! I think that your implementation is not filtering out two zero-sized images since there are 8 images and there should be 6. A little hint: Usually you want two separate loops, one for filtering out the images and then one for doing the actual split. Doing these two steps within the same loop might yield undesired results.
Double check your solution with this in mind and try again
If this persists then let us know so we can take a look at your code.
Hi @a-zarta, I actually got the same error although I proceeded to splitting only afer removal of the 0 sized images. Can you aid over the issue in that case please?
Sure, DM me with a screenshot of your code so I can take a look
To everyone facing similar issues please note that if your implementation iterates over a list and removes items during the iteration, this operation is unsafe in Python and might yield undesired results. A better approach is to start with an empty list and append the items that pass the filtering to it or use a list comprehension (although you miss the print statements if you use this, but still worth mentioning).
Is you want to understand why this happens take a look at this: python - Strange result when removing item from a list while iterating over it - Stack Overflow
Hopefully this clears things out! 
2 Likes
thanks very much. I got same error. I have taken your suggestion, and created a file list, and use append(filename) to append to new file list, and solved the issue.