C1_W3_assignment

{moderator edit; code removed}

Y_hat = forward_propagation(X, parameters)

print(Y_hat)

[[-0.00493387 0.01659322 -0.01338333 0.00266656 -0.01770289 -0.00777096
0.03559277 0.0105737 0.00593931 0.01357588 0.03185961 0.01702083
0.01700957 -0.01753349 -0.02698312 0.00190047 0.01447146 -0.02512013
-0.02261117 -0.0139429 0.01177189 -0.00820183 0.00816806 0.00414283
-0.00901311 -0.00065283 -0.01393153 0.00385646 0.00946067 0.00498611]]

w3_unittest.test_forward_propagation(forward_propagation) error

ValueError Traceback (most recent call last)
in
----> 1 w3_unittest.test_forward_propagation(forward_propagation)

~/work/w3_unittest.py in test_forward_propagation(target_forward_propagation)
286
287 for test_case in test_cases:
→ 288 result = target_forward_propagation(test_case[“input”][“X”], test_case[“input”][“parameters”])
289
290 try:

in forward_propagation(X, parameters)
19 # Implement Forward Propagation to calculate Z.
20 ### START CODE HERE ### (~ 2 lines of code)
—> 21 Z = np.add(np.matmul(W,X), b)
22 Y_hat = Z
23 ### END CODE HERE ###

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)

What should I do to resolve it?

Hi @Sandor_Vas,

Welcome to the community.

try
Z = np.dot(W,X) + b
for Y_hat, you have not applied the activation function
like
Y_hat = some_activation_function(Z)

Please do not post your code on the forum. That isn’t allowed by the community standards.

I have edited your message to remove the code.

I understood. Thanks.

Hi @Girijesh, Thank you for your help.

After execution
w3----------unittest.test--------------forward-propagation------------------- (forward_propagation)

I have the following message:

“Test case “default_check”. Wrong array A.” Ok, but what can I do with it? I haven’t got array A. Of course the test failed. I hope I did not violate the code rules

Exercise 4

  1. Implement Forward Propagation. Compute Z multiplying arrays w, X and adding vector b. Set the prediction array 𝐴 equal to 𝑍.
    ------------------------^^