Week 4 Assignment 2 : Error in UNQ_C5 output

I am getting right implementations and answers till UNQ_C4 function for Week 4 assignment 2.

I am not able to follow what step is getting wrong in UNQ_C5 function.

  • This is the error I am getting:
tf.Tensor(10221.223, shape=(), dtype=float32)
tf.Tensor(8850.47, shape=(), dtype=float32)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-29-e8adb96bb73f> in <module>
      9 J2 = train_step(generated_image)
     10 print(J2)
---> 11 assert np.isclose(J2, 6081.23541, rtol=0.05), f"Unexpected cost for epoch 1: {J2} != {6081.2354}"
     12 
     13 print("\033[92mAll tests passed")

AssertionError: Unexpected cost for epoch 1: 8850.4697265625 != 6081.2354

Expected output

tf.Tensor(10221.169, shape=(), dtype=float32)
tf.Tensor(6081.1763, shape=(), dtype=float32)
  • This is my implementation of UNQ_C5 function:
# UNQ_C5
# GRADED FUNCTION: train_step

# mentor edit: code removed to clear the Honor Code

Any help would be much appreciated.
Thank you.

you calculate style cost twice.

1 Like

Thank you for pointing that out.

1 Like