Learn R Programming

tfdatasets (version 2.17.0)

sample_from_datasets: Samples elements at random from the datasets in datasets.

Description

Samples elements at random from the datasets in datasets.

Usage

sample_from_datasets(
  datasets,
  weights = NULL,
  seed = NULL,
  stop_on_empty_dataset = TRUE
)

Value

A dataset that interleaves elements from datasets at random, according to weights if provided, otherwise with uniform probability.

Arguments

datasets

A list ofobjects with compatible structure.

weights

(Optional.) A list of length(datasets) floating-point values where weights[[i]] represents the probability with which an element should be sampled from datasets[[i]], or a dataset object where each element is such a list. Defaults to a uniform distribution across datasets.

seed

(Optional.) An integer, representing the random seed that will be used to create the distribution.

stop_on_empty_dataset

If TRUE, selection stops if it encounters an empty dataset. If FALSE, it skips empty datasets. It is recommended to set it to TRUE. Otherwise, the selected elements start off as the user intends, but may change as input datasets become empty. This can be difficult to detect since the dataset starts off looking correct. Defaults to TRUE.