티스토리 뷰

Daliy Note

LeNet - (4) iteration

Raziel 2021. 8. 26. 00:45

Colab

 

Shuffle 의 필요성?

효율적이 학습을 위해 나눠 놓은 미니 배치들에 가끔 특정 위치에 특정 정보가 쌓이게 된다. 이는 과적합으로 이어진다.

그래서 무작위로 섞어주는 절차가 필요하다.

 

.fit( x, y=None, batch_size=32, shuffle=True)

.fit( x, y=None, batch_size=32, shuffle=False) fit해줄때, 옆에 붙여주면된다.

 

# 모델을 학습하는 코드를 작성. (shuffle을 노사용)
results_no_shuffle = model.fit(train_images, train_labels, epochs=5, shuffle = False)

# 모델을 학습하는 코드를 작성. (shuffle을 사용)
results_shuffle = model.fit(train_images, train_labels, epochs=5, shuffle = True)

 

결과

 - 0s 253us/sample - loss: 1.1735 - categorical_accuracy: 0.0910
No Shuffle loss : [1.534, 1.204, 1.077, 1.001, 0.949]
   Shuffle loss : [0.946, 0.915, 0.886, 0.868, 0.849]
0.9489592630386352 0.8486728433609009

셔플을 실행한것이 Loss값이 많이 줄어든다.

 

 

 

 

참고: GradientBased Learning Applied to Document Recognition

'Daliy Note' 카테고리의 다른 글

Plz  (0) 2021.08.27
Autoencoders  (0) 2021.08.26
LeNet - (3) BatchNormalization  (0) 2021.08.25
CS231N - Convolutional Neural Networks for Visual Recognition  (0) 2021.08.25
CNN practice - 2  (0) 2021.08.25
댓글