使用tensorflow 1.2.0,我正在尝试恢复已保存的模型,但收到错误:
DataLossError (see above for traceback): Unable to open table file checkpoints/saved_2/saved_2_model_1.meta: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
[[Node: save/RestoreV2_185 = RestoreV2[dtypes=[DT_INT32], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_185/tensor_names, save/RestoreV2_185/shape_and_slices)]]
我使用相同的tensorflow版本进行保存和恢复。
保存:
saver = tf.train.Saver()
ckpt_dir = os.path.join(params['CHK_PATH'], folder)
if not os.path.exists(ckpt_dir):
os.makedirs(ckpt_dir)
ckpt_file = os.path.join(ckpt_dir, '{}'.format(name))
path = saver.save(sess, ckpt_file)
恢复:
saver.restore(sess, ckpt_file)
我试过了:model_saver = tf.train.Saver(write_version = saver_pb2.SaverDef.V1)
但同样的问题仍然存在。
答案 0 :(得分:0)
saver.restore(sess,tf.train.latest_checkpoint(ckpt_dir))
作品