Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在不启动会话的情况下检查TFRecordReader条目_Python_Tensorflow - Fatal编程技术网

Python 在不启动会话的情况下检查TFRecordReader条目

Python 在不启动会话的情况下检查TFRecordReader条目,python,tensorflow,Python,Tensorflow,假设我用MNIST示例()编写了一个TFRecords文件 这是这样做的: writer = tf.python_io.TFRecordWriter(filename) for index in range(num_examples): image_raw = images[index].tostring() example = tf.train.Example(features=tf.train.Features(feature={ 'height': _i

假设我用MNIST示例()编写了一个TFRecords文件 这是这样做的:

writer = tf.python_io.TFRecordWriter(filename)
  for index in range(num_examples):
    image_raw = images[index].tostring()
    example = tf.train.Example(features=tf.train.Features(feature={
        'height': _int64_feature(rows),
        'width': _int64_feature(cols),
        'depth': _int64_feature(depth),
        'label': _int64_feature(int(labels[index])),
        'image_raw': _bytes_feature(image_raw)}))
    writer.write(example.SerializeToString())
  writer.close()
然后在其他脚本中加载它。但我找到的唯一方法是将其作为张量运行并提取数据,其中
r
是迭代器
record\u iter=tf.python\u io.tf\u record\u迭代器(db\u path)

例如,可以使用
single_ex['height']
检索数据。 然而,在我看来,必须有一个更简单的方法。我似乎找不到相应的.proto来检索数据。数据肯定在那里。这里是
r
的转储:

?
?
    image_raw?
?
?&00>a?????????????(??Y??aC\?z??;??\????\e?\i???
                                                ??)L???^
?y????~??a???4??G??<????.M???n???t????VBљ?<???اZ???\?????,I?ņ

depth


label


width


height
?
?
原图?
?
&00>a???????(Y??aC \?z;??\e?\i???
我^

可以使用
tf.train.Example.ParseFromString()
将字符串转换为protobuf对象:

r = ...  # String object from `tf.python_io.tf_record_iterator()`.
example_proto = tf.train.Example()
example_proto.ParseFromString(r)

可以在中找到此协议缓冲区的架构。

谢谢,不知道为什么找不到它。
r = ...  # String object from `tf.python_io.tf_record_iterator()`.
example_proto = tf.train.Example()
example_proto.ParseFromString(r)