如何在张量流中读取Keras检查点? [英] How to read Keras checkpoint in tensorflow?

查看:98
本文介绍了如何在张量流中读取Keras检查点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在model.fit()中使用了ch_callback = ModelCheckpoint('./foo.bar').而我得到的正是我所要求的,即'./foo.bar'文件.

I used ch_callback = ModelCheckpoint('./foo.bar') with my model.fit(). And I got exactly what I requested, namely a './foo.bar' file.

  • 它实际上有什么格式?
  • 如何使用此检查点,我可以在哪里加载它?
  • 最重要的是,我可以将其转换为原生tensorflow检查点格式吗?

推荐答案

  1. Keras检查点为.hdf5或.h5格式.
  2. 您可以使用tf.keras.models.load_model("model.h5")加载keras检查点.
  3. 如果要将Keras检查点转换为TF检查点,可以加载Keras模型(带有Keras后端),然后导出加载Keras模型时创建的TF图的TF检查点.
  1. Keras checkpoint is in .hdf5 or .h5 format.
  2. You can load the keras checkpoint using tf.keras.models.load_model("model.h5").
  3. If you want to convert Keras checkpoint to TF checkpoint, you can load your Keras model (with the Keras backend), then export a TF checkpoint of the TF graph created when loading the Keras model.

model = keras.models.load_model("model.h5")
sess = keras.backend.get_session()
saver = tf.train.Saver()
save_path = saver.save(sess, "/tmp/model.ckpt")

这篇关于如何在张量流中读取Keras检查点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆