federer
Version:
Experiments in asynchronous federated learning and decentralized learning
47 lines • 2.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MnistCoordinator = void 0;
const assert = require("assert");
const coordinator_1 = require("../../../coordinator");
const cli_1 = require("../../../coordinator/cli");
const model_1 = require("./model");
const preprocess_1 = require("./preprocess");
const mnist_run_name_1 = require("./mnist-run-name");
class MnistCoordinator extends coordinator_1.Coordinator {
constructor(options, ipc, logger, stopCondition) {
checkMnistOptions(options);
const modelOptions = {
...options.model,
numberOutputClasses: options.numberLabelClasses,
};
super(model_1.createModel(modelOptions), ipc, options, logger, stopCondition);
this.experimentName = options.dataset;
this.options = options;
this.modelOptions = modelOptions;
}
async preprocessData() {
const result = await preprocess_1.preprocess({
dataset: this.options.dataset,
modelName: this.options.model.name,
numberLabelClasses: this.options.numberLabelClasses,
numberClients: cli_1.CoordinatorCLIOptions.get("number-clients"),
environment: cli_1.CoordinatorCLIOptions.get("environment"),
numberDigitBatchesPerClient: this.options.numberDigitBatchesPerClient,
shardingOptions: this.options.shardingOptions,
});
return result;
}
getRunName() {
return mnist_run_name_1.mnistRunName(this.options, cli_1.CoordinatorCLIOptions.getAll());
}
}
exports.MnistCoordinator = MnistCoordinator;
/** Check the options that aren't already checked by the superclass. */
function checkMnistOptions(options) {
assert(Number.isInteger(options.numberLabelClasses));
assert(options.numberLabelClasses > 0);
assert(options.numberLabelClasses <= 10);
assert(Number.isInteger(options.numberDigitBatchesPerClient));
assert(options.numberDigitBatchesPerClient > 0);
}
//# sourceMappingURL=MnistCoordinator.js.map