Week 04 assignment 1 exercise 5

In function L_model_forward getting this error;

ValueError: shapes (3,4) and (3,4) not aligned: 4 (dim 1) != 3 (dim 0)

How to debug?

for l in range(1, L):
A_prev = A

    A, cache = linear_activation_forward(A_prev, parameters['W' + str(l)], parameters['b' + str(l)], 'relu')

AL,cache = linear_activation_forward(A,parameters["W"+str(l)],parameters["b"+str(l)], activation = 'sigmoid')          

Dot product of 2 matrics requires that the inner dimensions match. i.e. they should be of shape (a, b) and (b,c) to produce a result of (a, c).

If you’re having trouble tracking the bug, click my name and message your notebook as an attachment.

Please fix computation of AL, cache (outside the for loop for the sigmoid activation function). You should use the correct layer for this.