I keep getting this error. What is wrong with my code?
Indentation is wrong. model
should be defined inside the method train_mnist
. callbacks
is a local variable.
Ok I’ve fixed my code and have gotten everything to run to accuracy but am having trouble calling train_mnist
I don’t follow you. You got the history
object by calling train_mnist
outside the function.
Please explain what the problem is.
Can you send the code to me by clicking on my name as .pdf file and .ipynb file
Thanks
@paragon You have to return history
from train_mnist
Yes! This might help you sir
If it does you need not share the notebook
I hope the issue is resolved sir by returning history
I returned the history by writing:
history=model.fit(x_train, y_train, epochs=10, callbacks=[myCallback()])
return history.epoch, history.history[‘accuracy’][-1]
But I keep failing the train_mnist part of the assignment. with the message:
Failed test case: hist has incorrect type.
Expected:
<class ‘keras.callbacks.History’>,
but got:
<class ‘NoneType’>.
I have tried everything.
Sir you just need to do
return history
And not anything else
Please try that and let me know
Thanks
I have completed your suggestion. The Jupiter lab is saying the code is correct, but I cannot pass the assignment in coursera with autograder. Is it possible that the code can be manually reviewed?
P.S. I am a woman lol.
So sorry for the mistake firstly ma’am . I will discuss this issue with my fellow mentors and get back to you
Can you please tell me what output is the grader showing
Also ma’am it isn’t possible to review code manually…i am so sorry for that
Please click my name and message your notebook as an attachment.
Hi @paragon, Hope you’re having fun with the course.
In the line you sent before :
history=model.fit(x_train, y_train, epochs=10, callbacks=[myCallback()])
Could you please try calling the instantiation of the Callback you created instead of the class itself
I suggest you should try this
model = tf.keras.Sequential([])
instead of
tf.keras.models.Sequential()
@rishi_29_02 They are the same
In [1]: import tensorflow as tf
In [2]: tf.keras.Sequential == tf.keras.models.Sequential
Out[2]: True
I tried that and it gave me the same:
Failed test case: hist has incorrect type.
Expected:
<class ‘keras.callbacks.History’>,
but got:
<class ‘NoneType’>.
I am trying a few different things to try and pass the assignment, but do not understand how I could pass in Jupyter and still not pass in Coursera autograder.
The course has been stimulating…and it’ll be fun again as soon as I figure out how to pass this assignment.
Thanks
Send me a copy of your notebook in a private message please, I’ll make sure to find what’s wrong so you could go back to having fun with the course ASAP.