# tff.templates.EstimationProcess

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) 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) |

A stateful process that can compute an estimate of some value.

Inherits From: [`IterativeProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/IterativeProcess)

    tff.templates.EstimationProcess(
        initialize_fn: https://www.tensorflow.org/federated/api_docs/python/tff/Computation,
        next_fn: https://www.tensorflow.org/federated/api_docs/python/tff/Computation,
        report_fn: https://www.tensorflow.org/federated/api_docs/python/tff/Computation,
        next_is_multi_arg: Optional[bool] = None
    )

This class inherits the constraints documented by
[`tff.templates.IterativeProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/IterativeProcess).

A [`tff.templates.EstimationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/EstimationProcess) is an [`tff.templates.IterativeProcess`](https://www.tensorflow.org/federated/api_docs/python/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`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `initialize_fn` | A no-arg [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/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`](https://www.tensorflow.org/federated/api_docs/python/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`](https://www.tensorflow.org/federated/api_docs/python/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. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `initialize_fn`, `next_fn` and `report_fn` are not instances of [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/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`. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `initialize` | A no-arg [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that returns the initial state. |
| `next` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that produces the next state. <br /> Its first argument should always be the current state (originally produced by [`tff.templates.IterativeProcess.initialize`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/IterativeProcess#initialize)), and the first (or only) returned value is the updated state. |
| `report` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that computes the current estimate from `state`. <br /> Given a `state` controlled by this process, computes and returns the most recent estimate of the estimated value. |
| `state_type` | The [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type) of the state of the process. |

<br />

## Methods

### `map`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    map(
        map_fn: https://www.tensorflow.org/federated/api_docs/python/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))`.

<br />

<br />

<br />

| Args ||
|---|---|
| `map_fn` | A [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) to apply to the result of the `report` function of the process. Must accept the return type of `report`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An `EstimationProcess`. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `EstimateNotAssignableError` | If the return type of `report` is not assignable to the expected input type of `map_fn`. |

<br />