Help protect the Great Barrier Reef with TensorFlow on Kaggle Join Challenge

tff.learning.templates.LearningProcess

A stateful process for learning tasks that produces metrics.

Inherits From: IterativeProcess

This class inherits the constraints documented by tff.templates.IterativeProcess, including an initialize and next attribute. The LearningProcess also contains an additional report attribute.

All of initialize, next and report must be tff.Computations, with the following type signatures:

  • initialize: ( -> S@SERVER)
  • next: (<S@SERVER, {D*}@CLIENTS> -> <state=S@SERVER, metrics=M@SERVER>)
  • report: (S -> R) where {D*}@CLIENTS represents the sequence of data at a client, with D denoting the type of a single member of that sequence, and R representing the (unplaced) output type of the report function.

For example, given a LearningProcess process and client data data, we could call the following to initialize, update the state three times, and get a report of the resulting state: ``` state = process.initialize() for _ in range(3): state, metrics = process.next(state, data) report = process.report(state)

initialize_fn: A no-arg tff.Computation that creates the initial state of the learning process. next_fn: A tff.Computation that defines an iterated function. Given that initialize_fn returns a type S@SERVER, the next_fn must return a LearningProcessOutput where the state attribute matches the type S@SERVER, and accepts two argument of types S@SERVER and {D*}@CLIENTS.
get_model_weights A tff.Computation that accepts an input S where the output of initialize_fn is of type S@SERVER. This computation is used to create a representation of the state that can be used for downstream tasks without requiring access to the entire server state. For example, get_model_weights could be used to extract model weights suitable for computing evaluation metrics on held-out data.

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.
TemplateNextFnNumArgsError If next_fn does not have at exactly two input arguments.
LearningProcessPlacementError If the placements of initialize_fn and next_fn do not match the expected type placements.
LearningProcessOutputError If next_fn does not return a LearningProcessOutput.
LearningProcessSequenceTypeError If the second argument to next_fn is not a sequence type.

get_model_weights A tff.Computation returning the model weights of a server state.

This computation accepts an unplaced state of the process (originally produced by the initialize attribute), and returns an unplaced representation of the model weights of the state. Note that this representation need not take the form of a tff.learning.ModelWeights object, and may depend on the specific LearningProcess in question.

initialize A tff.Computation that initializes the process.

This computation must have no input arguments, and its output must be the initial state of the iterative process, placed at SERVER.

next A tff.Computation that runs one iteration of the process.

The first argument of this computation should always be the current state (originally produced by the initialize attribute), the second argument must be a tff.SequenceType placed at CLIENTS. The return type must be a LearningProcessOutput, with each field placed at SERVER.

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