What does dim=-1 mean in torch.cat? - PyTorch Forums
discuss.pytorch.org › t › what-does-dim-1-mean-inFeb 04, 2021 · In torch, dim = -1means that the operation has to be performed along lastdimension, and I think that is why torch.cat((x, x, x,) -1) == torch.cat((x, x, x,), 1) (not strictly because it’s links and something but you got the idea) in your example. For better understanding : x = torch.Tensor([[1, 2, 3]]) x.shape > torch.Size([1, 3])
torch.cat — PyTorch 1.10.1 documentation
pytorch.org › docs › stabletorch.cat(tensors, dim=0, *, out=None) → Tensor Concatenates the given sequence of seq tensors in the given dimension. All tensors must either have the same shape (except in the concatenating dimension) or be empty. torch.cat () can be seen as an inverse operation for torch.split () and torch.chunk ().