Concatenating tensors
In this lesson, we would show how to concatenate tensors.
We'll cover the following
Concatenate the tensors
torch.cat()
can concatenate a sequence of tensors in a given dimension. All tensors should have the same shape. Below are the important parameters.
tensors
: A list of tensors must have the same shape.dim
: The dimension over which the tensors are concatenated. Take 2D tensors as an example,dim=0
means the operation would be performed row-wise.dim=1
means the operation would be performed column-wise.
Get hands-on with 1400+ tech skills courses.