आप उपयोग कर सकते हैं 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 पर बचाने और लोड मॉडल चौकियों.