์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- Python
- ์๊ทน์ฌ
- li-ion
- ์ ๋ฝ ๊ตํํ์
- Deeplearning
- ๋์23์ด
- ์ ๋ฝ
- set add
- Andrew ng
- ๋ฏธ๋์์ ํด์ธ๊ตํ
- ๋ฏธ๋์์ ์ฅํ์
- 2022๋
- ๋ฅ๋ฌ๋
- ์ด์ฐจ์ ์ง
- electrochemical models
- gradient descent
- ์ค์คํธ๋ฆฌ์
- cost function
- anaconda ๊ฐ์ํ๊ฒฝ
- ์ ํํ๊ท
- special method
- fatigue fracture
- Linear Regression
- m1 anaconda ์ค์น
- ํน๋ณ ๋ฉ์๋
- ๊ตํํ์
- ์ฒญ์ถ ํ์ดํ
- set method
- fluent python
- Machine learning
- Today
- Total
Done is Better Than Perfect
[๋ฅ๋ฌ๋] 6. ๋ฅ๋ฌ๋ ๋ชจ๋ธ ํ์ต์ ๋ฌธ์ ์ pt.3 : ๊ณผ์ ํฉ ๋ณธ๋ฌธ
[๋ฅ๋ฌ๋] 6. ๋ฅ๋ฌ๋ ๋ชจ๋ธ ํ์ต์ ๋ฌธ์ ์ pt.3 : ๊ณผ์ ํฉ
jimingee 2024. 6. 22. 20:284. ๊ณผ์ ํฉ ๋ฌธ์ ์ ๋ฐฉ์ง ๊ธฐ๋ฒ
๊ณผ์ ํฉ ๋ฌธ์ (overfitting) : ์๊ณ ๋ฆฌ์ฆ์ด ํ์ต ๋ฐ์ดํฐ์ ๊ณผํ๊ฒ ์ ํฉํ ์ํ.
ํ์ต ๋ฐ์ดํฐ๊ฐ ์๋ ๋ค๋ฅธ ๋ฐ์ดํฐ์์ ์ ํํ ์์ธก์ ์์ฑํ์ง ๋ชปํจ (์ผ๋ฐํ ํ์ง ๋ชปํจ)
- ๊ณผ์ ํฉ ๋ฐ์ ์์ธ :
- ๋ฐ์ดํฐ์ ํผ์ง ์ ๋, ์ฆ ๋ถ์ฐ(variance)์ด ๋์ ๊ฒฝ์ฐ
- ๋๋ฌด ๋ง์ด ํ์ต ๋ฐ์ดํฐ๋ฅผ ํ์ต์ํจ ๊ฒฝ์ฐ (epochs๊ฐ ๋งค์ฐ ํฐ ๊ฒฝ์ฐ)
- ํ์ต์ ์ฌ์ฉ๋ ํ๋ผ๋ฏธํฐ๊ฐ ๋๋ฌด ๋ง์ ๊ฒฝ์ฐ
- ๋ฐ์ดํฐ์ ๋นํด ๋ชจ๋ธ์ด ๋๋ฌด ๋ณต์กํ ๊ฒฝ์ฐ
- ๋ฐ์ดํฐ์ ๋ ธ์ด์ฆ & ์ด์์น(outlier)๊ฐ ๋๋ฌด ๋ง์ ๊ฒฝ์ฐ
- ๊ณผ์ ํฉ ํ์ ๋ฐฉ์ง ๊ธฐ๋ฒ : ์ ๊ทํ (Regularization), ๋๋กญ์์ (Dropout), ๋ฐฐ์น ์ ๊ทํ (Batch Normalization)
1. ์ ๊ทํ (Regularization) :
๋ชจ๋ธ์ด ๋ณต์กํด์ง์๋ก parameter๋ค์ ๋ง์์ง๊ณ , ์ ๋๊ฐ์ด ์ปค์ง๋ ๊ฒฝํฅ์ด ๋ฐ์ํจ. -> ๊ธฐ์กด ์์ค ํจ์์ ๊ท์ ํญ์ ๋ํด ์ต์ ๊ฐ ์ฐพ๊ธฐ ๊ฐ๋ฅ
๋ฅ๋ฌ๋์ ๊ท์ ํญ(loss)๊ฐ ์์์ง๋ ๋ฐฉํฅ์ผ๋ก ํ์ตํจ
- L1 ์ ๊ทํ (Lasso Regularization) :
- ๊ฐ์ค์น์ ์ ๋๊ฐ์ ํฉ์ ๊ท์ ํญ(loss)์ผ๋ก ์ ์.
- $ Total Loss = Loss + \lambda \sum_w|W| $
- ๋ชจ๋ธ ๋ด์ ์ผ๋ถ ๊ฐ์ค์น๋ฅผ 0์ผ๋ก ๋ง๋ค์ด ์๋ฏธ์๋ ๊ฐ์ค์น๋ง ๋จ๋๋ก ๋ง๋ค์ด ์ค > sparseํ ๋ชจ๋ธ์ ๋ง๋ฆ
- ๊ฐ์ค์น์ L1 ์ ๊ทํ๋ฅผ ์ ์ฉํ๋ ๋น์จ (0.001 ~0.005)
- tf.keras.layers.Dense(kernel_regularizer = tf.keras.regularizers.l1(ratio))
- L2 ์ ๊ทํ(Ridge Regularization):
- ๊ฐ์ค์น์ ์ ๊ณฑ์ ํฉ์ ๊ท์ ํญ(loss)์ผ๋ก ์ ์.
- $ Total Loss = Loss + \lambda \sum_w W^2$
- ํ์ต์ด ์งํ๋ ๋ ๊ฐ์ค์น์ ๊ฐ์ด 0์ ๊ฐ๊น์์ง๋๋ก ๋ง๋ค์ด์ค. ํฐ ๊ฐ์ ๊ฐ์ง ๊ฐ์ค์น๋ฅผ ๋์ฑ ์ ์ฝํ๋ ํจ๊ณผ
- L1 ์ ๊ทํ์ ๋นํ์ฌ 0์ผ๋ก ์๋ ดํ๋ ๊ฐ์ค์น๊ฐ ์ ์.
- ํน์ ๊ฐ์ค์น์ ์น์ค๋์ง ์๋๋ก ๊ฐ์ค์น ๊ฐ์ ์กฐ์จํ๊ฒ ๋๋ฉฐ ๊ฐ์ค์น ๊ฐ์ (Weight Decay)๋ผ๊ณ ๋ถ๋ฆ
- ๊ฐ์ค์น์ L2 ์ ๊ทํ๋ฅผ ์ ์ฉํ๋ ๋น์จ (0.001 ~0.005)
- tf.keras.layers.Dense(kernel_regularizer = tf.keras.regularizers.l2(ratio))
[ ๊ธฐ๋ณธ ๋ชจ๋ธ vs L1 ์ ๊ทํ ์ ์ฉ ๋ชจ๋ธ vs L2 ์ ๊ทํ ์ ์ฉ ๋ชจ๋ธ ๋น๊ต ]
import numpy as np
import tensorflow as tf
from visual import *
import logging, os
logging.disable(logging.WARNING)
# ๋ฐ์ดํฐ๋ฅผ ์ ์ฒ๋ฆฌํ๋ ํจ์ - one hot ์๋ฒ ๋ฉ
def sequences_shaping(sequences, dimension):
results = np.zeros((len(sequences), dimension))
for i, word_indices in enumerate(sequences):
results[i, word_indices] = 1.0
return results
''' ๊ธฐ๋ณธ ๋ชจ๋ธ '''
def Basic(word_num):
basic_model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation = 'relu', input_shape=(word_num,)),
tf.keras.layers.Dense(128, activation = 'relu'),
tf.keras.layers.Dense(1, activation= 'sigmoid')
])
return basic_model
''' ๊ธฐ๋ณธ ๋ชจ๋ธ์ L1 ์ ๊ทํ ์ ์ฉ (์
๋ ฅ์ธต๊ณผ ํ๋ ์ธต์๋ง ์ ์ฉ) '''
def L1(word_num):
l1_model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation = 'relu', input_shape=(word_num,), kernel_regularizer = tf.keras.regularizers.l1(0.002)),
tf.keras.layers.Dense(128, activation = 'relu', kernel_regularizer = tf.keras.regularizers.l1(0.002)),
tf.keras.layers.Dense(1, activation= 'sigmoid')
])
return l1_model
''' ๊ธฐ๋ณธ ๋ชจ๋ธ์ L2 ์ ๊ทํ ์ ์ฉ (์
๋ ฅ์ธต๊ณผ ํ๋ ์ธต์๋ง ์ ์ฉ) '''
def L2(word_num):
l2_model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation = 'relu', input_shape=(word_num,), kernel_regularizer = tf.keras.regularizers.l2(0.002)),
tf.keras.layers.Dense(128, activation = 'relu', kernel_regularizer = tf.keras.regularizers.l2(0.002)),
tf.keras.layers.Dense(1, activation= 'sigmoid')
])
return l2_model
''' ์ธ ๋ชจ๋ธ์ ๋ถ๋ฌ์จ ํ ํ์ต์ํค๊ณ ํ
์คํธ ๋ฐ์ดํฐ์ ๋ํด ํ๊ฐ (binary crossentropy ๊ฐ ์ถ๋ ฅ) '''
def main():
word_num = 100
data_num = 25000
# Keras์ ๋ด์ฅ๋์ด ์๋ imdb ๋ฐ์ดํฐ ์ธํธ๋ฅผ ๋ถ๋ฌ์ค๊ณ ์ ์ฒ๋ฆฌ
(train_data, train_labels), (test_data, test_labels) = tf.keras.datasets.imdb.load_data(num_words = word_num)
train_data = sequences_shaping(train_data, dimension = word_num)
test_data = sequences_shaping(test_data, dimension = word_num)
basic_model = Basic(word_num) # ๊ธฐ๋ณธ ๋ชจ๋ธ
l1_model = L1(word_num) # L1 ์ ๊ทํ๋ฅผ ์ ์ฉํ ๋ชจ๋ธ
l2_model = L2(word_num) # L2 ์ ๊ทํ๋ฅผ ์ ์ฉํ ๋ชจ๋ธ
# ๋ชจ๋ธ ์ต์ ํ
basic_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy','binary_crossentropy'])
l1_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy','binary_crossentropy'])
l2_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy','binary_crossentropy'])
basic_model.summary()
l1_model.summary()
l2_model.summary
# ๋ชจ๋ธ ํ์ต
basic_history = basic_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
print('\n')
l1_history = l1_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
print('\n')
l2_history = l2_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
# ๋ชจ๋ธ ํ๊ฐ
scores_basic = basic_model.evaluate(test_data, test_labels)
scores_l1 = l1_model.evaluate(test_data, test_labels)
scores_l2 = l2_model.evaluate(test_data, test_labels)
print('\nscores_basic: ', scores_basic[-1])
print('scores_l1: ', scores_l1[-1])
print('scores_l2: ', scores_l2[-1])
Visulaize([('Basic', basic_history),('L1 Regularization', l1_history), ('L2 Regularization', l2_history)])
return basic_history, l1_history, l2_history
if __name__ == "__main__":
main()
[ ์ฝ๋ ์คํ ๊ฒฐ๊ณผ ]
- ๊ท์ ๋ฅผ ์ ์ฉํ์ง ์์ basic ๋ชจ๋ธ์ train์ crossentropy ๊ฐ๊ณผ validation์ crossentropy ๊ฐ์ด ์ฐจ์ด๊ฐ ํผ -> overfitting๋ฐ์ํจ
- L1, L2 ์ ๊ทํ๋ฅผ ์ฌ์ฉํ ๋ชจ๋ธ์ train, validation์ cross entropy ๊ฐ ์ฐจ์ด๊ฐ ํฌ์ง ์์ -> overfitting์ด ์ํ๋์์
- ์์น ๋ฐ์ดํฐ์์ L1, L2 ์ ๊ทํ๋ฅผ ์ฌ์ฉํ ๋ชจ๋ธ์ ์ผ๋ฐํ ์ฑ๋ฅ์ด ๋ ์ข์์ ์์ ์์
### output ###
scores_basic: 0.7418451
scores_l1: 0.56926525
scores_l2: 0.56637627
2. ๋๋กญ ์์ (Drop out) :
- ๊ฐ layer๋ง๋ค ์ผ์ ๋น์จ์ ๋ด๋ฐ์ ์์๋ก drop์์ผ ๋๋จธ์ง ๋ด๋ฐ๋ค๋ง ํ์ตํ๋ ๋ฐฉ๋ฒ.
- ๋ฐ์ดํฐ๋ฅผ ํ์ตํ ๋, ์ผ๋ถ ํผ์ ํธ๋ก (๋ด๋ฐ)์ ๋๋คํ๊ฒ 0์ผ๋ก ๋ง๋ค์ด ๋ชจ๋ธ ๋ด๋ถ์ ํน์ ๊ฐ์ค์น(Weight)์ ์น์ค๋๋ ๊ฒ์ ๋ง์
- ๋๋กญ ์์์ ์ ์ฉํ๋ฉด ํ์ต๋๋ ๋ ธ๋์ ๊ฐ์ค์น๋ค์ด ๋งค๋ฒ ๋ฌ๋ผ์ง.
- ๋ค๋ฅธ ์ ๊ทํ ๊ธฐ๋ฒ๋ค๊ณผ ์ํธ ๋ณด์์ ์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅ
- drop๋ ๋ด๋ฐ์ backpropagation๋ ์ ํธ ์ฐจ๋จ. Test ๊ณผ์ ์์๋ dropout ์ฌ์ฉ X(๋ชจ๋ ๋ด๋ฐ์ ์ ํธ ์ ๋ฌ)
- ๋๋กญ ์์์ ์ ์ฉํ ํ๋ฅ : 0.1 ~ 0.5
- tf.keras.layers.Dropout(prob)
[ ๊ธฐ๋ณธ ๋ชจ๋ธ vs dropout ์ ์ฉ ๋ชจ๋ธ ๋น๊ต ]
import numpy as np
import tensorflow as tf
from visual import *
import logging, os
logging.disable(logging.WARNING)
# ๋ฐ์ดํฐ๋ฅผ ์ ์ฒ๋ฆฌํ๋ ํจ์
def sequences_shaping(sequences, dimension):
results = np.zeros((len(sequences), dimension))
for i, word_indices in enumerate(sequences):
results[i, word_indices] = 1.0
return results
''' ๊ธฐ๋ณธ ๋ชจ๋ธ ์์ฑ '''
def Basic(word_num):
basic_model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation = 'relu', input_shape=(word_num,)),
tf.keras.layers.Dense(128, activation = 'relu'),
tf.keras.layers.Dense(1, activation= 'sigmoid')
])
return basic_model
''' ๊ธฐ๋ณธ ๋ชจ๋ธ์ ๋๋กญ ์์ ๋ ์ด์ด ์ถ๊ฐ '''
def Dropout(word_num):
dropout_model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation = 'relu', input_shape=(word_num,)),
tf.keras.layers.Dropout(0.3),
tf.keras.layers.Dense(128, activation = 'relu'),
tf.keras.layers.Dropout(0.3),
tf.keras.layers.Dense(1, activation= 'sigmoid')
])
return dropout_model
''' ๋ ๋ชจ๋ธ์ ๋ถ๋ฌ์จ ํ ํ์ต์ํค๊ณ ํ
์คํธ ๋ฐ์ดํฐ์ ๋ํด ํ๊ฐ(binary crossentropy ์ ์ ์ถ๋ ฅ) '''
def main():
word_num = 100
data_num = 25000
# Keras์ ๋ด์ฅ๋์ด ์๋ imdb ๋ฐ์ดํฐ ์ธํธ๋ฅผ ๋ถ๋ฌ์ค๊ณ ์ ์ฒ๋ฆฌ
(train_data, train_labels), (test_data, test_labels) = tf.keras.datasets.imdb.load_data(num_words = word_num)
train_data = sequences_shaping(train_data, dimension = word_num)
test_data = sequences_shaping(test_data, dimension = word_num)
basic_model = Basic(word_num) # ๊ธฐ๋ณธ ๋ชจ๋ธ
dropout_model = Dropout(word_num) # ๋๋กญ ์์ ์ ์ฉํ ๋ชจ๋ธ
basic_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy','binary_crossentropy'])
dropout_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy','binary_crossentropy'])
basic_model.summary()
dropout_model.summary()
basic_history = basic_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
print('\n')
dropout_history = dropout_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
scores_basic = basic_model.evaluate(test_data, test_labels)
scores_dropout = dropout_model.evaluate(test_data, test_labels)
print('\nscores_basic: ', scores_basic[-1])
print('scores_dropout: ', scores_dropout[-1])
Visulaize([('Basic', basic_history),('Dropout', dropout_history)])
return basic_history, dropout_history
if __name__ == "__main__":
main()
[ ์ฝ๋ ์คํ ๊ฒฐ๊ณผ ]
- dropout์ ์ ์ฉํ์ง ์์ basic ๋ชจ๋ธ์ train์ crossentropy ๊ฐ๊ณผ validation์ crossentropy ๊ฐ์ด ์ฐจ์ด ํผ -> overfitting๋ฐ์
- dropout์ ์ ์ฉํ ๋ชจ๋ธ์ train, validation์ cross entropy ๊ฐ ์ฐจ์ด๊ฐ ํฌ์ง ์์ -> overfitting์ด ์ํ๋์์
- ํ ์คํธ ๋ฐ์ดํฐ์์ droupout์ ์ฌ์ฉํ ๋ชจ๋ธ์ binary crossentropy ์ ์๊ฐ ๋ ๋ฎ์ -> dropout ์ ์ฉ ๋ชจ๋ธ์ ์ผ๋ฐํ ์ฑ๋ฅ์ด ๋ ์ข์
### output ###
scores_basic: 0.7272758
scores_dropout: 0.60718566
3. ๋ฐฐ์น ์ ๊ทํ (Batch Normalization):
- Normalization(์ ๊ทํ)์ ์ฒ์ Input data ๋ฟ๋ง ์๋๋ผ ์ ๊ฒฝ๋ง ๋ด๋ถ Hidden Layer์ input์๋ ์ ์ฉ
- ๊ฐ์ ๋ถํฌ๋ฅผ ํต์ผํจ (scailing)
- ๋ฐฐ์น ์ ๊ทํ์ ์ฅ์ :
- ๋งค Layer๋ง๋ค ์ ๊ทํ๋ฅผ ์งํํ๋ฏ๋ก ๊ฐ์ค์น ์ด๊ธฐ๊ฐ์ ํฌ๊ฒ ์์กดํ์ง ์์. (๊ฐ์ค์น ์ด๊ธฐํ ์ค์๋ ๊ฐ์)
- ๊ณผ์ ํฉ ์ต์ (Dropout, L1, L2 ์ ๊ทํ ํ์์ฑ ๊ฐ์)
- ํต์ฌ์ ํ์ต ์๋์ ํฅ์
[ ๊ธฐ๋ณธ ๋ชจ๋ธ vs ๋ฐฐ์น ์ ๊ทํ ์ ์ฉ ๋ชจ๋ธ ๋น๊ต ]
- ๋ฐฐ์น ์ ๊ทํ๋ ํ๋์ ๋ ์ด์ด๋ก์จ Dense ๋ ์ด์ด์ ํ์ฑํ ํจ์ ์ฌ์ด์์ ์์ฉ
- ๋ฐ๋ผ์, ๊ธฐ๋ณธ ๋ชจ๋ธ์ ์์ฑํ ๋ ํ์ฑํ ํจ์์ ๋๊ฐ์ ์ญํ ์ ํ๋ Activation ๋ ์ด์ด๋ฅผ ๋ฐ๋ก ์์ฑํด์ผ ํจ
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import logging
import os
from visual import *
logging.disable(logging.WARNING)
np.random.seed(42)
tf.random.set_seed(42)
# ๊ธฐ๋ณธ ๋ชจ๋ธ
def generate_basic_model():
basic_model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(256),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(128),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(512),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(64),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(128),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(256),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(10, activation='softmax')])
return basic_model
''' ๋ฐฐ์น ์ ๊ทํ ์ ์ฉ ๋ชจ๋ธ(๊ฐ Dense Layer ์ฌ์ด์ ์ ์ฉ) '''
def generate_batch_norm_model():
bn_model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(256),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(128),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(512),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(64),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(128),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(256),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Activation('relu'),
tf.keras.layers.Dense(10, activation='softmax')])
return bn_model
def main():
# MNIST ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค๊ณ ์ ์ฒ๋ฆฌ
mnist = tf.keras.datasets.mnist
(train_data, train_labels), (test_data, test_labels) = mnist.load_data()
train_data, test_data = train_data / 255.0, test_data / 255.0
base_model = generate_basic_model() # ๊ธฐ๋ณธ ๋ชจ๋ธ
bn_model = generate_batch_norm_model() # ๋ฐฐ์น ์ ๊ทํ๋ฅผ ์ ์ฉํ ๋ชจ๋ธ
base_model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
bn_model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
base_model.summary()
bn_model.summary()
base_history = base_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
bn_history = bn_model.fit(train_data, train_labels, epochs=20, batch_size=500, validation_data=(test_data, test_labels), verbose=0)
score_basic = base_model.evaluate(test_data, test_labels)
score_bn = bn_model.evaluate(test_data, test_labels)
print('\naccuracy_basic : ', score_basic[-1])
print('\naccuracy_bn : ', score_bn[-1])
Visulaize([('Basic', base_history), ('Batch Normalization', bn_history)])
return base_history, bn_history
if __name__ == "__main__":
main()
[ ์ฝ๋ ์คํ ๊ฒฐ๊ณผ ]
- batch norm์ ์ฌ์ฉํ ๋ชจ๋ธ์ loss ๊ฐ ๋ ์์
- base model์ epoch๊ฐ ์ฆ๊ฐํจ์ ๋ฐ๋ผ loss๊ฐ ๊ฐ์ํ๊ธฐ๋ ํ๊ณ , ์ฆ๊ฐํ๊ธฐ๋ ํจ -> ํ์ต์ด ์์ ์ ์ผ๋ก ์ด๋ฃจ์ด์ง์ง ์์
- batch norm model์ epoch๊ฐ ์ฆ๊ฐํจ์ ๋ฐ๋ผ loss๊ฐ ๊ฐ์ํ๋ ๊ฒฝํฅ์ ๋ณด์ -> ํ์ต์ด ์์ ์ ์ผ๋ก ์ด๋ฃจ์ด์ง
'๐ค AI > Deep Learning' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฅ๋ฌ๋] 8. RNN (1) | 2024.07.01 |
---|---|
[๋ฅ๋ฌ๋] 7. CNN (0) | 2024.06.27 |
[๋ฅ๋ฌ๋] 5. ๋ฅ๋ฌ๋ ๋ชจ๋ธ ํ์ต์ ๋ฌธ์ ์ pt.2 : ๊ธฐ์ธ๊ธฐ ์์ค, ๊ฐ์ค์น ์ด๊ธฐํ ๋ฐฉ๋ฒ (2) | 2024.06.12 |
[๋ฅ๋ฌ๋] 4. ๋ฅ๋ฌ๋ ๋ชจ๋ธ ํ์ต์ ๋ฌธ์ ์ pt.1 : ์ต์ ํ ์๊ณ ๋ฆฌ์ฆ (0) | 2024.06.10 |
[๋ฅ๋ฌ๋] 3. ๋ฅ๋ฌ๋ ๋ชจ๋ธ ๊ตฌํ (์ ํ ํ๊ท, ๋น์ ํ ํ๊ท ๋ชจ๋ธ ๊ตฌํ) (0) | 2024.06.08 |