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

PaddleOCR2.7.5 训练到几百回合出现loss>1问题 #13267

Open
18325391772 opened this issue Jul 5, 2024 · 1 comment
Open

PaddleOCR2.7.5 训练到几百回合出现loss>1问题 #13267

18325391772 opened this issue Jul 5, 2024 · 1 comment

Comments

@18325391772
Copy link

1720147935352

报错代码:
class DiceLoss(nn.Layer):
def init(self, eps=1e-6):
super(DiceLoss, self).init()
self.eps = eps

def forward(self, pred, gt, mask, weights=None):
    """
    DiceLoss function.
    """

    assert pred.shape == gt.shape
    assert pred.shape == mask.shape
    if weights is not None:
        assert weights.shape == mask.shape
        mask = weights * mask
    intersection = paddle.sum(pred * gt * mask)

    union = paddle.sum(pred * mask) + paddle.sum(gt * mask) + self.eps
    loss = 1 - 2.0 * intersection / union
    assert loss <= 1
    return loss
@GreatV
Copy link
Collaborator

GreatV commented Jul 5, 2024

升级到2.8.0试试,照理说不会出现loss>1的情况

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