dataset_enumerate {tfdatasets} | R Documentation |
Enumerates the elements of this dataset
Description
Enumerates the elements of this dataset
Usage
dataset_enumerate(dataset, start = 0L)
Arguments
dataset |
A tensorflow dataset |
start |
An integer (coerced to a |
Details
It is similar to python's enumerate
, this transforms a sequence of
elements into a sequence of list(index, element)
, where index is an integer
that indicates the position of the element in the sequence.
Examples
## Not run:
dataset <- tensor_slices_dataset(100:103) %>%
dataset_enumerate()
iterator <- reticulate::as_iterator(dataset)
reticulate::iter_next(iterator) # list(0, 100)
reticulate::iter_next(iterator) # list(1, 101)
reticulate::iter_next(iterator) # list(2, 102)
reticulate::iter_next(iterator) # list(3, 103)
reticulate::iter_next(iterator) # NULL (iterator exhausted)
reticulate::iter_next(iterator) # NULL (iterator exhausted)
## End(Not run)
[Package tfdatasets version 2.17.0 Index]