Model and Dataset Setup
Define the MLP classifier, build a synthetic labeled dataset, and split it into train and test sets.
Implement client partitioning, local SGD, weighted aggregation, partial participation, and non-IID experiments.
Every source step is its own lesson with intuition, concepts, correctly rendered MathJax mathematics, implementation, tests, mistakes, and a checkpoint.
Define the MLP classifier, build a synthetic labeled dataset, and split it into train and test sets.
Distribute the training data across clients using IID and non-IID strategies and report per-client sample counts.
Iterate over a client's batches and run forward, loss, backward, and optimizer steps to train locally for several epochs.
Clone, load, initialize, add, and scale model state dicts to build the sample-weighted FedAvg aggregation.
Select participating clients, run a full communication round, evaluate accuracy, and drive the multi-round FedAvg training loop.
Compare against a centralized baseline and study IID vs non-IID gaps, the effect of local epochs, and the impact of client fraction.