View source: R/dataset_methods.R
dataset_enumerate | R Documentation |
Enumerates the elements of this dataset
dataset_enumerate(dataset, start = 0L)
dataset |
A tensorflow dataset |
start |
An integer (coerced to a |
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.