conda env create -f environment.yml
Install necessary dependencies in environment.
-
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'
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 categoriesloaders/[DATASET_NAME]_[train|val|test]_loaders:dict[[client_id|cls_id], torch.data.utils.DataLoader]
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 fittingprocessed/[DATASET_NAME]_clusters.pkl:dict[cluster_id: str, list[client_id: str]], a dictionary of the predicted clusters after running theCOMMUNITY_DETECTION_ALGOon the association graph
Output files in data/:
data/model_weights/FL/model[cls_id]_weights.pth: trained cluster server's weights, to resume state dict
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.
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.