27. CNN Basic

Basic information of CNN

tensorflow

Convolutional Neural Network (CNN)

  • A class of deep, feed-forward artificial neural network that have successfully been applied to analyzing visual imagery. - Wiki
Image 1. Convolutional Neural Network(src: http://parse.ele.tue.nl/education/cluster2)
  • CNN can be also adapted to voice recognition and other fields.

Architecture

  • Compared to traditional DNN, CNN has feature extraction section including convolution layers and pooling layers additionally.
  • Feature extraction section consists of convolution layers, active functions and pooling layers. (Pooling layer is optional.)
  • Classification section is organized with affine layers and active functions, like traditional DNN. This is also called as fully connected network.
  • From the feature extraction section, object information is extracted from the input image, and this information is classified in classification section. At the end of classification section, the machine guess what the input is finally.

Convolution Layer

  • As previous MNIST training in traditional DNN, geometric information is disappeared by flattening image to 1 x 784 array. However, CNN can be trained with geometric information. Besides, channel information is trained as the 3rd dimension.
  • An Input/Output of Convolution layer is called as feature map. Feature map
Image 2. Feature map(src: www.researchgate.net)
  • Along CNN, features becomes clear. At the beginning of CNN, detected feature size is too small, but the features from the last of feature extraction section is human-distinguishable.

Convolution

  • The process of adding each element of the image to its local neighbors, weighted by the kernel (= filter). - Wiki

    $$ \begin{bmatrix} 3 & 3 & 2 & 1 & 0 \\ 0 & 0 & 1 & 3 & 1 \\ 3 & 1 & 2 & 2 & 3 \\ 2 & 0 & 0 & 2 & 2 \\ 2 & 0 & 0 & 0 & 1 \end{bmatrix} \circledast \begin{bmatrix} 0 & 1 & 2 \\ 2 & 2 & 0 \\ 0 & 1 & 2\end{bmatrix} $$ $$ = \begin{bmatrix} 12 & 12 & 17 \\ 10 & 17 & 19 \\ 9 & 6 & 14 \end{bmatrix}$$

Image 3. Convolution(src: deeplearning.net)

Weights and Biases

  • CNN also has weights and biases like traditional DNN. Only multiplication of X and W is replaced by convolution of X and W.

  • In CNN, kernel and filter represent weight.

    $$ X \circledast W + b $$ $$ = \begin{bmatrix} 1 & 2 & 3 & 0 \\ 0 & 1 & 2 & 3 \\ 3 & 0 & 1 & 2 \\ 2 & 3 & 0 & 1 \end{bmatrix} \circledast \begin{bmatrix} 2 & 0 & 1 \\ 0 & 1 & 2 \\ 1 & 0 & 2 \end{bmatrix} + 3 $$ $$ = \begin{bmatrix} 15 & 16 \\ 6 & 15 \end{bmatrix} + 3 $$ $$ = \begin{bmatrix} 18 & 19 \\ 9 & 18 \end{bmatrix} $$

Padding

  • Padding is to wrap the input feature map with a specific value to prevent it from shrinking.
  • In the previous example, the convolution of the 4x4 input feature map and 3 x 3 filter returns the 2 x 2 output feature map. If input feature map passes through multiple convolution layers without padding, its information will be zipped into a single scalar value.
  • There are many kinds of Padding but usually zero padding is used.
  • With padding, the size of output feature map is the same as the size of input feature map.
Image 4. Convolution with padding(src: deeplearning.net)

Stride

  • Stride is an interval of moving filter.
  • If stride is 1 x 1, filter is moved as 1 along x axis and y axis. The stride of Image 3 is 1 x 1.
  • If stride is 2 x 2,
Image 5. Stride: 2 x 2(src: deeplearning.net)
  • According to stride, the size of output feature image is changed.

$$ OW = \frac{IW + 2P - FW}{SW} + 1 $$ $$ OH = \frac{IH + 2P - FH}{SH} + 1 $$

* IW: Input Width, IH: Input Height
* OW: Output Width, OH: Output Height
* SW: Stride Width, SH: Stride Height
* P: Padding

3 Dimensional Convolution

  • CNN does not consider only width and height, but also channel, which is color information usually.
  • For each channel, independent filters are required. The below example, R,G and B feature map has their own RF, GF and BF filters.
Image 6. 3D convolution
  • It is easy to think all channel's feature map as a block for further extension.
Image 7. Concept of block convolution
  • For CNN, it is possible to apply multiple filters to input feature map. The number of filters becomes the channel number of the output feature map.
Image 8. Multiple filters

Pooling Layer

  • Pooling is an operation to shrink input feature map, so it is called sub sampling.
  • Max pooling is to select the max value, and average pooling is to select the average in target area. The target area is shrunken into a scalar value chosen, then output feature map is smalled than input feature map.
Image 9. Pooling(src: inclass.kaggle.com)
  • Usually, max pooling is used.
  • 3 features of pooling layer
    • No weights to train
    • The number of channel is not changed
    • Stable to variation of input feature map

Fully Connected Layer

  • Fully connected (FC) layer is the traditional softmax regression of DNN.
  • After features are extracted by feature extraction section, FC layer inferences what the objects are with softmax classification.

COMMENTS

Name

0 weights,1,abstract class,1,active function,3,adam,2,Adapter,1,affine,2,argmax,1,back propagation,3,binary classification,3,blog,2,Bucket list,1,C++,11,Casting,1,cee,1,checkButton,1,cnn,3,col2im,1,columnspan,1,comboBox,1,concrete class,1,convolution,2,cost function,6,data preprocessing,2,data set,1,deep learning,31,Design Pattern,12,DIP,1,django,1,dnn,2,Don't Repeat Your code,1,drop out,2,ensemble,2,epoch,2,favicon,1,fcn,1,frame,1,gradient descent,5,gru,1,he,1,identify function,1,im2col,1,initialization,1,Lab,9,learning rate,2,LifeLog,1,linear regression,6,logistic function,1,logistic regression,3,logit,3,LSP,1,lstm,1,machine learning,31,matplotlib,1,menu,1,message box,1,mnist,3,mse,1,multinomial classification,3,mutli layer neural network,1,Non Virtual Interface,1,normalization,2,Note,21,numpy,4,one-hot encoding,3,OOP Principles,2,Open Close Principle,1,optimization,1,overfitting,1,padding,2,partial derivative,2,pooling,2,Prototype,1,pure virtual function,1,queue runner,1,radioButton,1,RBM,1,regularization,1,relu,2,reshape,1,restricted boltzmann machine,1,rnn,2,scrolledText,1,sigmoid,2,sigmoid function,1,single layer neural network,1,softmax,6,softmax classification,3,softmax cross entropy with logits,1,softmax function,2,softmax regression,3,softmax-with-loss,2,spinBox,1,SRP,1,standardization,1,sticky,1,stride,1,tab,1,Template Method,1,TensorFlow,31,testing data,1,this,2,tkinter,5,tooltip,1,Toplevel,1,training data,1,vanishing gradient,1,Virtual Copy Constructor,1,Virtual Destructor,1,Virtual Function,1,weight decay,1,xavier,2,xor,3,
ltr
item
Universe In Computer: 27. CNN Basic
27. CNN Basic
Basic information of CNN
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE9QfIQg9MqxmXv8wo1jRHrMgva3N0n9uaoJIHiM44Vt8k6nlufCwcOrXM4piATO-QqQmLgh_JEZUv2KXJVRIATvdu0xwckn-JPaRyfJpu9tFP929dbQgKHcd0zfVFfe9EjSkH18A4MxU4/s0/
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE9QfIQg9MqxmXv8wo1jRHrMgva3N0n9uaoJIHiM44Vt8k6nlufCwcOrXM4piATO-QqQmLgh_JEZUv2KXJVRIATvdu0xwckn-JPaRyfJpu9tFP929dbQgKHcd0zfVFfe9EjSkH18A4MxU4/s72-c/
Universe In Computer
https://kunicom.blogspot.com/2017/08/27-cnn-basic.html
https://kunicom.blogspot.com/
https://kunicom.blogspot.com/
https://kunicom.blogspot.com/2017/08/27-cnn-basic.html
true
2543631451419919204
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy