본문 바로가기

Coding/Pytorch

LeNET-구현 - Gradient-Based Learning Applied to Document Recognition(Yann LeCun)

http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf

 

CNN이 나오면서 가장 처음 구현된 논문이다.

 

우리가 AI 입문으로 공부하는 CNN-Mnist 토이셋이 구현된 논문이다.

LeNet은 이미 유명하기 때문에 따로 논문 리뷰 대신에 작성한 코드를 기초로 성능을 맛보기만 하자.

 

이번 포스팅하면서 주로 공부한 것은

Model을 학습하기 위해 일종의 모듈화를 했으며, WanDB를 이용해 실시간으로 Model의 성능을 평가했다.

또한 기존의 MLP모델과 성능을 비교했다.

 

1. LeNet

 

LeNet is a convolutional neural network structure proposed by LeCun et al. in 1998,[1] . In general, LeNet refers to LeNet-5 and is a simple convolutional neural network. Convolutional neural networks are a kind of feed-forward neural network whose artificial neurons can respond to a part of the surrounding cells in the coverage range and perform well in large-scale image processing. -Wikipedia

 

LeNet은 1998년에 CNN구조로 이루어진 다층 신경망이다.

구조는 다음과 같다

LeNet의 기본구조

총 2개의 Convolution NetWork로 이루어져있으며, Input부터 Output까지 차근차근 살펴보자.

 

1. Input

32*32크기의 손글씨가 input으로 들어온다. 저자는 손글씨를 좀 더 자세하게 보기 위해 input의 크기를 키웠다고 한다.

filter에 대한 언급은 따로 없으므로, filter 크기 계산하는 방법을 알아두자.

 

O : Size of output image

I : Size of input image

K : Size if kernels used in the Conv layer

N : num of kernels

S : Stride of the convolution operatino

P : Padding size

따라서 현재 c1이 28*28이 된 이유는

(32 - 5 + 2*0)/1 +1 = 28이다

 

 

2. Convolution Layer 1

C1 : 6@28*28

6개의 feature map(trainable weight parameter)

28*28 크기의 filter

 

S2 : 6@14&14

6개의 channel

14*14의 feature map

.

3. Convolution Layer

C3 : 16@10*10

16개의 feature map

 

S4 16@ 5*5

 

4. Fully Connected layer

 

C5 : 120*1

F6 : 84*1

Output : 10*1

 

4. Code

https://github.com/ChaeHeeWoong/study_ml/blob/master/MNIST_LeNet.ipynb

 

GitHub - ChaeHeeWoong/study_ml: coursera machine_learning python code

coursera machine_learning python code. Contribute to ChaeHeeWoong/study_ml development by creating an account on GitHub.

github.com

 

 

5. FeedBack

어떠한 튜닝없이 단순하게 모델을 구현한 결과 ACC에 차이가 있는 걸 볼 수 있다.

 

'Coding > Pytorch' 카테고리의 다른 글

spacy 설치 중 fileno에러  (0) 2022.10.07
Pytorch cuda 간단하게 GPU이용하기(1) ('22.08.28기준)  (0) 2022.08.28