Tensorflow assignment Exercise 5 HELP!

Hello, all!

I am doing DLS course 2 last assignment : Introduction to TensorFlow. I am having a huge trouble to implement Exercise 5, forward_propagation.

#(approx. 5 lines)                   # Numpy Equivalents:
    # Z1 = ...                           # Z1 = np.dot(W1, X) + b1
    # A1 = ...                           # A1 = relu(Z1)
    # Z2 = ...                           # Z2 = np.dot(W2, A1) + b2
    # A2 = ...                           # A2 = relu(Z2)
    # Z3 = ...                           # Z3 = np.dot(W3, Z2) + b3

As the comments show, I thought if just switching numpy functions to tf functions such as tf.math.add, tf.linalg.matmul, tf.keras.activations.relu, then everything might work well. But I got this error:

AssertionError: Output does not match

I double checked if I had typo or wrong variable, but I typed right.

When I print my current answer Z3, I got something different from correct value. Here is what I got:

[[ 0.31806493]
 [ 0.4478007 ]
 [ 1.6599247 ]
 [-1.261049  ]
 [ 0.56874084]
 [ 1.3622664 ]], shape=(6, 1), dtype=float32)

I tried to look around more info from tf official docs, but still no luck.

What am I missing? plz help!

Thanks in advance!

Hi, @baekTree.

That is exactly what you have to do. And the comments are correct. [the comments could be wrong in some notebooks, see @paulinpaloalto’s post below] Feel free to send me a private message with your code so that I can point you in the right direction.

The one thing to point out is that the comment that describes how to compute Z3 is wrong. The input there should be A2, not Z2. This has already been reported and fixed, but the new version is not deployed yet.

1 Like

Thank you, @paulinpaloalto.

It must’ve been deployed. I checked the formulas in my own notebook and they were correct. I didn’t realize they were different from the ones @baekTree posted :thinking:

Great! I saw the “pull” request with the fix, but figured if baekTree had seen it the other way that it still must be the previous version. Did you get an “autoupdate” of that notebook or did you do the manual “Lab Help → Get Latest Version” method?

Ok, I just answered my own question: I opened that notebook and it did not “autoupdate” and I still had the old incorrect version. Then I did the “rename” followed by “Lab Help → Get Latest Version” and I got the fixed version. So it is deployed, but you have to manually ask for the new version.

For anyone who has not been through the “Get Latest Version” procedure before, there’s a topic about it on the FAQ Thread. It’s easy, but the only thing that might trip anyone up is the point that you need to rename your existing notebook or it will not be replaced.

1 Like

It must’ve been updated automatically before I redid the assignment.

I found myself that I missed the fact that Z3 must have A2 in activation function not Z2 as @paulinpaloalto replied!

plus I have updated to the latest version through “Get Latest Version”.

Thank you all!

1 Like