tff.simulation.FilePerUserClientData

Class FilePerUserClientData

Inherits From: ClientData

Defined in simulation/file_per_user_client_data.py.

A tf.simulation.ClientData that maps a set of files to a dataset.

This mapping is restricted to one file per user.

__init__

__init__(
    client_ids,
    create_tf_dataset_fn
)

Constructs a tf.simulation.ClientData object.

Args:

  • client_ids: A list of client_ids.
  • create_tf_dataset_fn: A callable that takes a client_id and returns a tf.data.Dataset object.

Properties

client_ids

output_shapes

output_types

Methods

create_from_dir

@classmethod
create_from_dir(
    cls,
    path,
    create_tf_dataset_fn=tf.data.TFRecordDataset
)

Builds a tff.simulation.FilePerUserClientData.

Iterates over all files in path, using the filename as the client ID. Does not recursively search path.

Args:

  • path: A directory path to search for per-client files.
  • create_tf_dataset_fn: A callable that creates a tf.data.Datasaet object for a given file in the directory specified in path.

Returns:

A tff.simulation.FilePerUserClientData object.

create_tf_dataset_for_client

create_tf_dataset_for_client(client_id)

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.