首頁 > 軟體

PyTorch中torch.utils.data.Dataset的介紹與實戰

2022-06-22 14:02:59

一、前言

訓練模型一般都是先處理 資料的輸入問題 和 預處理問題 。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. 幹什麼用的?

  1. pytorch 提供了一個資料讀取的方法,其由兩個類構成:torch.utils.data.Dataset 和 DataLoader。
  2. 如果我們要自定義自己讀取資料的方法,就需要繼承類 torch.utils.data.Dataset ,並將其封裝到DataLoader 中。
  3. 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__

  1. __len__返回的是資料集的大小
  2. __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

要點:

  1. 自己定義的 dataset 類需要繼承 Dataset。
  2. 需要實現必要的魔法方法:

在 __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,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, 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+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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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, 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.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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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, 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, 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 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, 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 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 。

參考連結

  1. torch.Tensor.size()方法的使用舉例
  2. Pytorch筆記05-自定義資料讀取方式orch.utils.data.Dataset與Dataloader
  3. pytorch 可訓練資料集建立(torch.utils.data)
  4. Pytorch的第一步:(1) Dataset類的使用
  5. 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內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com