torch.cat

J·2021년 6월 11일
1

pytorch

목록 보기
10/23

공식설명은 아래와 같다.

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().

주어진 tensor들을 주어진 dimension에 따라 concatenate한다. 모든 tensor는 같은 shape을 갖고 있거나 비어있어야 한다. torch.cat은 torch.split() 과 torch.chunk()의 inverse 연산으로도 볼 수 있다.

  • Example
>>> x = torch.randn(2, 3)
>>> x
tensor([[ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497]])
>>> torch.cat((x, x, x), 0)
tensor([[ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497],
        [ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497],
        [ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497]])
>>> torch.cat((x, x, x), 1)
tensor([[ 0.6580, -1.0969, -0.4614,  0.6580, -1.0969, -0.4614,  0.6580,
         -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497, -0.1034, -0.5790,  0.1497, -0.1034,
         -0.5790,  0.1497]])
profile
I'm interested in processing video&images with deeplearning and solving problem in our lives.

0개의 댓글