2017-08-13 26 views
0

我想保存模型旁邊的所有模型參數(優化器,學習率,批量大小等)和模型架構(圖層的數量和類型),以便稍後回顧分析爲什麼某些模型可以更好地工作。與模型一起存儲Keras模型參數和模型架構的最佳方式是什麼?

有沒有簡單的方法來存儲這個元數據連同權重?

+0

我想如果你使用的是tensorflow後端,'tf.train.Saver'可以節省優化器和學習速度,我不知道它是否可以保存批量大小,但你可以試一試。 –

回答

1

the docs

from keras.models import load_model 

model.save('my_model.h5') # creates a HDF5 file 'my_model.h5' 
del model # deletes the existing model 

# returns a compiled model 
# identical to the previous one 
model = load_model('my_model.h5') 

這包括優化器(其應包括學習率和批量大小)。除此之外,你可以使用

  • 使用它們的版本控制下的配置腳本(我這樣做是爲我的碩士論文,見my configuration scripts
  • 如果你想一個文件存放培訓講稿

,只需使用像.tar這樣的容器文件格式即可。

相關問題