| ag_dataloader | R Documentation |
Returns an iterator environment. Each call to $next_batch() returns
a named list list(x, y) with ag_tensor objects of shape
[features, batch_size] / [labels, batch_size].
After the last batch, $has_next() returns FALSE; call
$reset() (or start a new epoch via $epoch()) to reshuffle
and restart.
ag_dataloader(x, y = NULL, batch_size = 32L, shuffle = TRUE, col_major = TRUE)
x |
Feature matrix |
y |
Label matrix with the same convention. |
batch_size |
Integer batch size. |
shuffle |
Logical; if |
col_major |
Logical; if |
An ag_dataloader environment
n <- 128L
x <- matrix(runif(4 * n), 4, n) # [4, 128] col-major
y <- matrix(runif(2 * n), 2, n)
dl <- ag_dataloader(x, y, batch_size = 32L)
dl$reset()
while (dl$has_next()) {
batch <- dl$next_batch()
# batch$x: [4, 32], batch$y: [2, 32]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.