These negative dimension indexes are taken mod input.ndimension by torch.cat. In your first example, -1 = 3 mod(4), where input.ndimension() == 4. In your second example, -2 = 2 mod(4) for the same reason.