Reputation: 1259
I tried various solutions for below, but I still get the errors as described:
log1p(1 + math.exp(comp * -1))
Error: OverflowError: math range error
So I changed it to: log1p(1 + np.exp(comp * -1))
Now I get error : RuntimeWarning: overflow encountered in exp
So again based on some suggestion on previous questions asked I changed it to: log1p(1 + np.exp((comp * -1), dtype=np.float256))
Now my error is : module 'numpy' has no attribute 'float256'
Any other suggestions? Please help thanks!
EDIT: X -> Input feature array of 'N' rows and 'm' features. w -> weight vector of size 'm'
for rowIndex in range(len(X)):
val1 = np.sum(np.dot(X[rowIndex], w))
val2 = y[rowIndex]
comp = np.dot(val2, val1)
loss = loss + log1p(1 + np.exp((comp * -1)))
Upvotes: 0
Views: 307
Reputation: 1259
I replaced the code as below:
loss = loss - log1p(expit(val))
Basically I rearranged my code to be able to use the expit function...
Upvotes: 0