{"id":20068286,"url":"https://github.com/pliang279/lg-fedavg","last_synced_at":"2025-08-21T02:09:50.409Z","repository":{"id":37712355,"uuid":"226192688","full_name":"pliang279/LG-FedAvg","owner":"pliang279","description":"[NeurIPS 2019 FL workshop] Federated Learning with Local and Global Representations","archived":false,"fork":false,"pushed_at":"2024-07-25T10:13:45.000Z","size":11325,"stargazers_count":238,"open_issues_count":7,"forks_count":54,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-19T13:07:08.269Z","etag":null,"topics":["federated-learning","machine-learning","research"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pliang279.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-05T21:32:50.000Z","updated_at":"2025-05-19T03:16:06.000Z","dependencies_parsed_at":"2025-01-01T10:08:15.631Z","dependency_job_id":"8c92a1ce-7030-46cf-aaa1-22399c2f0964","html_url":"https://github.com/pliang279/LG-FedAvg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pliang279/LG-FedAvg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pliang279%2FLG-FedAvg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pliang279%2FLG-FedAvg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pliang279%2FLG-FedAvg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pliang279%2FLG-FedAvg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pliang279","download_url":"https://codeload.github.com/pliang279/LG-FedAvg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pliang279%2FLG-FedAvg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271415496,"owners_count":24755639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["federated-learning","machine-learning","research"],"created_at":"2024-11-13T14:06:00.629Z","updated_at":"2025-08-21T02:09:50.393Z","avatar_url":"https://github.com/pliang279.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Federated Learning with Local and Global Representations\n\n\u003e Pytorch implementation for federated learning with local and global representations.\n\nCorrespondence to: \n  - Paul Liang (pliang@cs.cmu.edu)\n  - Terrance Liu (terrancl@cs.cmu.edu)\n  \n## Paper\n\n[**Think Locally, Act Globally: Federated Learning with Local and Global Representations**](https://arxiv.org/abs/2001.01523)\u003cbr\u003e\n[Paul Pu Liang*](http://www.cs.cmu.edu/~pliang/), Terrance Liu*, [Liu Ziyin](http://cat.phys.s.u-tokyo.ac.jp/~zliu/), [Ruslan Salakhutdinov](https://www.cs.cmu.edu/~rsalakhu/), and [Louis-Philippe Morency](https://www.cs.cmu.edu/~morency/)\u003cbr\u003e\nNeurIPS 2019 Workshop on Federated Learning (distinguished student paper award). (*equal contribution)\n\nIf you find this repository useful, please cite our paper:\n```\n@article{liang2020think,\n  title={Think locally, act globally: Federated learning with local and global representations},\n  author={Liang, Paul Pu and Liu, Terrance and Ziyin, Liu and Salakhutdinov, Ruslan and Morency, Louis-Philippe},\n  journal={arXiv preprint arXiv:2001.01523},\n  year={2020}\n}\n```\n\n## Installation\n\nFirst check that the requirements are satisfied:\u003c/br\u003e\nPython 3.6\u003c/br\u003e\ntorch 1.2.0\u003c/br\u003e\ntorchvision 0.4.0\u003c/br\u003e\nnumpy 1.18.1\u003c/br\u003e\nsklearn 0.20.0\u003c/br\u003e\nmatplotlib 3.1.2\u003c/br\u003e\nPillow 4.1.1\u003c/br\u003e\n\nThe next step is to clone the repository:\n```bash\ngit clone https://github.com/pliang279/LG-FedAvg.git\n```\n\n## Data\n\nWe run FedAvg and LG-FedAvg experiments on MNIST ([link](http://yann.lecun.com/exdb/mnist/)) and CIFAR10 ([link](https://www.cs.toronto.edu/~kriz/cifar.html)). See our paper for a description how we process and partition the data for federated learning experiments.\n\n## FedAvg\n\nResults can be reproduced running the following:\n\n#### MNIST\n\u003e python main_fed.py --dataset mnist --model mlp --num_classes 10 --epochs 1000 --lr 0.05 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 10 --results_save run1\n\n#### CIFAR10 \n\u003e python main_fed.py --dataset cifar10 --model cnn --num_classes 10 --epochs 2000 --lr 0.1 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 50 --results_save run1\n\n## LG-FedAvg\n\nResults can be reproduced by first running the above commands for FedAvg and then running the following:\n\n#### MNIST \n\u003e python main_lg.py --dataset mnist --model mlp --num_classes 10 --epochs 200 --lr 0.05 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 10 --num_layers_keep 3 --results_save run1 --load_fed best_400.pt\n\n#### CIFAR10 \n\u003e python main_lg.py --dataset cifar10 --model cnn --num_classes 10 --epochs 200 --lr 0.1 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 50 --num_layers_keep 2 --results_save run1 --load_fed best_1200.pt\n\n## MTL\n\nResults can be reproduced running the following:\n\n#### MNIST \n\u003e python main_mtl.py --dataset mnist --model mlp --num_classes 10 --epochs 1000 --lr 0.05 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 10 --num_layers_keep 5 --results_save run1\n\n#### CIFAR10 \n\u003e python main_mtl.py --dataset cifar10 --model cnn --num_classes 10 --epochs 2000 --lr 0.1 --num_users 100 --shard_per_user 2 --frac 0.1 --local_ep 1 --local_bs 50 --num_layers_keep 5 --results_save run1\n\n\nIf you use this code, please cite our paper:\n\n```bash\n@article{liang2019_federated,\n  title={Think Locally, Act Globally: Federated Learning with Local and Global Representations},\n  author={Paul Pu Liang and Terrance Liu and Ziyin Liu and Ruslan Salakhutdinov and Louis-Philippe Morency},\n  journal={ArXiv},\n  year={2019},\n  volume={abs/2001.01523}\n}\n```\n\n# Acknowledgements\n\nThis codebase was adapted from https://github.com/shaoxiongji/federated-learning.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpliang279%2Flg-fedavg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpliang279%2Flg-fedavg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpliang279%2Flg-fedavg/lists"}