关于多分类任务的一个报错
您好,我在完成一个多分类任务时遇到了一些困难。我运行指令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。
我在网上看到的解释是输出层数跟我的标签数不匹配,我想问一下我应该改动哪里的代码呢?