weixin_57396998 2022-03-21 08:30 采纳率: 100%
浏览 164
已结题

pytorch官网给的resnet程序跑不通

问题遇到的现象和发生背景

程序跑不起来,停在0/24,

问题相关代码,请勿粘贴截图

https://github.com/miraclewkf/ImageClassification-PyTorch/blob/master/level1/train.py
中loss = criterion(outputs, labels)

运行结果及报错内容

D:\Anaconda3\python.exe "D:\PyCharm 2020.1.3\plugins\python\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 62455 --file D:/PycharmProjects/untitled/2.py
pydev debugger: process 3900 is connecting

Connected to pydev debugger (build 201.8538.36)
D:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py:935: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead.
warnings.warn("The use of the transforms.RandomSizedCrop transform is deprecated, " +
D:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py:317: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
warnings.warn("The use of the transforms.Scale transform is deprecated, " +
Epoch 0/24


D:\Anaconda3\lib\site-packages\torch\optim\lr_scheduler.py:129: UserWarning: Detected call of lr_scheduler.step() before optimizer.step(). In PyTorch 1.1.0 and later, you should call them in the opposite order: optimizer.step() before lr_scheduler.step(). Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate
warnings.warn("Detected call of lr_scheduler.step() before optimizer.step(). "

Process finished with exit code -1

我的解答思路和尝试过的方法

好像是数据类型对应不上

我想要达到的结果

跑通出结果

  • 写回答

1条回答 默认 最新

  • 爱晚乏客游 2022-03-21 11:20
    关注

    提示不是说了吗,需要切换函数的API,你用的函数是旧版本的,需要切换到新版本去,报错提示里面也跟你说了要切换哪些什么函数了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月30日
  • 已采纳回答 3月22日
  • 创建了问题 3月21日

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据