Home > Software engineering >  Error object 'ClientData' has no attribute 'from_clients_and_fn' while building
Error object 'ClientData' has no attribute 'from_clients_and_fn' while building

Time:06-10

I am building a federated dataset from a single csv file. I have followed this earlier question How to create federated dataset from a CSV file? While running tff.simulation.datasets.ClientData.from_clients_and_fn:

train_data = tff.simulation.datasets.ClientData.from_clients_and_fn(
    client_ids=train_client_ids,
    create_tf_dataset_for_client_fn=create_tf_dataset_for_client_fn
)
test_data = tff.simulation.datasets.ClientData.from_clients_and_fn(
        client_ids=test_client_ids,
        create_tf_dataset_for_client_fn=create_tf_dataset_for_client_fn
    )

I am getting error: AttributeError: type object 'ClientData' has no attribute 'from_clients_and_fn'

CodePudding user response:

from_clients_and_fn has been changed in the updated documentation as can be seen here: https://www.tensorflow.org/federated/api_docs/python/tff/simulation/datasets/ClientData

The solution is to change for both train_data and test_data:

  1. from_clients_and_fn to from_clients_and_tf_fn
  2. The parameter create_tf_dataset_for_client_fn to serializable_dataset_fn
  • Related