C2W1 Assignment | Failed test case has incorrect type

Hi, I am getting this error for all the graded functions. My program seems to be working just fine and as expected. Also, the training history is accepted in my submission. I don’t know where I get wrong. Can someone please tell me what I should do? Thank you.

Details of failed tests for create_train_val_dirs
Failed test case: create_train_val_dirs has incorrect type.
Expected: typing.Callable, but got: <class ‘NoneType’>.

Details of failed tests for split_data
Failed test case: split_data has incorrect type.
Expected: typing.Callable, but got: <class ‘NoneType’>.

Details of failed tests for train_val_generators
Failed test case: train_val_generators has incorrect type.
Expected: typing.Callable, but got: <class ‘NoneType’>.

Details of failed tests for create_model
Failed test case: create_model has incorrect type.
Expected: typing.Callable, but got: <class ‘NoneType’>.

Hello @mhdlyy.k ,

Welcome to the Community!

It is giving “None Type” which signifies that the parameters are still having None type despite you passed certain arguments, as probably the file not saved.

Save the file and submit again.

(If it still doesn’t pass,
let me know by mentioning me here and dm your notebook. By clicking on my profile picture, you will see an option to message. There you can attach your notebook.Then we will discuss the issues here.)

With regards,
Nilosree Sengupta

Hello @nilosreesengupta ,

I already tried it but I still face the same problem. Please kindly check your dm, there I already attached my notebook file. Thank you so much in advance!

Regards,
Mahdia

Hello @mhdlyy.k ,

I have checked your notebook.
Under every function, Your outputs have matched with the expected outputs.But target is not just matching outputs, but also passing test cases.

For passing test cases, you need to go thoroughly through the hints and informations provided before every graded functions.

So all functions, you need to rewrite.

1. Under GRADED FUNCTION: create_train_test_dirs

Refer to my reply to another learner here : Details of failed tests for create_train_test_dirs - #7 by nilosreesengupta

2. Under GRADED FUNCTION: split_data

It’s given in the paragraph above :

2.1. All images should be checked before the copy, so if they have a zero file length, they will be omitted from the copying process. If this is the case then your function should print out a message such as “filename is zero length, so ignoring.”. You should perform this check before the split so that only non-zero images are considered when doing the actual split.
But You are checking this at last.

The thing is if you remove the non-required part before, it will decrease the time for checking.
(Not only this particular assignment, whenever you are given data, remove the non-required part, it will reduce space and time.This will improve efficiency of your code.)

2.2 You need to keep in mind the division of data. 90% for training and 10% for validation.

You are checking value of i < total_file*SPLIT_SIZE.This won’t pass the test case.Check the hint.
You need to divide at first into 2 parts. 90% and 10%.
Then you have to run a loop check i belongs to which part.
Then copy file from source to destination

2.3. In the hint it is given:

##copyfile(source, destination) : copies a file from source to destination
So file should be copied using this instead of os.path.join.

Go step by step.Read the paragraph and the hints.

3. Under def train_val_generators(TRAINING_DIR, VALIDATION_DIR):

Under this part :
#Pass in the appropiate arguments to the flow_from_directory method for train_generator and validation_generator:

i.Batch sizes will be more. Try to figure out what it can be.
ii. You dont need to take input shape thrice for Conv2D.

Hope this helps.

With regards,
Nilosree Sengupta

And let me know when you solve the errors @mhdlyy.k !
Happy Learning!!

With regards,
Nilosree Sengupta

Hi @nilosreesengupta ,

Thanks for pointing it all out. I really appreciate all your help and suggestions. I already modified my code multiple times, but still, nothing seems to be working. They all get the same test case error message (NoneType). I honestly don’t know what to change anymore. I don’t know what the grader is expecting. Please help me :cry: . I’ll send you my latest code. Thank you so much, Nilosree.

Warm regards,
Mahdia

Hello @mhdlyy.k ,

You are welcome!!
Seen your updated code.
Again the approach desired is not there for the graded functions.

The thing is this that your outputs are coming as expected output, but there are test cases which does not only wants specific answers but also specific methods.There are many approaches to solve a coding problem but here the grader will pass specific approach only.

And the approaches to be applied are are clearly stated in the hints and I have also explained each hint and whatever changes you need to make.Read again.

For example :
Under GRADED FUNCTION: create_train_val_dirs
It’s written in the hint :

# HINT:
  # Use os.makedirs to create your directories with intermediate subdirectories
  # Don't hardcode the paths. Use os.path.join to append the new directories to the root_path parameter

You have used os.path.join but You have written so many lines, writing one line for each one .
Try to think out an optimised way.

I have already given this link in my previous reply to refer:

Clearly stated how to do here that must be done in fewer lines and how it will be : Details of failed tests for create_train_test_dirs - #7 by nilosreesengupta

I would suggest you to re-read again the hints and my explanations minutely and try to figure it out.Everything is there.

And one thing I again I will say, you need to optimise your code.

Hope this helps.

With regards,
Nilosree Sengupta