交叉熵损失函数报错
本帖最后由 Handsome_zhou 于 2022-10-10 22:48 编辑IndexError: Target 3 is out of bounds.
原因:交叉熵损失函数的输入矩阵元素大小不能超过2.
import torch
import torch.nn as nn
a = torch.tensor([])
b = torch.tensor()
loss = nn.CrossEntropyLoss()
l = loss(a, b)
print(l)
页:
[1]