I got this error from the minimal example
a = torch.tensor(4.0) a.unsqueeze(1)
So I assume the problem is trying to unsqueeze a scalar, which has dimension 0 . As the error suggests, the dimension is maxed at zero.
0