tff.templates.IterativeProcess

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

def next(state):
  ...

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

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

def next(state, item):
  ...

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

initialize_fn a no-arg tff.Computation that creates the initial state of the chained computation.
next_fn a tff.Computation that defines an iterated function. If initialize_fn returns a type T, then next_fn must 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 initialize_fn and next_fn are not compatible function types.

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

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