deep learning tutorial with theano study - ch 3, ch 4

14
Deep Learning Tutorial with Theano http://deeplearning.net/tutorial/deeplearning.pdf CHAPTER 3 ~ CHAPTER 4 Classifying mnist digits using logistic regression

Upload: -

Post on 14-Apr-2017

146 views

Category:

Technology


1 download

TRANSCRIPT

Deep Learning Tutorialwith Theano

http://deeplearning.net/tutorial/deeplearning.pdf

CHAPTER 3 ~ CHAPTER 4Classifying mnist digits using logistic regression

Softmax classification with Theano : data

• consists of handwritten digit im-ages

• 60,000 examples for the train-ing set (an actual training set of 50,000 examples and 10,000 validation examples)

• 10,000 examples for testing

Softmax classification with Theano : data

• image size : 28 * 28

• # of label : 10 ( 0 ~ 9 )

Softmax classification with Theano : initialize

weight 들의 행렬 과 bias 값 를 0으로 초기화 한다 .share 로 선언하여 함수 호출 후에도 변화된 값이 유지 될 수 있게 한다 .

p_y_given_x 변수 즉 , x 에 대한 y 값의 확률을 구하는 함수를 symbolize 한다 .

prediction 값을 결정짓는 ‘ hot_encoding’즉 , p_y_given_x 값 중에서 max 값을 찾는 함수를 symbolize 한다 .

Softmax classification with Theano : initialize

𝐿= 1𝑁∑

𝑛𝐷𝑛 (𝑌 ,𝑌 )

input data X 와 label y를 symbolize 한다 .

W 와 b 값을 initialize 한다

cost function 을 설정한다 .

Softmax classification with Theano : Learning

gradient descent method• Use the method of stochastic gradient method with mini-batches(MSGD)

stochastic gradient descent method

전체 data 에 대해서 gradient descent method 를 적용

특정 data 에 대해서 gradient descent method 를 적용

Softmax classification with Theano : Learning

minibatch stochastic gradient descent method• Use the method of stochastic gradient method with mini-batches(MSGD)

전체 data 에 대해서 gradient descent method 를 적용하는 것이 아닌 batch 단위로 gra-dient 를 계산하여 다음 learning 에 반영한다 .batch size 가 1 일 때는 임의의 데이터 1 개에 대해 cost function 을 미분하는 stochastic gradient descent method 와 같다 .

Softmax classification with Theano : Learning

• Use the method of stochastic gradient method with mini-batches(MSGD) [0]

[1]

[2]

[n]

batch size

index

batch size 단위로 학습한다 .

Softmax classification with Theano : Learning• Use the method of stochastic gradient method with mini-batches(MSGD) [0]

[1]

[2]

[n]

batch size = 600

index

n_train_batches

Softmax classification with Theano : Testing

Error 의 평균 값 return

Softmax classification with Theano : Testing

Regularization : Early Stopping

• Overfitting 을 막기 위해 training 중 주기적으로 validation data 로 test 후 더 이상 성능 향상이 일어나지 않으면 조기 종료 (Early Stopping) 시킨다 .

training 중 validation check 의 주기

Softmax classification with Theano : Testing

Regularization : Early Stopping

성능이 향상 되었으면 training 기간을 늘리고 Test data 로 test

Softmax classification with Theano : Result(n_epoch=1000, bach_size=600)

Learning Rate

Validation Score (%)

Test performance

(%)# of Epoch Epochs per

SecTotal

Time(s)

0.07 7.583333 7.500000 116 3.947123 29.40.10 7.531250 7.489583 86 3.830604 22.50.13 7.500000 7.489583 74 3.669838 20.20.16 7.250000 7.333333 116 3.841252 30.20.19 7.187500 7.322917 116 3.809352 30.50.21 7.250000 7.354167 90 3.813764 23.60.30 6.906250 7.125000 144 3.827152 37.60.40 7.114584 7.375000 62 3.734331 16.60.50 7.083333 7.270833 61 3.757007 16.20.60 6.989583 7.291667 62 3.689389 16.8

Softmax classification with Theano : Result(n_epoch=1000, learning_rate=0.13)

Batch size Validation Score (%)

Test performance

(%)# of Epoch Epochs per

SecTotal

Time(s)

100 6.890000 7.570000 80 3.848073 20.8200 6.860000 7.420000 132 3.925566 33.6300 7.202020 7.626263 74 3.847854 19.2400 7.320000 7.810000 68 3.790947 17.9500 7.220000 7.690000 96 3.714642 25.8600 7.500000 7.489583 74 3.669838 20.2700 7.469388 7.642857 98 3.828589 25.6800 7.468750 7.489583 114 3.707930 30.7900 7.424242 7.707071 126 3.655928 34.5

1000 7.270000 7.740000 180 3.709061 48.5