When Calculate Cost Function returning array instead scalar value

here is my code should I sum it? and how to do summation in numpy?

{Moderator Edit: Solution Code Removed for the 2nd time}

You can use np.sum. Please note that sharing your code is not allowed by the community code of conduct.

1 Like

sorry. I have edited. here is output after sum

The cost after training is 6.78395445.
The resulting vector of weights is [4.1e-07, 0.00035658, 7.309e-05]

Expected output

The cost after training is 0.67094970.
The resulting vector of weights is [4.1e-07, 0.00035658, 7.309e-05]

I found it. The problem was with np.dot. Thx for responding

I edited your post to delete your code, you edited your post to add code again. Please note that sharing your code in a public thread is strictly prohibited by the community code of conduct and if you keep sharing your code, this will lead to suspend your account.

Regarding your query, use dot product and don’t need to use sum function.