MCPcopy Index your code
hub / github.com/AI-secure/CRFL

github.com/AI-secure/CRFL @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
130 symbols 383 edges 19 files 9 documented · 7% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

CRFL

In this repository, code is for our ICML 2021 paper CRFL: Certifiably Robust Federated Learning against Backdoor Attacks

Installation

  1. Create a virtual environment via conda.

shell conda create -n crfl python=3.6 source activate crfl

  1. Install torch and torchvision according to your CUDA Version and the instructions at PyTorch. For example,

shell conda install pytorch cudatoolkit=10.1 torchvision -c pytorch

  1. Install requirements.

shell pip install -r requirements.txt

Dataset

  1. MNIST and EMNIST: MNIST and EMNIST datasets will be automatically downloaded into the dir ./data during training or testing.

  2. LOAN: Download the raw dataset loan.csv from Google Drive into the dir ./data.
    Run
    shell python utils/loan_preprocess.py We will get 51 csv files in ./data/loan/.

Get Started

  1. First, we training the FL models on the three datasets:
python main.py --params configs/mnist_params.yaml
python main.py --params configs/emnist_params.yaml
python main.py --params configs/loan_params.yaml

Hyperparameters can be changed according to the comments in those yaml files (configs/mnist_params.yaml,configs/emnist_params.yaml, configs/loan_params.yaml) to reproduce our experiments.

  1. Second, we perform parameter smoothing for the global models on the three datasets:
python smooth_mnist.py
python smooth_emnist.py
python smooth_loan.py

The filepaths of models can be changed in those yaml files (configs/mnist_smooth_params.yaml,configs/emnist_smooth_params.yaml, configs/loan_smooth_params.yaml) .

  1. Third, we plot the certified accuracy and certified rate for the three datasets:
python certify_mnist.py
python certify_emnist.py
python certify_loan.py

Citation

If you find our work useful in your research, please consider citing:

@InProceedings{pmlr-v139-xie21a,
  title =    {CRFL: Certifiably Robust Federated Learning against Backdoor Attacks},
  author =       {Xie, Chulin and Chen, Minghao and Chen, Pin-Yu and Li, Bo},
  booktitle =    {Proceedings of the 38th International Conference on Machine Learning},
  pages =    {11372--11382},
  year =     {2021},
  volume =   {139},
  series =   {Proceedings of Machine Learning Research},
  month =    {18--24 Jul},
  publisher =    {PMLR},
  pdf =      {http://proceedings.mlr.press/v139/xie21a/xie21a.pdf},
  url =      {http://proceedings.mlr.press/v139/xie21a.html},
}

Core symbols most depended-on inside this repo

get_batch
called by 10
utils/loan_helper.py
get_poison_batch
called by 7
utils/loan_helper.py
load_data
called by 6
utils/loan_helper.py
get_testloader
called by 5
utils/loan_helper.py
eval_model
called by 4
smooth_mnist.py
create_model
called by 4
utils/loan_helper.py
SetIsTrain
called by 4
utils/loan_helper.py
save_checkpoint
called by 4
utils/helper.py

Shape

Method 73
Function 34
Class 23

Languages

Python100%

Modules by API surface

utils/loan_helper.py20 symbols
certify_mnist.py16 symbols
certify_loan.py16 symbols
certify_emnist.py16 symbols
utils/helper.py12 symbols
utils/image_helper.py11 symbols
smooth_mnist.py5 symbols
smooth_loan.py5 symbols
smooth_emnist.py5 symbols
models/MnistNet.py5 symbols
models/EmnistNet.py5 symbols
utils/csv_record.py4 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add CRFL \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact