Giter VIP home page Giter VIP logo

addressing-class-imbalance-fl's Introduction

Addressing Class Imbalance in Federated Learning

This is the code for our AAAI-2021 paper: Addressing Class Imbalance in Federated Learning.

Run the code

To run the monitoring scheme, you can

cd ./FEMNIST-monitor/
python3 main_nn.py

To load different loss functions on federated learning, you can

cd ./FEMNIST-4-Losses/
python3 main_nn.py --loss ce/focal/ratio/ghm

Citation

If you find our work is helpful for your research, please cite our paper.

@inproceedings{wang2021addressing,
  title={Addressing Class Imbalance in Federated Learning},
  author={Wang, Lixu and Xu, Shichao and Wang, Xiao and Zhu, Qi},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  volume={35},
  number={11},
  pages={10165--10173},
  year={2021}
}

addressing-class-imbalance-fl's People

Contributors

balanced-fl avatar conditionwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

addressing-class-imbalance-fl's Issues

some questions about the code

Thank you for providing your code. After reading your code, I have several questions and I really appreciate it if you could answer these questions for me.

(1) In the paper, it is said that a threshold is used to select components of W_p (set to 1.25 in experiments), but I did not find any trace of it in the codes.
(2) In the code below, I don't understand the reason for setting the ratio for class p to 10 when the denominator is zero, why it should be 10 and not some other numbers? Is there any other empirical observation to support that?

FEMNIST-monitor/models/Fed.py in whole_determination()
if aux_other_sum != 0:
            res = abs(aux_sum) / abs(aux_other_sum)  
        else:  
            res = 10  

(3) In the code, Np, the predicted number of classes p, is computed by the code below. It is confusing that the code computes the average value of Ra_pi by summing up all the nominators and denominators respectively and divides those two summations to get the ratio Ra_p for class p. Could you please explain why?

FEMNIST-monitor/models/Fed.py in whole_determination()
for it in range(26):
        cc_class = it
        aux_sum = 0
        aux_other_sum = 0
        layer = 1
        for i in range(pos.shape[1]):
            for j in range(pos.shape[2]):
                if pos[cc_class, i, j] == 1:
                    temp = []
                    last = w_glob_last['resnet.fc{}.weight'.format(layer)].cpu().numpy()[i, j]
                    cc = cc_net[cc_class]['resnet.fc{}.weight'.format(layer)].cpu().numpy()[i, j]
                    for p in range(len(cc_net)):
                        temp.append(cc_net[p]['resnet.fc{}.weight'.format(layer)].cpu().numpy()[i, j] - last)
                    temp = np.array(temp)
                    temp = np.delete(temp, cc_class)
                    temp_ave = np.sum(temp) / (len(cc_net) - 1)
                    aux_sum += cc - last
                    aux_other_sum += temp_ave
        if aux_other_sum != 0:
            res = abs(aux_sum) / abs(aux_other_sum)
        else:
            res = 10

(4) In the following code, why the predicted number of class p should be less than 1.5 times the average number of samples for each class?

FEMNIST-monitor/models/Fed.py in monitoring()

if 0 < res_temp < num_samples * 1.5 / num_class:
    temp_res.append(res_temp)

Thank you for your attention and any help/answers will be highly appreciated.

About the implementation code

Hello,I have read your paper, Addressing Class Imbalance in Federated Learning. It is really a wonderful idea! Will you open your source code? I'm looking forward to learning it! Thanks a lot!

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.