keras model save and restore

Keras save and restore

基於tensorflow 1.9版本,工作中發現keras保存的ckpt內的key和estimator,slim等保存的不一樣。keras使用的是object-based ckpt,而estimator等使用的是name-based ckpt存儲方式。object-based方式會在名字中加入該節點的依賴項,使用ckpt中的key和graph中的node_name不一樣。需要轉換一下,而這個轉換其實也是protobufer

大致整理了save和restore的流程圖:

變量
函數
條件判斷
繼承
成員函數
成員變量
定義
賦值
成員函數
調用
成員函數
調用
成員函數
init
update
失敗:使用name-based
成員函數
成功:使用object-based
init
hold status
1
update
2
成員函數
start
Keras.Model
keras.engine.network.Network
save_weights
_checkpointable_saver = CheckpointableSaver< weakref.ref >
checkpointable_utils
CheckpointableSaver
load_weights
save
restore
_serialize_object_graph
_breadth_first_checkpointable_traversal
_serialize_slot_variables
_serialize_checkpointables
named_variables
graph_proto
feed_additions
_object_graph_feed_tensor
tf.train.Saver
save
GetTensor
_NameBasedRestoreCoordinator
restore_coordinator
NameBasedSaverStatus
run_restore_ops
tf.train.Saver.restore
ParseFromString
object_graph_proto
_CheckpointRestoreCoordinator
checkpoint
checkpointable_lib._CheckpointPosition.restore
_restore_from_checkpoint_position
restore_ops
CheckpointLoadStatus
run_restore_ops
sess.run
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章