pytorch报错如下:
File "/home/ch/code/plan1/my_model.py", line 119, in forward
softmax[:, 1].detach() + softmax[:, 1]
IndexError: too many indices for tensor of dimension 1
经过1天仔细推理发现错误原因是“119行所指的softmax没有维度1”,所以报错。
解决方法:
给报错数据加维度使其具有维度1,或者修改修改line119