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

Loss: nan #3

Open
semchan opened this issue Jun 12, 2020 · 4 comments
Open

Loss: nan #3

semchan opened this issue Jun 12, 2020 · 4 comments

Comments

@semchan
Copy link

semchan commented Jun 12, 2020

您好!我发现多轮训练后会出现 Loss: nan 的情况,仔细看代码,有一点点不是特别明白想请教您:如下代码中计算loss时为何需要先exp()再求log呢?这里如果score[0][x][y]如果为0,就会出现loss等于nan的情况.另外,这里求loss与论文中似乎有点差别呢?期待您的解答.

check if indexed correctly

    loss = []
    for i in range(len(all_matches[0])):
        x = all_matches[0][i][0]
        y = all_matches[0][i][1]
        loss.append(-torch.log( scores[0][x][y].exp() )) # check batch size == 1 ?
@semchan
Copy link
Author

semchan commented Jun 12, 2020

防止出现负数

@zwyking
Copy link

zwyking commented Oct 2, 2020

你好,请问这个问题解决了么?

@zwyking
Copy link

zwyking commented Oct 2, 2020

我在训练的时候也遇到了这个问题😂,但是这个score出现0的话也不会导致nan叭

@TangXiaoyu9
Copy link

遇到了一样的问题 也同问loss部分和paper里似乎有差别

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