C2W1Assignment - Split_data function result

Hi
I got 45/50 of the graded function.

About the split_data function, the result is: "

Details of failed tests for split_data

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:
63.

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

Could anyone help with this mistake?

I used a for-loop in the random shuffle of data, and use an if-statement when image size equal to 0, and else to count numbers of the loop when meeting the split size, to split “source” into the train and validation directory.
I cannot find where the details went wrong


2 Likes

Hello @apple9855 ,

Send me your notebook via dm such that I can check where it went wrong. By clicking on the profile picture, you will see an option to message. There you can attach your notebook. Then we can discuss the issues here, under the topic you created.

With regards,
Nilosree Sengupta

1 Like

Hello @apple9855 ,

Your code isn’t correct.

At first I would suggest you to read the hints and instructions carefully, not only for this assignment, but for all. You need to understand it at first and do the steps sequentially as per the hint.

I am explaining to you what you need to do :

Create an empty list
Loop through all the files in the source directory
Check for file size >0 or not then print the given condition
Calculate the length of the training and validation sets based on the split size
Shuffle the list
Divide the into training set and validation set
Copy the files from the source directory to the training and validation directories

With regards,
Nilosree Sengupta

1 Like

Hi C2W1Assignment - Split_data function result - #3 by nilosreesengupta ,
Thanks very much for your suggestions.
I tried coding the “split_data” function as follows and the output is same as suggested:

START CODE HERE

[code removed by mentor]

END CODE HERE

[updated assignment link]
[link removed by mentor]

If any suggested improvements to the function codes, please tell me. :blush:
Thanks again for your help!

1 Like

Hello @apple9855 ,

You’re most welcome!!
Your code is absolutely fine now.
Happy learning!!

With regards,
Nilosree Sengupta

1 Like


Hi I got this when i try to compile to test my split data function.
I run all the cells before this and didnt have issue with the source directory.

1 Like

Hello @sammiao914 ,

check this : C2W1Assignment - Split_data function result - #3 by nilosreesengupta

With regards,
Nilosree Sengupta

Hello! A have a problem with Failed Test Case:
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, 5)."
Please, could not you check my code? I can’t figure out what’s a problem. I believe I did everything through the hints


1 Like

Hello! I have an issue with submitting my assignment. Here is the grader output:
There was a problem compiling the code from your notebook. Details:
No module named ‘IPython’

What I should do with it?

1 Like

Are you importing IPython or something from it?

NOTE: To prevent errors from the autograder, pleave avoid editing or deleting non-graded cells in this notebook . Please only put your solutions in between the ### START CODE HERE and ### END CODE HERE code comments, and refrain from adding any new cells.

1 Like

Hello @Oleg_Zadneprovskiy ,

Yes sure!
It’s given in the hint : split size → 0.9. That is 90% for Training and 10% for Validation.
So use 0.9

Then if it doesn’t work, send me your notebook via dm such that I can check where it went wrong. By clicking on the profile picture, you will see an option to message. There you can attach your notebook. Then we can discuss the issues here.

With regards,
Nilosree Sengupta

1 Like

Hello @saifkhanengr ,

This might be a possibility :

Check this one : Submission Error - Upload Notebook - #2 by nilosreesengupta

With regards,
Nilosree Sengupta

1 Like

Hello! I have already found a design! Thanks :+1:

сб, 15 Оюл. 2023 Đł., 23:00 Nilosree Sengupta via DeepLearning.AI <notifications@dlai.discoursemail.com>:

1 Like

Hello @Oleg_Zadneprovskiy ,

You’re welcome !!
Happy learning !!

With regards,
Nilosree Sengupta

1 Like

Hello!
I hope you are doing well. I was having a very similar problem to what you discussed in this topic, and wanted to try my luck asking you as well. If you have the time I would be very very happy!
Best Regards
Meryem

*I tried different ways to split the data, or remove the zero size files, but best I get this failed case (it seems to me that I’m not able to discard 1 zero-size image but I can discard the rest so I do not understand the error I’m making)

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).

1 Like

Hello @Meryem_Eren ,

Welcome to the community!!

Check the below :

With regards,
Nilosree Sengupta

1 Like

Hello,

I have a similar problem with the Split_data function.

In my solution I first create a list of the file names in the source and then shuffle the list.
I create an empty clean_list and in a for loop I check if the files are not 0 size and append the filename in the clean_list.
Afterwards the clean_list is split in the training_list and the validation_list and the files are copied with these lists.

In my tests the split works also for different split sizes, but the grader output is:

Details of failed tests for split_data

Failed test case: failed to omit zero-length image. Tested with 6 images (one of zero length).
Expected:
5 files copied,
but got:
4.

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

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:
110.

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:
13.

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

For me it seems that in the grader the split_size is not set correctly.

I would appreciate any suggestions.

Best regards
Michael

1 Like

I ran into a similar problem. Be sure to check that your directory naming is consistent through the methods. You can have the logic correct but naming improperly will produce this error. ~ Rian

1 Like

having the same problem too

1 Like

I would advise making heavy use of print() inside of the split_data() method. As in, after every assignment to a variable print out the results. You may also want to print out the input parameters to copyfile() so you have visibility. That should give you a trace log so you can see what is happening inside of that method at each step. ~ Rian

1 Like