Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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
Archives
Today
Total
관리 메뉴

Jun Station 준스테이션

딥러닝에서 사용되는 다양한 Convolution 기법들 본문

Networks (& Architectures)/다양한 Convolution 기법

딥러닝에서 사용되는 다양한 Convolution 기법들

julyjuny 2021. 8. 19. 21:08

[참고 사이트]

https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md

 

GitHub - vdumoulin/conv_arithmetic: A technical report on convolution arithmetic in the context of deep learning

A technical report on convolution arithmetic in the context of deep learning - GitHub - vdumoulin/conv_arithmetic: A technical report on convolution arithmetic in the context of deep learning

github.com

https://eehoeskrap.tistory.com/431

 

[Deep Learning] 딥러닝에서 사용되는 다양한 Convolution 기법들

기존 2차원 컨볼루션은 세가지 문제점이 존재한다. Expensive Cost Dead Channels Low Correlation between channels 또한, 영상 내의 객체에 대한 정확한 판단을 위해서는 Contextual Information 이 중요하다...

eehoeskrap.tistory.com

https://hichoe95.tistory.com/48

 

Different types of Convolutions (Grouped convolution, depthwise convolution, pointwise convolution, depthwise separable convolut

오늘 정리해 볼 것들은 앞으로 정리할 논문들을 위해 미리 알아두면 좋은 convolution입니다. 각 convolution들에 대한 간단한 특징과 param수, 연산량 등에대해서 알아봅시다 ㅎㅎ 들어가기에 앞서 몇

hichoe95.tistory.com

https://coding-yoon.tistory.com/122

 

[딥러닝] Depth-wise Separable Convolution 원리(Pytorch 구현)

안녕하세요. 오늘은 CNN에서 Depth-wise Separable Convolution에 대해 이야기해보겠습니다. Depth-wise separable Convolution을 가장 잘 표현한 그림이라고 생각합니다. 하지만 CNN에 대해 자세한 이해가 없으..

coding-yoon.tistory.com

 

 

1. 기본 Convolution

<설명>

<example>

class torch.nn.Conv2d(in_channels

,

out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)

>>> # With square kernels and equal stride
>>> m = nn.Conv2d(16, 33, 3, stride=2)
>>> # non-square kernels and unequal stride and with padding
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
>>> # non-square kernels and unequal stride and with padding and dilation
>>> m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
>>> input = torch.randn(20, 16, 50, 100)
>>> output = m(input)

https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html?highlight=dilated%20convolution 

 

Conv2d — PyTorch 1.9.0 documentation

Shortcuts

pytorch.org

2. Dilated Convolution

저번에 dilated UNet 만들때 끝단 stage 부분에서 사용된 convolution

3. Transposed Convolution

 

 

4. Separable Convolution

 

5. Depthwise Convolution

<example>

class depthwise_conv(nn.Module):
    def __init__(self, nin, kernels_per_layer):
        super(depthwise_separable_conv, self).__init__()
        self.depthwise = nn.Conv2d(nin, nin * kernels_per_layer, kernel_size=3, padding=1, groups=nin)


    def forward(self, x):
        out = self.depthwise(x)
        return out

첫 칸은 in_channels 이고, 두번째 칸은 out_channels

하나의 레이어에서 몇 개의 아웃풋을 만들 것이냐는 뜻

여기에서의 구현의 핵심은 groups = nin 부분인데, 입력 레이어를 nin개의 서로 다른 group으로 만들어서 해당 연산을 수행하겠다는 뜻이 된다. (반대로 생각해보면, group의 default 값이 1이라는 소리이다.)

 

6. Depthwise Separable Convolution (경량화 하는 방법)

 

Depthwise separable convolution = Depthwise conv + Pointwise conv

 

# of Parameters

 

단순히 Depthwise conv후에 Pointwise conv를 수행하는 방식이므로 두 방식의 param을 더해주기만 하면 된다.

따라서 총 param수는 K2C + CM = C(K2 + M)이 된다.

 

<example>

class depthwise_separable_conv(nn.Module):
    def __init__(self, nin, kernels_per_layer, nout):
        super(depthwise_separable_conv, self).__init__()
        self.depthwise = nn.Conv2d(nin, nin * kernels_per_layer, kernel_size=3, padding=1, groups=nin)
        self.pointwise = nn.Conv2d(nin * kernels_per_layer, nout, kernel_size=1)

    def forward(self, x):
        out = self.depthwise(x)
        out = self.pointwise(out)
        return out

<참고 사이트>

https://discuss.pytorch.org/t/how-to-modify-a-conv2d-to-depthwise-separable-convolution/15843/7

 

How to modify a Conv2d to Depthwise Separable Convolution?

Here is a simple example: class depthwise_separable_conv(nn.Module): def __init__(self, nin, nout): super(depthwise_separable_conv, self).__init__() self.depthwise = nn.Conv2d(nin, nin, kernel_size=3, padding=1, groups=nin) self.pointwise = nn.Conv2d(nin,

discuss.pytorch.org

 

7. Pointwise Convolution

<example>

class pointwise_conv(nn.Module):
    def __init__(self, nin, nout):
        super(depthwise_separable_conv, self).__init__()
        self.pointwise = nn.Conv2d(nin, nout, kernel_size=1)

    def forward(self, x):
        out = self.pointwise(x)
        return out

 

8. Grouped Convolution

 

9. Defornable Convolution

Comments