@epfml/discojs 1.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -8
- package/dist/{async_buffer.d.ts → core/async_buffer.d.ts} +3 -3
- package/dist/{async_buffer.js → core/async_buffer.js} +5 -6
- package/dist/{async_informant.d.ts → core/async_informant.d.ts} +0 -0
- package/dist/{async_informant.js → core/async_informant.js} +0 -0
- package/dist/{client → core/client}/base.d.ts +4 -7
- package/dist/{client → core/client}/base.js +3 -2
- package/dist/core/client/decentralized/base.d.ts +32 -0
- package/dist/core/client/decentralized/base.js +212 -0
- package/dist/core/client/decentralized/clear_text.d.ts +14 -0
- package/dist/core/client/decentralized/clear_text.js +96 -0
- package/dist/{client → core/client}/decentralized/index.d.ts +0 -0
- package/dist/{client → core/client}/decentralized/index.js +0 -0
- package/dist/core/client/decentralized/messages.d.ts +41 -0
- package/dist/core/client/decentralized/messages.js +54 -0
- package/dist/core/client/decentralized/peer.d.ts +26 -0
- package/dist/core/client/decentralized/peer.js +210 -0
- package/dist/core/client/decentralized/peer_pool.d.ts +14 -0
- package/dist/core/client/decentralized/peer_pool.js +92 -0
- package/dist/core/client/decentralized/sec_agg.d.ts +22 -0
- package/dist/core/client/decentralized/sec_agg.js +190 -0
- package/dist/core/client/decentralized/secret_shares.d.ts +3 -0
- package/dist/core/client/decentralized/secret_shares.js +39 -0
- package/dist/core/client/decentralized/types.d.ts +2 -0
- package/dist/core/client/decentralized/types.js +7 -0
- package/dist/core/client/event_connection.d.ts +37 -0
- package/dist/core/client/event_connection.js +158 -0
- package/dist/core/client/federated/client.d.ts +37 -0
- package/dist/core/client/federated/client.js +273 -0
- package/dist/core/client/federated/index.d.ts +2 -0
- package/dist/core/client/federated/index.js +7 -0
- package/dist/core/client/federated/messages.d.ts +38 -0
- package/dist/core/client/federated/messages.js +25 -0
- package/dist/{client → core/client}/index.d.ts +2 -1
- package/dist/{client → core/client}/index.js +3 -3
- package/dist/{client → core/client}/local.d.ts +2 -2
- package/dist/{client → core/client}/local.js +0 -0
- package/dist/core/client/messages.d.ts +28 -0
- package/dist/core/client/messages.js +33 -0
- package/dist/core/client/utils.d.ts +2 -0
- package/dist/core/client/utils.js +19 -0
- package/dist/core/dataset/data/data.d.ts +11 -0
- package/dist/core/dataset/data/data.js +20 -0
- package/dist/core/dataset/data/data_split.d.ts +5 -0
- package/dist/{client/decentralized/types.js → core/dataset/data/data_split.js} +0 -0
- package/dist/core/dataset/data/image_data.d.ts +8 -0
- package/dist/core/dataset/data/image_data.js +64 -0
- package/dist/core/dataset/data/index.d.ts +5 -0
- package/dist/core/dataset/data/index.js +11 -0
- package/dist/core/dataset/data/preprocessing.d.ts +13 -0
- package/dist/core/dataset/data/preprocessing.js +33 -0
- package/dist/core/dataset/data/tabular_data.d.ts +8 -0
- package/dist/core/dataset/data/tabular_data.js +40 -0
- package/dist/{dataset → core/dataset}/data_loader/data_loader.d.ts +4 -11
- package/dist/{dataset → core/dataset}/data_loader/data_loader.js +0 -0
- package/dist/core/dataset/data_loader/image_loader.d.ts +17 -0
- package/dist/core/dataset/data_loader/image_loader.js +141 -0
- package/dist/core/dataset/data_loader/index.d.ts +3 -0
- package/dist/core/dataset/data_loader/index.js +9 -0
- package/dist/core/dataset/data_loader/tabular_loader.d.ts +29 -0
- package/dist/core/dataset/data_loader/tabular_loader.js +101 -0
- package/dist/core/dataset/dataset.d.ts +2 -0
- package/dist/{task/training_information.js → core/dataset/dataset.js} +0 -0
- package/dist/{dataset → core/dataset}/dataset_builder.d.ts +5 -5
- package/dist/{dataset → core/dataset}/dataset_builder.js +14 -10
- package/dist/core/dataset/index.d.ts +4 -0
- package/dist/core/dataset/index.js +14 -0
- package/dist/core/default_tasks/cifar10.d.ts +2 -0
- package/dist/core/default_tasks/cifar10.js +68 -0
- package/dist/core/default_tasks/geotags.d.ts +2 -0
- package/dist/core/default_tasks/geotags.js +69 -0
- package/dist/core/default_tasks/index.d.ts +6 -0
- package/dist/core/default_tasks/index.js +15 -0
- package/dist/core/default_tasks/lus_covid.d.ts +2 -0
- package/dist/core/default_tasks/lus_covid.js +96 -0
- package/dist/core/default_tasks/mnist.d.ts +2 -0
- package/dist/core/default_tasks/mnist.js +69 -0
- package/dist/core/default_tasks/simple_face.d.ts +2 -0
- package/dist/core/default_tasks/simple_face.js +53 -0
- package/dist/core/default_tasks/titanic.d.ts +2 -0
- package/dist/core/default_tasks/titanic.js +97 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/index.js +39 -0
- package/dist/{informant → core/informant}/graph_informant.d.ts +0 -0
- package/dist/{informant → core/informant}/graph_informant.js +0 -0
- package/dist/{informant → core/informant}/index.d.ts +0 -0
- package/dist/{informant → core/informant}/index.js +0 -0
- package/dist/{informant → core/informant}/training_informant/base.d.ts +3 -3
- package/dist/{informant → core/informant}/training_informant/base.js +3 -2
- package/dist/{informant → core/informant}/training_informant/decentralized.d.ts +0 -0
- package/dist/{informant → core/informant}/training_informant/decentralized.js +0 -0
- package/dist/{informant → core/informant}/training_informant/federated.d.ts +0 -0
- package/dist/{informant → core/informant}/training_informant/federated.js +0 -0
- package/dist/{informant → core/informant}/training_informant/index.d.ts +0 -0
- package/dist/{informant → core/informant}/training_informant/index.js +0 -0
- package/dist/{informant → core/informant}/training_informant/local.d.ts +2 -2
- package/dist/{informant → core/informant}/training_informant/local.js +2 -2
- package/dist/{logging → core/logging}/console_logger.d.ts +0 -0
- package/dist/{logging → core/logging}/console_logger.js +0 -0
- package/dist/{logging → core/logging}/index.d.ts +0 -0
- package/dist/{logging → core/logging}/index.js +0 -0
- package/dist/{logging → core/logging}/logger.d.ts +0 -0
- package/dist/{logging → core/logging}/logger.js +0 -0
- package/dist/{logging → core/logging}/trainer_logger.d.ts +0 -0
- package/dist/{logging → core/logging}/trainer_logger.js +0 -0
- package/dist/{memory → core/memory}/base.d.ts +2 -2
- package/dist/{memory → core/memory}/base.js +0 -0
- package/dist/{memory → core/memory}/empty.d.ts +0 -0
- package/dist/{memory → core/memory}/empty.js +0 -0
- package/dist/core/memory/index.d.ts +3 -0
- package/dist/core/memory/index.js +9 -0
- package/dist/{memory → core/memory}/model_type.d.ts +0 -0
- package/dist/{memory → core/memory}/model_type.js +0 -0
- package/dist/{privacy.d.ts → core/privacy.d.ts} +2 -3
- package/dist/{privacy.js → core/privacy.js} +3 -16
- package/dist/{serialization → core/serialization}/index.d.ts +0 -0
- package/dist/{serialization → core/serialization}/index.js +0 -0
- package/dist/{serialization → core/serialization}/model.d.ts +0 -0
- package/dist/{serialization → core/serialization}/model.js +0 -0
- package/dist/core/serialization/weights.d.ts +5 -0
- package/dist/{serialization → core/serialization}/weights.js +11 -9
- package/dist/{task → core/task}/data_example.d.ts +0 -0
- package/dist/{task → core/task}/data_example.js +0 -0
- package/dist/core/task/digest.d.ts +5 -0
- package/dist/core/task/digest.js +18 -0
- package/dist/{task → core/task}/display_information.d.ts +5 -5
- package/dist/{task → core/task}/display_information.js +5 -10
- package/dist/{task → core/task}/index.d.ts +3 -0
- package/dist/core/task/index.js +15 -0
- package/dist/core/task/model_compile_data.d.ts +6 -0
- package/dist/core/task/model_compile_data.js +22 -0
- package/dist/{task → core/task}/summary.d.ts +0 -0
- package/dist/{task → core/task}/summary.js +0 -4
- package/dist/{task → core/task}/task.d.ts +4 -2
- package/dist/{task → core/task}/task.js +10 -7
- package/dist/core/task/task_handler.d.ts +5 -0
- package/dist/core/task/task_handler.js +53 -0
- package/dist/core/task/task_provider.d.ts +6 -0
- package/dist/core/task/task_provider.js +13 -0
- package/dist/{task → core/task}/training_information.d.ts +10 -14
- package/dist/core/task/training_information.js +66 -0
- package/dist/core/training/disco.d.ts +23 -0
- package/dist/core/training/disco.js +130 -0
- package/dist/{training → core/training}/index.d.ts +0 -0
- package/dist/{training → core/training}/index.js +0 -0
- package/dist/{training → core/training}/trainer/distributed_trainer.d.ts +1 -2
- package/dist/{training → core/training}/trainer/distributed_trainer.js +6 -5
- package/dist/{training → core/training}/trainer/local_trainer.d.ts +2 -2
- package/dist/{training → core/training}/trainer/local_trainer.js +0 -0
- package/dist/{training → core/training}/trainer/round_tracker.d.ts +0 -0
- package/dist/{training → core/training}/trainer/round_tracker.js +0 -0
- package/dist/{training → core/training}/trainer/trainer.d.ts +1 -2
- package/dist/{training → core/training}/trainer/trainer.js +2 -2
- package/dist/{training → core/training}/trainer/trainer_builder.d.ts +0 -0
- package/dist/{training → core/training}/trainer/trainer_builder.js +0 -0
- package/dist/core/training/training_schemes.d.ts +5 -0
- package/dist/{training → core/training}/training_schemes.js +2 -2
- package/dist/{types.d.ts → core/types.d.ts} +0 -0
- package/dist/{types.js → core/types.js} +0 -0
- package/dist/{validation → core/validation}/index.d.ts +0 -0
- package/dist/{validation → core/validation}/index.js +0 -0
- package/dist/{validation → core/validation}/validator.d.ts +5 -8
- package/dist/{validation → core/validation}/validator.js +9 -11
- package/dist/core/weights/aggregation.d.ts +7 -0
- package/dist/core/weights/aggregation.js +72 -0
- package/dist/core/weights/index.d.ts +2 -0
- package/dist/core/weights/index.js +7 -0
- package/dist/core/weights/weights_container.d.ts +19 -0
- package/dist/core/weights/weights_container.js +64 -0
- package/dist/dataset/data_loader/image_loader.d.ts +3 -15
- package/dist/dataset/data_loader/image_loader.js +12 -125
- package/dist/dataset/data_loader/index.d.ts +2 -3
- package/dist/dataset/data_loader/index.js +3 -5
- package/dist/dataset/data_loader/tabular_loader.d.ts +3 -28
- package/dist/dataset/data_loader/tabular_loader.js +11 -92
- package/dist/imports.d.ts +2 -0
- package/dist/imports.js +7 -0
- package/dist/index.d.ts +2 -19
- package/dist/index.js +3 -39
- package/dist/memory/index.d.ts +1 -3
- package/dist/memory/index.js +3 -7
- package/dist/memory/memory.d.ts +26 -0
- package/dist/memory/memory.js +160 -0
- package/package.json +13 -26
- package/dist/aggregation.d.ts +0 -5
- package/dist/aggregation.js +0 -33
- package/dist/client/decentralized/base.d.ts +0 -43
- package/dist/client/decentralized/base.js +0 -243
- package/dist/client/decentralized/clear_text.d.ts +0 -13
- package/dist/client/decentralized/clear_text.js +0 -78
- package/dist/client/decentralized/messages.d.ts +0 -37
- package/dist/client/decentralized/messages.js +0 -15
- package/dist/client/decentralized/sec_agg.d.ts +0 -18
- package/dist/client/decentralized/sec_agg.js +0 -169
- package/dist/client/decentralized/secret_shares.d.ts +0 -5
- package/dist/client/decentralized/secret_shares.js +0 -58
- package/dist/client/decentralized/types.d.ts +0 -1
- package/dist/client/federated.d.ts +0 -30
- package/dist/client/federated.js +0 -218
- package/dist/dataset/index.d.ts +0 -2
- package/dist/dataset/index.js +0 -7
- package/dist/model_actor.d.ts +0 -16
- package/dist/model_actor.js +0 -20
- package/dist/serialization/weights.d.ts +0 -5
- package/dist/task/index.js +0 -8
- package/dist/task/model_compile_data.d.ts +0 -6
- package/dist/task/model_compile_data.js +0 -12
- package/dist/tasks/cifar10.d.ts +0 -4
- package/dist/tasks/cifar10.js +0 -76
- package/dist/tasks/index.d.ts +0 -5
- package/dist/tasks/index.js +0 -9
- package/dist/tasks/lus_covid.d.ts +0 -4
- package/dist/tasks/lus_covid.js +0 -85
- package/dist/tasks/mnist.d.ts +0 -4
- package/dist/tasks/mnist.js +0 -58
- package/dist/tasks/simple_face.d.ts +0 -4
- package/dist/tasks/simple_face.js +0 -84
- package/dist/tasks/titanic.d.ts +0 -4
- package/dist/tasks/titanic.js +0 -88
- package/dist/tfjs.d.ts +0 -2
- package/dist/tfjs.js +0 -6
- package/dist/training/disco.d.ts +0 -14
- package/dist/training/disco.js +0 -70
- package/dist/training/training_schemes.d.ts +0 -5
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultTasks = exports.Validator = exports.TrainingSchemes = exports.Disco = exports.EmptyMemory = exports.ModelType = exports.Memory = exports.TrainerLog = exports.ConsoleLogger = exports.Logger = exports.AsyncInformant = exports.AsyncBuffer = exports.aggregation = exports.WeightsContainer = exports.client = exports.Client = exports.informant = exports.TrainingInformant = exports.GraphInformant = exports.privacy = exports.training = exports.serialization = exports.data = exports.tf = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
exports.tf = (0, tslib_1.__importStar)(require("@tensorflow/tfjs"));
|
|
6
|
+
exports.data = (0, tslib_1.__importStar)(require("./dataset"));
|
|
7
|
+
exports.serialization = (0, tslib_1.__importStar)(require("./serialization"));
|
|
8
|
+
exports.training = (0, tslib_1.__importStar)(require("./training"));
|
|
9
|
+
exports.privacy = (0, tslib_1.__importStar)(require("./privacy"));
|
|
10
|
+
var informant_1 = require("./informant");
|
|
11
|
+
Object.defineProperty(exports, "GraphInformant", { enumerable: true, get: function () { return informant_1.GraphInformant; } });
|
|
12
|
+
Object.defineProperty(exports, "TrainingInformant", { enumerable: true, get: function () { return informant_1.TrainingInformant; } });
|
|
13
|
+
Object.defineProperty(exports, "informant", { enumerable: true, get: function () { return informant_1.informant; } });
|
|
14
|
+
var client_1 = require("./client");
|
|
15
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Base; } });
|
|
16
|
+
exports.client = (0, tslib_1.__importStar)(require("./client"));
|
|
17
|
+
var weights_1 = require("./weights");
|
|
18
|
+
Object.defineProperty(exports, "WeightsContainer", { enumerable: true, get: function () { return weights_1.WeightsContainer; } });
|
|
19
|
+
Object.defineProperty(exports, "aggregation", { enumerable: true, get: function () { return weights_1.aggregation; } });
|
|
20
|
+
var async_buffer_1 = require("./async_buffer");
|
|
21
|
+
Object.defineProperty(exports, "AsyncBuffer", { enumerable: true, get: function () { return async_buffer_1.AsyncBuffer; } });
|
|
22
|
+
var async_informant_1 = require("./async_informant");
|
|
23
|
+
Object.defineProperty(exports, "AsyncInformant", { enumerable: true, get: function () { return async_informant_1.AsyncInformant; } });
|
|
24
|
+
var logging_1 = require("./logging");
|
|
25
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logging_1.Logger; } });
|
|
26
|
+
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return logging_1.ConsoleLogger; } });
|
|
27
|
+
Object.defineProperty(exports, "TrainerLog", { enumerable: true, get: function () { return logging_1.TrainerLog; } });
|
|
28
|
+
var memory_1 = require("./memory");
|
|
29
|
+
Object.defineProperty(exports, "Memory", { enumerable: true, get: function () { return memory_1.Memory; } });
|
|
30
|
+
Object.defineProperty(exports, "ModelType", { enumerable: true, get: function () { return memory_1.ModelType; } });
|
|
31
|
+
Object.defineProperty(exports, "EmptyMemory", { enumerable: true, get: function () { return memory_1.Empty; } });
|
|
32
|
+
var training_1 = require("./training");
|
|
33
|
+
Object.defineProperty(exports, "Disco", { enumerable: true, get: function () { return training_1.Disco; } });
|
|
34
|
+
Object.defineProperty(exports, "TrainingSchemes", { enumerable: true, get: function () { return training_1.TrainingSchemes; } });
|
|
35
|
+
var validation_1 = require("./validation");
|
|
36
|
+
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return validation_1.Validator; } });
|
|
37
|
+
(0, tslib_1.__exportStar)(require("./task"), exports);
|
|
38
|
+
exports.defaultTasks = (0, tslib_1.__importStar)(require("./default_tasks"));
|
|
39
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { List } from 'immutable';
|
|
2
|
-
import {
|
|
2
|
+
import { Task } from '../../task';
|
|
3
3
|
import { GraphInformant } from '../graph_informant';
|
|
4
4
|
export declare abstract class Base {
|
|
5
|
-
readonly
|
|
5
|
+
readonly task: Task;
|
|
6
6
|
private readonly nbrMessagesToShow;
|
|
7
7
|
private messages;
|
|
8
8
|
protected readonly trainingGraphInformant: GraphInformant;
|
|
@@ -11,7 +11,7 @@ export declare abstract class Base {
|
|
|
11
11
|
protected currentNumberOfParticipants: number;
|
|
12
12
|
protected totalNumberOfParticipants: number;
|
|
13
13
|
protected averageNumberOfParticipants: number;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(task: Task, nbrMessagesToShow?: number);
|
|
15
15
|
abstract update(statistics: Record<string, number>): void;
|
|
16
16
|
addMessage(msg: string): void;
|
|
17
17
|
getMessages(): string[];
|
|
@@ -4,8 +4,9 @@ exports.Base = void 0;
|
|
|
4
4
|
var immutable_1 = require("immutable");
|
|
5
5
|
var graph_informant_1 = require("../graph_informant");
|
|
6
6
|
var Base = /** @class */ (function () {
|
|
7
|
-
function Base(
|
|
8
|
-
|
|
7
|
+
function Base(task, nbrMessagesToShow) {
|
|
8
|
+
if (nbrMessagesToShow === void 0) { nbrMessagesToShow = 10; }
|
|
9
|
+
this.task = task;
|
|
9
10
|
this.nbrMessagesToShow = nbrMessagesToShow;
|
|
10
11
|
// written feedback
|
|
11
12
|
this.messages = (0, immutable_1.List)();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Task } from '../../task';
|
|
2
2
|
import { Base } from '.';
|
|
3
3
|
export declare class LocalInformant extends Base {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(task: Task, nbrMessagesToShow?: number);
|
|
5
5
|
update(statistics: Record<string, number>): void;
|
|
6
6
|
}
|
|
@@ -5,8 +5,8 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var _1 = require(".");
|
|
6
6
|
var LocalInformant = /** @class */ (function (_super) {
|
|
7
7
|
(0, tslib_1.__extends)(LocalInformant, _super);
|
|
8
|
-
function LocalInformant(
|
|
9
|
-
var _this = _super.call(this,
|
|
8
|
+
function LocalInformant(task, nbrMessagesToShow) {
|
|
9
|
+
var _this = _super.call(this, task, nbrMessagesToShow) || this;
|
|
10
10
|
_this.currentNumberOfParticipants = 1;
|
|
11
11
|
_this.averageNumberOfParticipants = 1;
|
|
12
12
|
_this.totalNumberOfParticipants = 1;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,14 +5,14 @@ export declare type Path = string;
|
|
|
5
5
|
export interface ModelInfo {
|
|
6
6
|
type?: ModelType;
|
|
7
7
|
taskID: TaskID;
|
|
8
|
-
name
|
|
8
|
+
name: string;
|
|
9
9
|
}
|
|
10
10
|
export declare type ModelSource = ModelInfo | Path;
|
|
11
11
|
export declare abstract class Memory {
|
|
12
12
|
abstract getModel(source: ModelSource): Promise<tf.LayersModel>;
|
|
13
13
|
abstract deleteModel(source: ModelSource): Promise<void>;
|
|
14
14
|
abstract loadModel(source: ModelSource): Promise<void>;
|
|
15
|
-
abstract getModelMetadata(source: ModelSource): Promise<
|
|
15
|
+
abstract getModelMetadata(source: ModelSource): Promise<object | undefined>;
|
|
16
16
|
abstract updateWorkingModel(source: ModelSource, model: tf.LayersModel): Promise<void>;
|
|
17
17
|
abstract saveWorkingModel(source: ModelSource): Promise<void>;
|
|
18
18
|
abstract downloadModel(source: ModelSource): Promise<void>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelType = exports.Memory = exports.Empty = void 0;
|
|
4
|
+
var empty_1 = require("./empty");
|
|
5
|
+
Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return empty_1.Empty; } });
|
|
6
|
+
var base_1 = require("./base");
|
|
7
|
+
Object.defineProperty(exports, "Memory", { enumerable: true, get: function () { return base_1.Memory; } });
|
|
8
|
+
var model_type_1 = require("./model_type");
|
|
9
|
+
Object.defineProperty(exports, "ModelType", { enumerable: true, get: function () { return model_type_1.ModelType; } });
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Task } from '@/task';
|
|
1
|
+
import { Task, WeightsContainer } from '.';
|
|
3
2
|
/**
|
|
4
3
|
* Add task-parametrized Gaussian noise to and clip the weights update between the previous and current rounds.
|
|
5
4
|
* The previous round's weights are the last weights pulled from server/peers.
|
|
@@ -9,4 +8,4 @@ import { Task } from '@/task';
|
|
|
9
8
|
* @param task the task
|
|
10
9
|
* @returns the noised weights for the current round
|
|
11
10
|
*/
|
|
12
|
-
export declare function addDifferentialPrivacy(updatedWeights:
|
|
11
|
+
export declare function addDifferentialPrivacy(updatedWeights: WeightsContainer, staleWeights: WeightsContainer, task: Task): WeightsContainer;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDifferentialPrivacy = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var immutable_1 = require("immutable");
|
|
6
4
|
var _1 = require(".");
|
|
7
5
|
/**
|
|
8
6
|
* Add task-parametrized Gaussian noise to and clip the weights update between the previous and current rounds.
|
|
@@ -17,16 +15,11 @@ function addDifferentialPrivacy(updatedWeights, staleWeights, task) {
|
|
|
17
15
|
var _a, _b;
|
|
18
16
|
var noiseScale = (_a = task.trainingInformation) === null || _a === void 0 ? void 0 : _a.noiseScale;
|
|
19
17
|
var clippingRadius = (_b = task.trainingInformation) === null || _b === void 0 ? void 0 : _b.clippingRadius;
|
|
20
|
-
var weightsDiff =
|
|
21
|
-
.zip((0, immutable_1.List)(staleWeights))
|
|
22
|
-
.map(function (_a) {
|
|
23
|
-
var _b = (0, tslib_1.__read)(_a, 2), w1 = _b[0], w2 = _b[1];
|
|
24
|
-
return w1.add(-w2);
|
|
25
|
-
});
|
|
18
|
+
var weightsDiff = updatedWeights.sub(staleWeights);
|
|
26
19
|
var newWeightsDiff;
|
|
27
20
|
if (clippingRadius !== undefined) {
|
|
28
21
|
// Frobenius norm
|
|
29
|
-
var norm_1 =
|
|
22
|
+
var norm_1 = weightsDiff.frobeniusNorm();
|
|
30
23
|
newWeightsDiff = weightsDiff.map(function (w) {
|
|
31
24
|
var clipped = w.div(Math.max(1, norm_1 / clippingRadius));
|
|
32
25
|
if (noiseScale !== undefined) {
|
|
@@ -49,12 +42,6 @@ function addDifferentialPrivacy(updatedWeights, staleWeights, task) {
|
|
|
49
42
|
return updatedWeights;
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
|
-
return
|
|
53
|
-
.zip(newWeightsDiff)
|
|
54
|
-
.map(function (_a) {
|
|
55
|
-
var _b = (0, tslib_1.__read)(_a, 2), w = _b[0], d = _b[1];
|
|
56
|
-
return w.add(d);
|
|
57
|
-
})
|
|
58
|
-
.toArray();
|
|
45
|
+
return staleWeights.add(newWeightsDiff);
|
|
59
46
|
}
|
|
60
47
|
exports.addDifferentialPrivacy = addDifferentialPrivacy;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WeightsContainer } from '..';
|
|
2
|
+
export declare type Encoded = number[];
|
|
3
|
+
export declare function isEncoded(raw: unknown): raw is Encoded;
|
|
4
|
+
export declare function encode(weights: WeightsContainer): Promise<Encoded>;
|
|
5
|
+
export declare function decode(encoded: Encoded): WeightsContainer;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decode = exports.encode = exports.isEncoded = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var __1 = require("..");
|
|
6
5
|
var msgpack = (0, tslib_1.__importStar)(require("msgpack-lite"));
|
|
6
|
+
var __1 = require("..");
|
|
7
7
|
function isSerialized(raw) {
|
|
8
8
|
if (typeof raw !== 'object' || raw === null) {
|
|
9
9
|
return false;
|
|
@@ -13,7 +13,7 @@ function isSerialized(raw) {
|
|
|
13
13
|
}
|
|
14
14
|
var _a = raw, shape = _a.shape, data = _a.data;
|
|
15
15
|
if (!(Array.isArray(shape) && shape.every(function (e) { return typeof e === 'number'; })) ||
|
|
16
|
-
!(data
|
|
16
|
+
!(Array.isArray(data) && data.every(function (e) { return typeof e === 'number'; }))) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
// eslint-disable-next-line
|
|
@@ -30,17 +30,19 @@ function encode(weights) {
|
|
|
30
30
|
var _this = this;
|
|
31
31
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
32
32
|
switch (_a.label) {
|
|
33
|
-
case 0: return [4 /*yield*/, Promise.all(weights.map(function (t) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
33
|
+
case 0: return [4 /*yield*/, Promise.all(weights.weights.map(function (t) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
34
34
|
var _a;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
var _b;
|
|
36
|
+
return (0, tslib_1.__generator)(this, function (_c) {
|
|
37
|
+
switch (_c.label) {
|
|
37
38
|
case 0:
|
|
38
|
-
|
|
39
|
+
_b = {
|
|
39
40
|
shape: t.shape
|
|
40
41
|
};
|
|
42
|
+
_a = [[]];
|
|
41
43
|
return [4 /*yield*/, t.data()];
|
|
42
|
-
case 1: return [2 /*return*/, (
|
|
43
|
-
|
|
44
|
+
case 1: return [2 /*return*/, (_b.data = tslib_1.__spreadArray.apply(void 0, _a.concat([tslib_1.__read.apply(void 0, [_c.sent()]), false])),
|
|
45
|
+
_b)];
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
48
|
}); }))];
|
|
@@ -57,6 +59,6 @@ function decode(encoded) {
|
|
|
57
59
|
if (!(Array.isArray(raw) && raw.every(isSerialized))) {
|
|
58
60
|
throw new Error('expected to decode an array of serialized weights');
|
|
59
61
|
}
|
|
60
|
-
return raw.map(function (w) { return __1.tf.tensor(w.data, w.shape); });
|
|
62
|
+
return new __1.WeightsContainer(raw.map(function (w) { return __1.tf.tensor(w.data, w.shape); }));
|
|
61
63
|
}
|
|
62
64
|
exports.decode = decode;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDigest = void 0;
|
|
4
|
+
function isDigest(raw) {
|
|
5
|
+
if (typeof raw !== 'object') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (raw === null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
var _a = raw, algorithm = _a.algorithm, value = _a.value;
|
|
12
|
+
if (!(typeof algorithm === 'string' &&
|
|
13
|
+
typeof value === 'string')) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
exports.isDigest = isDigest;
|
|
@@ -2,11 +2,11 @@ import { Summary } from './summary';
|
|
|
2
2
|
import { DataExample } from './data_example';
|
|
3
3
|
export declare function isDisplayInformation(raw: unknown): raw is DisplayInformation;
|
|
4
4
|
export interface DisplayInformation {
|
|
5
|
-
taskTitle
|
|
6
|
-
summary
|
|
7
|
-
tradeoffs
|
|
8
|
-
dataFormatInformation
|
|
9
|
-
dataExampleText
|
|
5
|
+
taskTitle?: string;
|
|
6
|
+
summary?: Summary;
|
|
7
|
+
tradeoffs?: string;
|
|
8
|
+
dataFormatInformation?: string;
|
|
9
|
+
dataExampleText?: string;
|
|
10
10
|
model?: string;
|
|
11
11
|
dataExample?: DataExample[];
|
|
12
12
|
headers?: string[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDisplayInformation = void 0;
|
|
4
|
-
var immutable_1 = require("immutable");
|
|
5
4
|
var summary_1 = require("./summary");
|
|
6
5
|
var data_example_1 = require("./data_example");
|
|
7
6
|
function isDisplayInformation(raw) {
|
|
@@ -11,21 +10,17 @@ function isDisplayInformation(raw) {
|
|
|
11
10
|
if (raw === null) {
|
|
12
11
|
return false;
|
|
13
12
|
}
|
|
14
|
-
var requiredFields = immutable_1.Set.of('dataExampleText', 'dataFormatInformation', 'summary', 'taskTitle', 'tradeoffs');
|
|
15
|
-
if (!requiredFields.isSubset(Object.keys(raw))) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
13
|
var _a = raw, dataExample = _a.dataExample, dataExampleImage = _a.dataExampleImage, dataExampleText = _a.dataExampleText, dataFormatInformation = _a.dataFormatInformation, headers = _a.headers, limitations = _a.limitations, model = _a.model, summary = _a.summary, taskTitle = _a.taskTitle, tradeoffs = _a.tradeoffs;
|
|
19
|
-
if (typeof
|
|
20
|
-
typeof
|
|
21
|
-
typeof
|
|
22
|
-
typeof tradeoffs !== 'string' ||
|
|
14
|
+
if (typeof taskTitle !== 'string' ||
|
|
15
|
+
(dataExampleText !== undefined && typeof dataExampleText !== 'string') ||
|
|
16
|
+
(dataFormatInformation !== undefined && typeof dataFormatInformation !== 'string') ||
|
|
17
|
+
(tradeoffs !== undefined && typeof tradeoffs !== 'string') ||
|
|
23
18
|
(model !== undefined && typeof model !== 'string') ||
|
|
24
19
|
(dataExampleImage !== undefined && typeof dataExampleImage !== 'string') ||
|
|
25
20
|
(limitations !== undefined && typeof limitations !== 'string')) {
|
|
26
21
|
return false;
|
|
27
22
|
}
|
|
28
|
-
if (!(0, summary_1.isSummary)(summary)) {
|
|
23
|
+
if (summary !== undefined && !(0, summary_1.isSummary)(summary)) {
|
|
29
24
|
return false;
|
|
30
25
|
}
|
|
31
26
|
if (dataExample !== undefined && !(Array.isArray(dataExample) &&
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { isTask, Task, isTaskID, TaskID } from './task';
|
|
2
|
+
export { TaskProvider, isTaskProvider } from './task_provider';
|
|
3
|
+
export { isDigest, Digest } from './digest';
|
|
2
4
|
export { isDisplayInformation, DisplayInformation } from './display_information';
|
|
3
5
|
export { TrainingInformation } from './training_information';
|
|
6
|
+
export { pushTask, fetchTasks } from './task_handler';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchTasks = exports.pushTask = exports.isDisplayInformation = exports.isDigest = exports.isTaskProvider = exports.isTaskID = exports.isTask = void 0;
|
|
4
|
+
var task_1 = require("./task");
|
|
5
|
+
Object.defineProperty(exports, "isTask", { enumerable: true, get: function () { return task_1.isTask; } });
|
|
6
|
+
Object.defineProperty(exports, "isTaskID", { enumerable: true, get: function () { return task_1.isTaskID; } });
|
|
7
|
+
var task_provider_1 = require("./task_provider");
|
|
8
|
+
Object.defineProperty(exports, "isTaskProvider", { enumerable: true, get: function () { return task_provider_1.isTaskProvider; } });
|
|
9
|
+
var digest_1 = require("./digest");
|
|
10
|
+
Object.defineProperty(exports, "isDigest", { enumerable: true, get: function () { return digest_1.isDigest; } });
|
|
11
|
+
var display_information_1 = require("./display_information");
|
|
12
|
+
Object.defineProperty(exports, "isDisplayInformation", { enumerable: true, get: function () { return display_information_1.isDisplayInformation; } });
|
|
13
|
+
var task_handler_1 = require("./task_handler");
|
|
14
|
+
Object.defineProperty(exports, "pushTask", { enumerable: true, get: function () { return task_handler_1.pushTask; } });
|
|
15
|
+
Object.defineProperty(exports, "fetchTasks", { enumerable: true, get: function () { return task_handler_1.fetchTasks; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isModelCompileData = void 0;
|
|
4
|
+
function isModelCompileData(raw) {
|
|
5
|
+
if (typeof raw !== 'object') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (raw === null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
var _a = raw, optimizer = _a.optimizer, loss = _a.loss, metrics = _a.metrics;
|
|
12
|
+
if (typeof optimizer !== 'string' ||
|
|
13
|
+
typeof loss !== 'string') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (!(Array.isArray(metrics) &&
|
|
17
|
+
metrics.every(function (e) { return typeof e === 'string'; }))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
exports.isModelCompileData = isModelCompileData;
|
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSummary = void 0;
|
|
4
|
-
var immutable_1 = require("immutable");
|
|
5
4
|
function isSummary(raw) {
|
|
6
5
|
if (typeof raw !== 'object') {
|
|
7
6
|
return false;
|
|
@@ -9,9 +8,6 @@ function isSummary(raw) {
|
|
|
9
8
|
if (raw === null) {
|
|
10
9
|
return false;
|
|
11
10
|
}
|
|
12
|
-
if (!(0, immutable_1.Set)(Object.keys(raw)).equals(immutable_1.Set.of('preview', 'overview'))) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
11
|
var _a = raw, preview = _a.preview, overview = _a.overview;
|
|
16
12
|
if (!(typeof preview === 'string' && typeof overview === 'string')) {
|
|
17
13
|
return false;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DisplayInformation } from './display_information';
|
|
2
2
|
import { TrainingInformation } from './training_information';
|
|
3
|
+
import { Digest } from './digest';
|
|
3
4
|
export declare type TaskID = string;
|
|
4
5
|
export declare function isTaskID(obj: unknown): obj is TaskID;
|
|
5
6
|
export declare function isTask(raw: unknown): raw is Task;
|
|
6
7
|
export interface Task {
|
|
7
8
|
taskID: TaskID;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
digest?: Digest;
|
|
10
|
+
displayInformation: DisplayInformation;
|
|
11
|
+
trainingInformation: TrainingInformation;
|
|
10
12
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isTask = exports.isTaskID = void 0;
|
|
4
4
|
var display_information_1 = require("./display_information");
|
|
5
|
+
var training_information_1 = require("./training_information");
|
|
6
|
+
var digest_1 = require("./digest");
|
|
5
7
|
function isTaskID(obj) {
|
|
6
8
|
return typeof obj === 'string';
|
|
7
9
|
}
|
|
@@ -13,20 +15,21 @@ function isTask(raw) {
|
|
|
13
15
|
if (raw === null) {
|
|
14
16
|
return false;
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
var _a = raw, taskID = _a.taskID, digest = _a.digest, displayInformation = _a.displayInformation, trainingInformation = _a.trainingInformation;
|
|
19
|
+
if (typeof taskID !== 'string') {
|
|
17
20
|
return false;
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
if (digest !== undefined && !(0, digest_1.isDigest)(digest)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (!(0, display_information_1.isDisplayInformation)(displayInformation)) {
|
|
21
26
|
return false;
|
|
22
27
|
}
|
|
23
|
-
if (
|
|
24
|
-
!(0, display_information_1.isDisplayInformation)(displayInformation)) {
|
|
28
|
+
if (!(0, training_information_1.isTrainingInformation)(trainingInformation)) {
|
|
25
29
|
return false;
|
|
26
30
|
}
|
|
27
|
-
// TODO check for TrainingInformation
|
|
28
31
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
-
var _ = { taskID: taskID, displayInformation: displayInformation };
|
|
32
|
+
var _ = { taskID: taskID, displayInformation: displayInformation, trainingInformation: trainingInformation };
|
|
30
33
|
return true;
|
|
31
34
|
}
|
|
32
35
|
exports.isTask = isTask;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Map } from 'immutable';
|
|
2
|
+
import { tf } from '..';
|
|
3
|
+
import { Task, TaskID } from './task';
|
|
4
|
+
export declare function pushTask(url: URL, task: Task, model: tf.LayersModel): Promise<void>;
|
|
5
|
+
export declare function fetchTasks(url: URL): Promise<Map<TaskID, Task>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchTasks = exports.pushTask = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var immutable_1 = require("immutable");
|
|
6
|
+
var axios_1 = (0, tslib_1.__importDefault)(require("axios"));
|
|
7
|
+
var __1 = require("..");
|
|
8
|
+
var task_1 = require("./task");
|
|
9
|
+
var TASK_ENDPOINT = 'tasks';
|
|
10
|
+
function pushTask(url, task, model) {
|
|
11
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
var _d;
|
|
14
|
+
return (0, tslib_1.__generator)(this, function (_e) {
|
|
15
|
+
switch (_e.label) {
|
|
16
|
+
case 0:
|
|
17
|
+
_b = (_a = axios_1.default).post;
|
|
18
|
+
_c = [url.href + TASK_ENDPOINT];
|
|
19
|
+
_d = {
|
|
20
|
+
task: task
|
|
21
|
+
};
|
|
22
|
+
return [4 /*yield*/, __1.serialization.model.encode(model)];
|
|
23
|
+
case 1:
|
|
24
|
+
_d.model = _e.sent();
|
|
25
|
+
return [4 /*yield*/, __1.serialization.weights.encode(__1.WeightsContainer.from(model))];
|
|
26
|
+
case 2: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.weights = _e.sent(),
|
|
27
|
+
_d)]))];
|
|
28
|
+
case 3:
|
|
29
|
+
_e.sent();
|
|
30
|
+
return [2 /*return*/];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.pushTask = pushTask;
|
|
36
|
+
function fetchTasks(url) {
|
|
37
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
38
|
+
var response, tasks;
|
|
39
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
40
|
+
switch (_a.label) {
|
|
41
|
+
case 0: return [4 /*yield*/, axios_1.default.get(url.href + TASK_ENDPOINT)];
|
|
42
|
+
case 1:
|
|
43
|
+
response = _a.sent();
|
|
44
|
+
tasks = response.data;
|
|
45
|
+
if (!Array.isArray(tasks) || !tasks.every(task_1.isTask)) {
|
|
46
|
+
throw new Error('invalid tasks response');
|
|
47
|
+
}
|
|
48
|
+
return [2 /*return*/, (0, immutable_1.Map)(tasks.map(function (t) { return [t.taskID, t]; }))];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.fetchTasks = fetchTasks;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTaskProvider = void 0;
|
|
4
|
+
function isTaskProvider(obj) {
|
|
5
|
+
if ('getModel' in obj && typeof obj.getModel === 'function' &&
|
|
6
|
+
'getTask' in obj && typeof obj.getTask === 'function') {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.isTaskProvider = isTaskProvider;
|