Skip to content

损失函数 #33

Description

@houyuchao

我想将二元交叉熵变换为多元交叉熵函数,将F.binary_cross_entropy更换为F.cross_entropy,不对预测分数和target矩阵做flat_scores = scores.reshape(-1),flat_matrix = matrix.reshape(-1)直接使用scores 和matrix作为F.cross_entropy,但是在最后 loss = ((flat_loss.view(input_ids.size(0), -1)*mask).sum(dim=-1)).mean()这一步的时候出现了维度不匹配问题,经过交叉熵出来的损失函数维度变成了[8,15,5]而二元交叉熵的输出维度为[8,15,15,5]导致使用交叉熵后与mask维度不匹配,这该怎么办啊?
image
作者有没有什么办法啊,求助求助

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions