tff.templates.EstimationProcess
Stay organized with collections
Save and categorize content based on your preferences.
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
,
next_is_multi_arg: Optional[bool] = None
)
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 returns the initial state
of the estimation process. Let the type of this state be called S .
|
next_fn
|
A tff.Computation that represents the iterated function. The
first or only argument must match the state type S . The first or only
return value must also match state type S .
|
report_fn
|
A tff.Computation that represents the estimation based on
state. Its input argument must match the state type S .
|
next_is_multi_arg
|
An optional boolean indicating that next_fn will
receive more than just the state argument (if True ) or only the state
argument (if False ). This parameter is primarily used to provide
better error messages.
|
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 tff.templates.IterativeProcess.initialize ), and the first (or only)
returned value is the updated state.
|
report
|
A tff.Computation that computes the current estimate from state .
Given a state controlled by this process, computes and returns the most
recent estimate of the estimated value.
|
state_type
|
The tff.Type of the state of the process.
|
Methods
map
View source
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 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.templates.EstimationProcess\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nA stateful process that can compute an estimate of some value.\n\nInherits From: [`IterativeProcess`](../../tff/templates/IterativeProcess) \n\n tff.templates.EstimationProcess(\n initialize_fn: ../../tff/Computation,\n next_fn: ../../tff/Computation,\n report_fn: ../../tff/Computation,\n next_is_multi_arg: Optional[bool] = None\n )\n\nThis class inherits the constraints documented by\n[`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess).\n\nA [`tff.templates.EstimationProcess`](../../tff/templates/EstimationProcess) is an [`tff.templates.IterativeProcess`](../../tff/templates/IterativeProcess)\nthat in addition to the `initialize` and `next` functions, has a\n`report` function that returns the result of some computation based on the\nstate of the process. The argument of `report` must be of the same type as the\nstate, that is, the type of object returned by `initialize`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `initialize_fn` | A no-arg [`tff.Computation`](../../tff/Computation) that returns the initial state of the estimation process. Let the type of this state be called `S`. |\n| `next_fn` | A [`tff.Computation`](../../tff/Computation) that represents the iterated function. The first or only argument must match the state type `S`. The first or only return value must also match state type `S`. |\n| `report_fn` | A [`tff.Computation`](../../tff/Computation) that represents the estimation based on state. Its input argument must match the state type `S`. |\n| `next_is_multi_arg` | An optional boolean indicating that `next_fn` will receive more than just the state argument (if `True`) or only the state argument (if `False`). This parameter is primarily used to provide better error messages. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `TypeError` | If `initialize_fn`, `next_fn` and `report_fn` are not instances of [`tff.Computation`](../../tff/Computation). |\n| `TemplateInitFnParamNotEmptyError` | If `initialize_fn` has any input arguments. |\n| `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`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `initialize` | A no-arg [`tff.Computation`](../../tff/Computation) that returns the initial state. |\n| `next` | A [`tff.Computation`](../../tff/Computation) that produces the next state. \u003cbr /\u003e Its first argument should always be the current state (originally produced by [`tff.templates.IterativeProcess.initialize`](../../tff/templates/IterativeProcess#initialize)), and the first (or only) returned value is the updated state. |\n| `report` | A [`tff.Computation`](../../tff/Computation) that computes the current estimate from `state`. \u003cbr /\u003e Given a `state` controlled by this process, computes and returns the most recent estimate of the estimated value. |\n| `state_type` | The [`tff.Type`](../../tff/types/Type) of the state of the process. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `map`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n map(\n map_fn: ../../tff/Computation\n )\n\nApplies `map_fn` to the estimate function of the process.\n\nThis method will return a new instance of `EstimationProcess` with the same\n`initailize` and `next` functions, and its `report` function replaced by\n`map_fn(report(state))`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `map_fn` | A [`tff.Computation`](../../tff/Computation) to apply to the result of the `report` function of the process. Must accept the return type of `report`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An `EstimationProcess`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|------------------------------|------------------------------------------------------------------------------------------|\n| `EstimateNotAssignableError` | If the return type of `report` is not assignable to the expected input type of `map_fn`. |\n\n\u003cbr /\u003e"]]