Skip to content

Instantly share code, notes, and snippets.

@vortexkd vortexkd/train_model.py Secret
Last active May 30, 2019

Embed
What would you like to do?
import tensorflow as tf
model = build_model() #ここに学習させたいモデルをロードするか、作成する
# 大量のデータで学習しているからこそチェックポイントなどをつけましょう。
ckpt = tf.keras.callbacks.ModelCheckpoint('models/ckpt.hdf5', monitor='val_loss',
verbose=0, save_best_only=True,
save_weights_only=False, mode='auto', period=3)
lr = tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.1, patience=5,
verbose=1, mode='auto', min_delta=0.0001,
cooldown=3, min_lr=0)
model.fit_generator(
generate_input_data(class_map, path),
steps_per_epoch=train_size // batch_size,
validation_data=generate_input_data(path=test_data_path),
validation_steps= test_size // batch_size,
epochs=30,
callbacks=[ckpt, lr]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.