Skip to contents

Mini-batch index plan with deterministic Fisher-Yates shuffling (hmdld)

Usage

morie_geron_dataloader(
  dataset,
  batch_size,
  shuffle = FALSE,
  drop_last = FALSE,
  seed = 0,
  num_workers = 0
)

Arguments

dataset

Array (batched on dim 1) or an integer length.

batch_size

int (>=1).

shuffle, drop_last

Logical.

seed

LCG seed.

num_workers

Non-negative int, only affects worker_assignment.

Value

List with batches (0-based indices), order, n_batches, dropped.

Examples

morie_geron_dataloader(dataset = data.frame(x = c(1, 2, 3, 4), y = c(2, 4, 5, 9)), batch_size = 5L)
#> $batches
#> $batches[[1]]
#> [1] 0 1
#> 
#> 
#> $order
#> [1] 0 1
#> 
#> $n_batches
#> [1] 1
#> 
#> $last_batch_size
#> [1] 2
#> 
#> $dropped
#> [1] 0
#> 
#> $batch_size
#> [1] 5
#> 
#> $shuffle
#> [1] FALSE
#> 
#> $drop_last
#> [1] FALSE
#> 
#> $worker_assignment
#> [1] 0
#> 
#> $num_workers
#> [1] 0
#> 
#> $batch_data
#> $batch_data[[1]]
#>   x y
#> 1 1 2
#> 2 2 4
#> 3 3 5
#> 4 4 9
#> 
#> 
#> $estimate
#> [1] 1
#> 
#> $n
#> [1] 2
#> 
#> $method
#> [1] "mini-batch index plan with deterministic Fisher-Yates shuffling"
#>