Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- programmers
- 편스토랑 우승상품
- 파이썬
- SW Expert Academy
- Git
- Kaggle
- 캐치카페
- hackerrank
- ChatGPT
- 편스토랑
- 금융문자분석경진대회
- 맥북
- leetcode
- ubuntu
- gs25
- 데이콘
- Docker
- 코로나19
- 프로그래머스 파이썬
- AI 경진대회
- 우분투
- github
- 프로그래머스
- PYTHON
- 자연어처리
- dacon
- Baekjoon
- 백준
- Real or Not? NLP with Disaster Tweets
- 더현대서울 맛집
Archives
- Today
- Total
솜씨좋은장씨
[DACON] 소설 작가 분류 AI 경진대회 13일차! 본문
728x90
반응형

소설 작가 분류 AI 경진대회
출처 : DACON - Data Science Competition
dacon.io
애플 이벤트를 시청하며 진행했던 13일차!
오늘도 역시 NIPA에서 지원받은 V100 GPU 서버를 활용하여 도전해보았습니다.
13일차는 12일차에서 열심히 전처리 했던 데이터를 바탕으로 시도해보았습니다.

왜냐하면 12일차에서는 결과를 도출하고 다 제출하고 나서야 전처리한 데이터를 활용하지 않았다는 것을
깨달았기 때문입니다.
여러 모델 중에서 가장 validation loss 가 좋아보이는 세개를 골라서 제출해보았습니다.
Bi-LSTM, Baseline model, LSTM 모델을 활용해 보았습니다.
예전에 금융 문자 분석 경진대회에서는 LSTM 모델이 성능이 괜찮게 나왔었는데 아직 전처리 과정이 부족한 것인지
데이터 EDA 과정이 부족한 것인지 더 도전해봐야할 것 같습니다.
import tensorflow as tf
model5 = tf.keras.Sequential([
tf.keras.layers.Embedding(vocab_size, 100, input_length=max_len),
tf.keras.layers.GlobalAveragePooling1D(),
tf.keras.layers.Dense(24, activation='relu'),
tf.keras.layers.Dense(5, activation='softmax')
])
model5.compile(loss='sparse_categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)
MODEL_SAVE_FOLDER_PATH = './model12_5/'
if not os.path.exists(MODEL_SAVE_FOLDER_PATH):
os.mkdir(MODEL_SAVE_FOLDER_PATH)
model_path = MODEL_SAVE_FOLDER_PATH + '{epoch:02d}-{val_loss:.4f}.hdf5'
cb_checkpoint = ModelCheckpoint(filepath=model_path, monitor='val_loss',
verbose=1, save_best_only=True)
model5.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['acc'])
history = model5.fit(X_train, y_train, epochs=30, callbacks=[es, cb_checkpoint], batch_size=256, validation_split=0.2)
Baseline model을 활용하여 학습한 모델 중에 19번째 epoch에서 validation loss 값이 0.5926이었던
체크포인트를 활용하여 결과를 도출하고 제출해보았습니다.
결과 도출
from tensorflow.keras.models import load_model
best_model_path = "./model12_5/19-0.5926.hdf5"
best_model = load_model(best_model_path)
# predict values
sample_submission = pd.read_csv("./sample_submission.csv")
pred = best_model.predict_proba(X_test)
sample_submission[['0','1','2','3','4']] = pred
sample_submission.to_csv('submission_37.csv', index = False, encoding = 'utf-8')
DACON 제출 결과

전처리에 더 신경써서 진행해서 그런지 기존에 Baseline model을 바탕으로 학습하고 결과를 도출했을때 보다
훨씬 좋은 점수를 얻을 수 있었습니다.
import tensorflow as tf
model8 = tf.keras.Sequential([
tf.keras.layers.Embedding(vocab_size, 100, input_length=max_len),
tf.keras.layers.GlobalAveragePooling1D(),
tf.keras.layers.Dense(24, activation='relu'),
tf.keras.layers.Dense(5, activation='softmax')
])
model8.compile(loss='sparse_categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)
MODEL_SAVE_FOLDER_PATH = './model13_8/'
if not os.path.exists(MODEL_SAVE_FOLDER_PATH):
os.mkdir(MODEL_SAVE_FOLDER_PATH)
model_path = MODEL_SAVE_FOLDER_PATH + '{epoch:02d}-{val_loss:.4f}.hdf5'
cb_checkpoint = ModelCheckpoint(filepath=model_path, monitor='val_loss',
verbose=1, save_best_only=True)
model8.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['acc'])
history = model8.fit(X_train, y_train, epochs=100, callbacks=[es, cb_checkpoint], batch_size=512, validation_split=0.2)
이번에는 batch size의 크기를 키워서
'DACON > 소설 작가 분류 AI 경진대회' 카테고리의 다른 글
[DACON] 소설 작가 분류 AI 경진대회 16일차! (0) | 2020.11.15 |
---|---|
[DACON] 소설 작가 분류 AI 경진대회 12일차! (0) | 2020.11.10 |
[DACON] 소설 작가 분류 AI 경진대회 9일차! (0) | 2020.11.07 |
[DACON] 소설 작가 분류 AI 경진대회 8일차! (0) | 2020.11.06 |
[DACON] 소설 작가 분류 AI 경진대회 7일차! (0) | 2020.11.05 |