Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- Swin Transformer
- Diffusion
- CNN
- depthwise convolution
- Unreal Engine
- 포인터
- DDPM
- 모수 추정 방법
- 티스토리챌린지
- 최대 가능도 추정
- Focal loss
- covolution
- Deep Learning
- Image denoising
- deformable covolution
- 최대 사후 확률
- mobilenet
- Vision Transformer
- convolution
- 오블완
- computer graphics
- C++
- 딥러닝
- posec3d
- OpenGL
- Action Recognition
Archives
- Today
- Total
심드렁하게 저장
Convolution - Depthwise Convolution & Pointwise Convolution 본문
Artificial intelligence/Deep Learning
Convolution - Depthwise Convolution & Pointwise Convolution
Ggoosae 2025. 4. 23. 00:271. Depthwise Convolution

Depthwise Convolution은 일반적인 Conv2D에서 채널 간 연산을 제거하고, 각 채널 별로 독립적 커널을 적용하는 방식이다. 이것은 MobileNet 계열에서 파라미터 수와 연산량을 줄이는데 효과적으로 사용되고있다. 이때 Spatial filtering만 수행하고 채널간 결합은 Pointwise Conv(1x1)로 따로 처리하는 것이 일반적이다.

- $Y_{c}(i,j)$: 출력 feature map의 c 채널, 위치$(i,j)$의 값
- $X_{c}$ : 입력의 c 채널
- $W_{c}(m,n)$: 해당 채널에만 적용되는 커널(필터) $k_{n}\times k_{n}$ 크기
- $(i+m,j+n)$: 필터를 적용할 입력 이미지의 위치
- $c$ : 채널 인덱스, 모든 채널에 대해 독립적인 필터가 존재
Pytorch에서는 다음과 같이 구현할 수 있다.
import torch
import torch.nn as nn
import torch.nn.functional as F
class DepthwiseConv2d(nn.Module):
def __init__(self, in_channels, kernel_size, stride=1, padding=0):
super().__init__()
# groups 인자에 in_channels 부여
self.conv = nn.Conv2d(in_channels, in_channels, kernel_size, stride, padding, groups=in_channels)
def forward(self, x):
return self.conv(x)
Depthwise Conv의 활용 모델은 다음과 같다.
| 활용 모델 | 설명 |
| MobileNet | Depthwise + Pointwise Conv 조합으로 경량화 |
| EfficientNet | 일부 block에서 Depthwise 사용 |
| ConvNeXt,MixNet | Modern CNN에서 variation으로 사용 |
2. Pointwise Convolution

Pointwise Convolution은 커널 크기가 1x1인 Conv로 각 위치에서 채널 간 선형 결합만 수행하는 연산이다. 입력의 Spatial 정보(위치)는 유지하면서 채널 정보를 조합하는데 특화되어있기 때문에 Depthwise Conv 이후 채널 정보를 통합할 때 자주 사용된다.

- $Y_{c_{out}}(i,j)$: 출력 채널 $c_{out}$의 위치 $(i,j)$ 값
- $X_{c_{in}}(i,j)$ : 입력 채널 $c_{in}$의 동일 위치 값
- $W_{c_{out},c_{in}}$: 1x1 위치에서 입력 채널을 출력 채널로 연결하는 가중치
- $(i,j)$: 공간상 위치 인덱스 (H,W)
Pytorch를 사용하면 다음과 같이 간단히 구현할 수 있다.
class PointwiseConv2d(nn.Module):
def __init__(self, in_channels, out_channels):
super().__init__()
# 커널 사이즈 1
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1)
def forward(self, x):
return self.conv(x)
Pointwise Conv는 다음 모델들에서 활용된다.
| 활용 모델 | 설명 |
| Inception Module | 다양한 크기의 filter 결과를 1x1 conv로 통합 |
| ResNet Bottleneck | 채널 수 축소와 확장을 위해 1x1 conv 사용 |
| ViT Patch Embedding | 이미지 패치를 채널로 인코딩할 때 사용됨 |
'Artificial intelligence > Deep Learning' 카테고리의 다른 글
| Denoising Diffusion Probabilistic Models (DDPM) 논문 리뷰 (0) | 2025.05.19 |
|---|---|
| Convolution - Dilated Convolution, Deformable Convolution (0) | 2025.05.06 |
| FocalLoss 이론과 구현 (0) | 2025.04.23 |
| Swin Transformer - 이론과 구현 (0) | 2025.04.21 |
| Vision Transformer - 이론과 구현 (0) | 2025.04.17 |