NameError: name 'SOURCE' is not defined

please help!!!

NameError Traceback (most recent call last)

in <cell line: 37>() 35 # Run the function 36 # NOTE: Messages about zero length images should be printed out —> 37 split_data(CAT_SOURCE_DIR, TRAINING_CATS_DIR, VALIDATION_CATS_DIR, split_size) 38 split_data(DOG_SOURCE_DIR, TRAINING_DOGS_DIR, VALIDATION_DOGS_DIR, split_size) 39

in split_data(SOURCE_DIR, TRAINING_DIR, VALIDATION_DIR, SPLIT_SIZE) 18 ### START CODE HERE 19 files= —> 20 for filename in os.listdir(SOURCE): 21 file = SOURCE + filename 22 if os.path.getsize(file) > 0:

NameError: name ‘SOURCE’ is not defined

Hello @Deepti_Prasad ,

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

I have sent, please check

Okay, I will look into it! Will get back to you shortly!

Hello @Deepti_Prasad ,

  1. For # GRADED FUNCTION: split_data,

You have written “SOURCE” . It should be “SOURCE_DIR”, as mentioned in the parameter of the function : def split_data(SOURCE_DIR, TRAINING_DIR, VALIDATION_DIR, SPLIT_SIZE)
Therefore it is not defined.

So to fix your error : Replace all the “SOURCE” with “SOURCE_DIR”.

  1. After this gets fixed you will fall to more errors, as you have written :
  • “VALIDATION” instead of “VALIDATION_DIR”
  • “shuffled_Set” instead of “shuffled_set”
    So replace these as well.

You need to keep in mind the correct parameter names.

  1. Next you will face another error due the code you wrote in # GRADED FUNCTION: create_train_val_dirs. Check this : Details of failed tests for create_train_test_dirs - #7 by nilosreesengupta

Hope this helps.

With regards,
Nilosree Sengupta

Lol that was such a detail mistake log. thank you very much. :slight_smile:

I will look into the mistakes. thanks again
DP

DO I need to change the training to TRAINING_DIR too in that last cell with mistake?

Hello @Deepti_Prasad ,

You are welcome!
Happy learning!

With regards,
Nilosree Sengupta

Under this part :
for filename in training_set:
you have written “VALIDATION” instead of “VALIDATION_DIR”
Replace this.

hey I need one more help, I have a doubt, after I finish the assignment and at the end there is a download option in notebook. so I need to upload that document in the Coursera page right?? for grading??

Hello @Deepti_Prasad ,

Yes. You need to uplooad the notebook- .ipynb file and the history.pkl file under the submission section for grading.

With regards,
Nilosree Sengupta

1 Like

history.pkl file? :frowning you mean there are two files to be uploaded for grading?

one more question my model is getting trained, what I can see the training percentage first increased and then reduced and again increased after 6 epoch, can this happen? or there is an issue??

Hello @Deepti_Prasad ,

Yes there are 2 files.

Btw this is a different issue than this particular one which is solved :

Could you kindly create another topic stating your new issue, such that in future learners don’t get confused, when going through this topic as a reference. I will clear your doubts under the new topic that you create!

With regards,
Nilosree Sengupta

you mean for the upload issue you want me to create a new post??

hey I cleared the grader for both files, thanks once again for the guidance. Your replies were direct, clear and really helpful. Thanks again.

Regards
DP

Hello @Deepti_Prasad ,

Not upload,

  1. since you didn’t knew about .pkl file
  2. and this part :

For briefly explaining those 2 points to you, I asked you to create a separate topic as these 2 apparently goes out of context of NameError: name ‘SOURCE’ is not defined, such that learners don’t get confused, when going through this topic as a reference.

With regards,
Nilosree Sengupta

Hello @Deepti_Prasad ,

That’s great!!You’re welcome!!
Feel free to post whenever you get stuck.
Happy learning!!

With regards,
Nilosree Sengupta

I have posted that issue as a new topic and tagged you, so you can reply there. Thanks again!!! happy learning!!!

Okay! I have replied.