fcn.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:lsun-room 作者: leVirve 项目源码 文件源码
def cross_entropy2d(pred, target, weight=None, size_average=True):
    n, num_classes, h, w = pred.size()

    log_p = F.log_softmax(pred)

    log_p = channel_first_to_last(log_p).view(-1, num_classes)
    target = channel_first_to_last(target).view(-1)
    loss = F.nll_loss(log_p, target, weight=weight, size_average=False)

    if size_average:
        loss /= (h * w * n)
    return loss
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号