I have read and studied the TFF guide and APIs pages precisely. But I am confused in some detail parts.
For example, when I want to wrap/decorate a TF/python function, use these two below APIs:
1. tff.tf_computation()
2. tff.federated_computation()
I can not find what are differences between them and when I am allowed to use them. Especially, in case I want to use other algorithms except for FedAvg or FedSgd. I wonder if you know:
tff.federated_mean
or tff.federated_sum
that the value will be in the server? tff.tf_computation()
from tff.federated_computation()
? In this link, there was not any explanation about them.tff.federated_mean
or tff.federated_sum
) modify the output elements of each @CLIENT and bring them to the @SERVER? Could anyone help me to understand intuitive behind the concept?
A possible rule of thumb about the different function decorators:
tff.tf_computation
is for wrapping TF logic. Think "tensors in, tensors out": this should be very similar to the usage of tf.function
, where the parameters and return values are tensors, or nested structures of tensors. TFF intrinsics (e.g. tff.federated_mean
) cannot be used inside a tff.tf_computation
, and tff.tf_computations
cannot call tff.federated_computations
. The type signature is always on unplaced.
tff.federated_computation
should be used to wrap TFF programming abstractions. Think "tensors here, tensors there": Inside this context, a tff.tf_computation
can be applied to tff.Value
s and tff.Value
s can be communicated to other placements using the intrinsics. The type signature can accept federated types (i.e. types with placements).
For your list of questions:
CLIENTS
or SERVER
. For example, tff.tf_computation
called my_comp
can be applied to a value v
with type int32@CLIENTS
with tff.federated_map(my_comp, v)
, which will run my_comp
on each client.tff.federated_map()
supports applying a computation pointwise (across clients) to data not on the server. You can manipulate the metrics on each client using tff.federated_map
. TFF isn't intended for separate options on different clients; the abstractions do not support addressing individuals. You may be able to simulate this in Python, see Operations performed on the communications between the server and clients.tff.Computation
, and invoking that computation. The values should be available in the Python environment. tff.tf_computation
s should be invokable from anywhere, if there is documentation that says otherwise please point to it. I believe what was intended to highlight is that a tff.federated_computation
may invoke a tff.tf_computation
, but not vice versa.tff.tf_computations
should be executed directly if desired. This will avoid any of the federated part of TFF, and simply delegate to TensorFlow. To apply the computation to federated values and use in combination with federated intrinsics, they must be called inside a tff.federated_computation
.