nn.Conv2d에서 dilation과 groups 파라미터가 의미하는 것을 간단히 작성하시오.
torch.nn.Conv2d(in_channel, out_channel, kernel_size, stride=1,
padding=0, **dilation=1, groups=1**, bias=True)
답:
dilation은 적용될 필터의 간격을 의미한다.
groups는 input channel을 여러개의 group으로 나누기 위한 값을 의미한다.
CNN Architecture는 무엇이 있는지 3가지만 작성하시오.
답:
다음은 CNN의 LeNet-5 Architecture이다.
LeNet-5 구조는 C1→S2→C3→S4→C5→F6의 순서로 이루어진다. (C: Convolution, S: Subsampling, FC: Full connection)
다음 코드를 완성하시오.
import torch.nn as nn
import toch.nn.functional as F
Class LeNet5(self):
__init__(self):
self.C1 = ...
self.S2 = ...
self.C3 = ...
self.S4 = ...
self.C5 = Linear(16 * 5 * 5, 120)
self.FC2 = Linear(120, 84)
forward(self, x):
x = ... # C1: Convolutions
x = ... # S2: Subsampling
x = ... # C3: Convolutions
x = ... # S4: Subsampling
x = self.FC1(x) # C5: Full Connection
x = self.FC2(x) # F6: Full Connection
x = F.sigmoid(x) # Gaussian connections
답:
import torch.nn as nn
import toch.nn.functional as F
Class LeNet5():
__init__():
self.C1 = nn.Conv2d(1, 6, 5, padding=0)
self.S2 = nn.MaxPool2d(2, 2)
self.C3 = nn.Conv2d(6, 16, 5, padding=0)
self.S4 = nn.MaxPool2d(2, 2)
self.C5 = nn.Linear(16 * 5 * 5, 120)
self.FC1 = nn.Linear(120, 84)
forward(self, x):
x = self.C1(x) # C1: Convolutions
x = self.S2(x) # S2: Subsampling
x = self.C3(x) # C3: Convolutions
x = self.S4(x) # S4: Subsampling
x = self.FC1(x) # C5: Full Connection
x = self.FC2(x) # F6: Full Connection
x = F.sigmoid(x) # Gaussian connections
return x