the function compute_cost
should return a scalar value float
but in your case here it’s returning a NumPy array.
this what cause you an error. check the function implementation again. I believe you just miss to sum
the values.
Cheers,
Moaz
I understand your point but i don’t know how to solve this issue
Please, do not post any if your code as it’s against the Student Honor code.
i deleted the photo, how can i solve this problem?
@Mohamed.Hesham.nour
The problem is that your function is returning an array not a scalar value.
try using indexing
at your return like
return total_cost[0]
and see it solves your problem or not.
@Moaz_Elesawey
it returned float value, but it clashed in case 2
can please tell me the shape of the output without using indexing
(97,)
<class ‘numpy.ndarray’>
------------------------------------
=if i used return total_cost[0]
()
<class ‘numpy.float64’>
Hello @Mohamed.Hesham.nour,
You have less than 10 lines of code, so after each line, I suggest you to add a new line to print the content of the assigned variable in the previous line. Below is an example:
Source: general code debugging tips
As soon as you see your printed variable being an array or a list, there is the problem.
Raymond