我正在尝试对自己的数据进行微调。这是我正在尝试的repository。我收到以下错误消息。这是什么意思?我是python和深度学习编程的新手。
Traceback (most recent call last):
File "finetune.py", line 254, in <module>
main()
File "finetune.py", line 127, in main
train(TrainImgLoader, model, optimizer, log, epoch)
File "finetune.py", line 171, in train
for x in range(num_out)]
File "finetune.py", line 171, in <listcomp>
for x in range(num_out)]
IndexError: too many indices for tensor of dimension 3
代码部分在下面。
>
> for batch_idx, (imgL, imgR, disp_L) in enumerate(dataloader):
> imgL = imgL.float()#.cuda()
> imgR = imgR.float()#.cuda()
> disp_L = disp_L.float()#.cuda()
>
> optimizer.zero_grad()
> mask = disp_L > 0
> mask.detach_()
> outputs = model(imgL, imgR)
>
> if args.with_spn:
> if epoch >= args.start_epoch_for_spn:
> num_out = len(outputs)
> else:
> num_out = len(outputs) - 1
> else:
> num_out = len(outputs)
>
> outputs = [torch.squeeze(output, 1) for output in outputs]
> loss = [args.loss_weights[x] * F.smooth_l1_loss(outputs[x][mask], disp_L[mask], size_average=True)
> for x in range(num_out)]
> sum(loss).backward()
> optimizer.step()
>
> for idx in range(num_out):
> losses[idx].update(loss[idx].item())
>
> if batch_idx % args.print_freq:
> info_str = ['Stage {} = {:.2f}({:.2f})'.format(x, losses[x].val, losses[x].avg) for x in range(num_out)]
> info_str = '\t'.join(info_str)
>
> log.info('Epoch{} [{}/{}] {}'.format(
> epoch, batch_idx, length_loader, info_str))
> info_str = '\t'.join(['Stage {} = {:.2f}'.format(x, losses[x].avg) for x in range(stages)])
> log.info('Average train loss = ' + info_str)
请让我知道该怎么做。
预先感谢:)