C1_W3_assignment random values

I’m trying to solve questions which involve generating an array with random values but output shows error that values dont match expected value , please help

Hi @Aniket_Bankar,

It would be helpful if you could please print the error message.

below error is displayed

Test case “default_check”. Wrong array A.
Expected:
[[ 0.00570642 -0.01919142 0.01547892 -0.0030841 0.02047485 0.00898775
-0.04116597 -0.01222935 -0.0068693 -0.01570162 -0.03684825 -0.01968598
-0.01967296 0.02027892 0.03120819 -0.00219805 -0.01673743 0.0290535
0.02615167 0.0161261 -0.01361516 0.00948609 -0.00944703 -0.00479152
0.0104244 0.00075505 0.01611296 -0.00446031 -0.01094205 -0.00576684]]
Got:
[[ 0.08271167 -0.27816974 0.22435905 -0.04470244 0.29677242 0.13027289
-0.59667954 -0.17725812 -0.09956703 -0.22758694 -0.53409652 -0.28533822
-0.2851495 0.2939325 0.45234672 -0.03185959 -0.24260051 0.42111551
0.37905506 0.2337396 -0.19734475 0.13749595 -0.13692982 -0.06945064
0.15109627 0.01094402 0.23354911 -0.06464988 -0.15859935 -0.08358745]].
Test case “change_weights_check”. Wrong array A.
Expected:
[[-0.00245289 0.00824937 -0.00665357 0.00132569 -0.00880105 -0.00386336
0.01769506 0.00525675 0.00295275 0.00674929 0.0158391 0.00846196
0.00845636 -0.00871683 -0.01341474 0.00094482 0.00719453 -0.01248855
-0.01124121 -0.00693175 0.00585243 -0.00407756 0.00406077 0.00205962
-0.00448089 -0.00032455 -0.0069261 0.00191725 0.0047034 0.00247886]]
Got:
[[ 0.13243351 -0.44539056 0.35923174 -0.07157516 0.47517618 0.208586
-0.95537147 -0.28381625 -0.15942142 -0.36440008 -0.85516687 -0.45686834
-0.45656618 0.47062905 0.72427345 -0.05101188 -0.38843901 0.6742677
0.60692276 0.37425139 -0.3159779 0.22015119 -0.21924473 -0.11120066
0.24192729 0.01752298 0.37394638 -0.10351394 -0.25394082 -0.13383577]].

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)
289
290 for test_case in test_cases:
→ 291 result = target_forward_propagation(
292 test_case[“input”][“X”],
293 test_case[“input”][“parameters”],

in forward_propagation(X, parameters, n_y)
18 # Implement Forward Propagation to calculate Z.
19 ### START CODE HERE ### (~ 2 lines of code)
—> 20 Z = W @ X + b
21 Y_hat = Z
22 ### 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)

I am sorry, it is quite confusing the way you present it. I think there are different errors in different places. It would be helpful if you can please organize it like:

error 1: snapshot of the error 1 in cell 1
.
.
.
error-n: snapshot of the error n in cell n

A screen capture image would have been more useful. Using a text copy-and-paste tends to be interpreted as Markdown, and it mangles the indentation.

The error says that for some reason, the W and X variables don’t have compatible sizes for the matrix @ operation.

Did you do something in your notebook that would have altered the size of either W or X?

  • Your code in forward_propagation() should not modify X.

  • Your code in forward_propagation() should get the W variable by extracting it from the ‘parameters’ dictionary.




Can you answer the questions that were in my previous post?