![]() |
A stateful process that can compute an estimate of some value.
Inherits From: IterativeProcess
tff.templates.EstimationProcess(
initialize_fn: tff.Computation
,
next_fn: tff.Computation
,
report_fn: tff.Computation
)
This class inherits the constraints documented by
tff.templates.IterativeProcess
.
A tff.templates.EstimationProcess
is an tff.templates.IterativeProcess
that in addition to the initialize
and next
functions, has a
report
function that returns the result of some computation based on the
state of the process. The argument of report
must be of the same type as the
state, that is, the type of object returned by initialize
.
Args | |
---|---|
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 .
|
report_fn
|
A tff.Computation that represents the estimation based on
state. Its input argument must be assignable from return type of
initialize_fn .
|
Raises | |
---|---|
TypeError
|
If initialize_fn , next_fn and report_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 and report_fn .
|
Attributes | |
---|---|
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 |
report
|
A tff.Computation that computes the current estimate from state .
Given a |
state_type
|
The tff.Type of the state of the process.
|
Methods
map
map(
map_fn: tff.Computation
)
Applies map_fn
to the estimate function of the process.
This method will return a new instance of EstimationProcess
with the same
initailize
and next
functions, and its report
function replaced by
map_fn(report(state))
.
Args | |
---|---|
map_fn
|
A tff.Computation to apply to the result of the report
function of the process. Must accept the return type of report .
|
Returns | |
---|---|
An EstimationProcess .
|
Raises | |
---|---|
EstimateNotAssignableError
|
If the return type of report is not
assignable to the expected input type of map_fn .
|