Open hry8310 opened 4 years ago
lossAver.append(loss.data[0]) ----------> lossAver.append(loss.item())
您好! 谢谢你的回复,我有时间重试一下 再次感谢
------------------ 原始邮件 ------------------ 发件人: "JpDing"<notifications@github.com>; 发送时间: 2019年12月12日(星期四) 下午2:59 收件人: "detectRecog/CCPD"<CCPD@noreply.github.com>; 抄送: "黄日燕-男的"<247403822@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [detectRecog/CCPD] train 的时候 报错 (#53)
lossAver.append(loss.data[0]) ----------> lossAver.append(loss.item())
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
使用命令 : python wR2.py -i /root/mt/cimg/home/booy/booy/ccpd_dataset/ccpd_db/ -b 4
报错内容 /usr/local/lib/python3.6/dist-packages/torch/optim/lr_scheduler.py:100: UserWarning: Detected call of
model_conv = train_model(model_conv, criterion, optimizer_conv, num_epochs=epochs)
File "wR2.py", line 213, in train_model
lossAver.append(loss.data[0])
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
lr_scheduler.step()
beforeoptimizer.step()
. In PyTorch 1.1.0 and later, you should call them in the opposite order:optimizer.step()
beforelr_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 "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning) Traceback (most recent call last): File "wR2.py", line 230, in检查了一下。是