命令行接口

命令行接口#

我们提供了命令行接口(CLI)用于运行多个联邦学习实验。唯一参数是实验配置文件(YAML 格式)的路径。配置文件示例见 example-configs 目录。例如 all-alg-fedprox-femnist.yml 文件:

[example-configs/all-alg-fedprox-femnist.yml]
# Example config file for fl-sim command line interface

strategy:
matrix:
    algorithm:
    - Ditto
    - FedDR
    - FedAvg
    - FedAdam
    - FedProx
    - FedPD
    - FedSplit
    - IFCA
    - pFedMac
    - pFedMe
    - ProxSkip
    - SCAFFOLD
    clients_sample_ratio:
    - 0.1
    - 0.3
    - 0.7
    - 1.0

algorithm:
name: ${{ matrix.algorithm }}
server:
    num_clients: null
    clients_sample_ratio: ${{ matrix.clients_sample_ratio }}
    num_iters: 100
    p: 0.3  # for FedPD, ProxSkip
    lr: 0.03  # for SCAFFOLD
    num_clusters: 10  # for IFCA
    log_dir: all-alg-fedprox-femnist
client:
    lr: 0.03
    num_epochs: 10
    batch_size: null  # null for default batch size
    scheduler:
    name: step  # StepLR
    step_size: 1
    gamma: 0.99
dataset:
name: FedProxFEMNIST
datadir: null  # default dir
transform: none  # none for static transform (only normalization, no augmentation)
model:
name: cnn_femmist_tiny
seed: 0

其中 strategy (可选)一节指定网格搜索策略; algorithm 一节指定联邦学习算法的超参数: name 为算法名称, server 为服务器端的超参数, client 为客户端的超参数; dataset 一节指定数据集; model 一节指定要使用的具名模型(参见数据集类的 candidate_models 属性)。