tff.sequence_map
Stay organized with collections
Save and categorize content based on your preferences.
Maps a TFF sequence value
pointwise using a given function fn
.
tff.sequence_map(
fn, arg
)
This function supports two modes of usage:
When applied to a non-federated sequence, it maps individual elements of
the sequence pointwise. If the supplied fn
is of type T->U
and
the sequence arg
is of type T*
(a sequence of T
-typed elements),
the result is a sequence of type U*
(a sequence of U
-typed elements),
with each element of the input sequence individually mapped by fn
.
In this mode of usage, sequence_map
behaves like a computatation with type
signature <T->U,T*> -> U*
.
When applied to a federated sequence, sequence_map
behaves as if it were
individually applied to each member constituent. In this mode of usage, one
can think of sequence_map
as a specialized variant of federated_map
that
is designed to work with sequences and allows one to
specify a fn
that operates at the level of individual elements.
Indeed, under the hood, when sequence_map
is invoked on a federated type,
it injects federated_map
, thus
emitting expressions like
federated_map(a -> sequence_map(fn, x), arg)
.
Args |
fn
|
A mapping function to apply pointwise to elements of arg .
|
arg
|
A value of a TFF type that is either a sequence, or a federated
sequence.
|
Returns |
A sequence with the result of applying fn pointwise to each
element of arg , or if arg was federated, a federated sequence
with the result of invoking sequence_map on member sequences locally
and independently at each location.
|
Raises |
TypeError
|
If the arguments are not of the appropriate types.
|
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.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.sequence_map\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\nMaps a TFF sequence `value` pointwise using a given function `fn`. \n\n tff.sequence_map(\n fn, arg\n )\n\nThis function supports two modes of usage:\n\n- When applied to a non-federated sequence, it maps individual elements of\n the sequence pointwise. If the supplied `fn` is of type `T-\u003eU` and\n the sequence `arg` is of type `T*` (a sequence of `T`-typed elements),\n the result is a sequence of type `U*` (a sequence of `U`-typed elements),\n with each element of the input sequence individually mapped by `fn`.\n In this mode of usage, `sequence_map` behaves like a computatation with type\n signature `\u003cT-\u003eU,T*\u003e -\u003e U*`.\n\n- When applied to a federated sequence, `sequence_map` behaves as if it were\n individually applied to each member constituent. In this mode of usage, one\n can think of `sequence_map` as a specialized variant of `federated_map` that\n is designed to work with sequences and allows one to\n specify a `fn` that operates at the level of individual elements.\n Indeed, under the hood, when `sequence_map` is invoked on a federated type,\n it injects `federated_map`, thus\n emitting expressions like\n `federated_map(a -\u003e sequence_map(fn, x), arg)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------|---------------------------------------------------------------------------|\n| `fn` | A mapping function to apply pointwise to elements of `arg`. |\n| `arg` | A value of a TFF type that is either a sequence, or a federated sequence. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A sequence with the result of applying `fn` pointwise to each element of `arg`, or if `arg` was federated, a federated sequence with the result of invoking `sequence_map` on member sequences locally and independently at each location. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------------------|\n| `TypeError` | If the arguments are not of the appropriate types. |\n\n\u003cbr /\u003e"]]