C2W1_Unable to split data

Hi all,

I’m trying to execute C2W1 assignment but I’m unable to split the data, it gives attached error

I think this could be the reason due to Source file is not copied to the destination file.

Appreciate any assistance pls as I’m trying since yesterday but unable to crack this…

1 Like

This error happens when a you call a function inside a function like split_data(split_size(split_size))…

Make sure you read the instructions before the grader cell correctly .


@Deepti_Prasad , Thank you for the response…

I tried couple of things, but now I get below error

This indicates you have recalled the directory path incorrectly. go to back to first grader cell. Use search tool, you can refer the below comment, it will help you understand on how to write the codes for directory cell as well as split data

Let me know if you are unable to understand anything.



Thanks for the detailed explanation, I think i’m stuck at this place

" the split data grader cell first wants you to create a source_directory which is mentioned as SOURCE_DIR "

i have written as below for SOURCE_DIR. Is this correct?

No your source directory path is incorrectly recalled. read the instructions in the comments. Use search tool in the discourse community where learners have faced similar issue and a response has been given. that way you will learn more.

there is error in the splitting of data also but the first main error is how you have recalled your directory path, so it is giving source dir error.


2 things to remember:

  1. create_train_val_dirs is used for setting up the folder structure.
  2. split_data is responsible ONLY for copying the images in SOURCE_DIR into TRAINING_DIR and VALIDATION_DIR.

os.remove will raise OSError if you attempt to remove a directory. Consider using os.rmdir or shutil.rmtree for removing directories (not required in this step of the assignment).

The staff have provided support code to run split_data multiple times (see this comment: # Empty directories in case you run this cell multiple times ). You don’t need to worry about cleaning the destination directories before splitting files.

Hi all, thanks for the guidance…
I’m still unable to get the right source path…appreciate if someone can assist with this pls.

See the proper variable name below:

Please get familiar with python before moving forward. Happy learning.

Hi @balaji.ambresh
Thank you for your response.
Any course you will recommend me to enhance my further python skill?

There are about a hundred good Python tutorial courses on YouTube.
Pick one that has a lot of views. That’s a good indicator it is highly useful.

Om my previous comment has clear instructions on how to write the source _dir.

If you read that comments point by point, you would be able to do the corrections.

As far as improving python skills, I can tell you I myself I am still learning as I am not from programming background, so doing a course plus working on many self learning project from kaggle or your local jupyter notebook will surely help you improve. You could also take guidance from @rmwkwok who has a shared a journey of learning by himself through research and improving day by day.

Python course will surely help you but the more you practice, more you get better.

You can send your notebook if you are still stuck.


Hi @Deepti_Prasad , thank you for the response dear!

Indeed my background is not from programming and this makes learning bit challenging. I’m trying to learn by practices : )

I’m also stuck at the source part since 3 days, I wanted to share my notebook but as I’m using company laptop I can’t access my google drive and will be unable to share. Sharing screenshot can work but that will be against community guidelines. Please let me know if I can DM you?

As per my current coding I’m getting below output which means data is not copied to subdirectories and folders are empty… this could be due to Source_dir defined/path is not correct


Kind regrads,

Ok send screenshot via DM for the starting two grader cells

You need to read all the instructions in the grader cell and before the grader cell carefully.

then the comment I have shared

Literally explains each codes line by line.

using only os.makedir for creating your directory is totally incorrect. The instruction in the grader cell clearly indicates you to use root path which you are ignoring in your codes.

So with a totally fresh copy start again. stop referring to the codes you wrote because it is incorrect.


Hi @Deepti_Prasad ,

I’m still unable to understand, if my code was incorrect why my below output is correct


it is surely creating the directory you are writing codes for but it is not creating the path or images it is looking for

you would get further down the road error even if the grader cell has passed in the previous cell

Hi @Deepti_Prasad , pls advise how to correct this? I followed your code guidance but still unable to make any progress…

Hi all, appreciate if someone can guide me further on this as i’m stuck on this since last week…

Tagging @balaji.ambresh

1 Like