A tff.program.FederatedDataSourceIterator
that prefetches data.
Inherits From: FederatedDataSourceIterator
tff.program.PrefetchingDataSourceIterator(
iterator: tff.program.FederatedDataSourceIterator
,
context: tff.framework.AsyncExecutionContext
,
total_rounds: int,
num_rounds_to_prefetch: int,
num_clients_to_prefetch: int,
prefetch_threshold: int = 0
)
Args |
iterator
|
A tff.program.FederatedDataSourceIterator used to prefetch
data from.
|
context
|
The tff.framework.AsyncExecutionContext to prefetch data in.
|
total_rounds
|
The total number of rounds.
|
num_rounds_to_prefetch
|
The number of rounds to prefetch.
|
num_clients_to_prefetch
|
The number of clients to prefetch per round. Must
be greater than 1 and must be identical across all rounds; attempts to
select any other number of clients will fail.
|
prefetch_threshold
|
The threshold below which the data source starts
prefetching.
|
Raises |
ValueError
|
If num_clients_to_prefetch is not greater than 1.
|
Attributes |
federated_type
|
The type of the data returned by calling select .
|
Methods
select
View source
select(
num_clients: Optional[int] = None
) -> Any
Returns a new selection of data from this iterator.
Args |
num_clients
|
A number of clients to use when selecting data. Must be a
positive integer and equal to num_clients_to_prefetch .
|
Raises |
ValueError
|
If num_clients is not a positive integer or if num_clients
is not equal to num_clients_to_prefetch .
|