tensor([[-2.3935, 1.1712, 0.7412, -0.8840, -0.1491], [-0.3738, 1.3685, -0.0647, 0.4447, 0.1237], [-0.0622, -1.4562, -0.0293, 1.4932, -0.6611]], requires_grad=True)
tensor([4, 1, 0])
上面使用交叉熵函数可以正常运算。为什么下面这个就出现维度问题。
tensor([[[ 0.0576, -0.7956, -0.1969]], [[ 0.3662, -0.6685, -0.2650]], [[ 0.3640, -0.7650, -0.3304]], [[ 0.3184, -0.7652, -0.3420]], [[ 0.1153, -0.8198, -0.1901]]], grad_fn=<StackBackward>)
tensor([[2], [0], [1], [2], [1]])