google/fedjax

Problem of Quick Start in Readme.md

Ichiruchan opened this issue · 2 comments

I tried to run the code in the QuickStart and I found some problems.
federated_data = fedjax.FederatedData() can not be executed because it is an abstract class. So I replaced it as

client_a_data = {
        'x': np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]),
        'y': np.array([7, 8])
    }
client_b_data = {'x': np.array([[9.0, 10.0, 11.0]]), 'y': np.array([12])}
client_to_data_mapping = {'a': client_a_data, 'b': client_b_data}
federated_data = fedjax.InMemoryFederatedData(client_to_data_mapping)

The other things are same as the QuickStart, but i got an error

for client_id, client_output, _ in func(shared_input, clients):
for client_id, client_batches, client_input in clients:
ValueError: not enough values to unpack (expected 3, got 2)

It seems that client_batches is missing and we need to batch the dataset, but there is no example which fits this situation.

kho commented

I would recommend looking at https://github.com/google/fedjax/blob/main/examples/emnist_fed_avg.py instead for a real working example.

Thanks for brining this to our attention!
I just submitted an update to our README so the code snippet is a working example #240
This code snippet is meant to just be a quick "hello world" example to make sure FedJAX is installed correctly.
As mentioned already, https://github.com/google/fedjax/blob/main/examples is the better place to look for real working examples.