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.

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

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)
#> $train_ds #> <new_dataset> #> Inherits from: <dataset> #> Public: #> .getitem: function (i) #> .length: function () #> clone: function (deep = FALSE) #> initialize: function (df, y2) #> x_cont: torch_tensor, R7 #> y: torch_tensor, R7 #> #> $test_ds #> <new_dataset> #> Inherits from: <dataset> #> Public: #> .getitem: function (i) #> .length: function () #> clone: function (deep = FALSE) #> initialize: function (df, y2) #> x_cont: torch_tensor, R7 #> y: torch_tensor, R7 #> #> $train_dl #> <dataloader> #> Public: #> .auto_collation: active binding #> .dataset_kind: map #> .has_getbatch: FALSE #> .index_sampler: active binding #> .iter: function () #> .length: function () #> batch_sampler: utils_sampler_batch, utils_sampler, R6 #> batch_size: 1 #> clone: function (deep = FALSE) #> collate_fn: function (batch) #> dataset: new_dataset, dataset, R6 #> drop_last: FALSE #> generator: NULL #> initialize: function (dataset, batch_size = 1, shuffle = FALSE, sampler = NULL, #> multiprocessing_context: NULL #> num_workers: 0 #> pin_memory: FALSE #> sampler: utils_sampler_sequential, utils_sampler, R6 #> timeout: -1 #> worker_globals: NULL #> worker_init_fn: NULL #> worker_packages: NULL #> #> $test_dl #> <dataloader> #> Public: #> .auto_collation: active binding #> .dataset_kind: map #> .has_getbatch: FALSE #> .index_sampler: active binding #> .iter: function () #> .length: function () #> batch_sampler: utils_sampler_batch, utils_sampler, R6 #> batch_size: 1 #> clone: function (deep = FALSE) #> collate_fn: function (batch) #> dataset: new_dataset, dataset, R6 #> drop_last: FALSE #> generator: NULL #> initialize: function (dataset, batch_size = 1, shuffle = FALSE, sampler = NULL, #> multiprocessing_context: NULL #> num_workers: 0 #> pin_memory: FALSE #> sampler: utils_sampler_sequential, utils_sampler, R6 #> timeout: -1 #> worker_globals: NULL #> worker_init_fn: NULL #> worker_packages: NULL #>