# Supported datasets: **CIFAR-10**, **Synthetic**, **Shakespeare**.

---

## Repository Structure

```
.
├── gen_data.py            # Dataset generation (CIFAR-10 and Synthetic)
├── gen_shakespeare.py     # Dataset preparation for Shakespeare (wraps LEAF)
├── gen_shadow.py          # Shadow experiment: builds candidate dropout index list
├── main.py                # Main training entry point
├── run_experiments.sh     # End-to-end script to reproduce all results
├── configuration.py       # Argument parser shared by main.py
├── language_utils.py      # Character-level encoding utilities (Shakespeare)
├── algorithm/
│   ├── __init__.py        # Base trainer class and trainer selection logic
│   ├── fedavg_trainer.py      # FedAvg / FedProx trainer
│   ├── fedavg_var_trainer.py  # FedAvg_var / FedProx_var trainer
│   ├── mifa_trainer.py        # MIFA trainer
│   ├── gm_trainer.py          # Geometric Median (GM / bucketing_gm) trainer
│   └── cclip_trainer.py       # Centered Clipping (cclip / bucketing_cclip) trainer
├── backend/
│   ├── Client.py          # Client-side local training
│   └── Server.py          # Server-side aggregation and evaluation
├── model/
│   ├── lenet.py           # LeNet-5 for CIFAR-10
│   ├── logistic.py        # Logistic regression for Synthetic data
│   └── charlstm.py        # Stacked LSTM for Shakespeare (next-character prediction)
├── optimizer/
│   └── __init__.py        # FedProx proximal SGD optimizer
└── utils/
    └── function.py        # Data loading, aggregation helpers, observation utilities
```

---

## Supported Algorithms

| `--algorithm` value | Description |
|---|---|
| `FedAvg` | Federated Averaging with standard SGD local solver |
| `FedAvg_var` | FedAvg variant: uses an adaptive global stepsize `Beta` in aggregation |
| `FedProx` | FedAvg with a proximal term `mu` added to the local objective |
| `FedProx_var` | FedProx local solver combined with the `FedAvg_var` aggregation rule |
| `MIFA` | Mean Iterative Federated Algorithm with gradient tracking |
| `gm` | Robust aggregation via the smoothed Weiszfeld (Geometric Median) algorithm |
| `bucketing_gm` | Bucketed variant of GM: clients are grouped before computing the median |
| `cclip` | Byzantine-robust aggregation via iterative centered clipping |
| `bucketing_cclip` | Bucketed variant of cclip |

**Aggregation rules:**
- `FedAvg`: $x = \sum\_{i}(x\_{i} \cdot n\_{i}) / \sum\_{i}(n\_{i})$
- `FedAvg_var`: $x = x + \beta \cdot \sum\_{i}(x\_{i} - x) \cdot n\_{i} / \sum\_{i}(n\_{i})$