Course 2 week 3 Exercise 5 forward propagation

Hi! I don’t know what is happening to me…
I have this:

    # YOUR CODE STARTS HERE
    Z1 = tf.math.add(tf.linalg.matmul(W1,X), b1) 
    A1 = tf.keras.activations.relu(Z1)
    Z2 = tf.math.add(tf.linalg.matmul(W2,A1), b2) 
    A2 = tf.keras.activations.relu(Z2)
    Z3 = tf.math.add(tf.linalg.matmul(W3,A2), b3)

And I get this error:

AssertionError                            Traceback (most recent call last)
<ipython-input-26-cdfbf6341dd3> in <module>
     18     print("\033[92mAll test passed")
     19 
---> 20 forward_propagation_test(forward_propagation, new_train)

<ipython-input-26-cdfbf6341dd3> in forward_propagation_test(target, examples)
      4         forward_pass = target(tf.transpose(minibatch), parameters)
      5         print(forward_pass)
----> 6         assert type(forward_pass) == EagerTensor, "Your output is not a tensor"
      7         assert forward_pass.shape == (6, 2), "Last layer must use W3 and b3"
      8         assert np.allclose(forward_pass,

AssertionError: Your output is not a tensor

I dont know why my Z3 is a EagerTensor.
please help :slight_smile:

Just to make sure we’re on the same page, what the error message is telling you is that your result is not an EagerTensor. But having said that, I have to say that the code you show looks correct to me. The only difference in my code was that I used tf.matmul, instead of tf.linalg.matmul, but I tried it your way also and it passed the tests for me.

So the theories I can think of are:

  1. You’re not actually running the code you show above because you haven’t hit “Shift-Enter” on that cell since the last time you changed it. Just typing new code and then calling the function again runs the old code, right?
  2. There is something else wrong, e.g. maybe you changed part of the template code that they gave you in a way that causes this error.