![]() |
A tff.program.FederatedDataSourceIterator
that prefetches data.
Inherits From: FederatedDataSourceIterator
tff.program.PrefetchingDataSourceIterator(
iterator: tff.program.FederatedDataSourceIterator
,
total_iterations: int,
iterations_to_prefetch: int,
k_to_prefetch: int,
prefetch_threshold: int = 0
)
Args | |
---|---|
iterator
|
A tff.program.FederatedDataSourceIterator used to prefetch
data from.
|
total_iterations
|
The total number of iterations. |
iterations_to_prefetch
|
The number of iterations to prefetch. |
k_to_prefetch
|
The number of elements to prefetch per round. Must be greater than 1 and must be identical across all iterations; attempts to select any other number of elements will fail. |
prefetch_threshold
|
The threshold below which the data source starts prefetching. |
Raises | |
---|---|
ValueError
|
If k_to_prefetch is not greater than 1.
|
RuntimeError
|
If the iterator is not constructed in an
tff.framework.AsyncExecutionContext .
|
Attributes | |
---|---|
federated_type
|
The type of the data returned by calling select .
|
Methods
from_bytes
@classmethod
from_bytes( buffer: bytes ) -> 'PrefetchingDataSourceIterator'
Deserializes the object from bytes.
select
select(
k: Optional[int] = None
) -> object
Returns a new selection of data from this iterator.
Args | |
---|---|
k
|
A number of elements to select. Must be a positive integer and equal to
k_to_prefetch .
|
Raises | |
---|---|
ValueError
|
If k is not a positive integer or if k is not equal to
k_to_prefetch .
|
to_bytes
to_bytes() -> bytes
Serializes the object to bytes.
__eq__
__eq__(
other: object
) -> bool
Return self==value.