텐서 업샘플링 관련 - nn.Upsample(), ConvTranspose2d()
nn.Upsample()PyTorch의 nn.Upsample()은 입력 텐서를 ‘업샘플링(Up-sampling)’해주는 기능을 제공한다. 입력 텐서의 spatial 차원(예: 높이와 너비)을 원하는 크기 또는 배율로 늘려서 출력 텐서를 생성하는데, 일반적으로 이미지 처리나 Feature map을 확대하는 과정에서 자주 사용한다. 아래 코드와 같이 [1, 3, 64, 64]인 텐서를 nn.Upsample을 통해 [1, 3, 128, 128]로 변형할 수 있다.import torchimport torch.nn as nn# 2D 업샘플링 예시upsample = nn.Upsample(size=(128, 128), mode='nearest')input_tensor = torch.randn(1, 3, 64, 64)..
2025. 1. 8.