1

So when I save a int16 numpy array and reload it I get the same shape as expected. In this particular case the shape is (335,306,306) yielding a size of 31368060.

Now I am attempting to load such arrays into a tensorflow pipeline as follows;

def loadFiles():
    imgPaths = glob.glob("*.npy") # List containing the one numpy array

    Q = tf.train.string_input_producer(imgPaths,num_epochs=10,shuffle=True)
    reader = tf.WholeFileReader()
    key, value = reader.read(Q)
    image_bytes = tf.decode_raw(value,tf.int16)
    return key, image_bytes

Evaluating the same example in a session I get;

p,img = loadFiles()
 with tf.Session() as sess:
        tf.global_variables_initializer().run()
        tf.local_variables_initializer().run()
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord,sess=sess)
        im = img.eval()
        print(im.shape)

Yielding (31368100,) which is not the same as (31368060,). What is going wrong?

mattdns
  • 894
  • 1
  • 11
  • 26
  • 1
    Just a guess, but are the first few bytes of the Tensor [x93NUMPY](https://docs.scipy.org/doc/numpy-dev/neps/npy-format.html)? I think there's just a bit of header that gets saved in `.npy` files. – Allen Lavoie Feb 08 '17 at 18:22
  • Your absolutley right, there is a header. Hopefully there is a option in TFs WholeFileReader to pass this. – mattdns Feb 10 '17 at 15:52
  • 1
    Can you write out a `.bin` file as in http://stackoverflow.com/a/34637731/6824418 ? – Allen Lavoie Feb 10 '17 at 15:58
  • Ah yes, that would make more sense. – mattdns Feb 10 '17 at 16:01

0 Answers0