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

Average loss of 1 (and incorrect labels) reported in --binary mode #180

Closed
mjwillson opened this issue Nov 4, 2013 · 2 comments
Closed

Comments

@mjwillson
Copy link

Perhaps the easiest way to explain this is to show output with and without the --binary option with everything else held fixed. My input lines look like

-1 |Text hello this is an example
1 |Text and another one

Without --binary everything behaves itself:

$ vw -kcd examples.txt --loss_function logistic
Num weight bits = 18
learning rate = 0.5
initial_t = 0
power_t = 0.5
creating cache_file = examples.txt.cache
Reading datafile = examples.txt
num sources = 1
average    since         example     example  current  current  current
loss       last          counter      weight    label  predict features
0.641010   0.641010            3         3.0  -1.0000  -0.1864        4
0.577645   0.514281            6         6.0  -1.0000  -0.5663        7
0.476604   0.355354           11        11.0  -1.0000  -2.1518       35
0.405201   0.333797           22        22.0  -1.0000  -2.0671       21
0.307740   0.210278           44        44.0  -1.0000  -1.3955       16
0.213920   0.117918           87        87.0  -1.0000  -2.8665       11
0.146646   0.079372          174       174.0  -1.0000  -1.7852        3
0.098552   0.050458          348       348.0  -1.0000  -3.5060        6
0.078723   0.058894          696       696.0  -1.0000  -4.2158       13
0.055447   0.032171         1392      1392.0  -1.0000  -4.3897        5
0.053205   0.050964         2784      2784.0  -1.0000  -8.2964       17
0.046466   0.039726         5568      5568.0  -1.0000  -3.8190        4
0.036872   0.027276        11135     11135.0  -1.0000  -3.5071        2
0.035412   0.033953        22269     22269.0  -1.0000  -8.4659       15

finished run
number of examples per pass = 39442
passes used = 1
weighted example sum = 39442
weighted label sum = -38960
average loss = 0.0311541
best constant = -0.987779
total feature number = 504260

But with --binary I see an average loss of exactly 1 reported in each log line and in the final output. Also a weighted label sum of exactly 0 (which is incorrect), and "current label" of 3212836864 (= 0xbf800000) for all examples, also incorrect, the labels are all 1 or -1:

$ vw -kcd examples.txt --loss_function logistic --binary
Num weight bits = 18
learning rate = 0.5
initial_t = 0
power_t = 0.5
creating cache_file = examples.txt.cache
Reading datafile = examples.txt
num sources = 1
average    since         example     example  current  current  current
loss       last          counter      weight    label  predict features
1.000000   1.000000          3      3.0   3212836864       -1        4
1.000000   1.000000          6      6.0   3212836864       -1        7
1.000000   1.000000         11     11.0   3212836864       -1       35
1.000000   1.000000         22     22.0   3212836864       -1       21
1.000000   1.000000         44     44.0   3212836864       -1       16
1.000000   1.000000         87     87.0   3212836864       -1       11
1.000000   1.000000        174    174.0   3212836864       -1        3
1.000000   1.000000        348    348.0   3212836864       -1        6
1.000000   1.000000        696    696.0   3212836864       -1       13
1.000000   1.000000       1392   1392.0   3212836864       -1        5
1.000000   1.000000       2784   2784.0   3212836864       -1       17
1.000000   1.000000       5568   5568.0   3212836864       -1        4
1.000000   1.000000      11135  11135.0   3212836864       -1        2
1.000000   1.000000      22269  22269.0   3212836864       -1       15

finished run
number of examples per pass = 39442
passes used = 1
weighted example sum = 39442
weighted label sum = 0
average loss = 1
best constant = 0
total feature number = 504260

I'm using the latest master from github. I get similar behaviour using other loss functions (hinge, squared), with multiple passes and in bfgs mode. I also tried labels of 0 and 1 which didn't help.

@mjwillson
Copy link
Author

In case this helps, 3212836864 appears to be what you get if you treat a float -1.0 (the correct label in this case) as an unsigned int.

@JohnLangford
Copy link
Member

Fixed.

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

2 participants