true 12271 766 Traceback (most recent call last): File "/home/adminis/hpy/ConvNextV2_Demo/train+ca.py", line 279, in <module> train_loss, train_acc = train(model_ft, DEVICE, train_loader, optimizer, epoch,model_ema) File "/home/adminis/hpy/ConvNextV2_Demo/train+ca.py", line 46, in train loss = torch.nan_to_num(criterion_train(output, targets)) # 计算loss File "/home/adminis/anaconda3/envs/wln/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/home/adminis/hpy/ConvNextV2_Demo/models/utils.py", line 621, in forward index.scatter_(1, target.data.view(-1, 1), 1) IndexError: scatter_(): Expected dtype int64 for index.
时间: 2024-02-04 21:04:23 浏览: 77
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这是一个出错的 traceback,看起来是在使用 PyTorch 进行模型训练时出现的问题。具体地,代码在执行 `index.scatter_(1, target.data.view(-1, 1), 1)` 时,发现 `target` 的数据类型不是 int64,导致了 `scatter_()` 函数的出错。可能需要检查一下代码中 `target` 的数据类型是否正确。
阅读全文