扩展mnist-python包
emnist的Python项目详细描述
emnist
扩展mnist-python包
EMNIST数据集
emnist数据集是原始mnist数据集的扩展,也包括字母。有关详细信息,请参见 EMNIST web page和 paper与其版本相关:
Cohen,G.,Afshar,S.,Tapson,J.,和Van Schaik,A.(2017年)。 emnist:mnist对手写信件的扩展。 检索自http://arxiv.org/abs/1702.05373
emnist python包
这个包是emnist数据集的方便包装。该包提供了 自动下载并缓存数据集,并将其加载为numpy数组,从而最小化样板文件 使用数据集所必需的。(注意:python包的作者在任何方面都不是附属的 与数据集和相关论文的作者一起。)
安装
要安装emnist python包及其依赖项,请运行以下命令:
pip安装emnist
数据集本身会在需要时自动下载和缓存。抢先下载数据 并避免稍后在程序执行过程中出现延迟,请在 安装:
python-c“导入emnist;emnist.sure_cached_data()”
或者,如果您已经从emnist网页下载了原始idx格式的数据集,
复制或移动到~/.cache/emnist/
,其中~
是您的主文件夹,并将其从gzip.zip
重命名为
emnist.zip
。包将使用现有文件,而不是再次下载它。
用法
emnist python包的使用非常简单。
要获取可用子集的列表:
>>>fromemnistimportlist_datasets>>>list_datasets()['balanced','byclass','bymerge','digits','letters','mnist']
(有关每个 这些子集。)
加载“数字”子集的训练样本:
>>>fromemnistimportextract_training_samples>>>images,labels=extract_training_samples('digits')>>>images.shape(240000,28,28)>>>labels.shape(240000,)
加载“数字”子集的测试样本:
>>>fromemnistimportextract_test_samples>>>images,labels=extract_test_samples('digits')>>>images.shape(40000,28,28)>>>labels.shape(40000,)
数据直接从下载的压缩文件中提取,以尽量减少磁盘使用量,并返回 作为标准的numpy数组。