2

I have a dataset written to an h5 file, and I want to convert it totff.simulation.datasets.ClientData,That is, after pre-processing it becomes this form <tensorflow_federated.python.simulation.datasets.client_data.PreprocessClientData at 0x7f00947f6f50>. A week ago, I was able to read it with this

train_path='FederatedClients/dataTrain.h5'
train_data = tff.simulation.HDF5ClientData(train_path)

but now, I get the following error with this statement again.

----------------------------------------------------------
AttributeError           Traceback (most recent call last)
<ipython-input-6-f4c34c62ca50> in <module>
      1 train_path='FederatedClients/dataTrain.h5'
      2 #train_data=pd.read_hdf(train_path)
----> 3 train_data = tff.simulation.HDF5ClientData(train_path)
      4 test_path='FederatedClients/dataTest.h5'
      5 test_data=pd.read_hdf(test_path)

AttributeError: module 'tensorflow_federated.python.simulation' has no attribute 'HDF5ClientData'

I don't know what to do anymore, I use the most basic panda to read the H5 file and I also get the error, TAT

train_data=pd.read_hdf(train_path)
----------------------------------------------------------
ValueError               Traceback (most recent call last)
<ipython-input-7-151fe098668c> in <module>
      1 train_path='FederatedClients/dataTrain.h5'
----> 2 train_data=pd.read_hdf(train_path)
      3 train_data = tff.simulation.HDF5ClientData(train_path)
      4 test_path='FederatedClients/dataTest.h5'
      5 test_data=pd.read_hdf(test_path)

~/anaconda3/envs/tff/lib/python3.7/site-packages/pandas/io/pytables.py in read_hdf(path_or_buf, key, mode, errors, where, start, stop, columns, iterator, chunksize, **kwargs)
    437             if len(groups) == 0:
    438                 raise ValueError(
--> 439                     "Dataset(s) incompatible with Pandas data types, "
    440                     "not table, or no datasets found in HDF5 file."
    441                 )

ValueError: Dataset(s) incompatible with Pandas data types, not table, or no datasets found in HDF5 file.

I would be grateful if you could solve my problem

1 Answer 1

1

TFF version 0.19.0 removed tff.simulation.HDF5ClientData (release notes). TFF datasets are now backed by SQLite instead of HDF5.

The HDF5 implementation could be recovered from https://github.com/tensorflow/federated/blob/v0.18.0/tensorflow_federated/python/simulation/hdf5_client_data.py. Copying that locally and replacing:

  • client_data.ClientData with tff.simulation.datasets.ClientData.
  • Remove py_typecheck and tensor_utils usage, they are not necessary.
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much for your answer. But when I did what you said, I had other error【---------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-18-c38025bbc72a> in <module> 1 train_path='FederatedClients/dataTrain.h5' 2 #train_data=pd.read_hdf(train_path) ----> 3 train_data = HDF5ClientData(train_path) 4 test_path='FederatedClients/dataTest.h5' 5 test_data=pd.read_hdf(test_path) TypeError: Can't instantiate abstract class HDF5ClientData with abstract methods serializable_dataset_fn】
I copy that locally and replace,when I use"train_path='FederatedClients/dataTrain.h5' train_data = HDF5ClientData(train_path)", the above error occurs. QAQ Thank you again for answering my confusion!!!
Hello, do you know why this error occurred? Again, I would like to ask for your help, thank you very much!!

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.