gll89的个人博客分享 http://blog.sciencenet.cn/u/gll89

博文

Pytorch bugs

已有 1630 次阅读 2019-7-19 19:05 |个人分类:DeepLearning|系统分类:科研笔记

  1. when running at the code of self.criterion(outputs, labels), where I use CrossEntropy as my loss function, I meet the bug of "Dimension out of range (expected to be in range of [-1, 0], but got 1)"

    Solution:

  2. From the doc of CrossEntropy (https://pytorch.org/docs/stable/nn.html?highlight=crossentropy#torch.nn.CrossEntropyLoss)

   image

       这表明对于loss = self.criterion(output, label)中,output的维度是N*C,而label的维度是N,即label并不是one-hot,CrossEntropy会自动将label转成one-hot




https://blog.sciencenet.cn/blog-1969089-1190271.html

上一篇:Python and Pytorch knowledge
下一篇:Pycharm professional安装及激活

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2022-1-29 07:38

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部