Week 3 Forward Propogation shapes not aligned


In my forward propagation step in the Week 3 assignment, I’m getting this error:

Notice, I’m printing X and W1. To compute Z, I’m using np.dot() In the spirit of dimensional analysis, a 4x2 matrix for W1 would lead me to expect a 2x4 matrix for X, but I’m getting a 2x3 matrix. Earlier in the layer_sizes() function, we were instructed to hard code n_h to 4 because we are building a model with 4 nodes in the hidden layer. Based on my dimensional analysis, if I’m given a 2x3 input matrix (X), then I expect to initialize a 3x2 W1 matrix…but that n_h is hard-coded to 4. If you look at the initalize_parameters() comments, it says to initialize W1 to be a matrix of shape (n_h, n_x).

The forward_progogation_test_case initializes an input (X) matrix of 2x3:

What am I not understanding correctly? :frowning:

Thanks in advance.

Never mind! Typing that long explanation helped rivet my mind on the problem. The assert wasn’t pointing out Z1, it was pointing to Z2. That led me to discover that my Z2 formula was not correct…I wasn’t passing in the output of the previous layer (A1) into Z2…pretty important point for implementing a forward propagation algorithm. :slight_smile: