tff.federated_computation
Stay organized with collections
Save and categorize content based on your preferences.
Decorates/wraps Python functions as TFF federated/composite computations.
tff.federated_computation(
*args, **kwargs
)
Used in the notebooks
The term federated computation as used here refers to any computation that
uses TFF programming abstractions. Examples of such computations may include
federated training or federated evaluation that involve both client-side and
server-side logic and involve network communication. However, this
decorator/wrapper can also be used to construct composite computations that
only involve local processing on a client or on a server.
The main feature that distinguishes federated computation function bodies
in Python from the bodies of TensorFlow defuns is that whereas in the latter,
one slices and dices tf.Tensor
instances using a variety of TensorFlow ops,
in the former one slices and dices tff.Value
instances using TFF operators.
The supported modes of usage are identical to those for
tff.tensorflow.computation
.
Example |
@tff.federated_computation((tff.FunctionType(np.int32, np.int32), np.int32))
def foo(f, x):
return f(f(x))
The above defines foo as a function that takes a tuple consisting of an
unary integer operator as the first element, and an integer as the second
element, and returns the result of applying the unary operator to the
integer twice. The body of foo does not contain federated communication
operators, but we define it with tff.federated_computation as it can be
used as building block in any section of TFF code (except inside sections
of pure TensorFlow logic).
|
Args |
*args
|
Either a Python function, or TFF type spec, or both (function first),
or neither. See also tff.tensorflow.computation for an extended
documentation.
|
Returns |
If invoked with a function as an argument, returns an instance of a TFF
computation constructed based on this function. If called without one, as
in the typical decorator style of usage, returns a callable that expects
to be called with the function definition supplied as a parameter. See
also tff.tensorflow.computation for an extended documentation.
|
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-04-26 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-04-26 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-04-26 UTC."],[],[]]