F.cross_entropy 交叉熵損失

https://blog.csdn.net/wuliBob/article/details/104119616

    Examples::

        >>>import torch.nn.functional as F

        >>> input = torch.randn(3, 5, requires_grad=True)
        >>> target = torch.randint(5, (3,), dtype=torch.int64) #其中(3,)是輸出的shape
        >>> loss = F.cross_entropy(input, target)
        >>> loss.backward()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章