I’ve reviewed at least 6 or 7 posts on this AssertionError and have tried all suggested fixes including:
tf.square or **2
tf.substract or -
checking that various cost function calls receive correct content, style, and generated arguments in the correct position
Kernel > Restart & Run All
closing browser, shutting computer down, going for walk
repeating the above in various permutations in the same or different sessions
All tests for the assignment are passed (and the model trains/works, even on my own content and style photos), but the unit test for UNQ_C5 – it gives the following error
AssertionError: Unexpected cost for epoch 0: 24085.95703125 != 25629.055
Given that the just below that cell, the “Expected output” for the 1st tensor is
tf.Tensor(25700.346, shape=(), dtype=float32)
the output of my code is close, but how can I get it closer/pass the unit test?
Following the instructions on the site, I renamed the python notebook assignment and then got the latest version of the assignment, a clean version.
I had downloaded my completed but error-generating version as html and just pasted the unicode text from it into the new, clean version–error gone, I got 100% on the submitted assignment.
Might a been a hidden “global” var I whacked partway through the assignment that wasn’t in the clean version.
I got the same error when I did this assignment in my local computer with a different version of Python, TensorFlow, etc. from the Coursera environment. Are you using the local machine or the Coursera environment?
What is the meaning of that “Last cell”? The last cell of the notebook frees up the resources but here “Last cell” is referring to any other cell. So, where it is?
Then maybe you’ve changed content_layer = [('block5_conv4', 1)] or number of iteration in optimizer = tf.keras.optimizers.Adam(learning_rate=0.01). Check it out.
If you didn’t change anything, try Kernel → Restart & Clear Output. Then run all the cells again. Let’s see if it solves the issue.
The only thing that seems to bring the cost close to the expected one is by tinkering with the noise value. The default is -0.25, 0.25, if I’m not mistaken. Changing it to -0.22 and 0.22 brings the cost to 27474. Don’t know what else to do.
Send me your code of train_step in a private message. But make sure you didn’t change anything. If you did, revert it to the original. Click my name and message.
It’s a normal practice that we have to run a previous cell before the test cell. I don’t know why they mentioned that. And the wording is vague, “Last cell” confuse me with the last cell of the notebook.