Help! I don’t understand why I keep getting this error.
ValueError: non-broadcastable output operand with shape (2,1) doesn't match the broadcast shape (2,3)
It also indicates that this operation happens in
"parameters[“W” + str(l)] =
parameters[“b” + str(l)] = " lines.
These are the results printed until error occurs:
Expected values:
W1 =
[[ 1.63937725 -0.62327448 -0.54308727]
[-1.0578897 0.85032154 -2.31657668]]
W2 =
[[ 0.33400549 -0.23563857]
[ 1.47715417 -2.04561842]
[-0.33729882 -0.36908457]]
b1 =
[[ 1.72995096]
[-0.7762447 ]]
b2 =
[[ 1.14852557]
[-1.08492339]
[-0.15740527]]
Please share your full error.
ValueError Traceback (most recent call last)
<ipython-input-57-99ca62433443> in <module>
1 parametersi, grads, vi, si, t, learning_rate, beta1, beta2, epsilon = update_parameters_with_adam_test_case()
2
----> 3 parameters, v, s, vc, sc = update_parameters_with_adam(parametersi, grads, vi, si, t, learning_rate, beta1, beta2, epsilon)
4 print(f"W1 = \n{parameters['W1']}")
5 print(f"W2 = \n{parameters['W2']}")
<ipython-input-56-b0b9dd6bf45b> in update_parameters_with_adam(parameters, grads, v, s, t, learning_rate, beta1, beta2, epsilon)
78 # YOUR CODE STARTS HERE
79 parameters["W" + str(l)] -= learning_rate * (v_corrected["dW" + str(l)] / (np.sqrt(s_corrected["dW" + str(l)]) + epsilon))
---> 80 parameters["b" + str(l)] -= learning_rate * (v_corrected["db" + str(l)] / (np.sqrt(s_corrected["db" + str(l)]) + epsilon))
81
82 # YOUR CODE ENDS HERE
ValueError: non-broadcastable output operand with shape (2,1) doesn't match the broadcast shape (2,3)
Please double-check how you are calculating these terms:
v["db" + str(l)] = ...
v_corrected["db" + str(l)] = ...
s["db" + str(l)] = ...
s_corrected["db" + str(l)] = ...
You did this correctly for dW
, so, I guess there might be a typo or minor mistake in case of db
You were right I used dW inside calculation of s_corrected[“db” …
Thank you !