# tff.aggregators.DiscreteFourierTransformFactory

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

`UnweightedAggregationFactory` for discrete Fourier transform.

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

    tff.aggregators.DiscreteFourierTransformFactory(
        inner_agg_factory: Optional[https://www.tensorflow.org/federated/api_docs/python/tff/aggregators/UnweightedAggregationFactory] = None,
        num_repeats: int = 1
    )

The created [`tff.templates.AggregationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/AggregationProcess) takes an input structure
and applies the randomized discrete Fourier transform (using TF's fast Fourier
transform implementation `tf.signal.fft/ifft`) to each tensor in the
structure, reshaped to a rank-1 tensor in `O(d*log(d))` time, where `d` is the
number of elements of the tensor.

See <https://en.wikipedia.org/wiki/Discrete_Fourier_transform>

Specifically, for each tensor, the following operations are first performed at
[`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS):

1. Flattens the tensor into a rank-1 tensor.
2. Pads the tensor with zeros to an even number of elements (i.e. pad at most one zero).
3. Packs the real valued tensor into a tensor with a complex dtype with `d/2` elements, by filling the real and imaginary values with two halves of the tensor.
4. Randomly rotates each coordinate of the complex tensor.
5. Applies the discrete Fourier transform.
6. Unpacks the complex tensor back to a real tensor with length `d`.
7. Normalizes the tensor by `1 / sqrt(d/2)`. Steps 4 and 5 are repeated multiple times with independent randomness, if `num_repeats > 1`.

The resulting tensors are passed to the `inner_agg_factory`. After
aggregation, at `tff.SEREVR`, inverses of these steps are applied in reverse
order.

The allowed input dtypes are integers and floats. However, the dtype passed to
the `inner_agg_factory` will always be a float.

## Methods

### `create`

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

    create(
        value_type: factory.ValueType
    ) -> https://www.tensorflow.org/federated/api_docs/python/tff/templates/AggregationProcess

Creates a `tff.aggregators.AggregationProcess` without weights.

The provided `value_type` is a non-federated [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type), that is, not a
[`tff.FederatedType`](https://www.tensorflow.org/federated/api_docs/python/tff/types/FederatedType).

The returned `tff.aggregators.AggregationProcess` will be created for
aggregation of values matching `value_type` placed at [`tff.CLIENTS`](https://www.tensorflow.org/federated/api_docs/python/tff#CLIENTS).
That is, its `next` method will expect type
`<S@SERVER, {value_type}@CLIENTS>`, where `S` is the unplaced return type of
its `initialize` method.

<br />

<br />

<br />

| Args ||
|---|---|
| `value_type` | A non-federated [`tff.Type`](https://www.tensorflow.org/federated/api_docs/python/tff/types/Type). |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A [`tff.templates.AggregationProcess`](https://www.tensorflow.org/federated/api_docs/python/tff/templates/AggregationProcess). ||

<br />