Hello everyone, I was trying to compute the gradient descent on a different dataset and run into the error below.
C:\Users\migas\AppData\Local\Temp\ipykernel_34976\4288327375.py:11: RuntimeWarning: overflow encountered in double_scalars w_adj = (y_pred - y[i]) * x[i] C:\Users\migas\AppData\Local\Temp\ipykernel_34976\3680357176.py:12: RuntimeWarning: invalid value encountered in double_scalars w = w - learning_rate * dw C:\Users\migas\AppData\Local\Temp\ipykernel_34976\3680357176.py:13: RuntimeWarning: invalid value encountered in double_scalars b = b - learning_rate * db
I believe this overflow error is caused by the value being out of the defined range of the data type. I tried using numpy.exp()
but it just rounded my results to 0. Is there something I can do here?
See the code below!
#### Computing the gradient
def compute_gradient(x,y,w,b):
(code removed)
w, b = 0,0
compute_gradient(x_org,y_org,w,b)
Output for one iteration → (-5.228267343780145e+149, -1.0251504595647343e+148)
`
#### Compute the gradient descent
def compute_gradient_descent(x,y,w_in,b_in,learning_rate ,num_iter):
(code removed)
w_final, b_final = compute_gradient_descent(x_org,y_org,w,b,0.01,10000)