Giter Site home page Giter Site logo

Comments (11)

codaibk avatar codaibk commented on September 16, 2024

Hi,
Is there any update or suggestion to fix this issue? because your cifar10 setting is only ok with 10 clients but not for flexible number of client. @ZacharyGarrett

from federated.

xjiajiahao avatar xjiajiahao commented on September 16, 2024

Hi,
Is there any update or suggestion to fix this issue? because your cifar10 setting is only ok with 10 clients but not for flexible number of client. @ZacharyGarrett

Hi,
I think there is a typo in the utils/datasets/cifar10_dataset.py file. The code on line 101 seems wrong.

for k in range(NUM_CLASSES):

The correct one should be

     for k in range(NUM_CLIENTS): 

from federated.

ZacharyGarrett avatar ZacharyGarrett commented on September 16, 2024

Thanks for investigating @xjiajiahao! Would you be willing to submit a pull request to make the change?

from federated.

codaibk avatar codaibk commented on September 16, 2024

@xjiajiahao @ZacharyGarrett Change only that line will not fix problem because the code determine train_client_samples based on "train_example_indices" index:
train_client_samples[k].append( train_example_indices[sampled_label, train_count[sampled_label]])
and train_example_indices size is set based on number of examples each class (5000 for train, 1000 for test)
When you change NUM_CLIENTS=> NUM_EXAMPLES_PER_CLIENT and TEST_SAMPLES_PER_CLIENT will be changed too. This one will make the error.

`for k in range(NUM_CLIENTS):

for i in range(NUM_EXAMPLES_PER_CLIENT):
  sampled_label = np.argwhere(
      np.random.multinomial(1, train_multinomial_vals[k, :]) == 1)[0][0]
  train_client_samples[k].append(
      train_example_indices[sampled_label, train_count[sampled_label]])
  train_count[sampled_label] += 1
  if train_count[sampled_label] == NUM_EXAMPLES_PER_CLIENT:
    train_multinomial_vals[:, sampled_label] = 0
    train_multinomial_vals = (
        train_multinomial_vals /
        train_multinomial_vals.sum(axis=1)[:, None])`
  • With NUM_CLIENTS < 10. The error is :`IndexError: index 5000 is out of bounds for axis 1 with size 5000
  • With NUM_CLIENTS > 10. The error is: np.random.multinomial(1, train_multinomial_vals[k, :]) == 1)[0][0] File "mtrand.pyx", line 4212, in numpy.random.mtrand.RandomState.multinomial File "_common.pyx", line 338, in numpy.random._common.check_array_constraint ValueError: pvals < 0, pvals > 1 or pvals contains NaNs

from federated.

zcharles8 avatar zcharles8 commented on September 16, 2024

@hsidahmed865 has kindly offered to take a look and potentially submit a fix, as they have been bumping up against this. Thanks @hsidahmed865!

from federated.

zcharles8 avatar zcharles8 commented on September 16, 2024

Hi @codaibk. This issue should have been fixed by commits 74fdc16 and 83b23c3. Can you confirm whether or not this fixed your problem?

from federated.

codaibk avatar codaibk commented on September 16, 2024

Sorry, but it does not fix the problem. The problem is that this code can't deal with flexible number of clients like I mentioned above. And you guys commits here don't change anything about algorithm but just only change the parameters. @zcharles8

from federated.

zcharles8 avatar zcharles8 commented on September 16, 2024

Hi @codaibk. Can you verify that your version of the repository includes the commit I listed above? They have added the functionality to allow the user to specify num_clients.

If so, can you run the following test using bazel: https://github.com/google-research/federated/blob/master/utils/datasets/cifar10_dataset_test.py

This test is passing for me, and explicitly tests num_clients = 8, num_clients = 10, and num_clients = 100.

from federated.

codaibk avatar codaibk commented on September 16, 2024

@zcharles8 . it seems you guys changed the run file run_federated.py in differential privacy folder too. The old file will call cifar10_dataset.py for generating data.
1
could you tell me what is the command for program running with cifar10_dataset_test.py?
Thanks.

from federated.

zcharles8 avatar zcharles8 commented on September 16, 2024

We recommend using Bazel (see https://bazel.build/). Once you have that configured, you can simply run bazel test {path to test}:{test_name} in order to run a test.

If you'd prefer to not use Bazel, you could run cifar10_dataset.load_cifar10_federated with different numbers of num_clients arguments, and make sure that you get a dataset with the requisite number of clients.

from federated.

zcharles8 avatar zcharles8 commented on September 16, 2024

Hi @codaibk. I am marking this as resolved for now, as it is working according to all of our tests. If you are still seeing errors, please post your full stack trace, as well as the commands that resulted in the error.

from federated.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.