Skip to content
/ G2G Public
forked from NKU-EmbeddedSystem/G2G

This is the Official PyTorch implemention of our ICASSP2024 paper "G2G: Generalized Learning by Cross-Domain Knowledge Transfer for Federated Domain Generalization".

Notifications You must be signed in to change notification settings

JevenM/G2G

 
 

Repository files navigation

G2G

This is the Official PyTorch implemention of our ICASSP2024 paper "G2G: Generalized Learning by Cross-Domain Knowledge Transfer for Federated Domain Generalization".

G2G:Generalized Learning by Cross-Domain Knowledge Transfer for Federated Domain Generalization

Code to reproduce the experiments of G2G:Generalized Learning by Cross-Domain Knowledge Transfer for Federated Domain Generalization.

How to use it

  • Clone or download the repository

Install the requirement

pip install -r requirements.txt

Download VLCS, PACS and Office-Home datasets

(MEGA|Baiduyun)使用百度云下载下来5个mat文件,读取不了。只能又去百度搜索,找到http://www.mediafire.com/file/7yv132lgn1v267r/vlcs.tar.gz/file,在此下载

(PACS在这下载不了,没权限。去谷歌一下找到一个仓库,这里发布了新的谷歌云盘,下载成功:https://drive.google.com/drive/folders/0B6x7gtvErXgfUU1WcGY5SzdwZVk?resourcekey=0-2fvpQY_QSyJf2uIECzqPuQ,从这个仓库:https://github.com/MachineLearning2020/Homework3-PACS/tree/master/PACS也可以下载,但是只是纯图像的压缩包,还得自己手动划分训练集测试集,参考https://blog.csdn.net/qq_43827595/article/details/121345640。两种数据加载方式不同,一个是hdf5一个是raw images)

Download Pre-trained models

下面的三个数据集都是只有4个domain,所以设置node_num=3,每个客户端一个source domain,另一个作为target domain

Running ours on VLCS

pymao main_warm.py --node_num 3  --device cuda:0 --dataset vlcs --classes 5 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_mutual --R 50 --E 7 --pretrained True --batch_size 64 --iteration 0 

Running ours on PACS

pymao main_warm.py --node_num 3  --device cuda:0 --dataset pacs --classes 7 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_mutual --R 50 --E 7 --pretrained True --batch_size 32 --iteration 0 

Running ours on Office-Home

pymao main_warm.py --node_num 3 --device cuda:0 --dataset office-home --classes 65 --lr 0.0008 --global_model ResNet50 --local_model ResNet50 --algorithm fed_mutual --R 50 --E 7 --batch_size 32 --iteration 0 

My

VLCS

pymao main_warm.py --node_num 3  --device cuda:0 --dataset vlcs --classes 5 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_adv --R 50 --E 7 --pretrained True --batch_size 64 --iteration 0  

pymao main_warm.py --node_num 3 --device cuda:1 --dataset vlcs --classes 5 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_adv --R 60 --E 1 --pretrained True --batch_size 512 --iteration 3 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.001 --gen_lr 0.001 --cl_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 100

main_warm.py --node_num 3 --device cuda:0 --dataset vlcs --classes 5 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_adv --R 30 --E 5 --pretrained True --batch_size 32 --iteration 0 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.0001 --gen_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 0 --warm 0 --mnist_subset 5 --embedding_d 128 --latent_space 128 --optimizer sgd

RotatedMNIST

pymao main_warm.py --node_num 5 --device cuda:0 --dataset rotatedmnist --classes 10 --lr 0.001 --global_model SmallCNN --local_model SmallCNN --algorithm fed_mutual --R 60 --E 5 --pretrained True --batch_size 512 --iteration 5 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.001 --gen_lr 0.001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 10 --warm 0 --mnist_subset 5

20240614新版 pymao main_warm.py --node_num 5 --device cuda:0 --dataset rotatedmnist --classes 10 --lr 0.01 --global_model SmallCNN --local_model SmallCNN --algorithm fed_adv --R 100 --E 5 --batch_size 512 --iteration 1 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.001 --gen_lr 0.001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 100

PACS

pymao main_warm.py --node_num 3 --device cuda:1 --dataset pacs --classes 7 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_adv --R 60 --E 1 --pretrained True --batch_size 512 --iteration 2 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.001 --gen_lr 0.001 --cl_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 60 --optimizer adam

pymao main_warm.py --node_num 3 --device cuda:1 --dataset pacs --classes 7 --lr 0.0008 --global_model Resnet18 --local_model Resnet18 --algorithm fed_adg --R 60 --E 5 --batch_size 64 --iteration 3 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.0001 --gen_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 0 --warm 0 --mnist_subset 5 --embedding_d 128 --latent_space 128 --optimizer sgd --pin --pretrained

pymao main_warm.py --node_num 3 --device cuda:1 --dataset pacs --classes 7 --lr 0.01 --global_model Resnet18 --local_model Resnet18 --algorithm fed_sr --R 60 --E 5 --batch_size 64 --iteration 0 --method ssl --simclr_e 10 --gen_e 2 --discr_e 2 --disc_lr 0.0001 --gen_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 0 --warm 0 --mnist_subset 5 --embedding_d 128 --latent_space 128 --optimizer sgd --pin --pretrained

pymao main_warm.py --node_num 3 --device cuda:0 --dataset pacs --classes 7 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_sr --R 60 --E 1 --pretrained True --batch_size 512 --iteration 1 --method ssl --simclr_e 10 --gen_e 1 --discr_e 1 --disc_lr 0.001 --gen_lr 0.001 --cl_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 30 --optimizer adam --embedding_d 2048

pymao main_warm.py --node_num 3 --device cuda:0 --dataset pacs --classes 7 --lr 0.0008 --global_model Alexnet --local_model Alexnet --algorithm fed_adv --R 60 --E 1 --pretrained True --batch_size 512 --iteration 1 --method ssl --simclr_e 10 --gen_e 1 --discr_e 1 --disc_lr 0.001 --gen_lr 0.001 --cl_lr 0.0001 --cls_epochs 10 --cls_lr 0.001 --ce_epochs 30 --optimizer adam

About

This is the Official PyTorch implemention of our ICASSP2024 paper "G2G: Generalized Learning by Cross-Domain Knowledge Transfer for Federated Domain Generalization".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 97.9%
  • Python 2.1%