dataset_loader: Creates datasets and dataloaders

Description Usage Arguments Value Examples

View source: R/prepare_data.R

Description

Creates two torch datasets, from given train_x, test_x matrices and train_y, test_y vectors and converts them into torch dataloaders with provided batch size. It is used for both classifier and adversarial. During the initialization NAs are ommited.

Usage

1
dataset_loader(train_x, train_y, test_x, test_y, batch_size = 50, dev)

Arguments

train_x

numeric, scaled matrix of predictors used for training

train_y

numeric, scaled vector of target used for training

test_x

integer, matrix of predictors used for testing

test_y

integer, vector of predictors used for testing

batch_size

integer indicating a batch size used in dataloader. Default: 50

dev

device used for calculations (cpu or gpu)

Value

list of two data sets and two dataloaders for train and test respectively

Examples

1
2
3
4
5
6
train_x <- matrix(c(1,2,3,4,5,6),nrow=3)
train_y <- c(1,2,3)
test_x  <- matrix(c(1,2,3,4),nrow=2)
test_y  <- c(1,2)
dev     <- "cpu"
dataset_loader(train_x,train_y,test_x,test_y,batch_size=1,dev)

ModelOriented/FairPAN documentation built on Dec. 17, 2021, 4:19 a.m.