Functions used to create pytorch `DataSet`s and `DataLoader`s.

class Data[source]

Data(*args) :: Dataset

Load raw x,y data

'int' in 'uint8'
True

class TestData[source]

TestData(x) :: Dataset

Load raw x,y data

class TrainData[source]

TrainData(x, y) :: TestData

Load raw x,y data

import numpy as np

x = np.random.randn(100, 3)
y = np.random.randn(100, 1)
train_ds = TrainData(x, y)

x_elem, y_elem = train_ds[99]
print(x_elem, x_elem.dtype)
print(y_elem, y_elem.dtype)
tensor([ 0.5909, -1.1880,  0.0718]) torch.float32
tensor([-1.3023]) torch.float32
y = np.random.randint(0, 3, (100, 1))
train_ds = TrainData(x, y)

x_elem, y_elem = train_ds[99]
print(x_elem, x_elem.dtype)
print(y_elem, y_elem.dtype)
tensor([ 0.5909, -1.1880,  0.0718]) torch.float32
tensor([2]) torch.int64

create_db[source]

create_db(x, y, train_size=0.8, bs=96, random_state=42)

Take dataframe and convert to Fastai databunch

x = np.random.randn(100, 3)
y = np.random.randn(100, 1)
db = create_db(x,y, bs=10)
[x.shape for x in db.one_batch()]
[torch.Size([10, 3]), torch.Size([10, 1])]