@epfml/discojs-node 2.1.1 → 2.1.2-p20240506085559.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.
Files changed (188) hide show
  1. package/dist/data/image_loader.d.ts +5 -0
  2. package/dist/data/image_loader.js +11 -0
  3. package/dist/data/index.d.ts +3 -0
  4. package/dist/data/index.js +3 -0
  5. package/dist/data/tabular_loader.d.ts +4 -0
  6. package/dist/data/tabular_loader.js +11 -0
  7. package/dist/data/text_loader.d.ts +4 -0
  8. package/dist/data/text_loader.js +14 -0
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +2 -6
  11. package/package.json +13 -16
  12. package/README.md +0 -53
  13. package/dist/core/async_buffer.d.ts +0 -41
  14. package/dist/core/async_buffer.js +0 -97
  15. package/dist/core/async_informant.d.ts +0 -20
  16. package/dist/core/async_informant.js +0 -69
  17. package/dist/core/client/base.d.ts +0 -33
  18. package/dist/core/client/base.js +0 -35
  19. package/dist/core/client/decentralized/base.d.ts +0 -32
  20. package/dist/core/client/decentralized/base.js +0 -212
  21. package/dist/core/client/decentralized/clear_text.d.ts +0 -14
  22. package/dist/core/client/decentralized/clear_text.js +0 -96
  23. package/dist/core/client/decentralized/index.d.ts +0 -4
  24. package/dist/core/client/decentralized/index.js +0 -9
  25. package/dist/core/client/decentralized/messages.d.ts +0 -41
  26. package/dist/core/client/decentralized/messages.js +0 -54
  27. package/dist/core/client/decentralized/peer.d.ts +0 -26
  28. package/dist/core/client/decentralized/peer.js +0 -210
  29. package/dist/core/client/decentralized/peer_pool.d.ts +0 -14
  30. package/dist/core/client/decentralized/peer_pool.js +0 -92
  31. package/dist/core/client/decentralized/sec_agg.d.ts +0 -22
  32. package/dist/core/client/decentralized/sec_agg.js +0 -190
  33. package/dist/core/client/decentralized/secret_shares.d.ts +0 -3
  34. package/dist/core/client/decentralized/secret_shares.js +0 -39
  35. package/dist/core/client/decentralized/types.d.ts +0 -2
  36. package/dist/core/client/decentralized/types.js +0 -7
  37. package/dist/core/client/event_connection.d.ts +0 -37
  38. package/dist/core/client/event_connection.js +0 -158
  39. package/dist/core/client/federated/client.d.ts +0 -37
  40. package/dist/core/client/federated/client.js +0 -273
  41. package/dist/core/client/federated/index.d.ts +0 -2
  42. package/dist/core/client/federated/index.js +0 -7
  43. package/dist/core/client/federated/messages.d.ts +0 -38
  44. package/dist/core/client/federated/messages.js +0 -25
  45. package/dist/core/client/index.d.ts +0 -5
  46. package/dist/core/client/index.js +0 -11
  47. package/dist/core/client/local.d.ts +0 -8
  48. package/dist/core/client/local.js +0 -36
  49. package/dist/core/client/messages.d.ts +0 -28
  50. package/dist/core/client/messages.js +0 -33
  51. package/dist/core/client/utils.d.ts +0 -2
  52. package/dist/core/client/utils.js +0 -19
  53. package/dist/core/dataset/data/data.d.ts +0 -11
  54. package/dist/core/dataset/data/data.js +0 -20
  55. package/dist/core/dataset/data/data_split.d.ts +0 -5
  56. package/dist/core/dataset/data/data_split.js +0 -2
  57. package/dist/core/dataset/data/image_data.d.ts +0 -8
  58. package/dist/core/dataset/data/image_data.js +0 -64
  59. package/dist/core/dataset/data/index.d.ts +0 -5
  60. package/dist/core/dataset/data/index.js +0 -11
  61. package/dist/core/dataset/data/preprocessing.d.ts +0 -13
  62. package/dist/core/dataset/data/preprocessing.js +0 -33
  63. package/dist/core/dataset/data/tabular_data.d.ts +0 -8
  64. package/dist/core/dataset/data/tabular_data.js +0 -40
  65. package/dist/core/dataset/data_loader/data_loader.d.ts +0 -15
  66. package/dist/core/dataset/data_loader/data_loader.js +0 -10
  67. package/dist/core/dataset/data_loader/image_loader.d.ts +0 -17
  68. package/dist/core/dataset/data_loader/image_loader.js +0 -141
  69. package/dist/core/dataset/data_loader/index.d.ts +0 -3
  70. package/dist/core/dataset/data_loader/index.js +0 -9
  71. package/dist/core/dataset/data_loader/tabular_loader.d.ts +0 -29
  72. package/dist/core/dataset/data_loader/tabular_loader.js +0 -101
  73. package/dist/core/dataset/dataset.d.ts +0 -2
  74. package/dist/core/dataset/dataset.js +0 -2
  75. package/dist/core/dataset/dataset_builder.d.ts +0 -18
  76. package/dist/core/dataset/dataset_builder.js +0 -96
  77. package/dist/core/dataset/index.d.ts +0 -4
  78. package/dist/core/dataset/index.js +0 -14
  79. package/dist/core/default_tasks/cifar10.d.ts +0 -2
  80. package/dist/core/default_tasks/cifar10.js +0 -68
  81. package/dist/core/default_tasks/geotags.d.ts +0 -2
  82. package/dist/core/default_tasks/geotags.js +0 -69
  83. package/dist/core/default_tasks/index.d.ts +0 -6
  84. package/dist/core/default_tasks/index.js +0 -15
  85. package/dist/core/default_tasks/lus_covid.d.ts +0 -2
  86. package/dist/core/default_tasks/lus_covid.js +0 -96
  87. package/dist/core/default_tasks/mnist.d.ts +0 -2
  88. package/dist/core/default_tasks/mnist.js +0 -69
  89. package/dist/core/default_tasks/simple_face.d.ts +0 -2
  90. package/dist/core/default_tasks/simple_face.js +0 -53
  91. package/dist/core/default_tasks/titanic.d.ts +0 -2
  92. package/dist/core/default_tasks/titanic.js +0 -97
  93. package/dist/core/index.d.ts +0 -18
  94. package/dist/core/index.js +0 -39
  95. package/dist/core/informant/graph_informant.d.ts +0 -10
  96. package/dist/core/informant/graph_informant.js +0 -23
  97. package/dist/core/informant/index.d.ts +0 -3
  98. package/dist/core/informant/index.js +0 -9
  99. package/dist/core/informant/training_informant/base.d.ts +0 -31
  100. package/dist/core/informant/training_informant/base.js +0 -83
  101. package/dist/core/informant/training_informant/decentralized.d.ts +0 -5
  102. package/dist/core/informant/training_informant/decentralized.js +0 -22
  103. package/dist/core/informant/training_informant/federated.d.ts +0 -14
  104. package/dist/core/informant/training_informant/federated.js +0 -32
  105. package/dist/core/informant/training_informant/index.d.ts +0 -4
  106. package/dist/core/informant/training_informant/index.js +0 -11
  107. package/dist/core/informant/training_informant/local.d.ts +0 -6
  108. package/dist/core/informant/training_informant/local.js +0 -20
  109. package/dist/core/logging/console_logger.d.ts +0 -18
  110. package/dist/core/logging/console_logger.js +0 -33
  111. package/dist/core/logging/index.d.ts +0 -3
  112. package/dist/core/logging/index.js +0 -9
  113. package/dist/core/logging/logger.d.ts +0 -12
  114. package/dist/core/logging/logger.js +0 -9
  115. package/dist/core/logging/trainer_logger.d.ts +0 -24
  116. package/dist/core/logging/trainer_logger.js +0 -59
  117. package/dist/core/memory/base.d.ts +0 -22
  118. package/dist/core/memory/base.js +0 -9
  119. package/dist/core/memory/empty.d.ts +0 -14
  120. package/dist/core/memory/empty.js +0 -75
  121. package/dist/core/memory/index.d.ts +0 -3
  122. package/dist/core/memory/index.js +0 -9
  123. package/dist/core/memory/model_type.d.ts +0 -4
  124. package/dist/core/memory/model_type.js +0 -9
  125. package/dist/core/privacy.d.ts +0 -11
  126. package/dist/core/privacy.js +0 -47
  127. package/dist/core/serialization/index.d.ts +0 -2
  128. package/dist/core/serialization/index.js +0 -6
  129. package/dist/core/serialization/model.d.ts +0 -5
  130. package/dist/core/serialization/model.js +0 -55
  131. package/dist/core/serialization/weights.d.ts +0 -5
  132. package/dist/core/serialization/weights.js +0 -64
  133. package/dist/core/task/data_example.d.ts +0 -5
  134. package/dist/core/task/data_example.js +0 -24
  135. package/dist/core/task/digest.d.ts +0 -5
  136. package/dist/core/task/digest.js +0 -18
  137. package/dist/core/task/display_information.d.ts +0 -15
  138. package/dist/core/task/display_information.js +0 -49
  139. package/dist/core/task/index.d.ts +0 -6
  140. package/dist/core/task/index.js +0 -15
  141. package/dist/core/task/model_compile_data.d.ts +0 -6
  142. package/dist/core/task/model_compile_data.js +0 -22
  143. package/dist/core/task/summary.d.ts +0 -5
  144. package/dist/core/task/summary.js +0 -19
  145. package/dist/core/task/task.d.ts +0 -12
  146. package/dist/core/task/task.js +0 -35
  147. package/dist/core/task/task_handler.d.ts +0 -5
  148. package/dist/core/task/task_handler.js +0 -53
  149. package/dist/core/task/task_provider.d.ts +0 -6
  150. package/dist/core/task/task_provider.js +0 -13
  151. package/dist/core/task/training_information.d.ts +0 -28
  152. package/dist/core/task/training_information.js +0 -66
  153. package/dist/core/training/disco.d.ts +0 -23
  154. package/dist/core/training/disco.js +0 -130
  155. package/dist/core/training/index.d.ts +0 -2
  156. package/dist/core/training/index.js +0 -7
  157. package/dist/core/training/trainer/distributed_trainer.d.ts +0 -20
  158. package/dist/core/training/trainer/distributed_trainer.js +0 -65
  159. package/dist/core/training/trainer/local_trainer.d.ts +0 -11
  160. package/dist/core/training/trainer/local_trainer.js +0 -34
  161. package/dist/core/training/trainer/round_tracker.d.ts +0 -30
  162. package/dist/core/training/trainer/round_tracker.js +0 -47
  163. package/dist/core/training/trainer/trainer.d.ts +0 -65
  164. package/dist/core/training/trainer/trainer.js +0 -160
  165. package/dist/core/training/trainer/trainer_builder.d.ts +0 -25
  166. package/dist/core/training/trainer/trainer_builder.js +0 -95
  167. package/dist/core/training/training_schemes.d.ts +0 -5
  168. package/dist/core/training/training_schemes.js +0 -10
  169. package/dist/core/types.d.ts +0 -4
  170. package/dist/core/types.js +0 -2
  171. package/dist/core/validation/index.d.ts +0 -1
  172. package/dist/core/validation/index.js +0 -5
  173. package/dist/core/validation/validator.d.ts +0 -17
  174. package/dist/core/validation/validator.js +0 -104
  175. package/dist/core/weights/aggregation.d.ts +0 -7
  176. package/dist/core/weights/aggregation.js +0 -72
  177. package/dist/core/weights/index.d.ts +0 -2
  178. package/dist/core/weights/index.js +0 -7
  179. package/dist/core/weights/weights_container.d.ts +0 -19
  180. package/dist/core/weights/weights_container.js +0 -64
  181. package/dist/dataset/data_loader/image_loader.d.ts +0 -4
  182. package/dist/dataset/data_loader/image_loader.js +0 -21
  183. package/dist/dataset/data_loader/index.d.ts +0 -2
  184. package/dist/dataset/data_loader/index.js +0 -7
  185. package/dist/dataset/data_loader/tabular_loader.d.ts +0 -4
  186. package/dist/dataset/data_loader/tabular_loader.js +0 -20
  187. package/dist/imports.d.ts +0 -1
  188. package/dist/imports.js +0 -5
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decode = exports.encode = exports.isEncoded = void 0;
4
- var tslib_1 = require("tslib");
5
- var __1 = require("..");
6
- var msgpack_lite_1 = (0, tslib_1.__importDefault)(require("msgpack-lite"));
7
- function isEncoded(raw) {
8
- return Array.isArray(raw) && raw.every(function (r) { return typeof r === 'number'; });
9
- }
10
- exports.isEncoded = isEncoded;
11
- function encode(model) {
12
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
13
- var saved;
14
- var _this = this;
15
- return (0, tslib_1.__generator)(this, function (_a) {
16
- switch (_a.label) {
17
- case 0: return [4 /*yield*/, new Promise(function (resolve) {
18
- void model.save({
19
- save: function (artifacts) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
20
- return (0, tslib_1.__generator)(this, function (_a) {
21
- resolve(artifacts);
22
- return [2 /*return*/, {
23
- modelArtifactsInfo: {
24
- dateSaved: new Date(),
25
- modelTopologyType: 'JSON'
26
- }
27
- }];
28
- });
29
- }); }
30
- });
31
- })];
32
- case 1:
33
- saved = _a.sent();
34
- return [2 /*return*/, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(msgpack_lite_1.default.encode(saved).values()), false)];
35
- }
36
- });
37
- });
38
- }
39
- exports.encode = encode;
40
- function decode(encoded) {
41
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
42
- var raw;
43
- return (0, tslib_1.__generator)(this, function (_a) {
44
- switch (_a.label) {
45
- case 0:
46
- raw = msgpack_lite_1.default.decode(encoded);
47
- return [4 /*yield*/, __1.tf.loadLayersModel({
48
- load: function () { return raw; }
49
- })];
50
- case 1: return [2 /*return*/, _a.sent()];
51
- }
52
- });
53
- });
54
- }
55
- exports.decode = decode;
@@ -1,5 +0,0 @@
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;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decode = exports.encode = exports.isEncoded = void 0;
4
- var tslib_1 = require("tslib");
5
- var msgpack = (0, tslib_1.__importStar)(require("msgpack-lite"));
6
- var __1 = require("..");
7
- function isSerialized(raw) {
8
- if (typeof raw !== 'object' || raw === null) {
9
- return false;
10
- }
11
- if (!('shape' in raw && 'data' in raw)) {
12
- return false;
13
- }
14
- var _a = raw, shape = _a.shape, data = _a.data;
15
- if (!(Array.isArray(shape) && shape.every(function (e) { return typeof e === 'number'; })) ||
16
- !(Array.isArray(data) && data.every(function (e) { return typeof e === 'number'; }))) {
17
- return false;
18
- }
19
- // eslint-disable-next-line
20
- var _ = { shape: shape, data: data };
21
- return true;
22
- }
23
- function isEncoded(raw) {
24
- return Array.isArray(raw) && raw.every(function (e) { return typeof e === 'number'; });
25
- }
26
- exports.isEncoded = isEncoded;
27
- function encode(weights) {
28
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
29
- var serialized;
30
- var _this = this;
31
- return (0, tslib_1.__generator)(this, function (_a) {
32
- switch (_a.label) {
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
- var _a;
35
- var _b;
36
- return (0, tslib_1.__generator)(this, function (_c) {
37
- switch (_c.label) {
38
- case 0:
39
- _b = {
40
- shape: t.shape
41
- };
42
- _a = [[]];
43
- return [4 /*yield*/, t.data()];
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)];
46
- }
47
- });
48
- }); }))];
49
- case 1:
50
- serialized = _a.sent();
51
- return [2 /*return*/, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(msgpack.encode(serialized).values()), false)];
52
- }
53
- });
54
- });
55
- }
56
- exports.encode = encode;
57
- function decode(encoded) {
58
- var raw = msgpack.decode(encoded);
59
- if (!(Array.isArray(raw) && raw.every(isSerialized))) {
60
- throw new Error('expected to decode an array of serialized weights');
61
- }
62
- return new __1.WeightsContainer(raw.map(function (w) { return __1.tf.tensor(w.data, w.shape); }));
63
- }
64
- exports.decode = decode;
@@ -1,5 +0,0 @@
1
- export declare function isDataExample(raw: unknown): raw is DataExample;
2
- export interface DataExample {
3
- columnName: string;
4
- columnData: string | number;
5
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDataExample = void 0;
4
- var immutable_1 = require("immutable");
5
- function isDataExample(raw) {
6
- if (typeof raw !== 'object') {
7
- return false;
8
- }
9
- if (raw === null) {
10
- return false;
11
- }
12
- if (!(0, immutable_1.Set)(Object.keys(raw)).equals(immutable_1.Set.of('columnName', 'columnData'))) {
13
- return false;
14
- }
15
- var _a = raw, columnName = _a.columnName, columnData = _a.columnData;
16
- if (typeof columnName !== 'string' ||
17
- (typeof columnData !== 'string' && typeof columnData !== 'number')) {
18
- return false;
19
- }
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
- var _ = { columnName: columnName, columnData: columnData };
22
- return true;
23
- }
24
- exports.isDataExample = isDataExample;
@@ -1,5 +0,0 @@
1
- export interface Digest {
2
- algorithm: string;
3
- value: string;
4
- }
5
- export declare function isDigest(raw: unknown): raw is Digest;
@@ -1,18 +0,0 @@
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;
@@ -1,15 +0,0 @@
1
- import { Summary } from './summary';
2
- import { DataExample } from './data_example';
3
- export declare function isDisplayInformation(raw: unknown): raw is DisplayInformation;
4
- export interface DisplayInformation {
5
- taskTitle?: string;
6
- summary?: Summary;
7
- tradeoffs?: string;
8
- dataFormatInformation?: string;
9
- dataExampleText?: string;
10
- model?: string;
11
- dataExample?: DataExample[];
12
- headers?: string[];
13
- dataExampleImage?: string;
14
- limitations?: string;
15
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDisplayInformation = void 0;
4
- var summary_1 = require("./summary");
5
- var data_example_1 = require("./data_example");
6
- function isDisplayInformation(raw) {
7
- if (typeof raw !== 'object') {
8
- return false;
9
- }
10
- if (raw === null) {
11
- return false;
12
- }
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;
14
- if (typeof taskTitle !== 'string' ||
15
- (dataExampleText !== undefined && typeof dataExampleText !== 'string') ||
16
- (dataFormatInformation !== undefined && typeof dataFormatInformation !== 'string') ||
17
- (tradeoffs !== undefined && typeof tradeoffs !== 'string') ||
18
- (model !== undefined && typeof model !== 'string') ||
19
- (dataExampleImage !== undefined && typeof dataExampleImage !== 'string') ||
20
- (limitations !== undefined && typeof limitations !== 'string')) {
21
- return false;
22
- }
23
- if (summary !== undefined && !(0, summary_1.isSummary)(summary)) {
24
- return false;
25
- }
26
- if (dataExample !== undefined && !(Array.isArray(dataExample) &&
27
- dataExample.every(data_example_1.isDataExample))) {
28
- return false;
29
- }
30
- if (headers !== undefined && !(Array.isArray(headers) &&
31
- headers.every(function (e) { return typeof e === 'string'; }))) {
32
- return false;
33
- }
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- var _ = {
36
- taskTitle: taskTitle,
37
- summary: summary,
38
- tradeoffs: tradeoffs,
39
- dataFormatInformation: dataFormatInformation,
40
- dataExampleText: dataExampleText,
41
- model: model,
42
- dataExample: dataExample,
43
- headers: headers,
44
- dataExampleImage: dataExampleImage,
45
- limitations: limitations
46
- };
47
- return true;
48
- }
49
- exports.isDisplayInformation = isDisplayInformation;
@@ -1,6 +0,0 @@
1
- export { isTask, Task, isTaskID, TaskID } from './task';
2
- export { TaskProvider, isTaskProvider } from './task_provider';
3
- export { isDigest, Digest } from './digest';
4
- export { isDisplayInformation, DisplayInformation } from './display_information';
5
- export { TrainingInformation } from './training_information';
6
- export { pushTask, fetchTasks } from './task_handler';
@@ -1,15 +0,0 @@
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; } });
@@ -1,6 +0,0 @@
1
- export declare function isModelCompileData(raw: unknown): raw is ModelCompileData;
2
- export interface ModelCompileData {
3
- optimizer: string;
4
- loss: string;
5
- metrics: string[];
6
- }
@@ -1,22 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- export declare function isSummary(raw: unknown): raw is Summary;
2
- export interface Summary {
3
- preview: string;
4
- overview: string;
5
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSummary = void 0;
4
- function isSummary(raw) {
5
- if (typeof raw !== 'object') {
6
- return false;
7
- }
8
- if (raw === null) {
9
- return false;
10
- }
11
- var _a = raw, preview = _a.preview, overview = _a.overview;
12
- if (!(typeof preview === 'string' && typeof overview === 'string')) {
13
- return false;
14
- }
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- var _ = { preview: preview, overview: overview };
17
- return true;
18
- }
19
- exports.isSummary = isSummary;
@@ -1,12 +0,0 @@
1
- import { DisplayInformation } from './display_information';
2
- import { TrainingInformation } from './training_information';
3
- import { Digest } from './digest';
4
- export declare type TaskID = string;
5
- export declare function isTaskID(obj: unknown): obj is TaskID;
6
- export declare function isTask(raw: unknown): raw is Task;
7
- export interface Task {
8
- taskID: TaskID;
9
- digest?: Digest;
10
- displayInformation: DisplayInformation;
11
- trainingInformation: TrainingInformation;
12
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTask = exports.isTaskID = void 0;
4
- var display_information_1 = require("./display_information");
5
- var training_information_1 = require("./training_information");
6
- var digest_1 = require("./digest");
7
- function isTaskID(obj) {
8
- return typeof obj === 'string';
9
- }
10
- exports.isTaskID = isTaskID;
11
- function isTask(raw) {
12
- if (typeof raw !== 'object') {
13
- return false;
14
- }
15
- if (raw === null) {
16
- return false;
17
- }
18
- var _a = raw, taskID = _a.taskID, digest = _a.digest, displayInformation = _a.displayInformation, trainingInformation = _a.trainingInformation;
19
- if (typeof taskID !== 'string') {
20
- return false;
21
- }
22
- if (digest !== undefined && !(0, digest_1.isDigest)(digest)) {
23
- return false;
24
- }
25
- if (!(0, display_information_1.isDisplayInformation)(displayInformation)) {
26
- return false;
27
- }
28
- if (!(0, training_information_1.isTrainingInformation)(trainingInformation)) {
29
- return false;
30
- }
31
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
- var _ = { taskID: taskID, displayInformation: displayInformation, trainingInformation: trainingInformation };
33
- return true;
34
- }
35
- exports.isTask = isTask;
@@ -1,5 +0,0 @@
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>>;
@@ -1,53 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- import { tf, Task } from '..';
2
- export interface TaskProvider {
3
- getTask: () => Task;
4
- getModel: () => Promise<tf.LayersModel>;
5
- }
6
- export declare function isTaskProvider(obj: any): obj is TaskProvider;
@@ -1,13 +0,0 @@
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;
@@ -1,28 +0,0 @@
1
- import { Preprocessing } from '../dataset/data/preprocessing';
2
- import { ModelCompileData } from './model_compile_data';
3
- export declare function isTrainingInformation(raw: unknown): raw is TrainingInformation;
4
- export interface TrainingInformation {
5
- modelID: string;
6
- epochs: number;
7
- roundDuration: number;
8
- validationSplit: number;
9
- batchSize: number;
10
- preprocessingFunctions?: Preprocessing[];
11
- modelCompileData: ModelCompileData;
12
- dataType: string;
13
- inputColumns?: string[];
14
- outputColumns?: string[];
15
- IMAGE_H?: number;
16
- IMAGE_W?: number;
17
- modelURL?: string;
18
- LABEL_LIST?: string[];
19
- learningRate?: number;
20
- scheme: string;
21
- noiseScale?: number;
22
- clippingRadius?: number;
23
- decentralizedSecure?: boolean;
24
- byzantineRobustAggregator?: boolean;
25
- tauPercentile?: number;
26
- maxShareValue?: number;
27
- minimumReadyPeers?: number;
28
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTrainingInformation = void 0;
4
- var model_compile_data_1 = require("./model_compile_data");
5
- function isTrainingInformation(raw) {
6
- if (typeof raw !== 'object') {
7
- return false;
8
- }
9
- if (raw === null) {
10
- return false;
11
- }
12
- var _a = raw, dataType = _a.dataType, scheme = _a.scheme, epochs = _a.epochs,
13
- // roundDuration,
14
- validationSplit = _a.validationSplit, batchSize = _a.batchSize, modelCompileData = _a.modelCompileData, modelID = _a.modelID, preprocessingFunctions = _a.preprocessingFunctions, inputColumns = _a.inputColumns, outputColumns = _a.outputColumns, IMAGE_H = _a.IMAGE_H, IMAGE_W = _a.IMAGE_W, roundDuration = _a.roundDuration, modelURL = _a.modelURL, learningRate = _a.learningRate, decentralizedSecure = _a.decentralizedSecure, maxShareValue = _a.maxShareValue, minimumReadyPeers = _a.minimumReadyPeers, LABEL_LIST = _a.LABEL_LIST, noiseScale = _a.noiseScale, clippingRadius = _a.clippingRadius;
15
- if (typeof dataType !== 'string' ||
16
- typeof modelID !== 'string' ||
17
- typeof epochs !== 'number' ||
18
- typeof batchSize !== 'number' ||
19
- typeof roundDuration !== 'number' ||
20
- typeof validationSplit !== 'number' ||
21
- (modelURL !== undefined && typeof modelURL !== 'string') ||
22
- (noiseScale !== undefined && typeof noiseScale !== 'number') ||
23
- (clippingRadius !== undefined && typeof clippingRadius !== 'number') ||
24
- (learningRate !== undefined && typeof learningRate !== 'number') ||
25
- (decentralizedSecure !== undefined && typeof decentralizedSecure !== 'boolean') ||
26
- (maxShareValue !== undefined && typeof maxShareValue !== 'number') ||
27
- (minimumReadyPeers !== undefined && typeof minimumReadyPeers !== 'number')) {
28
- return false;
29
- }
30
- // interdepences on data type
31
- switch (dataType) {
32
- case 'image':
33
- if (typeof IMAGE_H !== 'number' || typeof IMAGE_W !== 'number') {
34
- return false;
35
- }
36
- break;
37
- case 'tabular':
38
- if (!(Array.isArray(inputColumns) && inputColumns.every(function (e) { return typeof e === 'string'; }))) {
39
- return false;
40
- }
41
- if (!(Array.isArray(outputColumns) && outputColumns.every(function (e) { return typeof e === 'string'; }))) {
42
- return false;
43
- }
44
- break;
45
- }
46
- // interdepences on scheme
47
- switch (scheme) {
48
- case 'decentralized':
49
- break;
50
- case 'federated':
51
- break;
52
- case 'local':
53
- break;
54
- }
55
- if (!(0, model_compile_data_1.isModelCompileData)(modelCompileData)) {
56
- return false;
57
- }
58
- if (LABEL_LIST !== undefined && !(Array.isArray(LABEL_LIST) && LABEL_LIST.every(function (e) { return typeof e === 'string'; }))) {
59
- return false;
60
- }
61
- if (preprocessingFunctions !== undefined && !(Array.isArray(preprocessingFunctions) && preprocessingFunctions.every(function (e) { return typeof e === 'string'; }))) {
62
- return false;
63
- }
64
- return true;
65
- }
66
- exports.isTrainingInformation = isTrainingInformation;
@@ -1,23 +0,0 @@
1
- import { Client, data, Logger, Task, TrainingInformant, TrainingSchemes, Memory } from '..';
2
- import { TrainerLog } from '../logging/trainer_logger';
3
- interface DiscoOptions {
4
- client?: Client;
5
- url?: string | URL;
6
- scheme?: TrainingSchemes;
7
- informant?: TrainingInformant;
8
- logger?: Logger;
9
- memory?: Memory;
10
- }
11
- export declare class Disco {
12
- readonly task: Task;
13
- readonly logger: Logger;
14
- readonly memory: Memory;
15
- private readonly client;
16
- private readonly trainer;
17
- constructor(task: Task, options: DiscoOptions);
18
- fit(dataTuple: data.DataSplit): Promise<void>;
19
- pause(): Promise<void>;
20
- close(): Promise<void>;
21
- logs(): Promise<TrainerLog>;
22
- }
23
- export {};