I submitted my assignment and apparently one of my functions failed.
The given reason for this failure is commented as:
Details of failed tests for split_data
Failed test case: incorrect number of (training, validation) images when using a split of 0.5 and 12 images (6 are zero-sized).
Expected:
(3, 3),
but got:
(4, 4).
I have no clue why the following function would split the 6 images into 4 and 2 with a split size of 0.5.
I think you should finish off your while loop before you can start with the for loops.
In the if branch you are checking the first item in your list. After deleting that you then random sample and do operations on a list which not all item are checked of.
If you finish off your while loop first and do not include for loops within the while loop, then you have the chance of cleaning your list first and then perform the split operation after.
I think you could try to remove one of the image += 1 and unindent your for loops
Hi got same problem, how this function should look like ?
Here is how I implement it:
shufflelist
counter=0
for file in shufflelist:
if size is zero:
print(f"{file} is zero length, so ignoring.")
else:
counter += 1
if counter<=len(dir)*SPLIT_SIZE:
copyfile train
else:
copyfile validation