Save the date! Google I/O returns May 18-20 Register now


A process that includes an initialization and iterated computation.

Used in the notebooks

Used in the tutorials

An iterated process will usually be driven by a control loop like:

def initialize_fn():

def next_fn(state):

iterative_process = IterativeProcess(initialize_fn, next_fn)
state = iterative_process.initialize()
for round in range(num_rounds):
  state =

The initialize_fn function must return an object which is expected as input to and returned by the next_fn function. By convention, we refer to this object as state.

The iteration step (next_fn function) can accept arguments in addition to state (which must be the first argument), and return additional arguments, with state being the first output argument:

def next_fn(state, round_num):

iterative_process = ...
state = iterative_process.initialize()
for round in range(num_rounds):
  state, output =, round)

initialize_fn A no-arg tff.Computation that creates the initial state of the computation.
next_fn A tff.Computation that represents the iterated function. If initialize_fn returns a type T, then next_fn must either return a type U which is compatible with T or multiple values where the first type is U, and accept either a single argument of type U or multiple arguments where the first argument must be of type U.

TypeError If initialize_fn and next_fn are not instances of tff.Computation.
TemplateInitFnParamNotEmptyError If initialize_fn has any input arguments.
TemplateStateNotAssignableError If the state returned by either initialize_fn or next_fn is not assignable to the first input argument of next_fn.

initialize A no-arg tff.Computation that returns the initial state.
next A tff.Computation that produces the next state.

Its first argument should always be the current state (originally produced by tff.templates.IterativeProcess.initialize), and the first (or only) returned value is the updated state.

state_type The tff.Type of the state of the process.