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 对于这个问题的代码运行
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败