Watch talks from the 2019 TensorFlow Dev Summit Watch now

tff.simulation.TransformingClientData

Class TransformingClientData

Inherits From: ClientData

Defined in simulation/transforming_client_data.py.

Expands client data by performing transformations.

Each client of the raw_client_data is "expanded" into some number of pseudo-clients. Each client ID is a tuple containing the original client ID plus an integer index. A function f(x, i) maps datapoints x with index i to new datapoint. For example if x is an image, and i has values 0 or 1, f(x, 0) might be the identity, while f(x, 1) could be the reflection of the image.

__init__

__init__(
    raw_client_data,
    transform_fn,
    num_transformed_clients
)

Initializes the TransformingClientData.

Args:

  • raw_client_data: A ClientData to expand.
  • transform_fn: A function f(x, i) parameterized by i, mapping datapoint x to a new datapoint. x is a datapoint from the raw_client_data, while i is an integer index in the range 0...k (see 'num_transformed_clients' for definition of k). Typically by convention the index 0 corresponds to the identity function if the identity is supported.
  • num_transformed_clients: The total number of transformed clients to produce. If it is an integer multiple k of the number of real clients, there will be exactly k pseudo-clients per real client, with indices 0...k-1. Any remainder g will be generated from the first g real clients and will be given index k.

Properties

client_ids

output_shapes

output_types

Methods

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.