Exercise 2:
TypeError Traceback (most recent call last)
in
5 initial_b = 0.
6 cost = compute_cost(X_train, y_train, initial_w, initial_b)
----> 7 print(‘Cost at initial w and b (zeros): {:.3f}’.format(cost))
TypeError: unsupported format string passed to numpy.ndarray.format
Hi @Sudipto_Das_Sukanto

This line tried to substitute {:.3f}
with cost
and format it to a number with 3 decimal places. However, it failed because, as suggested by the error message, cost
was not a number, but an array
:

Note that cost
was returned from compute_cost
which is an exercise of this assignment:

So, go back to the computer_cost
exercise, and figure out why it did not return a number. Cost should be a number.
Good luck!
Raymond
1 Like
I concur. I have experienced similar difficulties. To ensure accuracy, we should confirm that the calculated cost is consistent with anticipated results and formatting conventions.