ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tff.aggregators.concat_factory

Aggregation factory for concatenation of input to a single tensor.

The created tff.templates.AggregationProcess takes the input structure, reshapes each tensor in the structure to a rank-1 tensor, and concatenates them into a single tensor, which is passed to the inner aggregation. After the inner aggregation, the concatenated tensor is split and packed into the original structure.

For example, if this factory receives TFF type <float32[N],float32[P,Q]>, then the inner_agg_factory will operate on <float32[N + P * Q]>. Note that the factory expects all tensors in the structure to have the same numeric dtype; for example, an input value_type of <int32[N],float32[P,Q]> or <string[N]> will raise an error.

This aggregator may be useful as a preprocessing step for algorithms that need to operate on client values as a single vector; for example, the algorithm may need to apply randomized Hadamard transform with zero padding on the client vectors, in which case applying the transform separately on each component may not be identical to applying the transform to the single vector at once.

The returned factory takes its weightedness (UnweightedAggregationFactory vs. WeightedAggregationFactory) from the inner_agg_factory.

This factory only accepts value_type of either tff.TensorType or tff.StructWithPythonType and expects the dtype of component tensors to be either all real integers or all real floats.

inner_agg_factory A factory specifying the type of aggregation to be done after flattening and concatenating the structure into a single vector.

An aggregation factory that flattens and concatenates the components of a tensor structure into a single rank-1 tensor.