์ค๋ฆฌ์๋ฅผ ํตํด ๋ฅ๋ฌ๋ 100% ์ดํดํ๊ธฐ ํ๋ก์ ํธ
(A project for 100% understanding Deep Learning in Julia)
ํด๋น ํ๋ก์ ํธ๋ ์ค๋ก์ง ์ค๋ฆฌ์(Julia)๋ง์ ์ฌ์ฉํ์ฌ ๋ฅ๋ฌ๋ ๋ชจ๋ธ์ ๊ตฌํํฉ๋๋ค.
This project uses only Julia language to implement deep learning model.
๊ต์ก์ฉ์ผ๋ก ์ ์๋ ๊ฒ์ด๊ธฐ์ ๋ฅ๋ฌ๋ ์๋ฆฌ์ ๋ํด ๊ณต๋ถํ์ค ๋ถ๋ค์๊ฒ ์ถ์ฒํฉ๋๋ค.
It's designed for education, so I recommend for those who want to study the principles of deep learning.
์ด ํ๋ก์ ํธ์์ ์ฌ์ฉ๋ ์ฝ๋๋ค์ ์๋์ ์ ์๋ฅผ ์ฐธ๊ณ ํ์์ต๋๋ค.
I refered to the book below.
์ ๋ธ๋ก๊ทธ์ Deep Learning in Julia์นดํ
๊ณ ๋ฆฌ์ ๊ตฌํ ๊ณผ์ ์ด ์
๋ก๋๋์ด ์์ต๋๋ค.
I uploaded some posts about the project's process on my blog, but they are written only Korean.
P.S. ์ค๋ฆฌ์์ ์ฌ์ฉ๋ฒ์ด ๊ถ๊ธํ๋ค๋ฉด, ์ ๋ธ๋ก๊ทธ์ ๋ฒ์ญํด๋ Think Julia์ ํตํด ๊ณต๋ถํ์ค ์ ์์ต๋๋ค.
-
์ค๋ฆฌ์์ ์ฌ์ฉ๋ฒ์ ๋ฐฐ์ด๋ค.
you can learn how to use Julia language -
๋ฅ๋ฌ๋์ ์๋๋ฐฉ์์ ์์ ํ ์ดํดํ๋ค.
you can totally understand deep learning's process. -
๋ง๋ ์ฝ๋๋ก ๋ชจ๋ธ์ ๋ง๋ค๊ณ ํ์ตํด๋ณธ๋ค.
you can make and train model using your own code.
๊ฐ๋จํ๊ฒ ์๊ธ์จ ์ซ์๋ฅผ ๋ง์ถ๋ ๋ถ๋ฅ ๋ชจ๋ธ์ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค.
Let's start making model that classify handwritten digits.
์ฐ๋ฆฌ๊ฐ ์ค๋ ์ฌ์ฉํ ๋ชจ๋ธ์ ๋ํ ์ ๋ณด๋ ์๋์ ๊ฐ์ต๋๋ค.
Here is the information about model structure and train parameters.
- model structure
Conv(filter_num = 32, filter_size = 3, stride = 1, padding = 0) + ReLU
Max_pool(filter size = 2, stride = 1, padding = 0)
Conv(filter_num = 64, filter_size = 3, stride = 1, padding = 0) + ReLU
Max_pool(filter size = 2, stride = 1, padding = 0)
Conv(filter_num = 64, filter_size = 3, stride = 1, padding = 0) + ReLU
Max_pool(filter size = 2, stride = 1, padding = 0)
Flatten
Dense(node_num = 64) + Relu
Dense(node_num = 10) + softmax- train parameters
weight initializer = He
optimizer = Adam
batch size = 100
epochs = 1
1. ํ๋ก์ ํธ์ ์ ์ฒด ์ฝ๋๋ฅผ ๋ค์ด๋ฐ์ต๋๋ค.
1.download the entire code in this project.
ํ๋ก์ ํธ ์๋จ์์ ์ง์ ๋ค์ด๋ฐ์ ์๋ ์๊ณ , git์ ์ฌ์ฉํ์ ๋ค๋ฉด ์๋์ ์ฝ๋๋ฅผ ์
๋ ฅํด์ ๋ค์ด๋ฐ์ ์๋ ์์ต๋๋ค.
you can download it directly from top of this page, or you can clone it using git.
$ git clone https://github.com/Hyeonji-Ryu/Deep_Learning_in_Julia.git
2. ์ปค๋งจ๋๋ผ์ธ์์ CNN ํด๋๋ก ๋๋ ํ ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ์ค์ ํฉ๋๋ค.
2.set a directory path to CNN folder in command line.
$ cd <your path>/Deep_Learning_in_Julia/CNN
3. ์ค๋ฆฌ์ REPL๋ฅผ ์ด๊ธฐ ์ํด ํด๋น ์ปค๋งจ๋๋ผ์ธ์์ Julia
๋ฅผ ์
๋ ฅํฉ๋๋ค.
3.enter Julia
in command line to open Julia REPL.
4.๋ง์ง๋ง์ผ๋ก ์๋์ ์ฝ๋๋ฅผ ์
๋ ฅํฉ๋๋ค.
4.enter the code below.
Julia> include("train_convNet.jl")
5. ์๋์ ๊ฐ์ด ๋ก์ค๊ฐ์ ๋ฐ๋ก ํ์ธํ ์ ์์ต๋๋ค.
5.you can see loss values in real time.
NO.1: 2.2886466121074425
NO.2: 2.280258799992027
NO.3: 2.2746683599835764
NO.4: 2.2608282595650575
NO.5: 2.243700243712272
NO.6: 2.214588691106391
.
.
NO.595: 0.10943427897500864
NO.596: 0.12955831960259565
NO.597: 0.03989749763491561
NO.598: 0.013439008366053344
NO.599: 0.1109573868949143
NO.600: 0.08915640203576712
6. ํ๋ จ์ด ๋๋ ํ, ์๋์ผ๋ก ํ
์คํธํ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์ฌ์ค๋๋ค.
6.you can see accuracy of test set automatically.
98.08
๋ชจ๋ธ์ด ์ ๋๋ก ํ๋ จ๋์๋์ง ํ์ธํด๋ด
์๋ค.
Let's check that the model is trained well.
๋จผ์ , ํ๋ จ๋ฐ์ดํฐ ์ค ํ๋๋ฅผ test
๋ก ํ ๋นํฉ๋๋ค.
First, assign one of train set to test
.
Julia> test = reshape(train_x[:,:,:,1],28,28,1,1)
๋ค์์ผ๋ก ์๋์ ์ฝ๋๋ฅผ ์
๋ ฅํ์ฌ ์์ธก ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์ต๋๋ค.
Next, enter the code below to get result of prediction.
julia> result = argmax(predict(test))
CartesianIndex(1, 6) #[0,1,2,3,4,*5*,6,7,8,9,10]
๋ชจ๋ธ์ test
๊ฐ 5๋ผ๊ณ ์์ธกํ์ต๋๋ค. ๊ณผ์ฐ 5์ธ์ง ํ์ธํด๋ด
์๋ค.
The model predicted that test
is 5. Let's check it.
Julia> train_y[1]
5
๋ชจ๋ธ์ด ์ ํํ ์์ธกํ์์ ํ์ธํ ์ ์์ต๋๋ค.
You can see that the model predicted it correctly.