Output result:
tensor([1, 2, 3, 4, 5, 6])
Example
import torch
# Create two 2D tensors
a = torch.randn(2,3)
b = torch.randn(2,3)
# Concatenate along the first dimension
c = torch.concatenate([a, b], dim=0)
print("a shape of:", a.shape)
print("b shape of:", b.shape)
print("c shape of:", c.shape)
Output result:
a shape of: torch.Size([2, 3]) b shape of: torch.Size([2, 3]) c shape of: torch.Size([4, 3])
Note: torch.concatenate is an alias for torch.cat, they have exactly the same functionality. In actual code, torch.cat is more commonly used.
YouTip