我在练习tfRecord的方法来加快我的训练速度。我读取.tfrecord
的代码如下
reader = tf.TFRecordReader()
filenameQueue = tf.train.string_input_producer(['train.tfrecords'])
_, serializedExample = reader.read(filenameQueue)
features = tf.io.parse_single_example(
serializedExample,
features = {
'image_raw': tf.io.FixedLenFeature([], tf.string),
'boxes': tf.io.FixedLenFeature([],tf.string),
})
image = tf.decode_raw(features['image_raw'],tf.uint8)
boxes = tf.decode_raw(features['boxes'],tf.float32)
sess = tf.compat.v1.Session()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess = sess, coord=coord)
for i in range(3):
_, Box = sess.run([image,boxes])
print(Box)
这很好,只是我保留了get信息,我需要使用tf.data.Dataset
来替换{
然后,我开始犯错误
TypeError: Failed to convert object of type <class 'tensorflow.python.data.ops.readers.TFRecordDatasetV1'> to Tensor. Contents: <TFRecordDatasetV1 shapes: (), types: tf.string>. Consider casting elements to a supported type.
我在网上找了好几条,但还没找到。可能我错过了一些简单的。。。在
目前没有回答
相关问题 更多 >
编程相关推荐