When I do:
summing += yval * np.log(sigmoid(np.dot(w.transpose(), xi.transpose()))) + (1-yval)* np.log(1-sigmoid(np.dot(w.transpose(), xi.transpose())))
where there is no division, why do I get a "divide by zero encountered in log" error? As a result, summing
becomes [nan]
.
That's the warning you get when you try to evaluate log with 0:
>>> import numpy as np
>>> np.log(0)
__main__:1: RuntimeWarning: divide by zero encountered in log
I agree it's not very clear.
So in your case, I would check why your input to log is 0.
PS: this is on numpy 1.10.4
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments