I am getting Train = 0 Test =0 and the predictions are all "nan"

393 views
Skip to first unread message

kensuke....@gmail.com

unread,
Nov 8, 2015, 10:39:57 AM11/8/15
to libFM - Factorization Machines
Hi,

I am new user to libFM, and I am trying to use it on my own problem, but I am having difficulty doing so.

I am getting the log below.

The command is:

/root/libfm/bin/libFM -task c -train /opt/vol/data/experiments/fm_data/libfm_train.txt -test /opt/vol/data/experiments/fm_data/libfm_test.txt -dim '1,1,4' -iter 500 -learn_rate 0.1 -method sgd -regular '1,0.01,0.001' -out /opt/vol/data/experiments/predictions/000248.rdata -save_model /opt/vol/data/experiments/models/000248.rdata -verbosity 1

-----------------------------------------------------------------
Loading train...
has x = 1
has xt = 0
num_rows=1105887 num_values=38573768 num_features=349 min_target=0 max_target=1
1 1:1 7:1 17:1 21:1 24:1 34:1 66:1 92:3 95:1 97:1 98:1 99:1 100:1 101:4 108:1 110:1 114:1 115:1 117:1 118:1 121:1 123:1 124:1 126:1 130:1 134:1 160:1 170:1 199:1 208:1 214:1 275:1 286:1 348:1
0 1:1 7:1 17:1 21:1 24:1 34:1 66:1 92:3 95:1 97:1 98:1 99:1 100:1 101:4 108:1 110:1 114:1 115:1 117:1 118:1 121:1 123:1 124:1 126:1 130:1 134:1 160:1 170:1 199:1 208:1 214:1 275:1 286:1 348:1
0 1:1 7:1 17:1 21:1 24:1 39:1 41:1 90:1 91:1 92:3 96:1 97:1 98:1 99:1 101:3 102:1 108:1 110:1 113:1 115:1 118:1 121:1 123:1 124:1 126:1 127:1 130:1 134:1 138:1 146:1 148:1 160:1 172:1 199:1 200:1 205:1 208:2 218:1 268:1 269:1 286:1 348:1
0 1:1 7:1 17:1 24:1 33:1 41:1 69:1 92:3 95:1 99:1 100:1 101:2 102:1 108:1 110:1 113:1 115:1 119:1 121:1 122:1 123:1 127:1 136:1 137:1 138:1 141:1 146:1 150:1 157:1 160:1 170:1 207:1 208:1 211:1 232:1 263:1 286:1 348:1
Loading test...
has x = 1
has xt = 0
num_rows=248919 num_values=8824468 num_features=348 min_target=0 max_target=1
0 1:1 5:1 20:1 23:1 32:1 39:1 40:1 68:1 91:2 93:1 96:1 97:1 98:1 100:3 104:1 107:1 108:1 110:1 111:1 112:1 114:1 117:1 122:1 125:1 126:1 129:1 130:1 132:1 147:1 151:1 156:1 159:1 165:1 169:1 197:1 206:1 207:5 209:1 222:1 225:1 285:1 286:1
0 1:1 2:1 9:1 18:1 23:1 38:1 40:1 89:1 90:1 91:3 95:1 96:1 97:1 98:1 100:3 101:1 107:1 109:1 112:1 114:1 117:1 120:1 122:1 123:1 125:1 126:1 129:1 133:1 137:1 145:1 147:1 159:1 171:1 198:1 199:1 204:1 207:2 217:1 267:1 268:1 285:1 294:1
0 1:1 2:1 9:1 18:1 23:1 38:1 40:1 89:1 90:1 91:3 95:1 96:1 97:1 98:1 100:3 101:1 107:1 109:1 112:1 114:1 117:1 120:1 122:1 123:1 125:1 126:1 129:1 133:1 137:1 145:1 147:1 159:1 171:1 198:1 199:1 204:1 207:2 217:1 267:1 268:1 285:1 294:1
0 1:1 10:1 23:1 37:1 39:1 89:1 90:1 91:3 94:1 96:1 97:1 98:1 100:3 104:1 107:1 108:1 109:1 110:1 113:1 122:1 125:1 129:1 133:1 152:1 156:1 159:1 165:1 168:1 198:1 199:1 206:1 207:2 220:1 222:1 285:1 286:1
#relations: 0
Loading meta data...
#attr=349 #groups=1
#attr_in_group[0]=349
num_attributes=349
use w0=1
use w1=1
dim v =4
reg_w0=1
reg_w=0.01
reg_v=0.001
init ~ N(0,0.1)
num_iter=500
task=1
min_target=0
max_target=1
learnrate=0.1
learnrates=0.1,0.1,0.1
#iterations=500
SGD: DON'T FORGET TO SHUFFLE THE ROWS IN TRAINING DATA TO GET THE BEST RESULTS.
#Iter= 0 Train=0 Test=0
#Iter= 1 Train=0 Test=0
#Iter= 2 Train=0 Test=0
#Iter= 3 Train=0 Test=0
#Iter= 4 Train=0 Test=0
#Iter= 5 Train=0 Test=0
#Iter= 6 Train=0 Test=0
#Iter= 7 Train=0 Test=0
#Iter= 8 Train=0 Test=0
#Iter= 9 Train=0 Test=0
#Iter= 10 Train=0 Test=0
#Iter= 11 Train=0 Test=0
#Iter= 12 Train=0 Test=0
..
..
..

-----------------------------------------------------------------

After this, the same "Train = 0 Test = 0" thing goes on and on,
and when I check the results, the prediction values are all "nan".


What could be causing this problem?

Thank you


Kensuke Koshijima

Thierry Silbermann

unread,
Nov 10, 2015, 9:14:58 AM11/10/15
to libFM - Factorization Machines, kensuke....@gmail.com
I rarely use sgd but often it is an issue on the values you are using for regularization, try to play with this number. The regularization you are using for the latent factor seems too low for me, try increasing that first.

I see you are save the model. Just train model on 10 iterations with different regularization values and see how the value of the parameter you are using changes. It's better to have strong regularization if you don't want your model to overfit.

Tell me if it changed anything.

Reza

unread,
Nov 26, 2015, 6:23:48 PM11/26/15
to libFM - Factorization Machines, kensuke....@gmail.com
I have the same problem. The MCMC works on the dataset and the testset but the accuracy is not so great. When I use SGD (different regularization parameters from 0.001 to 10) or SGDA, I get all nans in the output file:

ubuntu/libfm-1.42.src/bin$ ./libFM -task c -train trainX2.txt -test testX2.txt -dim '1,1,8' -iter 5 -method sgda -learn_rate 0.1 -init_stdev 1 -validation valX2.txt -out pred_file.txt
----------------------------------------------------------------------------
libFM
Version: 1.4.2
Author: Steffen Rendle, sre...@libfm.org
WWW: http://www.libfm.org/
This program comes with ABSOLUTELY NO WARRANTY; for details see license.txt.
This is free software, and you are welcome to redistribute it under certain
conditions; for details see license.txt.
----------------------------------------------------------------------------


Loading train...
has x = 1
has xt = 0

num_rows=60000 num_values=14771004 num_features=545 min_target=0 max_target=1


Loading test...
has x = 1
has xt = 0

num_rows=20000 num_values=4925899 num_features=545 min_target=0 max_target=1
Loading validation set...


has x = 1
has xt = 0

num_rows=20000 num_values=4922986 num_features=545 min_target=0 max_target=1


#relations: 0
Loading meta data...

learnrate=0.1
learnrates=0.1,0.1,0.1
#iterations=5
Training using self-adaptive-regularization SGD.
DON'T FORGET TO SHUFFLE THE ROWS IN TRAINING AND VALIDATION DATA TO GET THE BEST RESULTS.
Using 60000 rows for training model parameters and 20000 for training shrinkage.


#Iter= 0 Train=0 Test=0
#Iter= 1 Train=0 Test=0
#Iter= 2 Train=0 Test=0
#Iter= 3 Train=0 Test=0
#Iter= 4 Train=0 Test=0

Final Train=0 Test=0

ubuntu/libfm-1.42.src/bin$ cat pred_file.txt
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
nan
...

Message has been deleted

wenming xu

unread,
Aug 3, 2017, 2:53:06 AM8/3/17
to libFM - Factorization Machines, kensuke....@gmail.com
Hi,I try to increase the regularization latent factor as "1,1,10". but still get all  0. 
Any suggestion ? My training data is more than 10 mililion rows with thousands of sparse features.
Looking for your reply .Thanks a ton.

在 2015年11月10日星期二 UTC+8下午10:14:58,Thierry Silbermann写道:
Message has been deleted
Message has been deleted

kev...@gmail.com

unread,
Aug 26, 2018, 9:17:39 AM8/26/18
to libFM - Factorization Machines
So am I.
I try to reduce the training data from 100k lines to 300 lines.
I get first two epochs with 0.9xxx, but the rest epochs still remain 0.

Kevin Yu

kensuke....@gmail.com於 2015年11月8日星期日 UTC+8下午11時39分57秒寫道:

郭梦卓

unread,
Jul 25, 2019, 5:26:52 AM7/25/19
to libFM - Factorization Machines
Hi, I am also a new user. 
Did you use the latest verision in Windows? I cannot use the operation '-save_model'.
Could you please send me a latest version that can work with '-save_model'?

Thanks.

在 2015年11月8日星期日 UTC+8下午11:39:57,kensuke....@gmail.com写道:

yasi...@gmail.com

unread,
Jul 20, 2020, 3:46:07 AM7/20/20
to libFM - Factorization Machines
You should first create a train and test splits and create the libfm file out of that at the same time. Then it will work. 
Reply all
Reply to author
Forward
0 new messages