MNIST数据集解压的正确方式:ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1)

xiaoxiao2021-02-28  76

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)

原因

数据集解压方式错误,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-ubytegunzip –c train-images-idx3-ubyte.gz   > train-images-idx3-ubytegunzip –c t10k-images-idx3-ubyte.gz  > t10k-images-idx3-ubyte

gunzip –c t10k-labels-idx1-ubyte.gz   > t10k-labels-idx1-ubyte

转载请注明原文地址: https://www.6miu.com/read-2623281.html

最新回复(0)