Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math OverflowError in update_factors #6

Open
danielegrattarola opened this issue Nov 28, 2016 · 4 comments
Open

Math OverflowError in update_factors #6

danielegrattarola opened this issue Nov 28, 2016 · 4 comments

Comments

@danielegrattarola
Copy link

Hello,
I'm trying to use you code to learn and predict on a binary sparse matrix (meaning I only have 1s in the matrix), but during the training phase it will crash and throw this error:
Traceback (most recent call last): File "bpr.py", line 260, in <module> model.train(data,sampler,num_iters) File "bpr.py", line 52, in train self.update_factors(u,i,j) File "bpr.py", line 81, in update_factors z = 1.0/(1.0+exp(x)) OverflowError: math range error

I've checked to see who's guilty of this, and apparently the x variable of the fucntion is diverging, therefore causing the exp operator to overflow.
Have you encountered this issue? Can you suggest a fix?

Thanks

@YadalaRamya
Copy link

YadalaRamya commented Jan 23, 2017

What is the input data for bpr.py code?? can u provide a sample input

@HongxuChenUQ
Copy link

sampling 9993 <user,item i,item j> triples...
initial loss = 5242.5237869
starting iteration 0
Traceback (most recent call last):
File "testTopK.py", line 303, in
model.train(data,sampler,num_iters)
File "testTopK.py", line 52, in train
self.update_factors(u,i,j)
File "testTopK.py", line 80, in update_factors
z = 1.0/(1.0+exp(x))
OverflowError: math range error

Same problem, Any ideas?

@HongxuChenUQ
Copy link

Hi, please try this to fix
try:
z = 1.0/(1.0+exp(x))
except OverflowError:
z = float('inf')

@fukien
Copy link

fukien commented May 1, 2019

I met the same problem, and I tune the learning rate smaller to resolve the math range error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants