How can I convert TFRecords into numpy arrays?

前端 未结 1 874
孤街浪徒
孤街浪徒 2020-12-08 16:59

The main idea is to convert TFRecords into numpy arrays. Assume that the TFRecord stores images. Specifically:

  1. Read a TFRecord File and convert each image into
相关标签:
1条回答
  • 2020-12-08 17:23

    Oops, it was a silly mistake on my part. I used a string_input_producer but forgot to run the queue_runners.

    with tf.Session() as sess:
      filename_queue = tf.train.string_input_producer(["../data/svhn/svhn_train.tfrecords"])
      image, label, height, width, depth = read_and_decode(filename_queue)
      image = tf.reshape(image, tf.pack([height, width, 3]))
      image.set_shape([32,32,3])
      init_op = tf.initialize_all_variables()
      sess.run(init_op)
      coord = tf.train.Coordinator()
      threads = tf.train.start_queue_runners(coord=coord)
      for i in range(1000):
        example, l = sess.run([image, label])
        print (example,l)
      coord.request_stop()
      coord.join(threads)
    
    0 讨论(0)
提交回复
热议问题