C1_W2_Linear_Regression [2.6 Learning parameters using batch gradient descent ]

2.6 Learning parameters using batch gradient descent .

In this section when i run the cell, I am getting this error (This is non-editable section)

TypeError Traceback (most recent call last)
9 w,b,, = gradient_descent(x_train ,y_train, initial_w, initial_b,
—> 10 compute_cost, compute_gradient, alpha, iterations)
11 print(“w,b found by gradient descent:”, w, b)

in gradient_descent(x, y, w_in, b_in, cost_function, gradient_function, alpha, num_iters)
45 if i% math.ceil(num_iters/10) == 0:
46 w_history.append(w)
—> 47 print(f"Iteration {i:4}: Cost {float(J_history[-1]):8.2f} ")
49 return w, b, J_history, w_history #return w and J,w history for graphing

TypeError: only size-1 arrays can be converted to Python scalars

The error suggests that the “total_cost” variable returned by your compute_cost() function is not a scalar.

Probably you don’t return a list of j_history , in function 1gracient_descent