本文主要是介绍MNIST数据集解压的正确方式:ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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)
- 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-ubyte
gunzip –c train-images-idx3-ubyte.gz > train-images-idx3-ubyte
gunzip –c t10k-images-idx3-ubyte.gz > t10k-images-idx3-ubyte
gunzip –c t10k-labels-idx1-ubyte.gz > t10k-labels-idx1-ubyte
这篇关于MNIST数据集解压的正确方式:ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!