I keep getting this error in the forward propagation despite the inputs dimensions are set as per instructions and are valid (passed all the previous tests):
{moderator edit: code removed}
If I re-write that function in the non-vectorized form (which I am pretty sure it is wrong) I pass that test but I get a dimension error afterwards:
{moderator edit: code removed}
My inputs dimensions are:
Size of input layer:
n_x = (X.shape[0])
Size of output layer:
n_y = (Y.shape[0])
Weights:
W = np.random.randn(n_y, n_x) * 0.01
Bias:
b = np.zeros((n_y, 1))
I understand there is definitely a matrix dimensions problem but as soon as I try changing them in the sections above I start failing the other tests.
This worked. Thank you so much!
Easy solution, which was actually under my eyes (it is in the formula above that code cell) but which I could not see!
Cheers
I am stuck at the 1st exercise itself. It says ‘There was a problem compiling the code from your notebook. Details:
‘NoneType’ object has no attribute ‘shape’’
I am using np.shape(X) but still getting this. X.shape() also did not solve it.
please use np.dot(W,X) , exactly in that order, not X,W because the number of columns of W must match the number of rows of X for the dot product to be valid.
np.multiply() performs element-wise multiplication (not dot operation), which might work in certain cases. that’s why when the test runs different cases, let’s say the shape of X and W are changed to (1,2), (2,5) then element-wise won’t work, only dot product works. Thus, we fail the test.
np.dot(W,X) will work in all cases, regardless the number of rows and columns of W, X as long as we follow our original setup W(n_y,n_x), X (n_x,m) because:
(number of columns of W = number of rows of X = n_x ) is always true, hence it is a valid dot product.
It took me like 2 hours to learn the difference between element-wise multiplication and dot product lol. The key point is, they are similar but depending on the use case. In ML, dot product is preferred to achieve certain goals like the shape of the result matrix should be compatible to the next operation ( in this case, plus b, which in turn will result in z and y-hat)