reset password
Author Message
ummata
Posts: 68
Posted 15:54 Feb 08, 2014 |

"RuntimeWarning: divide by zero encountered in log"
I generates random numbers for theta and sometimes I get this message when run fmin_bfgs. 
But it shows "Optimization terminated successfully" and gives
 as well.
Does it work in this case?

 

msargent
Posts: 519
Posted 15:58 Feb 08, 2014 |

My guess is that it's occurring because your cost function is trying to take the log of zero. For a workaround, check out this post

http://stackoverflow.com/questions/13497891/python-getting-around-division-by-zero

ummata
Posts: 68
Posted 16:04 Feb 08, 2014 |

Even it has runtime warning but it also gets optimized thetas, fmin_bfgs might have internal mechanism to deal with that.
I will try your solution as well. However, how do you choose theta? do you also generate random numbers of theta?

Thank you.