PyTorch repeat, repeat_interleave, expand 차이
PyTorch의 repeat와 repeat_interleave와 expand의 주요 차이점을 설명한다.1. torch.repeat:1차원 텐서 x = torch.tensor([1, 2, 3])result = x.repeat(3)>> tensor([1, 2, 3, 1, 2, 3, 1, 2, 3]) 2차원 텐서 x = torch.tensor([[1, 2, 3], [4, 5, 6]])x.repeat(2, 1)>> tensor([[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]]) 이때 repeat 안에 들어가는 숫자는 복사하고자 하는 텐서의 차원이 같아야 한다. 2차원 텐서에 대해서 아래와 같이 입력하면 에러..
2024. 11. 1.