Programming Assignment: Cats vs Dogs failed tests for split_data

Hi,
i am doing the assignment for the 5th time and i am still get errors even though the output on my note book is the same as the required output yet i still get an error from the grader:

Details of failed tests for split_data

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
[Errno 2] No such file or directory: ‘./data/images-zero/cats/’.

this is my code any help would be appreciated:

sd = os.listdir(SOURCE_DIR)
for fname in sd:
if os.path.getsize(os.path.join(SOURCE_DIR, fname)) <= 0:
print(fname, “is zero length, so ignoring.”)
sd.remove(fname)

train_size = round(len(sd) * split_size)
validation_size = round(len(sd) * (split_size-1))

train_sample = random.sample(sd[:train_size], len(sd[:train_size]))
validation_sample = random.sample(sd[train_size:], len(sd[validation_size:]))

for fname in train_sample:
copyfile(os.path.join(SOURCE_DIR, fname), os.path.join(TRAINING_DIR, fname))

for fname in validation_sample:
copyfile(os.path.join(SOURCE_DIR, fname), os.path.join(VALIDATION_DIR, fname))

pass

@Gregory_Reiter ,

May be this is the issue:

Lets say for example that split_size = 0.8

For validation_size you are using (split_size - 1) = 0.8 - 1 = -0.2

Check that out - hopefully that’s your issue.

Juan

Yep!
thanks that was the error, however there is another problem, the error it is now giving me is:

Failed test case: incorrect number of training images when using split of 1.0 and a total of 123 images.
Expected:
123,
but got:
111.

Failed test case: incorrect number of training images when using split of 0.5 and a total of 123 images.
Expected:
a value close to 61 with absolute tolerance of +/- 1,
but got:
111.

Failed test case: incorrect number of validation images when using split of 0.5 and a total of 123 images.
Expected:
a value close to 61 with absolute tolerance of +/- 1,
but got:
12.

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:
(11, 1).

which is weird because when i test it on in the note book with different split sizes it always gives me the correct amount of images in each dir meaning if the split is 0.5 then both dir have the same amount of images. other then this i did not change the code.

train_size = round(len(sd) * split_size)

train_sample = random.sample(sd[:train_size], len(sd[:train_size]))
validation_sample = random.sample(sd[train_size:], len(sd[train_size:]))

is there any way i could get the data the grader is testing? because then i could find the problem a lot easier

I also have the same error, code run perfectly on my colab but got 40/50 score, please let me know if you already solve this issue