View source: R/sample_from_datasets.R
choose_from_datasets | R Documentation |
Creates a dataset that deterministically chooses elements from datasets.
choose_from_datasets(datasets, choice_dataset, stop_on_empty_dataset = TRUE)
datasets |
A non-empty list of tf.data.Dataset objects with compatible structure. |
choice_dataset |
A |
stop_on_empty_dataset |
If |
Returns a dataset that interleaves elements from datasets according to the values of choice_dataset.
## Not run:
datasets <- list(tensors_dataset("foo") %>% dataset_repeat(),
tensors_dataset("bar") %>% dataset_repeat(),
tensors_dataset("baz") %>% dataset_repeat())
# Define a dataset containing `[0, 1, 2, 0, 1, 2, 0, 1, 2]`.
choice_dataset <- range_dataset(0, 3) %>% dataset_repeat(3)
result <- choose_from_datasets(datasets, choice_dataset)
result %>% as_array_iterator() %>% iterate(function(s) s$decode()) %>% print()
# [1] "foo" "bar" "baz" "foo" "bar" "baz" "foo" "bar" "baz"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.