资源简介
Fashion-MNIST.zip(包括raw和processed文件夹)
代码片段和文件信息
from __future__ import print_function
import torch.utils.data as data
from PIL import Image
import os
import os.path
import errno
import numpy as np
import torch
import codecs
import os
import gzip
root = r‘/home/qinhaidong/桌面/书/动手学习深度学习/Dive-into-DL-PyTorch-master/data/Fashion-MNIST‘
raw_folder=‘raw‘
filenames=[‘train-images-idx3-ubyte.gz‘‘train-labels-idx1-ubyte.gz‘‘t10k-images-idx3-ubyte.gz‘‘t10k-labels-idx1-ubyte.gz‘]
for filename in filenames:
file_path=os.path.join(root raw_folder filename)
with open(file_path.replace(‘.gz‘ ‘‘) ‘wb‘) as out_f \
gzip.GzipFile(file_path) as zip_f:
out_f.write(zip_f.read())
os.unlink(file_path)
def get_int(b):
return int(codecs.encode(b ‘hex‘) 16)
def read_label_file(path):
with open(path ‘rb‘) as f:
data = f.read()
assert get_int(data[:4]) == 2049
length = get_int(data[4:8])
parsed = np.frombuffer(data dtype=np.uint8 offset=8)
return torch.from_numpy(parsed).view(length).long()
def read_image_file(path):
with open(path ‘rb‘) as f:
data = f.read()
assert get_int(data[:4]) == 2051
length = get_int(data[4:8])
num_rows = get_int(data[8:12])
num_cols = get_int(data[12:16])
images = []
parsed = np.frombuffer(data dtype=np.uint8 offset=16)
return torch.from_numpy(parsed).view(length num_rows num_cols)
splits = (‘byclass‘ ‘bymerge‘ ‘balanced‘ ‘letters‘ ‘digits‘ ‘mnist‘)
def _training_file(self split):
return ‘training_{}.pt‘.format(split)
def _test_file(self split):
return ‘test_{}.pt‘.format(split)
raw_folder = os.path.join(root raw_folder)
gzip_folder = os.path.join(raw_folder ‘gzip‘)
raw_folder=‘raw‘
processed_folder=‘processed‘
training_file = ‘training.pt‘
test_file = ‘test.pt‘
training_set = (
read_image_file(os.path.join(root raw_folder ‘train-images-idx3-ubyte‘))
read_label_file(os.path.join(root raw_folder ‘train-labels-idx1-ubyte‘))
)
test_set = (
read_image_file(os.path.join(root raw_folder ‘t10k-images-idx3-ubyte‘))
read_label_file(os.path.join(root raw_folder ‘t10k-labels-idx1-ubyte‘))
)
with open(os.path.join(root processed_folder training_file) ‘wb‘) as f:
torch.save(training_set f)
with open(os.path.join(root processed_folder test_file) ‘wb‘) as f:
torch.save(test_set f)
print(‘Done!‘)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-10-10 15:04 Fashion-MNIST\
目录 0 2019-10-10 15:13 Fashion-MNIST\processed\
文件 7920442 2019-10-10 15:13 Fashion-MNIST\processed\test.pt
文件 47520442 2019-10-10 15:13 Fashion-MNIST\processed\training.pt
目录 0 2019-10-10 15:13 Fashion-MNIST\raw\
文件 2431 2019-10-10 15:13 Fashion-MNIST\raw\format.py
文件 7840016 2019-10-10 15:13 Fashion-MNIST\raw\t10k-images-idx3-ubyte
文件 10008 2019-10-10 15:13 Fashion-MNIST\raw\t10k-labels-idx1-ubyte
文件 47040016 2019-10-10 15:13 Fashion-MNIST\raw\train-images-idx3-ubyte
文件 60008 2019-10-10 15:13 Fashion-MNIST\raw\train-labels-idx1-ubyte
相关资源
- 地理社交数据集
- PCD格式点云数据集
- 手写字符数据集已经普通字符、数字
- 多媒体技术教程
- 10万条社会类新闻未处理数据集
- 吴恩达老师deeplearning.ai-第三课和第四
- Machine.Learning.by.Tutorials.pdf
- 车牌识别数据集-自己辛苦收集的-已经
- 单通道噪声数据集
- 中国地面气候资料日值数据集(V3.0)
- vgg16_weights_tf_dim_ordering_tf_kernels_notop
- foursquare数据集1-4
- Deep Learning using Linear Support Vector Mach
- 交通标志数据集
- deepstream_sdk_v4.0.1_jetson.tbz2
- 高光谱遥感图像数据集
- 中国地面国际交换站气候资料日值数
- 复旦文本分类语料数据集 包含训练集
- NOISE-92数据集
- 新闻标题数据集.zip
- DeepNude Windows v2.0.0版本仅支持Win10
- deepin.com.baidu.pan_5.7.3deepin0_i386.deb
- ICDAR2015数据集
- cifar-10-batches-py
- 17flowers图片数据集
- 基于WiFi的动作是数据集
- 猫狗大战数据集
- 基于深度学习的面部表情和人物性别
- pix2pix/cityscapes数据集
- hands on machine learning with scikit learn an
评论
共有 条评论