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

FM: model coefficients Nan after fit #3

Closed
RiccardoNizzolo opened this issue Jan 28, 2018 · 4 comments
Closed

FM: model coefficients Nan after fit #3

RiccardoNizzolo opened this issue Jan 28, 2018 · 4 comments

Comments

@RiccardoNizzolo
Copy link

Hi!
I'm running this kernel on kaggle:
kernel

After the fit on a valid matrix (without NA) the status of the model still contains Nan.
During the fit there are neither exceptions nor warnings.

To see the status of de model I have called :
model.__getstate__()

The result is:

model FM_FTRL status:
(0.01, 0.01, 1e-05, 0.1, 0.01, 0.0, 1.0, 0.0, 1020688, 200, 17, array([ nan, 0., 0., ..., 1., 1., 1.]), array([ nan, nan, nan, ..., nan, nan, nan]), array([ nan, nan, nan, ..., nan, nan, nan]), array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan]), array([ nan, nan, nan, ..., nan, nan, nan]), array([ nan, nan, nan, ..., nan, nan, nan]), 0, 0, True)

@anttttti
Copy link
Owner

I think this is an issue with your parameters.

" 1.0, 0.0, 1020688".. the 0.0 parameter in the middle means you've initialized the factor weights as 0. A init_fm=value of 0.01-0.001 usually works well.

@RiccardoNizzolo
Copy link
Author

The init_fm parameter is initialized with value 0.2:
model = FM_FTRL(alpha=0.01, beta=0.01, L1=0.00001, L2=0.1, D=sparse_merge.shape[1], alpha_fm=0.01, L2_fm=0.1, init_fm=0.2, D_fm=200, e_noise=0.0001, iters=17, inv_link="identity", threads=4)

If i call model.__getstate__() just after the initialization I get init_fm=0 but the z array is randomly initialized:
log

The interesting fact is that the Nan came out dependently on the training set:
model.fit(train) -->converge
model.fit(train.sign()) --> get Nan values

@SpongebBob
Copy link

SpongebBob commented Feb 25, 2018

I have the same problem

If i call model.getstate() just after the initialization I get init_fm=0

All predict values are nan

@anttttti
Copy link
Owner

I could replicate this now. The problem is not with init_fm, that one you could set as 0, but with bad results. The issue is alpha_fm set too high compared to feature values, leading the updates to overflow. Try normalizing the input rows, or starting with very low alpha_fm, <0.01.

This could be fixed by gradient clipping, but in general you would still get low quality models in cases where this is happening. You should normalize the input rows or lower alpha_fm.

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

3 participants