tff.utils.build_dp_aggregate

Builds a stateful aggregator for tensorflow_privacy DPQueries.

The returned StatefulAggregateFn can be called with any nested structure for the values being statefully aggregated. However, it's necessary to provide two functions as arguments which indicate the properties (the tff.Type and the structure.Struct conversion) of the nested structure that will be used. If using a collections.OrderedDict as the value's nested structure, the defaults for the arguments suffice.

query A DPQuery to aggregate. For compatibility with tensorflow_federated, the global_state and sample_state of the query must be structures supported by tf.nest.
value_type_fn Python function that takes the value argument of next_fn and returns the value type. This will be used in determining the TensorSpecs that establish the initial sample state. If the value being aggregated is an collections.OrderedDict, the default for this argument can be used. This argument probably gets removed once b/123092620 is addressed (and the associated processing step gets replaced with a simple call to value.type_signature.member).

A tuple of:

  • a computation_utils.StatefulAggregateFn that aggregates according to the query
  • the TFF type of the DP aggregator's global state