# tff.program.DatasetDataSourceIterator

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

A [`tff.program.FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator) backed by [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset)s.

Inherits From: [`FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator)

    tff.program.DatasetDataSourceIterator(
        datasets: Sequence[tf.data.Dataset],
        federated_type: https://www.tensorflow.org/federated/api_docs/python/tff/types/FederatedType
    )

A [`tff.program.FederatedDataSourceIterator`](https://www.tensorflow.org/federated/api_docs/python/tff/program/FederatedDataSourceIterator) backed by a sequence of
`tf.data.Dataset's, one`tf.data.Dataset' per client. It selects datasources
uniformly at random, with replacement over successive calls of `select()` but
without replacement within a single call of `select()`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `datasets` | A sequence of `tf.data.Dataset's to use to yield the data from this data source. </td> </tr><tr> <td>`federated_type`<a id="federated_type"></a> </td> <td> The type of the data returned by calling`select\` on an iterator. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `datasets` is empty or if each [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset) in `datasets` does not have the same type specification. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `federated_type` | The type of the data returned by calling `select`. |

<br />

## Methods

### `from_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    @classmethod
    from_bytes(
        buffer: bytes
    ) -> 'DatasetDataSourceIterator'

Deserializes the object from bytes.

### `select`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    select(
        k: Optional[int] = None
    ) -> object

Returns a new selection of data from this iterator.

<br />

<br />

<br />

| Args ||
|---|---|
| `k` | A number of elements to select. Must be a positive integer and less than the number of `datasets`. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If `k` is not a positive integer or if `k` is not less than the number of `datasets`. |

<br />

### `to_bytes`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    to_bytes() -> bytes

Serializes the object to bytes.

### `__eq__`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    __eq__(
        other: object
    ) -> bool

Return self==value.