[Lesson 3] Introduction to CNNs (2)
- We just learned about convolutions and max pooling.
- Convolution is the process of applying a filter (“kernel”) to an image.
- Max pooling is the process of reducing the size of the image through downsampling.
- Convolutional layers can be added to the neural network model using the Conv2D layer type in Keras. This layer is similar to the Dense layer, and has weights and biases that need to be tuned to the right values.
<Terms that were introduced in this lesson>
- CNNs: Convolutional neural network. That is, a network which has at least one convolutional layer. A typical CNN also includes other types of layers, such as pooling layers and dense layers.
- Convolution: The process of applying a kernel (filter) to an image
- Kernel / filter: A matrix which is smaller than the input, used to transform the input into chunks
- Padding: Adding pixels of some value, usually 0, around the input image
- Pooling The process of reducing the size of an image through downsampling. There are several types of pooling layers. However, maxpooling is the most common.
- Maxpooling: A pooling process in which many values are converted into a single value by taking the maximum value from among them.
- Stride: the number of pixels to slide the kernel (filter) across the image.
- Downsampling: The act of reducing the size of an image
<Colab Notebook>
- To access the Colab Notebook, login to your Google account and click on the link below:
Google Colaboratory
colab.research.google.com
- In this colab, we'll see how to create a Convolutional Neural Network.
ex) tf.keras.layers.Conv2D(32, (3,3), padding='same', activation=tf.nn.relu, input_shape=(28, 28, 1))
- The first layer is a convolutional layer with a three-by-three kernel and padding to keep the original image size. The 32 here specifies that 32 convoluted outputs wil be created.
- So, we're going from a single input image, to 32 convoluted ones after this step.
ex) tf.keras.layers.MaxPooling2D((2, 2), strides=2)
- The next layer is a max pooling layer, with the two-by-two size and the stride of two. This will reduce the size of all the 32 convoluted images.
ex) tf.keras.layers.Conv2D(64, (3,3), padding='same', activation=tf.nn.relu),
tf.keras.layers.MaxPooling2D((2, 2), strides=2)
- Then we perform a similar round a convolution and max pool.
ex) tf.keras.layers.Flatten()
- The flattened layer takes all of the previous data and flattens it into a one-dimensional array.
ex) tf.keras.layers.Dense(128, activation=tf.nn.relu)
- Then, we have a dense layer with a 128 neurons and the relay activation.
ex) tf.keras.layers.Dense(10, activation=tf.nn.softmax)
- Finally, a dense layer with our 10-class scores as a probability distribution, since we're using the softmax activation function.
- We use so many epochs during training, that our convolutional network started over fitting(overfitting은 학습 데이터에 대해 과하게 학습하여 실제 데이터에 대한 오차가 증가하는 현상) or memorizing our training data. -> In the next lesson, we'll introduce techniques to avoid this.
<Lesson Summary>
- In this lesson we learned about Convolutional Neural Networks.
- we learned how convolutions and max pooling works.
- we created and trained a Convolutional Neural Network from scratch.
- We saw that our CNN was able to perform better than the neural network we created in the previous lesson.
- If you want to know more details about how CNNs works make sure to check out this Comprehensive Guide to Convolutional Neural Networks.
A Comprehensive Guide to Convolutional Neural Networks — the ELI5 way
Artificial Intelligence has been witnessing a monumental growth in bridging the gap between the capabilities of humans and machines…
towardsdatascience.com
<소스 코드>
HoYoungChun/TensorFlow_study
Udacity의 Intro to TensorFlow for Deep Learning 강좌 for TF_Certificate 취득 - HoYoungChun/TensorFlow_study
github.com