# tff.federated_mean

<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) |

Computes a [`tff.SERVER`](https://www.tensorflow.org/federated/api_docs/python/tff#SERVER) mean of `value` placed on [`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS).

    tff.federated_mean(
        value, weight=None
    )

For values `v_1, ..., v_k`, and weights `w_1, ..., w_k`, this means
`sum_{i=1}^k (w_i * v_i) / sum_{i=1}^k w_i`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `value` | The value of which the mean is to be computed. Must be of a TFF federated type placed at [`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS). The value may be structured, e.g., its member constituents can be named tuples. The tensor types that the value is composed of must be floating-point or complex. |
| `weight` | An optional weight, a TFF federated integer or floating-point tensor value, also placed at [`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A representation at the [`tff.SERVER`](https://www.tensorflow.org/federated/api_docs/python/tff#SERVER) of the mean of the member constituents of `value`, optionally weighted with `weight` if specified (otherwise, the member constituents contributed by all clients are equally weighted). ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If `value` is not a federated TFF value placed at [`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS), or if `weight` is not a federated integer or a floating-point tensor with the matching placement. |

<br />