關于多分類任務的一個報錯
您好,我在完成一個多分類任務時遇到了一些困難。我運行指令python run.py --model TextCNN --word True --embedding random后報錯Traceback (most recent call last): ?
File "run.py", line 54, in <module> ? ?train(config, model, train_iter, dev_iter, test_iter) ?File "C:\Users\Administrator\Desktop\project\System\TextCNN\train_eval.py", line 47, in train ??
?loss = F.cross_entropy(outputs, labels) ?
File "C:\Users\Administrator\Desktop\project\System\venv\lib\site-packages\torch\nn\functional.py", line 2996, in cross_entropy ? ?
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)?
IndexError: Target 48 is out of bounds。
我在網上看到的解釋是輸出層數跟我的標簽數不匹配,我想問一下我應該改動哪里的代碼呢?
2022-06-06
IndexError: Target 48 is out of bounds。這一句已經告訴你在哪兒了,