@epfml/discojs 2.1.1 → 2.1.2-p20240506085037.0
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/dist/aggregator/base.d.ts +180 -0
- package/dist/aggregator/base.js +236 -0
- package/dist/aggregator/get.d.ts +16 -0
- package/dist/aggregator/get.js +31 -0
- package/dist/aggregator/index.d.ts +7 -0
- package/dist/aggregator/index.js +4 -0
- package/dist/aggregator/mean.d.ts +23 -0
- package/dist/aggregator/mean.js +69 -0
- package/dist/aggregator/secure.d.ts +27 -0
- package/dist/aggregator/secure.js +91 -0
- package/dist/async_informant.d.ts +15 -0
- package/dist/async_informant.js +42 -0
- package/dist/client/base.d.ts +76 -0
- package/dist/client/base.js +88 -0
- package/dist/client/decentralized/base.d.ts +32 -0
- package/dist/client/decentralized/base.js +192 -0
- package/dist/client/decentralized/index.d.ts +2 -0
- package/dist/client/decentralized/index.js +2 -0
- package/dist/client/decentralized/messages.d.ts +28 -0
- package/dist/client/decentralized/messages.js +44 -0
- package/dist/client/decentralized/peer.d.ts +40 -0
- package/dist/client/decentralized/peer.js +189 -0
- package/dist/client/decentralized/peer_pool.d.ts +12 -0
- package/dist/client/decentralized/peer_pool.js +44 -0
- package/dist/client/event_connection.d.ts +34 -0
- package/dist/client/event_connection.js +105 -0
- package/dist/client/federated/base.d.ts +54 -0
- package/dist/client/federated/base.js +151 -0
- package/dist/client/federated/index.d.ts +2 -0
- package/dist/client/federated/index.js +2 -0
- package/dist/client/federated/messages.d.ts +30 -0
- package/dist/client/federated/messages.js +24 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +8 -0
- package/dist/client/local.d.ts +3 -0
- package/dist/client/local.js +3 -0
- package/dist/client/messages.d.ts +30 -0
- package/dist/client/messages.js +26 -0
- package/dist/client/types.d.ts +2 -0
- package/dist/client/types.js +4 -0
- package/dist/client/utils.d.ts +2 -0
- package/dist/client/utils.js +7 -0
- package/dist/dataset/data/data.d.ts +48 -0
- package/dist/dataset/data/data.js +72 -0
- package/dist/dataset/data/data_split.d.ts +8 -0
- package/dist/dataset/data/data_split.js +1 -0
- package/dist/dataset/data/image_data.d.ts +11 -0
- package/dist/dataset/data/image_data.js +38 -0
- package/dist/dataset/data/index.d.ts +6 -0
- package/dist/dataset/data/index.js +5 -0
- package/dist/dataset/data/preprocessing/base.d.ts +16 -0
- package/dist/dataset/data/preprocessing/base.js +1 -0
- package/dist/dataset/data/preprocessing/image_preprocessing.d.ts +13 -0
- package/dist/dataset/data/preprocessing/image_preprocessing.js +40 -0
- package/dist/dataset/data/preprocessing/index.d.ts +4 -0
- package/dist/dataset/data/preprocessing/index.js +3 -0
- package/dist/dataset/data/preprocessing/tabular_preprocessing.d.ts +13 -0
- package/dist/dataset/data/preprocessing/tabular_preprocessing.js +45 -0
- package/dist/dataset/data/preprocessing/text_preprocessing.d.ts +13 -0
- package/dist/dataset/data/preprocessing/text_preprocessing.js +85 -0
- package/dist/dataset/data/tabular_data.d.ts +11 -0
- package/dist/dataset/data/tabular_data.js +25 -0
- package/dist/dataset/data/text_data.d.ts +11 -0
- package/dist/dataset/data/text_data.js +14 -0
- package/dist/{core/dataset → dataset}/data_loader/data_loader.d.ts +3 -5
- package/dist/dataset/data_loader/data_loader.js +2 -0
- package/dist/dataset/data_loader/image_loader.d.ts +20 -3
- package/dist/dataset/data_loader/image_loader.js +98 -23
- package/dist/dataset/data_loader/index.d.ts +5 -2
- package/dist/dataset/data_loader/index.js +4 -7
- package/dist/dataset/data_loader/tabular_loader.d.ts +34 -3
- package/dist/dataset/data_loader/tabular_loader.js +75 -15
- package/dist/dataset/data_loader/text_loader.d.ts +14 -0
- package/dist/dataset/data_loader/text_loader.js +25 -0
- package/dist/dataset/dataset.d.ts +5 -0
- package/dist/dataset/dataset.js +1 -0
- package/dist/dataset/dataset_builder.d.ts +60 -0
- package/dist/dataset/dataset_builder.js +142 -0
- package/dist/dataset/index.d.ts +5 -0
- package/dist/dataset/index.js +3 -0
- package/dist/default_tasks/cifar10/index.d.ts +2 -0
- package/dist/{core/default_tasks/cifar10.js → default_tasks/cifar10/index.js} +28 -36
- package/dist/default_tasks/cifar10/model.d.ts +434 -0
- package/dist/default_tasks/cifar10/model.js +2385 -0
- package/dist/default_tasks/geotags/index.d.ts +2 -0
- package/dist/default_tasks/geotags/index.js +65 -0
- package/dist/default_tasks/geotags/model.d.ts +593 -0
- package/dist/default_tasks/geotags/model.js +4715 -0
- package/dist/default_tasks/index.d.ts +8 -0
- package/dist/default_tasks/index.js +8 -0
- package/dist/default_tasks/lus_covid.d.ts +2 -0
- package/dist/default_tasks/lus_covid.js +89 -0
- package/dist/default_tasks/mnist.d.ts +2 -0
- package/dist/{core/default_tasks → default_tasks}/mnist.js +26 -34
- package/dist/default_tasks/simple_face/index.d.ts +2 -0
- package/dist/{core/default_tasks/simple_face.js → default_tasks/simple_face/index.js} +17 -22
- package/dist/default_tasks/simple_face/model.d.ts +513 -0
- package/dist/default_tasks/simple_face/model.js +4301 -0
- package/dist/default_tasks/skin_mnist.d.ts +2 -0
- package/dist/default_tasks/skin_mnist.js +80 -0
- package/dist/default_tasks/titanic.d.ts +2 -0
- package/dist/{core/default_tasks → default_tasks}/titanic.js +24 -33
- package/dist/default_tasks/wikitext.d.ts +2 -0
- package/dist/default_tasks/wikitext.js +38 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +18 -6
- package/dist/{core/informant → informant}/graph_informant.d.ts +1 -1
- package/dist/informant/graph_informant.js +20 -0
- package/dist/informant/index.d.ts +1 -0
- package/dist/informant/index.js +1 -0
- package/dist/{core/logging → logging}/console_logger.d.ts +2 -2
- package/dist/logging/console_logger.js +22 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.js +1 -0
- package/dist/{core/logging → logging}/logger.d.ts +3 -3
- package/dist/logging/logger.js +1 -0
- package/dist/memory/base.d.ts +119 -0
- package/dist/memory/base.js +9 -0
- package/dist/memory/empty.d.ts +20 -0
- package/dist/memory/empty.js +43 -0
- package/dist/memory/index.d.ts +3 -1
- package/dist/memory/index.js +3 -5
- package/dist/memory/model_type.d.ts +9 -0
- package/dist/memory/model_type.js +10 -0
- package/dist/{core/privacy.d.ts → privacy.d.ts} +1 -1
- package/dist/{core/privacy.js → privacy.js} +11 -16
- package/dist/serialization/index.d.ts +2 -0
- package/dist/serialization/index.js +2 -0
- package/dist/serialization/model.d.ts +5 -0
- package/dist/serialization/model.js +67 -0
- package/dist/{core/serialization → serialization}/weights.d.ts +2 -2
- package/dist/serialization/weights.js +37 -0
- package/dist/task/data_example.js +14 -0
- package/dist/task/digest.js +14 -0
- package/dist/{core/task → task}/display_information.d.ts +5 -3
- package/dist/task/display_information.js +46 -0
- package/dist/task/index.d.ts +7 -0
- package/dist/task/index.js +5 -0
- package/dist/task/label_type.d.ts +9 -0
- package/dist/task/label_type.js +28 -0
- package/dist/task/summary.js +13 -0
- package/dist/{core/task → task}/task.d.ts +7 -7
- package/dist/task/task.js +22 -0
- package/dist/task/task_handler.d.ts +5 -0
- package/dist/task/task_handler.js +20 -0
- package/dist/task/task_provider.d.ts +5 -0
- package/dist/task/task_provider.js +1 -0
- package/dist/{core/task → task}/training_information.d.ts +9 -10
- package/dist/task/training_information.js +88 -0
- package/dist/training/disco.d.ts +40 -0
- package/dist/training/disco.js +107 -0
- package/dist/training/index.d.ts +2 -0
- package/dist/training/index.js +1 -0
- package/dist/training/trainer/distributed_trainer.d.ts +20 -0
- package/dist/training/trainer/distributed_trainer.js +36 -0
- package/dist/training/trainer/local_trainer.d.ts +12 -0
- package/dist/training/trainer/local_trainer.js +19 -0
- package/dist/training/trainer/trainer.d.ts +33 -0
- package/dist/training/trainer/trainer.js +52 -0
- package/dist/{core/training → training}/trainer/trainer_builder.d.ts +5 -7
- package/dist/training/trainer/trainer_builder.js +43 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +1 -0
- package/dist/utils/event_emitter.d.ts +40 -0
- package/dist/utils/event_emitter.js +57 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/validator.d.ts +28 -0
- package/dist/validation/validator.js +132 -0
- package/dist/weights/aggregation.d.ts +21 -0
- package/dist/weights/aggregation.js +44 -0
- package/dist/weights/index.d.ts +2 -0
- package/dist/weights/index.js +2 -0
- package/dist/weights/weights_container.d.ts +68 -0
- package/dist/weights/weights_container.js +96 -0
- package/package.json +24 -15
- package/README.md +0 -53
- package/dist/core/async_buffer.d.ts +0 -41
- package/dist/core/async_buffer.js +0 -97
- package/dist/core/async_informant.d.ts +0 -20
- package/dist/core/async_informant.js +0 -69
- package/dist/core/client/base.d.ts +0 -33
- package/dist/core/client/base.js +0 -35
- package/dist/core/client/decentralized/base.d.ts +0 -32
- package/dist/core/client/decentralized/base.js +0 -212
- package/dist/core/client/decentralized/clear_text.d.ts +0 -14
- package/dist/core/client/decentralized/clear_text.js +0 -96
- package/dist/core/client/decentralized/index.d.ts +0 -4
- package/dist/core/client/decentralized/index.js +0 -9
- package/dist/core/client/decentralized/messages.d.ts +0 -41
- package/dist/core/client/decentralized/messages.js +0 -54
- package/dist/core/client/decentralized/peer.d.ts +0 -26
- package/dist/core/client/decentralized/peer.js +0 -210
- package/dist/core/client/decentralized/peer_pool.d.ts +0 -14
- package/dist/core/client/decentralized/peer_pool.js +0 -92
- package/dist/core/client/decentralized/sec_agg.d.ts +0 -22
- package/dist/core/client/decentralized/sec_agg.js +0 -190
- package/dist/core/client/decentralized/secret_shares.d.ts +0 -3
- package/dist/core/client/decentralized/secret_shares.js +0 -39
- package/dist/core/client/decentralized/types.d.ts +0 -2
- package/dist/core/client/decentralized/types.js +0 -7
- package/dist/core/client/event_connection.d.ts +0 -37
- package/dist/core/client/event_connection.js +0 -158
- package/dist/core/client/federated/client.d.ts +0 -37
- package/dist/core/client/federated/client.js +0 -273
- package/dist/core/client/federated/index.d.ts +0 -2
- package/dist/core/client/federated/index.js +0 -7
- package/dist/core/client/federated/messages.d.ts +0 -38
- package/dist/core/client/federated/messages.js +0 -25
- package/dist/core/client/index.d.ts +0 -5
- package/dist/core/client/index.js +0 -11
- package/dist/core/client/local.d.ts +0 -8
- package/dist/core/client/local.js +0 -36
- package/dist/core/client/messages.d.ts +0 -28
- package/dist/core/client/messages.js +0 -33
- package/dist/core/client/utils.d.ts +0 -2
- package/dist/core/client/utils.js +0 -19
- package/dist/core/dataset/data/data.d.ts +0 -11
- package/dist/core/dataset/data/data.js +0 -20
- package/dist/core/dataset/data/data_split.d.ts +0 -5
- package/dist/core/dataset/data/data_split.js +0 -2
- package/dist/core/dataset/data/image_data.d.ts +0 -8
- package/dist/core/dataset/data/image_data.js +0 -64
- package/dist/core/dataset/data/index.d.ts +0 -5
- package/dist/core/dataset/data/index.js +0 -11
- package/dist/core/dataset/data/preprocessing.d.ts +0 -13
- package/dist/core/dataset/data/preprocessing.js +0 -33
- package/dist/core/dataset/data/tabular_data.d.ts +0 -8
- package/dist/core/dataset/data/tabular_data.js +0 -40
- package/dist/core/dataset/data_loader/data_loader.js +0 -10
- package/dist/core/dataset/data_loader/image_loader.d.ts +0 -17
- package/dist/core/dataset/data_loader/image_loader.js +0 -141
- package/dist/core/dataset/data_loader/index.d.ts +0 -3
- package/dist/core/dataset/data_loader/index.js +0 -9
- package/dist/core/dataset/data_loader/tabular_loader.d.ts +0 -29
- package/dist/core/dataset/data_loader/tabular_loader.js +0 -101
- package/dist/core/dataset/dataset.d.ts +0 -2
- package/dist/core/dataset/dataset.js +0 -2
- package/dist/core/dataset/dataset_builder.d.ts +0 -18
- package/dist/core/dataset/dataset_builder.js +0 -96
- package/dist/core/dataset/index.d.ts +0 -4
- package/dist/core/dataset/index.js +0 -14
- package/dist/core/default_tasks/cifar10.d.ts +0 -2
- package/dist/core/default_tasks/geotags.d.ts +0 -2
- package/dist/core/default_tasks/geotags.js +0 -69
- package/dist/core/default_tasks/index.d.ts +0 -6
- package/dist/core/default_tasks/index.js +0 -15
- package/dist/core/default_tasks/lus_covid.d.ts +0 -2
- package/dist/core/default_tasks/lus_covid.js +0 -96
- package/dist/core/default_tasks/mnist.d.ts +0 -2
- package/dist/core/default_tasks/simple_face.d.ts +0 -2
- package/dist/core/default_tasks/titanic.d.ts +0 -2
- package/dist/core/index.d.ts +0 -18
- package/dist/core/index.js +0 -39
- package/dist/core/informant/graph_informant.js +0 -23
- package/dist/core/informant/index.d.ts +0 -3
- package/dist/core/informant/index.js +0 -9
- package/dist/core/informant/training_informant/base.d.ts +0 -31
- package/dist/core/informant/training_informant/base.js +0 -83
- package/dist/core/informant/training_informant/decentralized.d.ts +0 -5
- package/dist/core/informant/training_informant/decentralized.js +0 -22
- package/dist/core/informant/training_informant/federated.d.ts +0 -14
- package/dist/core/informant/training_informant/federated.js +0 -32
- package/dist/core/informant/training_informant/index.d.ts +0 -4
- package/dist/core/informant/training_informant/index.js +0 -11
- package/dist/core/informant/training_informant/local.d.ts +0 -6
- package/dist/core/informant/training_informant/local.js +0 -20
- package/dist/core/logging/console_logger.js +0 -33
- package/dist/core/logging/index.d.ts +0 -3
- package/dist/core/logging/index.js +0 -9
- package/dist/core/logging/logger.js +0 -9
- package/dist/core/logging/trainer_logger.d.ts +0 -24
- package/dist/core/logging/trainer_logger.js +0 -59
- package/dist/core/memory/base.d.ts +0 -22
- package/dist/core/memory/base.js +0 -9
- package/dist/core/memory/empty.d.ts +0 -14
- package/dist/core/memory/empty.js +0 -75
- package/dist/core/memory/index.d.ts +0 -3
- package/dist/core/memory/index.js +0 -9
- package/dist/core/memory/model_type.d.ts +0 -4
- package/dist/core/memory/model_type.js +0 -9
- package/dist/core/serialization/index.d.ts +0 -2
- package/dist/core/serialization/index.js +0 -6
- package/dist/core/serialization/model.d.ts +0 -5
- package/dist/core/serialization/model.js +0 -55
- package/dist/core/serialization/weights.js +0 -64
- package/dist/core/task/data_example.js +0 -24
- package/dist/core/task/digest.js +0 -18
- package/dist/core/task/display_information.js +0 -49
- package/dist/core/task/index.d.ts +0 -6
- package/dist/core/task/index.js +0 -15
- package/dist/core/task/model_compile_data.d.ts +0 -6
- package/dist/core/task/model_compile_data.js +0 -22
- package/dist/core/task/summary.js +0 -19
- package/dist/core/task/task.js +0 -35
- package/dist/core/task/task_handler.d.ts +0 -5
- package/dist/core/task/task_handler.js +0 -53
- package/dist/core/task/task_provider.d.ts +0 -6
- package/dist/core/task/task_provider.js +0 -13
- package/dist/core/task/training_information.js +0 -66
- package/dist/core/training/disco.d.ts +0 -23
- package/dist/core/training/disco.js +0 -130
- package/dist/core/training/index.d.ts +0 -2
- package/dist/core/training/index.js +0 -7
- package/dist/core/training/trainer/distributed_trainer.d.ts +0 -20
- package/dist/core/training/trainer/distributed_trainer.js +0 -65
- package/dist/core/training/trainer/local_trainer.d.ts +0 -11
- package/dist/core/training/trainer/local_trainer.js +0 -34
- package/dist/core/training/trainer/round_tracker.d.ts +0 -30
- package/dist/core/training/trainer/round_tracker.js +0 -47
- package/dist/core/training/trainer/trainer.d.ts +0 -65
- package/dist/core/training/trainer/trainer.js +0 -160
- package/dist/core/training/trainer/trainer_builder.js +0 -95
- package/dist/core/training/training_schemes.d.ts +0 -5
- package/dist/core/training/training_schemes.js +0 -10
- package/dist/core/types.d.ts +0 -4
- package/dist/core/types.js +0 -2
- package/dist/core/validation/index.d.ts +0 -1
- package/dist/core/validation/index.js +0 -5
- package/dist/core/validation/validator.d.ts +0 -17
- package/dist/core/validation/validator.js +0 -104
- package/dist/core/weights/aggregation.d.ts +0 -7
- package/dist/core/weights/aggregation.js +0 -72
- package/dist/core/weights/index.d.ts +0 -2
- package/dist/core/weights/index.js +0 -7
- package/dist/core/weights/weights_container.d.ts +0 -19
- package/dist/core/weights/weights_container.js +0 -64
- package/dist/imports.d.ts +0 -2
- package/dist/imports.js +0 -7
- package/dist/memory/memory.d.ts +0 -26
- package/dist/memory/memory.js +0 -160
- package/dist/{core/task → task}/data_example.d.ts +1 -1
- package/dist/{core/task → task}/digest.d.ts +0 -0
- package/dist/{core/task → task}/summary.d.ts +1 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TrainingSchemes = void 0;
|
|
4
|
-
/* eslint-disable no-unused-vars */
|
|
5
|
-
var TrainingSchemes;
|
|
6
|
-
(function (TrainingSchemes) {
|
|
7
|
-
TrainingSchemes["LOCAL"] = "local";
|
|
8
|
-
TrainingSchemes["DECENTRALIZED"] = "decentralized";
|
|
9
|
-
TrainingSchemes["FEDERATED"] = "federated";
|
|
10
|
-
})(TrainingSchemes = exports.TrainingSchemes || (exports.TrainingSchemes = {}));
|
package/dist/core/types.d.ts
DELETED
package/dist/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Validator } from './validator';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Validator = void 0;
|
|
4
|
-
var validator_1 = require("./validator");
|
|
5
|
-
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return validator_1.Validator; } });
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { List } from 'immutable';
|
|
2
|
-
import { tf, data, Task, Logger, Client, Memory, ModelSource } from '..';
|
|
3
|
-
export declare class Validator {
|
|
4
|
-
readonly task: Task;
|
|
5
|
-
readonly logger: Logger;
|
|
6
|
-
private readonly memory;
|
|
7
|
-
private readonly source?;
|
|
8
|
-
private readonly client?;
|
|
9
|
-
private readonly graphInformant;
|
|
10
|
-
private size;
|
|
11
|
-
constructor(task: Task, logger: Logger, memory: Memory, source?: ModelSource | undefined, client?: Client | undefined);
|
|
12
|
-
assess(data: data.Data): Promise<void>;
|
|
13
|
-
getModel(): Promise<tf.LayersModel>;
|
|
14
|
-
accuracyData(): List<number>;
|
|
15
|
-
accuracy(): number;
|
|
16
|
-
visitedSamples(): number;
|
|
17
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Validator = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var immutable_1 = require("immutable");
|
|
6
|
-
var __1 = require("..");
|
|
7
|
-
var Validator = /** @class */ (function () {
|
|
8
|
-
function Validator(task, logger, memory, source, client) {
|
|
9
|
-
this.task = task;
|
|
10
|
-
this.logger = logger;
|
|
11
|
-
this.memory = memory;
|
|
12
|
-
this.source = source;
|
|
13
|
-
this.client = client;
|
|
14
|
-
this.graphInformant = new __1.GraphInformant();
|
|
15
|
-
this.size = 0;
|
|
16
|
-
if (source === undefined && client === undefined) {
|
|
17
|
-
throw new Error('cannot identify model');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
Validator.prototype.assess = function (data) {
|
|
21
|
-
var _a, _b, _c;
|
|
22
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
23
|
-
var batchSize, labels, classes, model, hits;
|
|
24
|
-
var _this = this;
|
|
25
|
-
return (0, tslib_1.__generator)(this, function (_d) {
|
|
26
|
-
switch (_d.label) {
|
|
27
|
-
case 0:
|
|
28
|
-
batchSize = (_a = this.task.trainingInformation) === null || _a === void 0 ? void 0 : _a.batchSize;
|
|
29
|
-
if (batchSize === undefined) {
|
|
30
|
-
throw new TypeError('batch size is undefined');
|
|
31
|
-
}
|
|
32
|
-
labels = (_b = this.task.trainingInformation) === null || _b === void 0 ? void 0 : _b.LABEL_LIST;
|
|
33
|
-
classes = (_c = labels === null || labels === void 0 ? void 0 : labels.length) !== null && _c !== void 0 ? _c : 1;
|
|
34
|
-
return [4 /*yield*/, this.getModel()];
|
|
35
|
-
case 1:
|
|
36
|
-
model = _d.sent();
|
|
37
|
-
hits = 0;
|
|
38
|
-
return [4 /*yield*/, data.dataset.batch(batchSize).forEachAsync(function (e) {
|
|
39
|
-
if (typeof e === 'object' && 'xs' in e && 'ys' in e) {
|
|
40
|
-
var xs = e.xs;
|
|
41
|
-
var ys = e.ys.dataSync();
|
|
42
|
-
var pred = model.predict(xs, { batchSize: batchSize })
|
|
43
|
-
.dataSync()
|
|
44
|
-
.map(Math.round);
|
|
45
|
-
_this.size += xs.shape[0];
|
|
46
|
-
hits += (0, immutable_1.List)(pred).zip((0, immutable_1.List)(ys))
|
|
47
|
-
.map(function (_a) {
|
|
48
|
-
var _b = (0, tslib_1.__read)(_a, 2), p = _b[0], y = _b[1];
|
|
49
|
-
return 1 - Math.abs(p - y);
|
|
50
|
-
})
|
|
51
|
-
.reduce(function (acc, e) { return acc + e; }) / classes;
|
|
52
|
-
var currentAccuracy = hits / _this.size;
|
|
53
|
-
_this.graphInformant.updateAccuracy(currentAccuracy);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
throw new TypeError('missing feature/label in dataset');
|
|
57
|
-
}
|
|
58
|
-
})];
|
|
59
|
-
case 2:
|
|
60
|
-
_d.sent();
|
|
61
|
-
this.logger.success("Obtained validation accuracy of " + this.accuracy());
|
|
62
|
-
this.logger.success("Visited " + this.visitedSamples() + " samples");
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
Validator.prototype.getModel = function () {
|
|
69
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
70
|
-
var _a;
|
|
71
|
-
return (0, tslib_1.__generator)(this, function (_b) {
|
|
72
|
-
switch (_b.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
_a = this.source !== undefined;
|
|
75
|
-
if (!_a) return [3 /*break*/, 2];
|
|
76
|
-
return [4 /*yield*/, this.memory.contains(this.source)];
|
|
77
|
-
case 1:
|
|
78
|
-
_a = (_b.sent());
|
|
79
|
-
_b.label = 2;
|
|
80
|
-
case 2:
|
|
81
|
-
if (!_a) return [3 /*break*/, 4];
|
|
82
|
-
return [4 /*yield*/, this.memory.getModel(this.source)];
|
|
83
|
-
case 3: return [2 /*return*/, _b.sent()];
|
|
84
|
-
case 4:
|
|
85
|
-
if (!(this.client !== undefined)) return [3 /*break*/, 6];
|
|
86
|
-
return [4 /*yield*/, this.client.getLatestModel()];
|
|
87
|
-
case 5: return [2 /*return*/, _b.sent()];
|
|
88
|
-
case 6: throw new Error('cannot identify model');
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
Validator.prototype.accuracyData = function () {
|
|
94
|
-
return this.graphInformant.data();
|
|
95
|
-
};
|
|
96
|
-
Validator.prototype.accuracy = function () {
|
|
97
|
-
return this.graphInformant.accuracy();
|
|
98
|
-
};
|
|
99
|
-
Validator.prototype.visitedSamples = function () {
|
|
100
|
-
return this.size;
|
|
101
|
-
};
|
|
102
|
-
return Validator;
|
|
103
|
-
}());
|
|
104
|
-
exports.Validator = Validator;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TensorLike, WeightsContainer } from './weights_container';
|
|
2
|
-
declare type WeightsLike = Iterable<TensorLike>;
|
|
3
|
-
export declare function sum(weights: Iterable<WeightsLike | WeightsContainer>): WeightsContainer;
|
|
4
|
-
export declare function diff(weights: Iterable<WeightsLike | WeightsContainer>): WeightsContainer;
|
|
5
|
-
export declare function avg(weights: Iterable<WeightsLike | WeightsContainer>): WeightsContainer;
|
|
6
|
-
export declare function avgClippingWeights(peersWeights: Iterable<WeightsLike | WeightsContainer>, currentModel: WeightsContainer, tauPercentile: number): WeightsContainer;
|
|
7
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.avgClippingWeights = exports.avg = exports.diff = exports.sum = void 0;
|
|
4
|
-
var immutable_1 = require("immutable");
|
|
5
|
-
var __1 = require("..");
|
|
6
|
-
var weights_container_1 = require("./weights_container");
|
|
7
|
-
function parseWeights(weights) {
|
|
8
|
-
var _a;
|
|
9
|
-
var r = (0, immutable_1.List)(weights).map(function (w) {
|
|
10
|
-
return w instanceof weights_container_1.WeightsContainer ? w : new weights_container_1.WeightsContainer(w);
|
|
11
|
-
});
|
|
12
|
-
var weightsSize = (_a = r.first()) === null || _a === void 0 ? void 0 : _a.weights.length;
|
|
13
|
-
if (weightsSize === undefined) {
|
|
14
|
-
throw new Error('no weights to work with');
|
|
15
|
-
}
|
|
16
|
-
if (r.rest().every(function (w) { return w.weights.length !== weightsSize; })) {
|
|
17
|
-
throw new Error('weights dimensions are different for some of the operands');
|
|
18
|
-
}
|
|
19
|
-
return r;
|
|
20
|
-
}
|
|
21
|
-
function centerWeights(weights, currentModel) {
|
|
22
|
-
return parseWeights(weights).map(function (model) { return model.mapWith(currentModel, __1.tf.sub); });
|
|
23
|
-
}
|
|
24
|
-
function clipWeights(modelList, normArray, tau) {
|
|
25
|
-
return modelList.map(function (weights) { return weights.map(function (w, i) { return __1.tf.prod(w, Math.min(1, tau / (normArray[i]))); }); });
|
|
26
|
-
}
|
|
27
|
-
function computeQuantile(array, q) {
|
|
28
|
-
var sorted = array.sort(function (a, b) { return a - b; });
|
|
29
|
-
var pos = (sorted.length - 1) * q;
|
|
30
|
-
var base = Math.floor(pos);
|
|
31
|
-
var rest = pos - base;
|
|
32
|
-
if (sorted[base + 1] !== undefined) {
|
|
33
|
-
return sorted[base] + rest * (sorted[base + 1] - sorted[base]);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return sorted[base];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function reduce(weights, fn) {
|
|
40
|
-
return parseWeights(weights).reduce(function (acc, ws) {
|
|
41
|
-
return new weights_container_1.WeightsContainer(acc.weights.map(function (w, i) {
|
|
42
|
-
return fn(w, ws.get(i));
|
|
43
|
-
}));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function sum(weights) {
|
|
47
|
-
return reduce(weights, __1.tf.add);
|
|
48
|
-
}
|
|
49
|
-
exports.sum = sum;
|
|
50
|
-
function diff(weights) {
|
|
51
|
-
return reduce(weights, __1.tf.sub);
|
|
52
|
-
}
|
|
53
|
-
exports.diff = diff;
|
|
54
|
-
function avg(weights) {
|
|
55
|
-
var size = (0, immutable_1.List)(weights).size;
|
|
56
|
-
return sum(weights).map(function (ws) { return ws.div(size); });
|
|
57
|
-
}
|
|
58
|
-
exports.avg = avg;
|
|
59
|
-
// See: https://arxiv.org/abs/2012.10333
|
|
60
|
-
function avgClippingWeights(peersWeights, currentModel, tauPercentile) {
|
|
61
|
-
// Computing the centered peers weights with respect to the previous model aggragation
|
|
62
|
-
var centeredPeersWeights = centerWeights(peersWeights, currentModel);
|
|
63
|
-
// Computing the Matrix Norm (Frobenius Norm) of the centered peers weights
|
|
64
|
-
var normArray = Array.from(centeredPeersWeights.map(function (model) { return model.frobeniusNorm(); }));
|
|
65
|
-
// Computing the parameter tau as third percentile with respect to the norm array
|
|
66
|
-
var tau = computeQuantile(normArray, tauPercentile);
|
|
67
|
-
// Computing the centered clipped peers weights given the norm array and the parameter tau
|
|
68
|
-
var centeredMean = clipWeights(centeredPeersWeights, normArray, tau);
|
|
69
|
-
// Aggregating all centered clipped peers weights
|
|
70
|
-
return avg(centeredMean);
|
|
71
|
-
}
|
|
72
|
-
exports.avgClippingWeights = avgClippingWeights;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.aggregation = exports.WeightsContainer = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var weights_container_1 = require("./weights_container");
|
|
6
|
-
Object.defineProperty(exports, "WeightsContainer", { enumerable: true, get: function () { return weights_container_1.WeightsContainer; } });
|
|
7
|
-
exports.aggregation = (0, tslib_1.__importStar)(require("./aggregation"));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { tf, Weights } from '..';
|
|
2
|
-
export declare type TensorLike = tf.Tensor | ArrayLike<number>;
|
|
3
|
-
export declare class WeightsContainer {
|
|
4
|
-
private readonly _weights;
|
|
5
|
-
constructor(weights: Iterable<TensorLike>);
|
|
6
|
-
get weights(): Weights;
|
|
7
|
-
add(other: WeightsContainer): WeightsContainer;
|
|
8
|
-
sub(other: WeightsContainer): WeightsContainer;
|
|
9
|
-
mapWith(other: WeightsContainer, fn: (a: tf.Tensor, b: tf.Tensor) => tf.Tensor): WeightsContainer;
|
|
10
|
-
map(fn: (t: tf.Tensor, i: number) => tf.Tensor): WeightsContainer;
|
|
11
|
-
map(fn: (t: tf.Tensor) => tf.Tensor): WeightsContainer;
|
|
12
|
-
reduce(fn: (acc: tf.Tensor, t: tf.Tensor) => tf.Tensor): tf.Tensor;
|
|
13
|
-
get(index: number): tf.Tensor | undefined;
|
|
14
|
-
frobeniusNorm(): number;
|
|
15
|
-
static of(...weights: TensorLike[]): WeightsContainer;
|
|
16
|
-
static from(model: tf.LayersModel): WeightsContainer;
|
|
17
|
-
static add(a: Iterable<TensorLike>, b: Iterable<TensorLike>): WeightsContainer;
|
|
18
|
-
static sub(a: Iterable<TensorLike>, b: Iterable<TensorLike>): WeightsContainer;
|
|
19
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WeightsContainer = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var immutable_1 = require("immutable");
|
|
6
|
-
var __1 = require("..");
|
|
7
|
-
var WeightsContainer = /** @class */ (function () {
|
|
8
|
-
function WeightsContainer(weights) {
|
|
9
|
-
this._weights = (0, immutable_1.List)(weights).map(function (w) {
|
|
10
|
-
return w instanceof __1.tf.Tensor ? w : __1.tf.tensor(w);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(WeightsContainer.prototype, "weights", {
|
|
14
|
-
get: function () {
|
|
15
|
-
return this._weights.toArray();
|
|
16
|
-
},
|
|
17
|
-
enumerable: false,
|
|
18
|
-
configurable: true
|
|
19
|
-
});
|
|
20
|
-
WeightsContainer.prototype.add = function (other) {
|
|
21
|
-
return this.mapWith(other, __1.tf.add);
|
|
22
|
-
};
|
|
23
|
-
WeightsContainer.prototype.sub = function (other) {
|
|
24
|
-
return this.mapWith(other, __1.tf.sub);
|
|
25
|
-
};
|
|
26
|
-
WeightsContainer.prototype.mapWith = function (other, fn) {
|
|
27
|
-
return new WeightsContainer(this._weights
|
|
28
|
-
.zip(other._weights)
|
|
29
|
-
.map(function (_a) {
|
|
30
|
-
var _b = (0, tslib_1.__read)(_a, 2), w1 = _b[0], w2 = _b[1];
|
|
31
|
-
return fn(w1, w2);
|
|
32
|
-
}));
|
|
33
|
-
};
|
|
34
|
-
WeightsContainer.prototype.map = function (fn) {
|
|
35
|
-
return new WeightsContainer(this._weights.map(fn));
|
|
36
|
-
};
|
|
37
|
-
WeightsContainer.prototype.reduce = function (fn) {
|
|
38
|
-
return this._weights.reduce(fn);
|
|
39
|
-
};
|
|
40
|
-
WeightsContainer.prototype.get = function (index) {
|
|
41
|
-
return this._weights.get(index);
|
|
42
|
-
};
|
|
43
|
-
WeightsContainer.prototype.frobeniusNorm = function () {
|
|
44
|
-
return Math.sqrt(this.map(function (w) { return w.square().sum(); }).reduce(function (a, b) { return a.add(b); }).dataSync()[0]);
|
|
45
|
-
};
|
|
46
|
-
WeightsContainer.of = function () {
|
|
47
|
-
var weights = [];
|
|
48
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
49
|
-
weights[_i] = arguments[_i];
|
|
50
|
-
}
|
|
51
|
-
return new this(weights);
|
|
52
|
-
};
|
|
53
|
-
WeightsContainer.from = function (model) {
|
|
54
|
-
return new this(model.weights.map(function (w) { return w.read(); }));
|
|
55
|
-
};
|
|
56
|
-
WeightsContainer.add = function (a, b) {
|
|
57
|
-
return new this(a).add(new this(b));
|
|
58
|
-
};
|
|
59
|
-
WeightsContainer.sub = function (a, b) {
|
|
60
|
-
return new this(a).sub(new this(b));
|
|
61
|
-
};
|
|
62
|
-
return WeightsContainer;
|
|
63
|
-
}());
|
|
64
|
-
exports.WeightsContainer = WeightsContainer;
|
package/dist/imports.d.ts
DELETED
package/dist/imports.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IndexedDB = exports.data = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
exports.data = (0, tslib_1.__importStar)(require("./dataset/data_loader"));
|
|
6
|
-
var memory_1 = require("./memory");
|
|
7
|
-
Object.defineProperty(exports, "IndexedDB", { enumerable: true, get: function () { return memory_1.IndexedDB; } });
|
package/dist/memory/memory.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { tf, Memory, Path, ModelInfo, ModelSource } from '..';
|
|
2
|
-
export declare class IndexedDB extends Memory {
|
|
3
|
-
pathFor(source: ModelSource): Path;
|
|
4
|
-
infoFor(source: ModelSource): ModelInfo;
|
|
5
|
-
getModelMetadata(source: ModelSource): Promise<tf.io.ModelArtifactsInfo | undefined>;
|
|
6
|
-
contains(source: ModelSource): Promise<boolean>;
|
|
7
|
-
getModel(source: ModelSource): Promise<tf.LayersModel>;
|
|
8
|
-
deleteModel(source: ModelSource): Promise<void>;
|
|
9
|
-
loadModel(source: ModelSource): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Saves the working model to the source.
|
|
12
|
-
* @param source the destination
|
|
13
|
-
* @param model the model
|
|
14
|
-
*/
|
|
15
|
-
updateWorkingModel(source: ModelSource, model: tf.LayersModel): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a saved copy of the working model corresponding to the source.
|
|
18
|
-
* @param source the source
|
|
19
|
-
*/
|
|
20
|
-
saveWorkingModel(source: ModelSource): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Downloads the model corresponding to the source.
|
|
23
|
-
* @param source the source
|
|
24
|
-
*/
|
|
25
|
-
downloadModel(source: ModelSource): Promise<void>;
|
|
26
|
-
}
|
package/dist/memory/memory.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IndexedDB = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* Helper functions used to load and save TFJS models from IndexedDB. The
|
|
7
|
-
* working model is the model currently being trained for a task. Saved models
|
|
8
|
-
* are models that were explicitly saved to IndexedDB. The two working/ and saved/
|
|
9
|
-
* folders are invisible to the user. The user only interacts with the saved/
|
|
10
|
-
* folder via the model library. The working/ folder is only used by the backend.
|
|
11
|
-
* The working model is loaded from IndexedDB for training (model.fit) only.
|
|
12
|
-
*/
|
|
13
|
-
var path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
|
-
var __1 = require("..");
|
|
15
|
-
var IndexedDB = /** @class */ (function (_super) {
|
|
16
|
-
(0, tslib_1.__extends)(IndexedDB, _super);
|
|
17
|
-
function IndexedDB() {
|
|
18
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
19
|
-
}
|
|
20
|
-
IndexedDB.prototype.pathFor = function (source) {
|
|
21
|
-
if (typeof source === 'string') {
|
|
22
|
-
return source;
|
|
23
|
-
}
|
|
24
|
-
if (source.type === undefined || source.taskID === undefined || source.name === undefined) {
|
|
25
|
-
throw new TypeError('source incomplete');
|
|
26
|
-
}
|
|
27
|
-
return 'indexeddb://' + path_1.default.join(source.type, source.taskID, source.name);
|
|
28
|
-
};
|
|
29
|
-
IndexedDB.prototype.infoFor = function (source) {
|
|
30
|
-
if (typeof source !== 'string') {
|
|
31
|
-
return source;
|
|
32
|
-
}
|
|
33
|
-
var _a = (0, tslib_1.__read)(source.split('/').splice(2), 3), stringType = _a[0], taskID = _a[1], name = _a[2];
|
|
34
|
-
var type = stringType === 'working' ? __1.ModelType.WORKING : __1.ModelType.SAVED;
|
|
35
|
-
return { type: type, taskID: taskID, name: name };
|
|
36
|
-
};
|
|
37
|
-
IndexedDB.prototype.getModelMetadata = function (source) {
|
|
38
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
39
|
-
var models;
|
|
40
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
41
|
-
switch (_a.label) {
|
|
42
|
-
case 0: return [4 /*yield*/, __1.tf.io.listModels()];
|
|
43
|
-
case 1:
|
|
44
|
-
models = _a.sent();
|
|
45
|
-
return [2 /*return*/, models[this.pathFor(source)]];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
IndexedDB.prototype.contains = function (source) {
|
|
51
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
52
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0: return [4 /*yield*/, this.getModelMetadata(source)];
|
|
55
|
-
case 1: return [2 /*return*/, (_a.sent()) !== undefined];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
IndexedDB.prototype.getModel = function (source) {
|
|
61
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
62
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0: return [4 /*yield*/, __1.tf.loadLayersModel(this.pathFor(source))];
|
|
65
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
IndexedDB.prototype.deleteModel = function (source) {
|
|
71
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
72
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0: return [4 /*yield*/, __1.tf.io.removeModel(this.pathFor(source))];
|
|
75
|
-
case 1:
|
|
76
|
-
_a.sent();
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
IndexedDB.prototype.loadModel = function (source) {
|
|
83
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
84
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0: return [4 /*yield*/, __1.tf.io.copyModel(this.pathFor(source), this.pathFor((0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.infoFor(source)), { type: __1.ModelType.WORKING })))];
|
|
87
|
-
case 1:
|
|
88
|
-
_a.sent();
|
|
89
|
-
return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Saves the working model to the source.
|
|
96
|
-
* @param source the destination
|
|
97
|
-
* @param model the model
|
|
98
|
-
*/
|
|
99
|
-
IndexedDB.prototype.updateWorkingModel = function (source, model) {
|
|
100
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
101
|
-
var src;
|
|
102
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
103
|
-
switch (_a.label) {
|
|
104
|
-
case 0:
|
|
105
|
-
src = this.infoFor(source);
|
|
106
|
-
if (src.type !== undefined && src.type !== __1.ModelType.WORKING) {
|
|
107
|
-
throw new TypeError('expected working model');
|
|
108
|
-
}
|
|
109
|
-
return [4 /*yield*/, model.save(this.pathFor((0, tslib_1.__assign)((0, tslib_1.__assign)({}, src), { type: __1.ModelType.WORKING })))];
|
|
110
|
-
case 1:
|
|
111
|
-
_a.sent();
|
|
112
|
-
return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Creates a saved copy of the working model corresponding to the source.
|
|
119
|
-
* @param source the source
|
|
120
|
-
*/
|
|
121
|
-
IndexedDB.prototype.saveWorkingModel = function (source) {
|
|
122
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
123
|
-
var src;
|
|
124
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
125
|
-
switch (_a.label) {
|
|
126
|
-
case 0:
|
|
127
|
-
src = this.infoFor(source);
|
|
128
|
-
if (src.type !== undefined && src.type !== __1.ModelType.WORKING) {
|
|
129
|
-
throw new TypeError('expected working model');
|
|
130
|
-
}
|
|
131
|
-
return [4 /*yield*/, __1.tf.io.copyModel(this.pathFor((0, tslib_1.__assign)((0, tslib_1.__assign)({}, src), { type: __1.ModelType.WORKING })), this.pathFor((0, tslib_1.__assign)((0, tslib_1.__assign)({}, src), { type: __1.ModelType.SAVED })))];
|
|
132
|
-
case 1:
|
|
133
|
-
_a.sent();
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Downloads the model corresponding to the source.
|
|
141
|
-
* @param source the source
|
|
142
|
-
*/
|
|
143
|
-
IndexedDB.prototype.downloadModel = function (source) {
|
|
144
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
145
|
-
var src;
|
|
146
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0:
|
|
149
|
-
src = this.infoFor(source);
|
|
150
|
-
return [4 /*yield*/, __1.tf.io.copyModel(this.pathFor(source), "downloads://" + src.taskID + "_" + src.name)];
|
|
151
|
-
case 1:
|
|
152
|
-
_a.sent();
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
return IndexedDB;
|
|
159
|
-
}(__1.Memory));
|
|
160
|
-
exports.IndexedDB = IndexedDB;
|
|
File without changes
|