Issue
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
def model_fn():
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(10, tf.nn.softmax, input_shape=(784,),
kernel_initializer='zeros')
])
trainer = tff.learning.algorithms.build_weighted_fed_avg(
model_fn,
client_optimizer_fn=lambda: tf.keras.optimizers.SGD(0.1))
However, I am getting the following error:
Traceback (most recent call last):
File "G:/pythonproject2/main.py", line 43, in <module>
trainer = tff.learning.algorithms.build_weighted_fed_avg(
AttributeError: module 'tensorflow_federated.python.learning' has no attribute 'algorithms'
Could someone please help me out?
Solution
I found the issue, tensorflow_federated
requires Python 3.9+. Since I was using Python 3.7, I encountered the above error.
From the Tensorflow-Federated Documentation:
Answered By - Lycanthropeus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.