• Tidak ada hasil yang ditemukan

Convolutional Neural Networks (CNNs) dengan Keras

N/A
N/A
Protected

Academic year: 2023

Membagikan "Convolutional Neural Networks (CNNs) dengan Keras"

Copied!
25
0
0

Teks penuh

(1)

Convolutional Neural Networks (CNNs) dengan Keras

Alfan Farizki Wicaksono Fakultas Ilmu Komputer

Universitas Indonesia

Alfan F. Wicaksono, Fasilkom UI

(2)

References

• http://ufldl.stanford.edu/tutorial/

• http://cs231n.github.io/convolutional-networks/

• https://docs.gimp.org/en/plug-in-convmatrix.html

Alfan F. Wicaksono, Fasilkom UI

(3)

Fully-Connected Networks

• ANN biasa yang sudah dipelajari sebelumnya merupakan “fully connected networks”.

• Semua hidden unit terhubung dengan semua input unit.

Keras menyebutnya dengan istilah Dense Layer

Alfan F. Wicaksono, Fasilkom UI

(4)

Fully-Connected Networks

x1

x2

x3

+1 𝑊11(1)

𝑊21(1)

𝑊12(1) 𝑊22(1) 𝑊13(1)

𝑊23(1)

𝑏1(1) 𝑏2(1)

𝑊11(2)

𝑊12(2) 𝑊21(2)

𝑊22(2)

𝑏1(2) 𝑏2(2)

Alfan F. Wicaksono, Fasilkom UI

(5)

Fully-Connected Networks

• Seandainya input adalah sebuah image berukuran 28x28 pixel (seperti kumpulan image pada dataset MNIST), input layer akan berukuran 784 unit.

• Masih feasible untuk melakukan komputasi berikutnya (learning)

• Bagaimana dengan image yang yang lebih besar?

• 98x98 pixel: 9604 unit

• 128x128 pixel: 16384 unit !

Alfan F. Wicaksono, Fasilkom UI

(6)

Locally-Connected Networks

Solution: to restrict the connections between the hidden units and the input units.

For image: Each hidden unit will connect to only a small contiguous region of pixels in the input.

For other modalities: there is often also a natural way to select

“contiguous groups” of input units to connect to a single hidden unit as well.

Alfan F. Wicaksono, Fasilkom UI

(7)

Convolutions

• Natural images have the property of being “stationary”, meaning that the statistics of one part of the image are the same as any other part.

• This suggests that the features that we learn at one part of the image can also be applied to other parts of the image, and we can use the same features at all

locations.

Alfan F. Wicaksono, Fasilkom UI

(8)

Proses Ekstraksi Fitur dengan Convolutions

Kernel/Filter 3x3

Alfan F. Wicaksono, Fasilkom UI

(9)

Convolutions: salah satu teknik image processing

• Convolution is the treatment of a matrix by another one which is called “kernel”.

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(10)

Convolutions: salah satu teknik image processing

• Here’s what happened!

Sharpen

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(11)

Convolutions: salah satu teknik image processing

• Here’s what happened!

Blur

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(12)

Convolutions: salah satu teknik image processing

• Here’s what happened!

Edge Enhance

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(13)

Convolutions: salah satu teknik image processing

• Here’s what happened!

Edge Detect

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(14)

Convolutions: salah satu teknik image processing

• Here’s what happened!

Edge Detect

https://docs.gimp.org/en/plug-in-convmatrix.htmlAlfan F. Wicaksono, Fasilkom UI

(15)

Convolutional Neural Networks

• Regular Feed-Forward ANNs

Alfan F. Wicaksono, Fasilkom UI

(16)

Convolutional Neural Networks

• CNNs

Alfan F. Wicaksono, Fasilkom UI

(17)

Convolutional Neural Networks

• CNNs

Dengan 5 Kernel/Filter

Alfan F. Wicaksono, Fasilkom UI

(18)

Convolutional Neural Networks

• Silakan baca:

• http://cs231n.github.io/convolutional-networks/

Alfan F. Wicaksono, Fasilkom UI

(19)

Convolutional Neural Networks

• Sebuah arsitektur Deep Learning yang mempunyai “ingredients”

• Convolutional Layer

• Pooling Layer

• Fully-Connected Layer (regular ANN) di bagian akhirnya

Alfan F. Wicaksono, Fasilkom UI

(20)

Convolutional Neural Networks

Alfan F. Wicaksono, Fasilkom UI

(21)

Pooling

• Setelah mendapatkan features yang diekstraksi dari Convolutional Layer, features yang dihasilkan terkadang masih berukuran sangat besar sehingga

memperlambat proses training.

• Remember stationary property!

features that are useful in one region are also likely to be useful for other regions

• Thus, to describe a large image, one natural approach is to aggregate statistics of these features at various locations.

Alfan F. Wicaksono, Fasilkom UI

(22)

Pooling

• For example, one could compute the mean (or max) value of a particular feature over a region of the image.

Alfan F. Wicaksono, Fasilkom UI

(23)

Max Pooling

Alfan F. Wicaksono, Fasilkom UI

(24)

Pooling

Alfan F. Wicaksono, Fasilkom UI

(25)

CNNs in Keras

model = Sequential()

# convolution layer, 64 filter berukuran 3x3

# input shape=ukuran image, 3x256x256

model.add(Convolution2D(64, 3, 3, border_mode='same', input_shape=(3, 256, 256)))

# output layer berdimensi (num_sample, 64, 256, 256) model.add(Activation('relu'))

# convolution layer, 32 filter berukuran 3x3

model.add(Convolution2D(32, 3, 3, border_mode='same'))

# output layer berdimensi berdimensi (num_sample, 32, 256, 256)

Alfan F. Wicaksono, Fasilkom UI

Referensi

Dokumen terkait

aConstituents of a single-layer network for the typical MNIST pattern recognition process in which input neurons yellow and output neurons green are fully connected by synaptic weight