tff.aggregators.DiscreteFourierTransformFactory
Stay organized with collections
Save and categorize content based on your preferences.
UnweightedAggregationFactory
for discrete Fourier transform.
Inherits From: UnweightedAggregationFactory
tff.aggregators.DiscreteFourierTransformFactory(
inner_agg_factory: Optional[tff.aggregators.UnweightedAggregationFactory
] = None,
num_repeats: int = 1
)
The created 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
:
- Flattens the tensor into a rank-1 tensor.
- Pads the tensor with zeros to an even number of elements (i.e. pad at
most one zero).
- 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.
- Randomly rotates each coordinate of the complex tensor.
- Applies the discrete Fourier transform.
- Unpacks the complex tensor back to a real tensor with length
d
.
- 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
create(
value_type: factory.ValueType
) -> tff.templates.AggregationProcess
Creates a tff.aggregators.AggregationProcess
without weights.
The provided value_type
is a non-federated tff.Type
, that is, not a
tff.FederatedType
.
The returned tff.aggregators.AggregationProcess
will be created for
aggregation of values matching value_type
placed at 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.
Args |
value_type
|
A non-federated tff.Type .
|
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-20 UTC."],[],[],null,["# tff.aggregators.DiscreteFourierTransformFactory\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\n`UnweightedAggregationFactory` for discrete Fourier transform.\n\nInherits From: [`UnweightedAggregationFactory`](../../tff/aggregators/UnweightedAggregationFactory) \n\n tff.aggregators.DiscreteFourierTransformFactory(\n inner_agg_factory: Optional[../../tff/aggregators/UnweightedAggregationFactory] = None,\n num_repeats: int = 1\n )\n\nThe created [`tff.templates.AggregationProcess`](../../tff/templates/AggregationProcess) takes an input structure\nand applies the randomized discrete Fourier transform (using TF's fast Fourier\ntransform implementation `tf.signal.fft/ifft`) to each tensor in the\nstructure, reshaped to a rank-1 tensor in `O(d*log(d))` time, where `d` is the\nnumber of elements of the tensor.\n\nSee \u003chttps://en.wikipedia.org/wiki/Discrete_Fourier_transform\u003e\n\nSpecifically, for each tensor, the following operations are first performed at\n[`tff.CLIENTS`](../../tff#CLIENTS):\n\n1. Flattens the tensor into a rank-1 tensor.\n2. Pads the tensor with zeros to an even number of elements (i.e. pad at most one zero).\n3. 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.\n4. Randomly rotates each coordinate of the complex tensor.\n5. Applies the discrete Fourier transform.\n6. Unpacks the complex tensor back to a real tensor with length `d`.\n7. Normalizes the tensor by `1 / sqrt(d/2)`. Steps 4 and 5 are repeated multiple times with independent randomness, if `num_repeats \u003e 1`.\n\nThe resulting tensors are passed to the `inner_agg_factory`. After\naggregation, at `tff.SEREVR`, inverses of these steps are applied in reverse\norder.\n\nThe allowed input dtypes are integers and floats. However, the dtype passed to\nthe `inner_agg_factory` will always be a float.\n\nMethods\n-------\n\n### `create`\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 create(\n value_type: factory.ValueType\n ) -\u003e ../../tff/templates/AggregationProcess\n\nCreates a `tff.aggregators.AggregationProcess` without weights.\n\nThe provided `value_type` is a non-federated [`tff.Type`](../../tff/types/Type), that is, not a\n[`tff.FederatedType`](../../tff/types/FederatedType).\n\nThe returned `tff.aggregators.AggregationProcess` will be created for\naggregation of values matching `value_type` placed at [`tff.CLIENTS`](../../tff#CLIENTS).\nThat is, its `next` method will expect type\n`\u003cS@SERVER, {value_type}@CLIENTS\u003e`, where `S` is the unplaced return type of\nits `initialize` method.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|-----------------------------------------------------|\n| `value_type` | A non-federated [`tff.Type`](../../tff/types/Type). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A [`tff.templates.AggregationProcess`](../../tff/templates/AggregationProcess). ||\n\n\u003cbr /\u003e"]]