Federated learning with tensorflow

115 Views Asked by At
test_data = tff.python.simulation.datasets.ClientData.from_clients_and_tf_fn(
      client_ids=test_client_ids,
      serializable_dataset_fn=create_tf_dataset_for_client_fn   
    )
print(test_data)

After running the above code I have got the below error... module 'tensorflow_federated.python.simulation.datasets' has no attribute 'ClientData'

How I can solve it?

1

There are 1 best solutions below

0
RanaMoizHaider On

It depends on which version of Tensorflow Federated you are using. Based on your code, you maybe using tensorflow_federated=0.20.0. For that, instead of using tff.python.simulation.datasets.ClientData, use tff.simulation.datasets.ClientData as follows:

test_data = tff.simulation.datasets.ClientData.from_clients_and_tf_fn(
      client_ids=test_client_ids,
      serializable_dataset_fn=create_tf_dataset_for_client_fn   
    )

This should sort out the mentioned error. If you've already done it with another approach, Kindly share that.