我想将MNIST图像作为PNG文件下载到我的计算机上。
我找到了这个页面:http://yann.lecun.com/exdb/mnist/
我按下后:train-images-idx3-ubyte.gz:training set images(9912422 bytes)
它下载了一个.gz文件,我不知道该怎么办。如果您有任何想法或建议,请告诉我。谢谢!
您需要解压缩这些特定文件才能使用它们。更好的方法是:
通过下载:
curl -O http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
下载到特定路径:
curl -O target/path/filename URL
解压缩下载的gzip档案:
gunzip t*-ubyte.gz
有关数据的进一步处理,请参阅documentation
import gzip
f = gzip.open('train-images-idx3-ubyte.gz','r')
image_size = 28
num_images = 5
import numpy as np
import matplotlib.pyplot as plt
f.read(16)
buf = f.read(image_size * image_size * num_images)
data = np.frombuffer(buf, dtype=np.uint8).astype(np.float32)
data = data.reshape(num_images, image_size, image_size, 1)
image = np.asarray(data[2]).squeeze()
plt.imshow(image)
用于提取图像see here
更新
尝试使用this link只需下载并扩展.gz
文件