我正在使用CNN進行面部表情識別。我使用Keras和Tensorflow作爲後端。我的模型保存爲h5格式。微調Keras模型
我想重新訓練我的網絡,並使用VGG模型微調我的模型。
我該怎麼做keras?從這裏再次
from keras.models import model_from_json
model = model_from_json(json_string)
model.load_weights('model_weights.h5')
開始訓練微調:
我正在使用CNN進行面部表情識別。我使用Keras和Tensorflow作爲後端。我的模型保存爲h5格式。微調Keras模型
我想重新訓練我的網絡,並使用VGG模型微調我的模型。
我該怎麼做keras?從這裏再次
from keras.models import model_from_json
model = model_from_json(json_string)
model.load_weights('model_weights.h5')
開始訓練微調:
保存您的模型架構和重量:
json_string = model.to_json()
model.save_weights('model_weights.h5')
負載模型結構和權重。我希望這有幫助。
您可以使用Keras model.save(filepath)
功能。
詳細的各種Keras保存和加載技術,在此YouTube視頻的例子討論:Save and load a Keras model
model.save(filepath)
節省:
要加載這個保存的模型,你可以使用下列內容:
from keras.models import load_model
new_model = load_model(filepath)
如果使用model.to_json()
,你只會被保存模型的架構。此外,如果您使用model.save_weights()
,則只會保存模型的權重。使用這兩種替代保存技術,您不會保存培訓配置(損失,優化器),也不會保存優化器的狀態。