1

I am trying to run the code given by Tensorflow in their official documentation, pertaining to Tensorflow-Federated. The code is as follows:

import tensorflow as tf
import tensorflow_federated as tff

training_process = tff.learning.algorithms.build_weighted_fed_avg(get_dense_nn, client_optimizer_fn=lambda: tf.keras.Sequential.SGD(learning_rate=client_lr),                                                                 server_optimizer_fn=lambda:tf.keras.optimizers.SGD(learning_rate=server_lr))

However, I am getting the following error:

AttributeError: module 'tensorflow_federated.python.learning' has no attribute 'from_keras_model'

Am I doing something wrong or is the documentation wrong?

1
  • Is your python version 3.9 or later? As per the documentation page Docs Commented Mar 18, 2024 at 1:27

1 Answer 1

0

The error message indicates that tensorflow_federated.python.learning.from_keras_model is attempting to be used, however this API does not exist.

In newer versions of TensorFlow Federated, the API has moved to tff.learning.models.from_keras_model.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.