LeNet-5

dongjun·2023년 9월 11일
0

구현

목록 보기
2/2

LeNet-5 (Yann Lecun, 1998)
http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf

입력 데이터: 32x32x1 (흑백 이미지 = 1 channel)
layer 1: 2D Convolution layer (output feature maps: 28x28x6)
layer 2: 2D Pooling layer (output feature maps: 14x14x6)
layer 3: 2D Convolution layer (output feature maps: 10x10x16)
layer 4: 2D Pooling layer (output feature maps: 5x5x16)
layer 5: 2D Convolution layer (output feature maps: 1x1x120, 120)
layer 6: Fully connected layer (output feature maps: 84)
layer 7: Fully connected layer (output feature maps: 10)

stride가 1일 때, nxn 크기의 인풋 이미지에 대한 mxm 크기의 convolution 필터 연산 결과는 (n-m+1, n-m+1)이 됩니다.

Activation function은 tanh가 사용되었습니다.

conv1 = Conv2d(1, 6, 5, 5)
tanh(conv1())

2x2 크기의 pooling layer를 통과하면서 nxn 크기의 이미지는 n/2 x n/2 크기의 이미지가 됩니다.

pool2 = AveragePool2d(2)

LeNet5에서 layer 2 -> layer 3 convolution 연산에서는 5x5 필터가 모든 인풋 channel에 연결되어있는 것이 아니고,
3개 채널 x 6개, 4개 채널 x 9개, 6개 채널 x 1개 이렇게 부분적으로 연결하였습니다.

conv3 = Conv2d(6, 16, 5, 5)
tanh(conv3())

pool4 = AveragePool2d(2)

5x5 크기의 이미지에 5x5 크기의 convolution 필터 연산을 하면 어떻게 될까요?
1x1 크기의 이미지가 될 것입니다. 그리고 같은 작업을 120번 해주면 1x1x120 의 데이터가 생길 것입니다.

conv5 = Conv2d(16, 120, 5, 5)
tanh(conv5)

fc6 = Linear(120, 64)
tanh(fc6)

10개의 카테고리에 대해 분류하기 위해서 output 레이어의 노드 갯수를 10개 만들어줍니다.

output = Linear(64, 10)
softmax(output)

conv1 = Conv2d(1, 6, 5, 5)
tanh(conv1())

pool2 = AveragePool2d(2)

conv3 = Conv2d(6, 16, 5, 5) # LeNet has different conv connection here
tanh(conv3())

pool4 = AveragePool2d(2)

conv5 = Conv2d(16, 120, 5, 5)
tanh(conv5)

fc6 = Linear(120, 64)
tanh(fc6)

output = Linear(64, 10)
softmax(output)
profile
AI + X!

0개의 댓글

관련 채용 정보