tff.templates.MeasuredProcess

View source on GitHub

A tff.templates.IterativeProcess with a specific output signature.

Inherits From: IterativeProcess

A tff.templates.MeasuredProcess is a tff.templates.IterativeProcess that formalizes the output signature of the next property to be a named three-tuple <state,result,measurements>. This definition enables tff.templates.MeasuredProcess to be composed following the rules below, something that wasn't possible with the more generic, less defined tff.templates.IterativeProcess.

Rules of Composition Given two MeasuredProcess F(x) and G(y), a new composition C is also a MeasuredProcess where:

  • C.state is the concatenation <F.state, G.state>.
  • C.result is the result of G applied to the result of F G(G.state, F(F.state, x).result).result.
  • C.measurements is the concatenation <F.measurements, G.measurements>.

The resulting composition C would have the following type signatures: initialize: ( -> <F.initialize, G.initialize>) next: (<<F.state, G.state>, F.input> -> <state=<F.state, G.State>, result=G.result, measurements=<F.measurements, G.measurements>)

initialize_fn a no-arg tff.Computation that creates the initial state of the measured process.
next_fn a tff.Computation that defines an iterated function. If initialize_fn returns a type S, then next_fn must return a TFF type <state=S,result=O,measurements=M>, and accept either a single argument of type T or multiple arguments where the first argument must be of type T.

TypeError initialize_fn and next_fn are not compatible function types, or next_fn does not have a valid output signature.

initialize A no-arg tff.Computation that returns the initial state.
next A tff.Computation that runs one iteration of the process.

The first argument of should always be the current state (originally produced by tff.templates.MeasuredProcess.initialize), and the return type must me a named tuple matching the signature <state=A,result=B,measurements=C>.