Created
August 10, 2020 00:49
-
-
Save Taekyoon/81d6ad8667d3adb4f29d5fb229b7de77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_name = "tf2_gpt2_naver_movie" | |
earlystop_callback = EarlyStopping(monitor='val_accuracy', min_delta=0.0001, patience=2) | |
checkpoint_path = os.path.join(DATA_OUT_PATH, model_name, 'weights.h5') | |
checkpoint_dir = os.path.dirname(checkpoint_path) | |
if os.path.exists(checkpoint_dir): | |
print("{} -- Folder already exists \n".format(checkpoint_dir)) | |
else: | |
os.makedirs(checkpoint_dir, exist_ok=True) | |
print("{} -- Folder create complete \n".format(checkpoint_dir)) | |
cp_callback = ModelCheckpoint( | |
checkpoint_path, monitor='val_accuracy', verbose=1, save_best_only=True, save_weights_only=True) | |
history = cls_model.fit(train_data_sents, train_data_labels, | |
epochs=NUM_EPOCHS, | |
batch_size=BATCH_SIZE, | |
validation_split=VALID_SPLIT, | |
callbacks=[earlystop_callback, cp_callback]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment