Ssd.pytorch: when i excute train.py, i meet this problem : loss = inf.

Created on 6 May 2018  路  6Comments  路  Source: amdegroot/ssd.pytorch

when i excute train.py, i meet this problem : loss = inf.
then i find loc_loss = inf.Can anyone help me,thanks!

Most helpful comment

This is because log calculation in box_utils.py.
In function "encode", you can add epsilon for preventing explosion.
For example,
eps = 1e-5
g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
g_wh = torch.log(g_wh+eps) / variances[1]

All 6 comments

i meet the same problem

so am i

Me too, what's the problem?

Finally, i solved my problem by referring to the chapter Pull requests, there is a column named "Fix infinity in target boxes", the author suggeste to change the source code in layers/box_utils.py like this:
change original code: g_wh = torch.log(g_wh) / variances[1] to g_wh = torch.log(g_wh + 1e-10) / variances[1]

what you can try is decreasing the lr or increasing the batch size

This is because log calculation in box_utils.py.
In function "encode", you can add epsilon for preventing explosion.
For example,
eps = 1e-5
g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
g_wh = torch.log(g_wh+eps) / variances[1]

This should be merged with the master branch

Was this page helpful?
0 / 5 - 0 ratings