这个错误的关键在于错误并不在出错的哪一行。 看了一些网上的帖子和自己错误,错误的原因是用index超过了tensor的范围。 比如: a = torch.randn(10) a[11] 这里的11超过了a的范围。