TensorFlow 2.0 Beta is available Learn more

tff.utils.StatefulBroadcastFn

Class StatefulBroadcastFn

A simple container for a stateful broadcast function.

Defined in python/core/utils/computation_utils.py.

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)))

__init__

__init__(
    initialize_fn,
    next_fn
)

Creates the StatefulFn.

Args:

  • 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_compuatation, as part of the initialization of a larger state object.
  • next_fn: A function matching the signature of __call__, see below.

Methods

__call__

__call__(
    state,
    value
)

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).

Args:

Returns:

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.

initialize

initialize()

Returns the initial state.