Q about 1st assignment results

Hi, I finished the assignment but I have a question about a solution that I apply to avoid errors. I built my cost function step by step then I merged it in one line to make forward and backward propagation. However, I did change the position of line ‘cost = np.squeeze(np.array(cost))’ in my code which was outside of the space for coding. I don’t understand what does np.squeeze in the code and why I had to move it to avoid errors. The code line is:
cost = -np.sum(np.squeeze(np.array(np.multiply(Y, np.log(A)) + np.multiply((1 - Y), (np.log(1 - A))))), axis = 0)/m

Thanks for your help.

Hi @Rubencho I think in the original code the squeeze function is used to remove the one dimensional axes which result after calling the np.array function. In your code you make also use of np.array at a certain stage probably coming to the same results.

1 Like

Thanks for the reply.
I don’t know if that gives the same solution because if I keep outside my code I get an error.