View source: R/dataset_methods.R
dataset_scan | R Documentation |
A transformation that scans a function across an input dataset
dataset_scan(dataset, initial_state, scan_func)
dataset |
A tensorflow dataset |
initial_state |
A nested structure of tensors, representing the initial state of the accumulator. |
scan_func |
A function that maps |
This transformation is a stateful relative of dataset_map()
.
In addition to mapping scan_func
across the elements of the input dataset,
scan()
accumulates one or more state tensors, whose initial values are
initial_state
.
## Not run:
initial_state <- as_tensor(0, dtype="int64")
scan_func <- function(state, i) list(state + i, state + i)
dataset <- range_dataset(0, 10) %>%
dataset_scan(initial_state, scan_func)
reticulate::iterate(dataset, as.array) %>%
unlist()
# 0 1 3 6 10 15 21 28 36 45
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.