Miscellaneous
Checkpoint related
Comparison:
Checkpoint(*.ckpt)
Contains three files normally:
model.ckpt.index
model.ckpt.meta
model.ckpt.data-00000-of-00001
Saved by
tf.trainer.Saver().save()
, only save thetf.Variables()
, not including graph model, thus impossible to recover a whole graph with ckpt only.Use
saver.restore(session, checkpoint_path)
to restore.
GraphDef(*.pb)
Contains serialized protobuf data and compute graph, but not Variable data.
Can only recover compute graph, need checkpoint to inject data.
FrozenGraphDef is slightly different, since it will convert all Variable to constant values(which can be loaded from checkpoint), usually used as pre-train model.
SavedModel
Combination of checkpoint and GraphDef, plus SignatureDef of input and output variables.
Reference: TensorFlow 到底有几种模型格式?
checkpoint
Print parameters in checkpoint
Using internal tool --
inspect_checkpoint
:Using
tf.compat.v1.NewCheckpointReader(ckpt_path)
:
Reference: 如何打印出TensorFlow保存的checkpoint里的参数名
saved_model
pb
keras h5
Keras save its model in h5 format, so we need to know how to read h5 in python if we only want to search for some specific parameters.
Reference: 模型复现之HDF5文件
Last updated