CCPD icon indicating copy to clipboard operation
CCPD copied to clipboard

train 的时候 报错

Open hry8310 opened this issue 6 years ago • 2 comments

使用命令 : 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 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 "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning) Traceback (most recent call last): File "wR2.py", line 230, in 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

检查了一下。是

            lossAver.append(loss.data[0]) 报错了。请问是不是我的执行命令有问题

hry8310 avatar Oct 20 '19 06:10 hry8310

lossAver.append(loss.data[0]) ----------> lossAver.append(loss.item())

dabblle avatar Dec 12 '19 06:12 dabblle

您好!       谢谢你的回复,我有时间重试一下       再次感谢

------------------ 原始邮件 ------------------ 发件人: "JpDing"<[email protected]>; 发送时间: 2019年12月12日(星期四) 下午2:59 收件人: "detectRecog/CCPD"<[email protected]>; 抄送: "黄日燕-男的"<[email protected]>;"Author"<[email protected]>; 主题: 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.

hry8310 avatar Dec 12 '19 07:12 hry8310