그래서 사용하고 싶 tf.keras.콜백이 있습니다.ModelCheckpoint 에 Keras 튜너지만,당신은 선택의 경로를 저장할점,허용하지 않으로 저장하는 파일을 특정 이름,이름을 연관된 평가 실행의는 체크포인트,만 연결된 epoch.
는 경우 나는 단순히 넣어 이 콜백에 Keras 튜너 순간에,체크포인트 저장을 발생,결국에는 알 수 없는 방법을 연결하는 체크포인트 저장 시험 및 평가 실행,만 시대.
그래서 사용하고 싶 tf.keras.콜백이 있습니다.ModelCheckpoint 에 Keras 튜너지만,당신은 선택의 경로를 저장할점,허용하지 않으로 저장하는 파일을 특정 이름,이름을 연관된 평가 실행의는 체크포인트,만 연결된 epoch.
는 경우 나는 단순히 넣어 이 콜백에 Keras 튜너 순간에,체크포인트 저장을 발생,결국에는 알 수 없는 방법을 연결하는 체크포인트 저장 시험 및 평가 실행,만 시대.
당신이 사용할 수 있는 tf.keras.callbacks.ModelCheckpoint
대 Keras tuner
동일한 방식으로 사용되는 다른 모델을 저장됩니다.
훈련 후로 모델 hyperparameters 에서 얻을 검색 따라 이 모형을 정의할 수 있습니다 모델에 검문소 저장하는 아래와 같:
hypermodel = tuner.hypermodel.build(best_hps)
# Retrain the model
hypermodel.fit(img_train, label_train, epochs=best_epoch, validation_split=0.2)
import os
checkpoint_path = "training_1/cp.ckpt"
checkpoint_dir = os.path.dirname(checkpoint_path)
# Create a callback that saves the model's weights
cp_callback = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_path,
save_weights_only=True,
verbose=1)
history = hypermodel.fit(img_train, label_train, epochs=5, validation_split=0.2, callbacks=[cp_callback])
os.listdir(checkpoint_dir)
# Re-evaluate the model
loss, acc = hypermodel.evaluate(img_test, label_test, verbose=2)
print("Restored model, accuracy: {:5.2f}%".format(100 * acc))
# Loads the weights
hypermodel.load_weights(checkpoint_path)
# Re-evaluate the model
loss, acc = hypermodel.evaluate(img_test, label_test, verbose=2)
print("Restored model, accuracy: {:5.2f}%".format(100 * acc))
참조하시기 바랍 이 링크에 대한 더 많은 inofrmation 에 저장하고 부하는 모델입니다.