티스토리 뷰
5x5 크기의 이미지가 3x3 커널과 stride 크기가 2인 Convolution과정에 의해 2x2사이즈의 이미지로 축소되었다고 가정해 보자. 축소된 2x2 크기의 이미지를 다시 5x5 크기의 이미지 혹은 다른 크기의 이미지로 확대시키는 과정을 Upsampling이라고 한다.
Transposed Convolution은 Convolution과정을 통해 Upsampling할 수 있는 한가지 방법이다. 흔히, Deconvolution이라고도 불리기도 하지만 Transposed Convolution과 Deconvolution은 다른 연산 과정을 통해 Upsampling을 진행한다.
Deconvolution은 Convolution과정에서 사용되었던 수학적 연산의 역 계산을 통하여 이미지를 Upsampling한다.
Transposed Convolution은 Upsampling대상인 이미지에 padding을 더하여 convolution을 과정을 진행함으로써 이미지의 크기를 확대시킨다.
Convolution과정 없이 단순하게 데이터의 차원을 늘릴 수도 있는데, 파이토치 함수에서 nn.Upsample, nn.UpsamplingNearest2d나 uu.UpsamplingBilinear2d등의 함수를 이용할 수 있다. 그중 nearest방식으로 upsampling한 예시는 아래와 같다.
>>> input_tensor = torch.arange(1, 5, dtype=torch.float32).view(1, 1, 2, 2)
>>> print(input_tensor)
tensor([[[[1., 2.],
[3., 4.]]]])
>>> upsampled_nearest = nn.Upsample(scale_factor=2, mode='nearest')
# or nn.UpsamplingNearest2d(scale_factor=2)
>>> upsampled_nearest(input_tensor)
tensor([[[[1., 1., 2., 2.],
[1., 1., 2., 2.],
[3., 3., 4., 4.],
[3., 3., 4., 4.]]]])
>>> upsampled_nearest = nn.Upsample(scale_factor=(2,3), mode='nearest')
# or nn.UpsamplingNearest2d(scale_factor=(2,3)))
>>> upsampled_nearest(input_tensor)
tensor([[[[1., 1., 1., 2., 2., 2.],
[1., 1., 1., 2., 2., 2.],
[3., 3., 3., 4., 4., 4.],
[3., 3., 3., 4., 4., 4.]]]])
참고
'머신러닝&딥러닝' 카테고리의 다른 글
인공지능 vs. 머신러닝 vs. 딥러닝 (0) | 2021.12.27 |
---|---|
Graph Convolutional Networks (GCN) (0) | 2021.12.15 |
Graph Neural Network (GNN) (0) | 2021.12.09 |
파이토치를 활용한 Convolutional AutoEncoder - CIFAR-10 (1) | 2021.02.16 |
Bert Extractive Summarizer을 활용하여 기본적인 Extractive Summary를 생성하기 (0) | 2021.01.10 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 파이토치
- anaconda3
- 티스토리 코드 폰트
- np.tri()
- pytorch
- BERT
- Graph Neural Networks
- np.ma.maked_where()
- 샴네트워크
- deep learning
- 합성곱
- 오토인코더
- 논문구현
- 파이썬
- kernal error
- ord()
- 주피터노트북
- NLP
- 윈도우
- Summarisation
- Extrative_Summarisation
- unique value
- Python
- 그래프
- Siamese Networks
- openCV기초
- 딥러닝
- 폰트 사이즈 변경
- GNN
- 재부팅
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함