Missed TensorFlow World? Check out the recap. Learn more

tff.learning.framework.build_encoded_sum_from_model

View source on GitHub

Builds StatefulAggregateFn for weights of model returned by model_fn.

tff.learning.framework.build_encoded_sum_from_model(
    model_fn,
    encoder_fn
)

This method creates a GatherEncoder for every trainable weight of model created by model_fn, as returned by encoder_fn.

Args:

  • model_fn: A Python callable with no arguments function that returns a tff.learning.Model.
  • encoder_fn: A Python callable with a single argument, which is expected to be a tf.Tensor of shape and dtype to be encoded. The function must return a tensor_encoding.core.SimpleEncoder, which expects a tf.Tensor with compatible type as the input to its encode method.

Returns:

A StatefulAggregateFn for encoding and summing the weights of model created by model_fn.

Raises:

  • TypeError: If model_fn or encoder_fn are not callable objects.