亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

關于多分類任務的一個報錯

您好,我在完成一個多分類任務時遇到了一些困難。我運行指令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。

我在網上看到的解釋是輸出層數跟我的標簽數不匹配,我想問一下我應該改動哪里的代碼呢?

正在回答

1 回答

IndexError: Target 48 is out of bounds。這一句已經告訴你在哪兒了,

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

關于多分類任務的一個報錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號