As a result of upgrading the sensor flow version, the checkpoint file format has been changed.

Asked 2 years ago, Updated 2 years ago, 54 views

The output format of the tensorflow learning model has changed from the previous one.
Only model.ckpt was
model.ckpt-1111.data-00000-of-000001,
model.ckpt-1111.index,
model.ckpt-1111.meta
I am having a hard time dealing with it because it has been changed to 3 files.

I would like to know which ckpt file to refer to and an example code.
~~~The following is a part of the code I am using~~~

images_placeholder=tf.placeholder("float", shape=(None,IMG_PIXELS))
keep_prob=tf.placeholder("float")
logs = reference(images_placeholder, keep_prob)
sess=tf.InteractiveSession()
saver=tf.train.Saver()
sess.run(tf.global_variables_initializer())
saver.restore(sess, "model.ckpt")

python tensorflow

2022-09-30 19:10

1 Answers

The checkpoint file format has been changed since tensorflow r12.

If you want to save in the past format,

import tensorflow as tf
from tensorflow.core.protobuf import saver_pb2
...
saver=tf.train.Saver (write_version=saver_pb2.SaverDef.V1)
saver.save(sess, './model.ckpt', global_step=step)

(cf:https://stackoverflow.com/questions/41048819/how-to-restore-a-model-by-filename-in-tensorflow-r12)

For restore,

with tf.Session() asess:
    saver=tf.train.import_meta_graph('/tmp/model.ckpt.meta')
    saver.restore(sess, "/tmp/model.ckpt")

cf:https://stackoverflow.com/questions/41265035/tensorflow-why-there-are-3-files-after-saving-the-model


2022-09-30 19:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.