PyTorch中torch.utils.data.Dataset的介绍与实战

PyTorch中torch.utils.data.Dataset的介绍与实战

目录

一、前言

二、torch.utils.data.Dataset 是什么

1. 干什么用的?

2. 长什么样子?

三、通过继承 torch.utils.data.Dataset 定义自己的数据集类

四、为什么要定义自己的数据集类?

五、实战:torch.utils.data.Dataset + Dataloader 实现数据集读取和迭代

实例 1

实例 2:进阶

参考链接

总结

一、前言

训练模型一般都是先处理 数据的输入问题 和 预处理问题 。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 是什么 1. 干什么用的?

pytorch 提供了一个数据读取的方法,其由两个类构成:torch.utils.data.Dataset 和 DataLoader。

如果我们要自定义自己读取数据的方法,就需要继承类 torch.utils.data.Dataset ,并将其封装到DataLoader 中。

torch.utils.data.Dataset 是一个 类 Dataset 。通过重写定义在该类上的方法,我们可以实现多种数据读取及数据预处理方式。

2. 长什么样子?

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 定义自己的数据集类

torch.utils.data.Dataset 是代表自定义数据集的抽象类,我们可以定义自己的数据类抽象这个类,只需要重写__len__和__getitem__这两个方法就可以。

要自定义自己的 Dataset 类,至少要重载两个方法:__len__, __getitem__

__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

要点:

自己定义的 dataset 类需要继承 Dataset。

需要实现必要的魔法方法:

在 __init__ 方法里面进行 读取数据文件 。

在 __getitem__ 方法里支持通过下标访问数据。

在 __len__ 方法里返回自定义数据集的大小,方便后期遍历。

五、实战:torch.utils.data.Dataset + Dataloader 实现数据集读取和迭代 实例 1

数据集 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。

实例 2:进阶 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, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0,
        0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,
        0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0,
        1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
        0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
        1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0,
        0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
        0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1,
        0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0,
        1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0,
        0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1,
        1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1,
        0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
        0, 1, 0, 1])
steop:1, batch_x:tensor([[0.0000e+00, 0.0000e+00, 0.0000e+00,  ..., 1.0000e+00, 1.0000e+00,
         2.0000e+00],
        [4.9000e-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, 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 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+03]], dtype=torch.float64), batch_y:tensor([1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
        0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0,
        1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
        0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0,
        0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0,
        0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0,
        0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0,
        0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1,
        0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0,
        1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 , 1, 0, 1, 0,
        0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0,
        0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0,
        1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 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, 0, 1, 0, 1, 1, 0, 1, 0, 0,
        0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
        0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0,
        1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
        1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0,
        0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0,
        0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1,
        0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0,
        0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1,
        0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1,
        1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0,
        1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 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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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.7420e+00, 1.1700e+02,
         1.3420e+03],
        [0.0000e+00, 0.0000e+00, 0.0000e+00,  ..., 2.6110e+00, 1.2000e+01,
         4.7000e+01]], dtype=torch.float64), batch_y:tensor([1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1,
        1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
        0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
        0, 0, 1, 0, 0, 0, 0, 0 , 1, 0, 0, 1, 0, 0, 1, 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 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, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
        1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,
        1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0,
        0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1,
        0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0,
        0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0,
        0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1,
        0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
        1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0,
        0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
        1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1,
        0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1,
        0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
        0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 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, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0,
        1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,
        1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0,
        0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1,
        0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
        0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
        0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0,
        1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1,
        0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1,
        0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1,
        1, 0, 0, 0])
steop:8, batch_x:tensor([[1.7000e-01, 0.0000e+00, 1.7000e-01,  ..., 1.7960e+00, 1.2000e+01,
         4.5800e+02],
        [3.7000e-01, 0.0000e+00, 6.3000e-01,  ..., 1.1810e+00, 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, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
        0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0,
        0, 1,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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 。

参考链接

torch.Tensor.size()方法的使用举例

Pytorch笔记05-自定义数据读取方式orch.utils.data.Dataset与Dataloader

pytorch 可训练数据集创建(torch.utils.data)

Pytorch的第一步:(1) Dataset类的使用

pytorch中的torch.utils.data.Dataset和torch.utils.data.DataLoader

总结

————————————————
版权声明:本文为CSDN博主「想变厉害的大白菜」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44211968/article/details/123744513

到此这篇关于PyTorch中torch.utils.data.Dataset的介绍与实战的文章就介绍到这了,更多相关PyTorch torch.utils.data.Dataset内容请搜索易知道(ezd.cc)以前的文章或继续浏览下面的相关文章希望大家以后多多支持易知道(ezd.cc)!

推荐阅读