Hello @Yesheng_Huang, thanks for reaching out.
Please do not post code publicly, consider sending it to a mentor privately next time, please.
Other than that you’ve done an amazing job so far, you just need to change a small thing.
Could you simply use:
next(csv_reader, None)
instead of
fields = next(csv_reader)
in your parse_data_from_input function
Let me know if this fixes your problem.
PS: Remove the .ipynb file from the post, please.
Hello @kisax,
You have the same error but for a different reason,
In your parse_data_from_input function: before appending the images to the list reshape them using np.reshape ,an example of that would be np.array(row[1:]).reshape(28,28).
After you’ve finished the iteration, use the method .astype for conversion of the numpy arrays.
For example: labels= np.array(labels).astype(float).
Furthermore, in this assignment you’re dealing with Multi-class Classification, so the number of units in your Last Dense layer should be equal to the number of classes.
Hint: sigmoid works better with binary classification, try another activation function.
Please consider making changes only where specified in the notebook, your problem is in the parse_data_from_input function, please use csv.reader and a loop to iterate through the csv file then append the data to labels and images.
Keep me posted.
Happy coding!
I’ve used csv.reader and a loop to iterate through the csv file then append the data to labels and images. But still getting same message from grader as before.
Sorry. I did not mean to publicize my code. I am a bit new to this forum, and I actually don’t know where I can privately message a mentor. Could you possibly let me know where I can find the list of mentors? I googled how to use deeplearning.ai forum, but did not find an answer.
Also, I changed it to next(csv_reader, None), but problem still exists and I still score 0 / 100 and got the same error messages.
The first line of the CSV file contains headers, which should be skipped during the iteration. I adored your creative attempt to do that by using if-else statements, I suggest that you use this line of code instead before your loop:
next(csv_reader, None)
Then in the loop remove the if-else condition and only keep what you wrote in the else statement.
If you follow this correctly you should get 100/100.
Thanks for your understanding @Yesheng_Huang, I believe that it was an honest mistake.
In the future, I suggest you post your problem like you did last time, and when a mentor replies to you, you can send them your code if they ask for it. By clicking on their name an option for messaging will appear, use that for private messages.
Please consider posting the problems you face here publically, so other people who’ve faced the same issue can find the answer.
For the code, I have tried it myself. If you haven’t made any other changes than that you should get 89/100. Use next(csv_reader, None), and do not assign it to anything, not fields = next(csv_reader, None) but simply next(csv_reader, None).
If you still get the same error message or want to get a perfect score (100/100), send me the updated notebook privately and I’ll do my best to guide you.
@Yesheng_Huang , Glad to see that you’re making progress, Congratulations for passing the assignment.
To get a perfect score, you need to change the loss function, give parse_categorical_crossentropy a try, but for it to work, you need to remove the one hot encoding that you did in the train_val_generators function.
Simply set y to training_labels in train_generator and set it to validation_labels in validation_generator.
For reaching 99% accuracy, I’ll let you play with code yourself and try to figure it out.
Hi all, this error is probably being caused because we updated the graders recently to allow the use of global scope.
Could you try getting the latest version of the assignment? To do this, visit the link provided in the classroom which should redirect you to colab. This new version of the assignment contains some extra metadata required for grading, so create a copy of it and on this new version (which should be blank) copy and paste your solution, check that everything is running correctly (you can also try submitting without running since the training usually takes a long time), download your notebook and submit for grading.