def save(self, name_suffix: str) -> str:
"""
Save current tensorflow graph to a checkpoint named with the given name suffix.
The checkpoint will be locaced in self.log_dir directory.
:param name_suffix: saved checkpoint name suffix
:return: path to the saved checkpoint
"""
graph_path = path.join(self._log_dir, 'model_{}.graph'.format(name_suffix))
checkpoint_path = path.join(self._log_dir, 'model_{}.ckpt'.format(name_suffix))
frozen_graph_path = path.join(self._log_dir, 'model_{}.pb'.format(name_suffix))
tf.train.write_graph(self._session.graph_def, '', graph_path, as_text=False)
self._saver.save(self._session, checkpoint_path)
if self._freeze_graph:
with tf.Graph().as_default():
freeze_graph(input_graph=graph_path,
input_checkpoint=checkpoint_path,
output_node_names=self.output_names,
output_graph=frozen_graph_path)
return checkpoint_path
评论列表
文章目录