A simple container for a stateful broadcast function.

A typical (though trivial) example would be:

stateless_federated_broadcast = tff.utils.StatefulBroadcastFn(
  initialize_fn=lambda: (),
  next_fn=lambda state, value: (
      state, tff.federated_broadcast(value)))

initialize_fn A no-arg function that returns a Python container which can be converted to a tff.Value, placed on the tff.SERVER, and passed as the first argument of __call__. This may be called in vanilla TensorFlow code, typically wrapped as a tff.tf_computation, as part of the initialization of a larger state object.
next_fn A function matching the signature of __call__, see below.



View source

Returns the initial state.


View source

Performs a broadcast of value@SERVER, producing value@CLIENTS.

This is a function intended to (only) be invoked in the context of a tff.federated_computation. It shold be compatible with the TFF type signature (state@SERVER, value@SERVER) -> (state@SERVER, value@CLIENTS).

state A tff.Value placed on the tff.SERVER.
value A tff.Value placed on the tff.SERVER, to be broadcast to the tff.CLIENTS.

A tuple of tff.Values (state@SERVER, value@CLIENTS) where

  • state: The updated state.
  • value: The input value now placed (communicated) to the tff.CLIENTS.