Tensorflow 来自tf.train.import\u元图的UnicodeDecodeError

Tensorflow 来自tf.train.import\u元图的UnicodeDecodeError,tensorflow,deserialization,Tensorflow,Deserialization,我用以下代码序列化了Tensorflow模型 save_path = self.saver.save(self.session, os.path.join(self.logdir, "model.ckpt"), global_step) logging.info("Model saved in file: %s" % save_path) 。。。我现在正尝试使用以下代码将其从零开始恢复到一个单独的文件中: saver = tf.train.import_meta_graph(PROJ_DIR

我用以下代码序列化了Tensorflow模型

save_path = self.saver.save(self.session, os.path.join(self.logdir, "model.ckpt"), global_step)
logging.info("Model saved in file: %s" % save_path)
。。。我现在正尝试使用以下代码将其从零开始恢复到一个单独的文件中:

saver = tf.train.import_meta_graph(PROJ_DIR + '/logs/default/model.ckpt-54.meta')
session = tf.Session()
saver.restore(session, PROJ_DIR + '/logs/default/model.ckpt-54')
print('Model restored')
调用tf.train.import_meta_图时,会引发以下异常:

[libprotobuf ERROR google/protobuf/io/coded_stream.cc:207] A protocol message was rejected because it was too big (more than 67108864 bytes).  To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
Traceback (most recent call last):
  File "/home/reid/projects/research/ccg/taggerflow_modified/test/tf_restore.py", line 4, in <module>
    saver = tf.train.import_meta_graph(PROJ_DIR + '/logs/default/model.ckpt-54.meta')
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1711, in import_meta_graph
    read_meta_graph_file(meta_graph_or_file), clear_devices)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1563, in read_meta_graph_file
    text_format.Merge(file_content.decode("utf-8"), meta_graph_def)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa7 in position 1: invalid start byte
以下是/logs/default/model.ckpt-54.meta的前几行,供参考:


我认为Tensorflow在序列化和反序列化时使用了不同的编码。如何指定Tensorflow在序列化/反序列化时使用的编码?还是解决方案有所不同?

我也面临同样的问题。您是否确保除了

.meta, .data-00000-of-00001 and the .index files
名为“checkpoint”的文件也在加载模型的目录中


在我确定这一点后,我的问题得到了解决。希望这有帮助

你能提交github问题吗?这看起来像个bug。我刚刚提交了一个GitHub问题,问题是:
.meta, .data-00000-of-00001 and the .index files