UNPKG

federer

Version:

Experiments in asynchronous federated learning and decentralized learning

78 lines 3.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runName = void 0; /** * Converts coordinator options to a short, unique name capturing all the * settings. * * This name is used to name runs in TensorBoard. */ function runName(options, cliOptions) { return combine(`K${cliOptions["number-clients"]}`, clientTrainingOptionsName(options.trainOptions), delayName(options.clientDelays), serverOptionsName(options.serverOptions), optimizerOptionsName(options.model.optimizer)); } exports.runName = runName; function clientTrainingOptionsName(options) { return combine(`B${options.batchSize}`, `E${options.epochs}`, learningRateScheduleName(options.learningRateSchedule)); } function learningRateScheduleName(options) { switch (options.type) { case "none": return ""; case "exponential": return combine("expdecay", options.stairCase ? "" : "linear", `from${options.initialLearningRate}`, optional("by", options.decayRate), optional("every", options.decayRounds)); } } function optimizerOptionsName(options) { switch (options.name) { case "adam": return combine(options.name, optional("β1=", options.beta1), optional("β2=", options.beta2), optional("ε", options.epsilon), optional("η", options.learningRate)); case "sgd": return combine(options.name, optional("η", options.learningRate)); } } function serverOptionsName(options) { switch (options.server) { case "FedAvg": case "LiFedAvg": return combine(options.server, `C${options.fractionOfClientsPerRound}`); case "FedAsync": return combine(options.server, ${options.epochDelay}`, ${options.alpha}`, stalenessOptionsName(options.staleness)); case "BatchedFedAsync": return combine(options.server, `n${options.numberClientsPerRound}`, `end${options.roundEndFraction}`, ${options.alpha}`); case "FedSemiSync": return combine(options.server, `n${options.numberClientsPerRound}`, `end${options.roundEndFraction}`, ${options.alpha}`, `a${options.a}`); case "FedCRDT": return combine(options.server, `n${options.numberClientsPerRound}`, `end${options.roundEndFraction}`, ${options.alpha}`, `a${options.a}`); } } function stalenessOptionsName(staleness) { switch (staleness.type) { case "Constant": return staleness.type; case "Hinge": return combine(staleness.type, `a${staleness.a}`, `b${staleness.b}`); case "Polynomial": return combine(staleness.type, `a${staleness.a}`); } } function delayName(options) { if (options === undefined) { return ""; } switch (options.type) { case "none": return ""; case "delay-groups": { const delays = options.groups.map((group) => `${Math.round(group.fraction * 100) / 100}@${group.delay}ms`); return `delays${delays.join(",")}`; } } } function optional(key, value) { if (value !== undefined) return `${key}${value}`; } function combine(...parts) { return parts.filter((x) => x !== undefined && x !== "").join("-"); } //# sourceMappingURL=run-name.js.map