原因
数据集解压方式错误,MNIST文件下载后是.gz格式,需要在linux环境下解压(win7环境用rar解压,报同样错误)
t10k-images-idx3-ubyte.gz
t10k-labels-idx1-ubyte.gz
train-images-idx3-ubyte.gz
train-labels-idx1-ubyte.gz
正确解压后文件下载:点击下载
文件列表:
t10k-images-idx3-ubyte
t10k-labels-idx1-ubyte
train-images-idx3-ubyte
train-labels-idx1-ubyte
linux(Ubuntu)环境gz解压指令
gunzip –c train-labels-idx1-ubyte.gz > train-labels-idx1-ubyte
win7 环境报错
File "C:/DCGAN/main.py", line 63, in main
sample_dir=FLAGS.sample_dir)
File "C:\DCGAN\model.py", line 74, in __init__
self.data_X, self.data_y = self.load_mnist()
File "C:\DCGAN\model.py", line 461, in load_mnist
trX = loaded[16:].reshape((60000,28,28,1)).astype(np.float)
ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1)
linux(Ubuntu)环境报错
File "main.py", line 63, in main
sample_dir=FLAGS.sample_dir)
File "/root/DCGAN-tensorflow-master/model.py", line 74, in __init__
self.data_X, self.data_y = self.load_mnist()
File "/root/DCGAN-tensorflow-master/model.py", line 459, in load_mnist
trX = loaded[16:].reshape((60000,28,28,1)).astype(np.float)
ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1)
以下网页提到了该问题,但是没有给出解决方案
http://www.cnblogs.com/Charles-Wan/p/6266279.html
其他类似报错,主要是传入数据问题,请检查数据文件格式、解压方式、组织格式。