|View source on GitHub|
A process that includes an initialization and iterated computation.
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)
__init__( initialize_fn, next_fn )
initialize_fn: a no-arg
tff.Computationthat creates the initial state of the chained computation.
tff.Computationthat defines an iterated function. If
initialize_fnreturns a type T, then
next_fnmust also return type T or multiple values where the first is of type T, and accept either a single argument of type T or multiple arguments where the first argument must be of type T.
next_fnare not compatible function types.
tff.Computation that returns the initial state.
tff.Computation that produces the next state.
The first argument of should always be the current state (originally
tff.IterativeProcess.initialize), and the first (or only)
returned value is the updated state.