Discrete Convolution에 대해 설명합니다.
- Discrete Convolution은 입력 데이터와 커널(Kernel)을 이용하여 출력 데이터를 계산하는 연산입니다.
- 입력 데이터와 커널의 각 원소를 곱한 후 그 값들을 합하여 출력 데이터의 각 원소 값을 구합니다.
- 이를 통해 입력 데이터의 특징을 추출하고 필터링하는 역할을 합니다.
Pooling의 대표적인 두 가지 방법은 Max Pooling과
Fully Connected Layer
CR C R P
…
DOG
POLAR BEAR
WOLF
ELEPHANT
FC
Reduce
Dimension
By previous procedures …
P
32 x 32 x 3
x Build Classifier
<Feature extraction> <Classification>
Pooling (Subsampling)
◦ Object
◦To reduce Rows/Cols from the matrix
◦ Advantage
◦ No parameters to train
◦ Invariable channels
◦ Not affected by variance of input
◦ Method
◦ Max Pooling
Use maximum value of the target area
◦ Mean Pooling
Use average value of the target area
31 8
15 30
12 27 7 3
31 9 6 8
9 15 3 12
6 3 30 13
12 27 7 3
31 9 6 8
9 15 3 12
6 3 30 13
12.25 6.00
8.25 14.50
<Max Pooling>
<Mean Pooling>
Kernel : 2x2
Stride : 2
12.
Applications
◦ LeNet-5 (1998)
◦AlexNet (2012)
◦ GoogLeNet (2014)
◦ Inception module : Parallel composition of layers.
◦ 1x1 convolution : Mathematically equivalent to a multi-layer perceptron.
◦ ResNet (2015)
◦ Fast Forward : Step over to skip some layers (Residual Net)
13.
Practical Use
◦ BuildNN with simplified API and Class by TensorFlow
◦ Training with MNIST dataset
◦ Test with MNIST dataset and ‘Hand-Written’ own data.
◦ Applying some techniques that we discussed before
◦ Ensemble, Dropout, Batch
14.
Define class fora model
Model
+ keep_prop
+ X, Y
+ sess
+ name
+ bool training
+ layers(conv, pool, dropout, dense …)
+ __init__(self, sess, name)
+ _build_net(self)
+ predict(self,x_test,training)
+ get_accuracy(self,x_test,y_test,training=False)
+ train(self,x_data_y_data_training=True)
Self Assignment
◦ 미완성된자필 숫자 인식기를 완성하라.
◦ 문제점
◦ pyplot.imshow() 메소드가 이미지를 자동으로 4채널(RGBA) 로 읽어 들임. (해결)
◦ Type Mismatch 오류, TensorFlow 에서 필요로 하는 Type을 제대로 설정하지 못하였을 가능성.
Troubleshooting
◦ Content ofMNIST dataset
……
Black (Background)
White (Content)
# of Test Images
Size of each image
(784 = 28*28)
24.
Troubleshooting
◦ Causes offailure
◦ Different from MNIST dataset, Hand-Written data have black content and white background.
◦ After convert to grayscale, each pixel has too large value different from MNIST dataset.
◦ Solutions
◦ Invert Hand-Written data to have black background and white content.
◦ Normalize grayscale converted image.
25.
Troubleshooting
◦ Read eachimage from the floder
◦ Convert to grayscale (28x28x3 -> 28x28)
◦ Reshape (28x28 -> 784)
◦ Append the image to the list.
◦ Convert the list to ndarray.
◦ Apply normalization.
◦ Get sum of predictions from models.
◦ Print the index of the max prediction value of each image.