Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FederatedAD

Step 0: Settings, configurations

0.A environment.yml

conda env create -f environment.yml
Install necessary dependencies in environment.

0.B configs/*.yaml

  • DATASET_NAME: 'mnist' | unsw

  • NUM_CLIENTS_PER_CLASS: a multiple of (num_class-1), eg. 9 for MNIST (10 classes)

  • NUM_FEATURES: number of features after flattening, eg. 784 for 28*28 image input

  • INIT_MODEL: 'OCSVM' | 'IF' | [TBD] for clustering step

  • OUTLIER_FRACTION: determines percentage of outlier samples for each class

  • ASSOCIATION_THRESHOLD: given 2 clients belonging in the same cluster (ie. same inlier class), this determines how close their models' performance on each other's data must be

  • COMMUNITY_DETECTION_ALGO: 'edge_betweenness' | 'fast_and_greedy'

Step 1: Preprocessing

For example, python3 -m src.preprocess.main --dataset mnist
Read, flatten, normalize, partition (with shuffling) DATASET_NAME, load data (train, val, test).
Partition note: with NUM_CLIENTS_PER_CLASS = 9, MNIST will be divided into 90 clients. With OUTLIER_FRACTION = 0.1, each client's local dataset will contain 10% outlier samples.
Output files in data/:

  • processed/[DATASET_NAME]_partitioned_test.pkl: dict[cls, pandas.DataFrame]
  • processed/[DATASET_NAME]_partitioned_train.pkl: dict[cls, dict[client_id, pandas.DataFrame]]
  • attack_cat_mapping (for UNSW only): label encode mapping of attack categories
  • loaders/[DATASET_NAME]_[train|val|test]_loaders: dict[[client_id|cls_id], torch.data.utils.DataLoader]

Step 2: Clustering

For example, python3 -m src.clustering.main --dataset mnist
Output files in data/:

  • model_weights/clustering/[DATASET_NAME]_trained_clients.pkl: list[Client] after model fitting
  • processed/[DATASET_NAME]_clusters.pkl: dict[cluster_id: str, list[client_id: str]], a dictionary of the predicted clusters after running the COMMUNITY_DETECTION_ALGO on the association graph

Step 3: Federated Learning

Output files in data/:

  • data/model_weights/FL/model[cls_id]_weights.pth: trained cluster server's weights, to resume state dict

3.A Binary classification on one inlier class

For example, python3 -m src.FL.task --dataset mnist --cls 2
This will initialize one central server (class/cluster server) for class 2, and its local clients.

3.B Multi-class classification

For example, python3 -m src.FL.main --dataset mnist
Hierarchical federated system, with one central server, an intermediate server for each class, and local clients. This serves as a global task.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages