Cost Function giving value error: operands could not be broadcast together with shapes (1,30) (1,5)

I’m having issues moving past defining compute_cost function. When i get to define NN, i keep getting this error. I’ve also tried np.subtract(). Not sure why Y is of shape (1,5). PS. I the code is supposed to be (Y_hat - Y) not the reverse

Hi @jgichimu ,

Please attached your notebook in a DM to me, I will have a look for you to see what the problem might be.

1 Like

Hi @jgichimu ,

In the nn_model() function, y_hat should be a local variable for hold the values returned from forward_propagation(). But there is no y_hat declared to hold those values. What is passed to the compute_cost() function is the y_hat used in cell for testing the forward_propagation() , and it is those values that are used within the nn_model(). So, amending your code for nn_model() should rectify the problem.

1 Like

OMGGG!!! I can’t even… THANK YOU!