UNPKG

federer

Version:

Experiments in asynchronous federated learning and decentralized learning

71 lines 2.96 kB
import * as tf from "@tensorflow/tfjs-node"; import { Logger } from "winston"; import { RoundSummary } from "../common"; import { CoordinatorOptions } from "./options/coordinator"; import { DataDistributionStats } from "./preprocess/distribution-stats"; import { PreprocessResult } from "./preprocess/PreprocessPipeline"; import { IPCServer } from "./network/IPCServer"; export declare type StopCondition = (results: RoundResults) => boolean; export interface RoundResults { readonly loss: number; readonly accuracy: number; readonly round: RoundSummary; } /** * The `Coordinator` class is the central piece of the coordinator node. It * manages: * * - Preprocessing, * - Starting nodes in the correct location, * - Setting up communication between nodes, * - Listening to results from the FL server and evaluating them, * - Writing results to TensorBoard. * * To do all these tasks, the coordinator uses a series of helper classes and * functions, including {@link TensorBoardOutput}, {@link ExperimentBuilder}, * {@link Experiment}, {@link Evaluator}, ... */ export declare abstract class Coordinator { protected readonly model: tf.Sequential; protected readonly ipc: IPCServer; protected readonly options: Readonly<CoordinatorOptions>; protected readonly logger: Logger; protected readonly stopCondition?: StopCondition | undefined; /** * Function to call when the `Promise` from {@link Coordinator.run} should be * resolved. This is `undefined` if no run is in progress. */ private resolveRun?; private unsubscribeNetworkEvents?; /** * The FL nodes that this coordinator controls. This is `undefined` if not all * nodes have connected yet. */ private network?; /** Writes to summary files that can be visualized in TensorBoard. */ private readonly tensorboard; /** Unique name of this experiment run, representing all options. */ protected readonly runName: string; constructor(model: tf.Sequential, ipc: IPCServer, options: Readonly<CoordinatorOptions>, logger: Logger, stopCondition?: StopCondition | undefined); run(): Promise<RoundResults>; /** Name of the experiment that the coordinator is running. */ protected abstract readonly experimentName: string; /** Runs the preprocessing pipeline and returns the result. */ protected abstract preprocessData(): Promise<PreprocessResult>; /** * Name of the experiment run, used for TensorBoard output. Must be unique for * the set of options. */ protected abstract getRunName(): string; /** * Saves `this.model` to a file. * * @returns A promise of the path to the saved model file */ private saveInitialModel; protected printDataDistributionStats(stats: DataDistributionStats): void; private checkStopCondition; private maybeBackupResults; cleanUp(): Promise<void>; } //# sourceMappingURL=Coordinator.d.ts.map