tff.simulation.build_uniform_sampling_fn
Builds the function for sampling from the input iterator at each round.
tff.simulation.build_uniform_sampling_fn(
sample_range: Sequence[T],
replace: bool = False,
random_seed: Optional[int] = None
) -> Callable[[int, int], list[T]]
If an integer random_seed
is provided, we set a random seed before sampling
clients according to a multiplicative linear congruential generator (aka
Lehmer generator, see 'The Art of Computer Programming, Vol. 3' by Donald
Knuth for reference). This does not affect model initialization, shuffling, or
other such aspects of the federated training process.
Args |
sample_range
|
A 1-D array-like sequence, to be used as input to
np.random.choice . Samples are generated randomly from the elements of
the sequence.
|
replace
|
A boolean indicating whether the sampling is done with replacement
(True) or without replacement (False).
|
random_seed
|
If an integer, it is used as a random seed for the client
sampling process. If None, a nondeterministic seed is used.
|
Returns |
A function that takes as input an integer round_num and integer size and
returns a list of size elements sampled (pseudo-)randomly from the input
sample_range .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[]]