Python 官方文档:入门教程 => 点击学习
目录PyTorch 中的 torch.utils.data 解析概述数据集数据加载顺序手动定义 sampler使用内置 sampler数据的 batching使用 batch sam
PyTorch 中的 torch.utils.data
解析
在 PyTorch 中,提供了一个处理数据集的工具包 torch.utils.data
。这里来简单介绍这个包的结构。以下内容翻译和整理自 PyTorch 官方文档。
PyTorch 数据集处理包 torch.utils.data
的核心是 DataLoader
类。该类的构造函数签名为
DataLoader(dataset, batch_size=1, shuffle=False, sampler=None,
batch_sampler=None, num_workers=0, collate_fn=None,
pin_memory=False, drop_last=False, timeout=0,
worker_init_fn=None, *, prefetch_factor=2,
persistent_workers=False)
它构造一个 可迭代对象 loader
,代表经过 “加工” 后的数据集。所谓的 “加工” 过程,是由构造函数参数表指定的,它包括:
shuffle
或 sampler
参数)batch_size
,batch_sampler
,collate_fn
及 drop_last
参数)一旦构造了 DataLoader
对象 loader
,就可以用
for data in loader:
# data 是数据集中的一组数据,且已转换成 Tensor
来加载数据。缺省情况下,PyTorch 会对数据进行 auto-batching,此时 data
对应一个 batch 的数据。
可以将 loader
理解成一个 生成器,其定义按情况可分为:(出现一些概念之后都会解释)
## 启用 auto-batching
# 对 map-style 数据集
for indices in batch_sampler:
yield collate_fn([dataset[i] for i in indices])
# 对 iterable-style 数据集
dataset_iter = iter(dataset)
for indices in batch_sampler:
yield collate_fn([next(dataset_iter) for _ in indices])
## 不启用 auto-batching (设置 batch_size=None 和 batch_sampler=None)
# 对 map-style 数据集
for index in sampler:
yield collate_fn(dataset[index])
# 对 iterable-style 数据集
for data in iter(dataset):
yield collate_fn(data)
DataLoader
构造函数中的必需参数 dataset
代表一个数据集。数据集主要分为两种:
torch.utils.data.Dataset
的子类,重载了 __getitem__
和 __len__
运算符,可以随机访问数据集中的数据torch.utils.data.IterableDataset
的子类,是可迭代对象可以通过指定 sampler
参数来手动设置加载顺序。一个 sampler
是可迭代对象,其迭代的每一个值表示下一个待加载数据的 key/index。它应当实例化泛型类 torch.utils.data.Sampler[int]
的一个子类,并且重载 __iter__
和 __len__
函数,具体地讲:
构造函数 __init__(self, data_source, *args)
必须提供一个重载了 __len__
的数据集 data_source
作为参数__iter__
返回一个整型迭代器,其每迭代一次的返回值为下一个待加载数据的 key/index__len__
返回要加载的数据总数
但是要注意,只有 map-style 数据集才可定义 sampler,因为 iterable-style 不一定支持随机访问。
在模块 torch.utils.data.sampler
中定义了一些内置的 sampler,通常来说已经够用了。在缺省 sampler
参数的情况下,如果指定参数 shuffle=False
将使用 SequentialSampler
,即按顺序加载整个数据集;如果指定 shuffle=True
则使用 RandomSampler
,即随机打乱数据后加载整个数据集。但是注意,不允许同时指定 sampler
参数和 shuffle
参数。
另外一些 sampler 可以参见模块源代码。
在训练神经网络的时候经常需要将数据分成 mini-batch。PyTorch 本身提供了 auto-batching 的功能,也可以通过修改参数 batch_size
,batch_sampler
,drop_last
及 collate_fn
进行自定义 batching。
在定义了 batching 后,PyTorch 会一次性输入多个(数量为 batch_size
)数据。这时候需使用 batch sampler 来取代普通的 sampler。
通过指定 batch_sampler
参数,可以手动实现想要的 batch sampler。一个 batch_sampler
是 torch.utils.data.BatchSampler
的实例。在 PyTorch 源代码中,该类继承了 Sampler[List[int]]
,并且封装了一个 sampler
。
__init__(self, sampler, batch_size: int, drop_last: bool)
,其中
sampler
是一个可迭代对象,代表被封装的 samplerbatch_size
代表每个 batch 的数据量drop_last
表示要不要把最后一个不足 batch_size
的 batch 丢掉__iter__
返回一个迭代器,它每迭代一次,返回一个 List[int]
,表示下一个 batch 的 key/index 列表__len__
返回 batch 总数请注意,
batch_sampler
,那么不能再指定 sampler
,shuffle
,batch_size
和 drop_last
参数batch_sampler
参数,但 batch_size
不为 None
,则 DataLoader
构造函数自动使用自定义的 sampler
或由 shuffle
指定的内置 sampler,以及 batch_size
和 drop_last
参数封装 batch samplerbatch_sampler
参数,又设置 batch_size
为 None
,则禁用 auto-batching,每加载一次输出的是单个数据。参数 collate_fn
指定如何对每一 batch 的数据做预处理。在模块 torch.utils.data._utils
中,定义了两个默认的 collate_fn
:
default_convert
:如果禁用 auto-batching,则用该函数将每个数据预处理为 torch.Tensor
default_collate
:如果启用 auto-batching,则用该函数将每个 batch 预处理为 torch.Tensor
训练模型一般都是先处理 数据的输入问题 和 预处理问题 。Pytorch提供了几个有用的工具:torch.utils.data.Dataset 类和 torch.utils.data.DataLoader 类 。
流程是先把原始数据转变成 torch.utils.data.Dataset 类,随后再把得到的 torch.utils.data.Dataset 类当作一个参数传递给 torch.utils.data.DataLoader 类,得到一个数据加载器,这个数据加载器每次可以返回一个 Batch 的数据供模型训练使用。
在 pytorch 中,提供了一种十分方便的数据读取机制,即使用 torch.utils.data.Dataset
与 Dataloader
组合得到数据迭代器。在每次训练时,利用这个迭代器输出每一个 batch 数据,并能在输出时对数据进行相应的预处理或数据增广操作。
本文我们主要介绍对 torch.utils.data.Dataset 的理解,对 Dataloader 的介绍请参考我的另一篇文章:【PyTorch】torch.utils.data.DataLoader 简单介绍与使用
在本文的最后将给出 torch.utils.data.Dataset
与 Dataloader
结合使用处理数据的实战代码。
torch.utils.data.Dataset 的源码:
class Dataset(object):
"""An abstract class representing a Dataset.
All other datasets should subclass it. All subclasses should override
``__len__``, that provides the size of the dataset, and ``__getitem__``,
supporting integer indexing in range from 0 to len(self) exclusive.
"""
def __getitem__(self, index):
raise NotImplementedError
def __len__(self):
raise NotImplementedError
def __add__(self, other):
return ConcatDataset([self, other])
注释翻译:
表示一个数据集的抽象类。
所有其他数据集都应该对其进行子类化。 所有子类都应该重写提供数据集大小的 __len__
和 __getitem__
,支持从 0 到 len(self) 独占的整数索引。
理解:
就是说,Dataset 是一个 数据集 抽象类,它是其他所有数据集类的父类(所有其他数据集类都应该继承它),继承时需要重写方法 __len__
和 __getitem__
, __len__
是提供数据集大小的方法, __getitem__
是可以通过索引号找到数据的方法。
torch.utils.data.Dataset 是代表自定义数据集的抽象类,我们可以定义自己的数据类抽象这个类,只需要重写__len__和__getitem__这两个方法就可以。
要自定义自己的 Dataset 类,至少要重载两个方法:__len__
, __getitem__
下面将简单实现一个返回 torch.Tensor 类型的数据集:
from torch.utils.data import Dataset
import torch
class TensorDataset(Dataset):
# TensorDataset继承Dataset, 重载了__init__, __getitem__, __len__
# 实现将一组Tensor数据对封装成Tensor数据集
# 能够通过index得到数据集的数据,能够通过len,得到数据集大小
def __init__(self, data_tensor, target_tensor):
self.data_tensor = data_tensor
self.target_tensor = target_tensor
def __getitem__(self, index):
return self.data_tensor[index], self.target_tensor[index]
def __len__(self):
return self.data_tensor.size(0) # size(0) 返回当前张量维数的第一维
# 生成数据
data_tensor = torch.randn(4, 3) # 4 行 3 列,服从正态分布的张量
print(data_tensor)
target_tensor = torch.rand(4) # 4 个元素,服从均匀分布的张量
print(target_tensor)
# 将数据封装成 Dataset (用 TensorDataset 类)
tensor_dataset = TensorDataset(data_tensor, target_tensor)
# 可使用索引调用数据
print('tensor_data[0]: ', tensor_dataset[0])
# 可返回数据len
print('len os tensor_dataset: ', len(tensor_dataset))
输出结果:
tensor([[ 0.8618, 0.4644, -0.5929],
[ 0.9566, -0.9067, 1.5781],
[ 0.3943, -0.7775, 2.0366],
[-1.2570, -0.3859, -0.3542]])
tensor([0.1363, 0.6545, 0.4345, 0.9928])
tensor_data[0]: (tensor([ 0.8618, 0.4644, -0.5929]), tensor(0.1363))
len os tensor_dataset: 4
因为我们可以通过定义自己的数据集类并重写该类上的方法 实现多种多样的(自定义的)数据读取方式。
比如,我们重写 __init__
实现用 pd.read_csv 读取 csv 文件:
from torch.utils.data import Dataset
import pandas as pd # 这个包用来读取CSV数据
# 继承Dataset,定义自己的数据集类 mydataset
class mydataset(Dataset):
def __init__(self, csv_file): # self 参数必须,其他参数及其形式随程序需要而不同,比如(self,*inputs)
self.csv_data = pd.read_csv(csv_file)
def __len__(self):
return len(self.csv_data)
def __getitem__(self, idx):
data = self.csv_data.values[idx]
return data
data = mydataset('spambase.csv')
print(data[3])
print(len(data))
输出结果:
[0.000e+00 0.000e+00 0.000e+00 0.000e+00 6.300e-01 0.000e+00 3.100e-01
6.300e-01 3.100e-01 6.300e-01 3.100e-01 3.100e-01 3.100e-01 0.000e+00
0.000e+00 3.100e-01 0.000e+00 0.000e+00 3.180e+00 0.000e+00 3.100e-01
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
1.370e-01 0.000e+00 1.370e-01 0.000e+00 0.000e+00 3.537e+00 4.000e+01
1.910e+02 1.000e+00]
4601
要点:
在 __init__
方法里面进行 读取数据文件 。
在 __getitem__
方法里支持通过下标访问数据。
在 __len__
方法里返回自定义数据集的大小,方便后期遍历。
数据集 spambase.csv 用的是 UCI 机器学习存储库里的垃圾邮件数据集,它一条数据有57个特征和1个标签。
import torch.utils.data as Data
import pandas as pd # 这个包用来读取CSV数据
import torch
# 继承Dataset,定义自己的数据集类 mydataset
class mydataset(Data.Dataset):
def __init__(self, csv_file): # self 参数必须,其他参数及其形式随程序需要而不同,比如(self,*inputs)
data_csv = pd.DataFrame(pd.read_csv(csv_file)) # 读数据
self.csv_data = data_csv.drop(axis=1, columns='58', inplace=False) # 删除最后一列标签
def __len__(self):
return len(self.csv_data)
def __getitem__(self, idx):
data = self.csv_data.values[idx]
return data
data = mydataset('spambase.csv')
x = torch.tensor(data[:5]) # 前五个数据
y = torch.tensor([1, 1, 1, 1, 1]) # 标签
torch_dataset = Data.TensorDataset(x, y) # 对给定的 tensor 数据,将他们包装成 dataset
loader = Data.DataLoader(
# 从数据库中每次抽出batch size个样本
dataset = torch_dataset, # torch TensorDataset fORMat
batch_size = 2, # mini batch size
shuffle=True, # 要不要打乱数据 (打乱比较好)
num_workers=2, # 多线程来读数据
)
def show_batch():
for step, (batch_x, batch_y) in enumerate(loader):
print("steop:{}, batch_x:{}, batch_y:{}".format(step, batch_x, batch_y))
show_batch()
输出结果:
steop:0, batch_x:tensor([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 6.3000e-01, 0.0000e+00,
3.1000e-01, 6.3000e-01, 3.1000e-01, 6.3000e-01, 3.1000e-01, 3.1000e-01,
3.1000e-01, 0.0000e+00, 0.0000e+00, 3.1000e-01, 0.0000e+00, 0.0000e+00,
3.1800e+00, 0.0000e+00, 3.1000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 1.3500e-01, 0.0000e+00, 1.3500e-01, 0.0000e+00, 0.0000e+00,
3.5370e+00, 4.0000e+01, 1.9100e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 6.3000e-01, 0.0000e+00,
3.1000e-01, 6.3000e-01, 3.1000e-01, 6.3000e-01, 3.1000e-01, 3.1000e-01,
3.1000e-01, 0.0000e+00, 0.0000e+00, 3.1000e-01, 0.0000e+00, 0.0000e+00,
3.1800e+00, 0.0000e+00, 3.1000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 1.3700e-01, 0.0000e+00, 1.3700e-01, 0.0000e+00, 0.0000e+00,
3.5370e+00, 4.0000e+01, 1.9100e+02]], dtype=torch.float64), batch_y:tensor([1, 1])
steop:1, batch_x:tensor([[2.1000e-01, 2.8000e-01, 5.0000e-01, 0.0000e+00, 1.4000e-01, 2.8000e-01,
2.1000e-01, 7.0000e-02, 0.0000e+00, 9.4000e-01, 2.1000e-01, 7.9000e-01,
6.5000e-01, 2.1000e-01, 1.4000e-01, 1.4000e-01, 7.0000e-02, 2.8000e-01,
3.4700e+00, 0.0000e+00, 1.5900e+00, 0.0000e+00, 4.3000e-01, 4.3000e-01,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
7.0000e-02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 1.3200e-01, 0.0000e+00, 3.7200e-01, 1.8000e-01, 4.8000e-02,
5.1140e+00, 1.0100e+02, 1.0280e+03],
[6.0000e-02, 0.0000e+00, 7.1000e-01, 0.0000e+00, 1.2300e+00, 1.9000e-01,
1.9000e-01, 1.2000e-01, 6.4000e-01, 2.5000e-01, 3.8000e-01, 4.5000e-01,
1.2000e-01, 0.0000e+00, 1.7500e+00, 6.0000e-02, 6.0000e-02, 1.0300e+00,
1.3600e+00, 3.2000e-01, 5.1000e-01, 0.0000e+00, 1.1600e+00, 6.0000e-02,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 6.0000e-02, 0.0000e+00, 0.0000e+00,
1.2000e-01, 0.0000e+00, 6.0000e-02, 6.0000e-02, 0.0000e+00, 0.0000e+00,
1.0000e-02, 1.4300e-01, 0.0000e+00, 2.7600e-01, 1.8400e-01, 1.0000e-02,
9.8210e+00, 4.8500e+02, 2.2590e+03]], dtype=torch.float64), batch_y:tensor([1, 1])
steop:2, batch_x:tensor([[ 0.0000, 0.6400, 0.6400, 0.0000, 0.3200, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000, 0.6400, 0.0000, 0.0000,
0.0000, 0.3200, 0.0000, 1.2900, 1.9300, 0.0000, 0.9600,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.7780, 0.0000, 0.0000, 3.7560, 61.0000,
278.0000]], dtype=torch.float64), batch_y:tensor([1])
一共 5 条数据,batch_size 设为 2 ,则数据被分为三组,每组的数据量为:2,2,1。
import torch.utils.data as Data
import pandas as pd # 这个包用来读取CSV数据
import numpy as np
# 继承Dataset,定义自己的数据集类 mydataset
class mydataset(Data.Dataset):
def __init__(self, csv_file): # self 参数必须,其他参数及其形式随程序需要而不同,比如(self,*inputs)
# 读取数据
frame = pd.DataFrame(pd.read_csv('spambase.csv'))
spam = frame[frame['58'] == 1]
ham = frame[frame['58'] == 0]
SpamNew = spam.drop(axis=1, columns='58', inplace=False) # 删除第58列,inplace=False不改变原数据,返回一个新dataframe
HamNew = ham.drop(axis=1, columns='58', inplace=False)
# 数据
self.csv_data = np.vstack([np.array(SpamNew), np.array(HamNew)]) # 将两个N维数组进行连接,形成X
# 标签
self.Label = np.array([1] * len(spam) + [0] * len(ham)) # 形成标签值列表y
def __len__(self):
return len(self.csv_data)
def __getitem__(self, idx):
data = self.csv_data[idx]
label = self.Label[idx]
return data, label
data = mydataset('spambase.csv')
print(len(data))
loader = Data.DataLoader(
# 从数据库中每次抽出batch size个样本
dataset = data, # torch TensorDataset format
batch_size = 460, # mini batch size
shuffle=True, # 要不要打乱数据 (打乱比较好)
num_workers=2, # 多线程来读数据
)
def show_batch():
for step, (batch_x, batch_y) in enumerate(loader):
print("steop:{}, batch_x:{}, batch_y:{}".format(step, batch_x, batch_y))
show_batch()
输出结果:
4601
steop:0, batch_x:tensor([[0.0000e+00, 2.4600e+00, 0.0000e+00, ..., 2.1420e+00, 1.0000e+01,
7.5000e+01],
[0.0000e+00, 0.0000e+00, 1.6000e+00, ..., 2.0650e+00, 1.2000e+01,
9.5000e+01],
[0.0000e+00, 0.0000e+00, 3.6000e-01, ..., 3.7220e+00, 2.0000e+01,
2.6800e+02],
...,
[7.7000e-01, 3.8000e-01, 7.7000e-01, ..., 1.4619e+01, 5.2500e+02,
9.2100e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.0000e+00, 1.0000e+00,
5.0000e+00],
[4.0000e-01, 1.8000e-01, 3.2000e-01, ..., 3.3050e+00, 1.8100e+02,
1.6130e+03]], dtype=torch.float64), batch_y:tensor([0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1,
0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0,
0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0,
1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
1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e-01, 0.0000e+00, 7.4000e-01, ..., 3.9750e+00, 4.7000e+01,
4.8500e+02],
[0.0000e+00, 0.0000e+00, 7.1000e-01, ..., 4.0220e+00, 9.7000e+01,
5.4300e+02],
...,
[0.0000e+00, 1.4000e-01, 1.4000e-01, ..., 5.3310e+00, 8.0000e+01,
1.0290e+03],
[0.0000e+00, 0.0000e+00, 3.6000e-01, ..., 3.1760e+00, 5.1000e+01,
2.7000e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.1660e+00, 2.0000e+00,
7.0000e+00]], dtype=torch.float64), batch_y:tensor([0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0,
0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,
1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0,
0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0,
0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0,
1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0,
0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1,
1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1,
1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1,
0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1,
1, 0, 0, 0])
steop:2, batch_x:tensor([[0.0000e+00, 0.0000e+00, 1.4700e+00, ..., 3.0000e+00, 3.3000e+01,
1.7700e+02],
[2.6000e-01, 4.6000e-01, 9.9000e-01, ..., 1.3235e+01, 2.7200e+02,
1.5750e+03],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 2.0450e+00, 6.0000e+00,
4.5000e+01],
...,
[4.0000e-01, 0.0000e+00, 0.0000e+00, ..., 1.1940e+00, 5.0000e+00,
1.2900e+02],
[2.6000e-01, 0.0000e+00, 0.0000e+00, ..., 1.8370e+00, 1.1000e+01,
1.5800e+02],
[5.0000e-02, 0.0000e+00, 1.0000e-01, ..., 3.7150e+00, 1.0700e+02,
1.3860e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 0, 0,
1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1,
1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0,
1, 1, 0, 0])
steop:3, batch_x:tensor([[2.6000e-01, 0.0000e+00, 5.3000e-01, ..., 2.6460e+00, 7.7000e+01,
1.7200e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 2.4280e+00, 5.0000e+00,
1.7000e+01],
[3.4000e-01, 0.0000e+00, 1.7000e+00, ..., 6.6700e+02, 1.3330e+03,
1.3340e+03],
...,
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.0000e+00, 1.0000e+00,
7.0000e+00],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 2.7010e+00, 2.0000e+01,
1.8100e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 4.0000e+00, 1.1000e+01,
3.6000e+01]], dtype=torch.float64), batch_y:tensor([0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1,
0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 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, 1, 1, 0,
1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0,
1, 0, 0, 1])
steop:4, batch_x:tensor([[ 0.0000, 0.0000, 0.3100, ..., 5.7080, 138.0000, 274.0000],
[ 0.0000, 0.0000, 0.3400, ..., 2.2570, 17.0000, 158.0000],
[ 1.0400, 0.0000, 0.0000, ..., 1.0000, 1.0000, 17.0000],
...,
[ 0.0000, 0.0000, 0.0000, ..., 4.0000, 12.0000, 28.0000],
[ 0.3300, 0.0000, 0.0000, ..., 1.7880, 6.0000, 93.0000],
[ 0.0000, 14.2800, 0.0000, ..., 1.8000, 5.0000, 9.0000]],
dtype=torch.float64), batch_y:tensor([1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1,
0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,
0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0,
1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0,
0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0,
1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1,
0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1,
1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
1, 1, 0, 0])
steop:5, batch_x:tensor([[7.0000e-01, 0.0000e+00, 1.0500e+00, ..., 1.1660e+00, 1.3000e+01,
1.8900e+02],
[0.0000e+00, 3.3600e+00, 1.9200e+00, ..., 6.1370e+00, 1.0700e+02,
1.7800e+02],
[5.4000e-01, 0.0000e+00, 1.0800e+00, ..., 5.4540e+00, 6.8000e+01,
1.8000e+02],
...,
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 3.8330e+00, 9.0000e+00,
2.3000e+01],
[6.0000e-02, 6.5000e-01, 7.1000e-01, ..., 4.7420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0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0,
0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0,
0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 1, 1, 1])
steop:6, batch_x:tensor([[0.0000e+00, 1.4280e+01, 0.0000e+00, ..., 1.8000e+00, 5.0000e+00,
9.0000e+00],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.9280e+00, 1.5000e+01,
5.4000e+01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.0692e+01, 6.5000e+01,
1.3900e+02],
...,
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.5000e+00, 5.0000e+00,
2.4000e+01],
[7.6000e-01, 1.9000e-01, 3.8000e-01, ..., 3.7020e+00, 4.5000e+01,
1.0700e+03],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 2.0000e+00, 1.2000e+01,
8.8000e+01]], dtype=torch.float64), batch_y:tensor([0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1,
0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0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 0, 0, 0, 1, 1,
1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1,
1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0])
steop:7, batch_x:tensor([[0.0000e+00, 2.7000e-01, 0.0000e+00, ..., 5.8020e+00, 4.3000e+01,
4.1200e+02],
[0.0000e+00, 3.5000e-01, 7.0000e-01, ..., 3.6390e+00, 6.1000e+01,
3.1300e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.5920e+00, 7.0000e+00,
1.2900e+02],
...,
[8.0000e-02, 1.6000e-01, 8.0000e-02, ..., 2.7470e+00, 8.6000e+01,
1.9950e+03],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.6130e+00, 1.1000e+01,
7.1000e+01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.9110e+00, 1.5000e+01,
6.5000e+01]], dtype=torch.float64), batch_y:tensor([0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1,
0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 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4.0000e+00,
1.0400e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.0000e+00, 1.0000e+00,
7.0000e+00],
...,
[2.3000e-01, 0.0000e+00, 4.7000e-01, ..., 2.4200e+00, 1.2000e+01,
3.3400e+02],
[0.0000e+00, 0.0000e+00, 1.2900e+00, ..., 1.3500e+00, 4.0000e+00,
2.7000e+01],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.3730e+00, 1.1000e+01,
1.6900e+02]], dtype=torch.float64), batch_y:tensor([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1,
0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,
1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0,
0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0,
0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1,
0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1,
0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0,
1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,
1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0,
1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1,
0, 0, 0, 0])
steop:9, batch_x:tensor([[0.0000e+00, 6.3000e-01, 0.0000e+00, ..., 2.2150e+00, 2.2000e+01,
1.1300e+02],
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 1.0000e+00, 1.0000e+00,
5.0000e+00],
[0.0000e+00, 0.0000e+00, 2.0000e-01, ..., 1.1870e+00, 1.1000e+01,
1.1400e+02],
...,
[0.0000e+00, 0.0000e+00, 0.0000e+00, ..., 2.3070e+00, 1.6000e+01,
3.0000e+01],
[5.1000e-01, 4.3000e-01, 2.9000e-01, ..., 6.5900e+00, 7.3900e+02,
2.3330e+03],
[6.8000e-01, 6.8000e-01, 6.8000e-01, ..., 2.4720e+00, 9.0000e+00,
8.9000e+01]], dtype=torch.float64), batch_y:tensor([0, 0, 0, 0, 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, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0,
1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1])
steop:10, batch_x:tensor([[0.0000e+00, 2.5000e-01, 7.5000e-01, 0.0000e+00, 1.0000e+00, 2.5000e-01,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 2.5000e-01, 2.5000e-01,
1.2500e+00, 0.0000e+00, 0.0000e+00, 2.5000e-01, 0.0000e+00, 1.2500e+00,
2.5100e+00, 0.0000e+00, 1.7500e+00, 0.0000e+00, 2.5000e-01, 0.0000e+00,
0.0000e+00, 0.0000e+00, 2.5000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00,
0.0000e+00, 0.0000e+00, 0.0000e+00, 4.2000e-02, 0.0000e+00, 0.0000e+00,
1.2040e+00, 7.0000e+00, 1.1800e+02]], dtype=torch.float64), batch_y:tensor([0])
一共 4601 条数据,按 batch_size = 460 来分:能划分为 11 组,前 10 组的数据量为 460,最后一组的数据量为 1 。
到此这篇关于PyTorch torch.utils.data.Dataset概述案例详解的文章就介绍到这了,更多相关PyTorch torch.utils.data.Dataset内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: PyTorch中的torch.utils.data解析(推荐)
本文链接: https://lsjlt.com/news/196840.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0