View source: R/dataset_methods.R
dataset_rebatch | R Documentation |
dataset_rebatch(N)
is functionally equivalent to dataset_unbatch()
followed by dataset_batch(N)
, but it performs only one copy operation,
making it more efficient.
dataset_rebatch(dataset, batch_size, drop_remainder = FALSE, name = NULL)
dataset |
A dataset. |
batch_size |
An integer or integer vector specifying batch sizes. If a vector, batch sizes cycle through these values in round-robin order. |
drop_remainder |
(Optional.) Logical. If |
name |
(Optional.) Name for the operation. |
If batch_size
is a vector, it cycles through the provided values in a
round-robin manner to determine the size of each batch.
A dataset.
Other dataset methods:
dataset_batch()
,
dataset_cache()
,
dataset_collect()
,
dataset_concatenate()
,
dataset_decode_delim()
,
dataset_filter()
,
dataset_interleave()
,
dataset_map()
,
dataset_map_and_batch()
,
dataset_padded_batch()
,
dataset_prefetch()
,
dataset_prefetch_to_device()
,
dataset_reduce()
,
dataset_repeat()
,
dataset_shuffle()
,
dataset_shuffle_and_repeat()
,
dataset_skip()
,
dataset_take()
,
dataset_take_while()
,
dataset_window()
## Not run:
ds <- dataset_range(6) %>% dataset_batch(2) %>% dataset_rebatch(3)
ds %>% as_array_iterator() %>% iterate(print)
# [0, 1, 2], [3, 4, 5]
ds <- dataset_range(7) %>% dataset_batch(4) %>% dataset_rebatch(3)
ds %>% as_array_iterator() %>% iterate(print)
# [0, 1, 2], [3, 4, 5], [6]
ds <- dataset_range(7) %>% dataset_batch(2) %>% dataset_rebatch(3, drop_remainder = TRUE)
ds %>% as_array_iterator() %>% iterate(print)
# [0, 1, 2], [3, 4, 5]
ds <- dataset_range(8) %>% dataset_batch(4) %>% dataset_rebatch(c(2, 1, 1))
ds %>% as_array_iterator() %>% iterate(print)
# [0, 1], [2], [3], [4, 5], [6], [7]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.