Train
모델을 학습하기 위한 데이터셋으로 이때 학습은 최적의 파라미터를 찾는 것입니다.
오직 학습 을 위한 데이터셋
Validation
학습이 이미 완료된 모델을 검증하기 위한 데이터셋입니다.
학습이 된 여러 가지 모델 중 가장 좋은 하나의 모델을 고르기 위한 데이터셋입니다.
학습 과정에 어느 정도 관여를 한다고 볼 수 있습니다.
하지만 Validation 데이터 자체가 학습에 직접적으로 관여하는 것은 아님
# 모델 학습
model.fit(x_train,y_train,epochs = 100 , batch_size = 128,validation_split=0.2)
test
모델의 '최종 성능'을 평가하기 위한 데이터셋
학습 과정에 관여를 하지 않음!!!
# 데이터 준비
import tensorflow as tf
import pandas as pd
(x_train , y_train) , (x_test , y_test) = tf.keras.datasets.mnist.load_data()
print(x_train.shape , y_train.shape)
# 2차원으로
x_train = x_train.reshape(60000 , 784)
x_test = x_test.reshape(10000 , 784)
# 원 핫 인코딩
y_train = pd.get_dummies(y_train)
y_test = pd.get_dummies(y_test)
print(x_train.shape , y_train.shape)
print(x_test.shape , y_test.shape)
# 모델 준비
X = tf.keras.Input(shape = [784])
Y = tf.keras.layers.Dense(10 , activation = 'softmax')(X)
model = tf.keras.Model(X,Y)
model.compile(loss="categorical_crossentropy" , metrics="accuracy")
model.summary()
# 모델 학습
model.fit(x_train,y_train,epochs = 100 , batch_size = 128)
# 모델 평가
model.evaluate(x_test, y_test)