tff.simulation.FromTensorSlicesClientData

Class FromTensorSlicesClientData

ClientData based on tf.data.Dataset.from_tensor_slices.

Inherits From: ClientData

Defined in simulation/from_tensor_slices_client_data.py.

__init__

__init__(tensor_slices_dict)

Constructs the object from a dictionary of client data.

NOTE: All clients are required to have non-empty data.

Args:

  • tensor_slices_dict: A dictionary keyed by client_id, where values are structures suitable for passing to tf.data.Dataset.from_tensor_slices.

Raises:

  • ValueError: If a client with no data is found.

Properties

client_ids

The list of string identifiers for clients in this dataset.

output_shapes

Returns the shape of each component of an element of the client datasets.

Any tf.data.Dataset constructed by this class is expected to have matching tf.data.Dataset.output_shapes properties.

Returns:

A nested structure of tf.TensorShape objects corresponding to each component of an element of the client datasets.

output_types

Returns the type of each component of an element of the client datasets.

Any tf.data.Dataset constructed by this class is expected have matching tf.data.Dataset.output_types properties.

Returns:

A nested structure of tf.DType objects corresponding to each component of an element of the client datasets.

Methods

create_tf_dataset_for_client

create_tf_dataset_for_client(client_id)

Creates a new tf.data.Dataset containing the client training examples.

Args:

  • client_id: The string client_id for the desired client.

Returns:

A tf.data.Dataset object.

create_tf_dataset_from_all_clients

create_tf_dataset_from_all_clients()

Creates a new tf.data.Dataset containing all client examples.

NOTE: the returned tf.data.Dataset is not serializable and runnable on other devices, as it uses tf.py_func internally.

Returns:

A tf.data.Dataset object.