1

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'

2 Answers2

3

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
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
ChaoS Adm
  • 715
  • 1
  • 5
  • 12
1

For people using TensorFlow Federated 0.20.0+

Try this:

train_data = tff.simulation.datasets.ClientData.from_clients_and_tf_fn(
        client_ids=train_client_ids,
        serializable_dataset_fn=create_tf_dataset_for_client_fn
    )
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
    )
LixL
  • 11
  • 1