TensorFlow:tf.saved_model和tf.train.Saver中保存的变量不兼容吗?

时间:2017-10-28 16:53:09

标签: tensorflow

我使用tf.saved_model保存了TensorFlow模型,现在我尝试使用tf.train.Saver仅加载来自该模型的变量,但是根据路径我得到以下两个错误之一给它:

DataLossError: Unable to open table file saved_model/variables:
Failed precondition: saved_model/variables: perhaps your file is in a
different file format and you need to use a different restore operator?

InvalidArgumentError: Unsuccessful TensorSliceReader constructor:
Failed to get matching files on saved_model/variables/variables:
Not found: saved_model/variables
 [[Node: save/RestoreV2_34 = RestoreV2[dtypes=[DT_FLOAT],
_device="/job:localhost/replica:0/task:0/cpu:0"]
(_arg_save/Const_1_0_0,
save/RestoreV2_34/tensor_names, save/RestoreV2_34/shape_and_slices)]]

tf.saved_model,在保存模型时,会创建一个saved_model.pb协议缓冲区和一个名为variables的文件夹,其中包含两个文件:

  1. variables.data-00000-of-00001
  2. variables.index
  3. tf.train.Saver.save()创建以下文件:

    1. some_name.data-00000-of-00001
    2. some_name.index
    3. some_name.meta
    4. checkpoint
    5. 我一直认为以.data-00000-of-00001.index结尾的两个输出文件在两个储户之间是兼容的。

      情况不是这样吗?

0 个答案:

没有答案