kvfrans/variational-autoencoder

TypeError: only integer scalar arrays can be converted to a scalar index

ProgramItUp opened this issue · 1 comments

I'm having trouble running your code and am getting the following error.
Any thoughts of what might be wrong?
Thanks.

$python main.py
....
Extracting MNIST_data/train-images-idx3-ubyte.gz
Traceback (most recent call last):
  File "main.py", line 79, in <module>
    model = LatentAttention()
  File "main.py", line 12, in __init__
    self.mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
  File "/home/medgar/models/autoencoders/variational-autoencoder-kvfrans/input_data.py", line 148, in read_data_sets
    train_images = extract_images(local_file)
  File "/home/medgar/models/autoencoders/variational-autoencoder-kvfrans/input_data.py", line 38, in extract_images
    buf = bytestream.read(rows * cols * num_images)
  File "/usr/lib/python2.7/gzip.py", line 275, in read
    chunk = self.extrabuf[offset: offset + size]
TypeError: only integer scalar arrays can be converted to a scalar index

A simple solution is to change the _read32 function in input_data.py to return the following value:

return numpy.asscalar(numpy.frombuffer(bytestream.read(4), dtype=dt))

It seems that bytestream.read does not know what to do with numpy.array even if it has a single value, so you need to transform it to scalar.