@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
package/dist/tasks/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.titanic = exports.simple_face = exports.mnist = exports.lus_covid = exports.cifar10 = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
exports.cifar10 = (0, tslib_1.__importStar)(require("./cifar10"));
|
|
6
|
-
exports.lus_covid = (0, tslib_1.__importStar)(require("./lus_covid"));
|
|
7
|
-
exports.mnist = (0, tslib_1.__importStar)(require("./mnist"));
|
|
8
|
-
exports.simple_face = (0, tslib_1.__importStar)(require("./simple_face"));
|
|
9
|
-
exports.titanic = (0, tslib_1.__importStar)(require("./titanic"));
|
package/dist/tasks/lus_covid.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.model = exports.task = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var tf = (0, tslib_1.__importStar)(require("@tensorflow/tfjs"));
|
|
6
|
-
exports.task = {
|
|
7
|
-
taskID: 'lus_covid',
|
|
8
|
-
displayInformation: {
|
|
9
|
-
taskTitle: 'COVID Lung Ultrasound',
|
|
10
|
-
summary: {
|
|
11
|
-
preview: "Do you have a dataset of lung ultrasound images on patients <b>suspected of Lower Respiratory Tract infection (LRTI) during the COVID pandemic</b>? <br> Learn how to discriminate between COVID positive and negative patients by joining this task. <br><br> Don’t have a dataset of your own? Download a sample of a few cases <a class='underline' href='https://drive.switch.ch/index.php/s/zM5ZrUWK3taaIly'>here</a>.",
|
|
12
|
-
overview: "Do you have a dataset of lung ultrasound images on patients <b>suspected of Lower Respiratory Tract infection (LRTI) during the COVID pandemic</b>? <br> Learn how to discriminate between COVID positive and negative patients by joining this task. <br><br> Don’t have a dataset of your own? Download a sample of a few cases <a class='underline' href='https://drive.switch.ch/index.php/s/zM5ZrUWK3taaIly'>here</a>."
|
|
13
|
-
},
|
|
14
|
-
model: "We use a simplified* version of the <b>DeepChest model</b>: A deep learning model developed in our lab (<a class='underline' href='https://www.epfl.ch/labs/mlo/igh-intelligent-global-health/'>intelligent Global Health</a>.). On a cohort of 400 Swiss patients suspected of LRTI, the model obtained over 90% area under the ROC curve for this task. <br><br>*Simplified to ensure smooth running on your browser, the performance is minimally affected. Details of the adaptations are below <br>- <b>Removed</b>: positional embedding (i.e. we don’t take the anatomic position into consideration). Rather, the model now does mean pooling over the feature vector of the images for each patient <br>- <b>Replaced</b>: ResNet18 by Mobilenet",
|
|
15
|
-
tradeoffs: 'We are using a simpler version of DeepChest in order to be able to run it on the browser.',
|
|
16
|
-
dataFormatInformation: 'This model takes as input an image dataset. It consists on a set of lung ultrasound images per patient with its corresponding label of covid positive or negative. Moreover, to identify the images per patient you have to follow the follwing naming pattern: "patientId_*.png"',
|
|
17
|
-
dataExampleText: 'Below you can find an example of an expected lung image for patient 2 named: 2_QAID_1.masked.reshaped.squared.224.png'
|
|
18
|
-
},
|
|
19
|
-
trainingInformation: {
|
|
20
|
-
modelID: 'lus-covid-model',
|
|
21
|
-
epochs: 15,
|
|
22
|
-
roundDuration: 10,
|
|
23
|
-
validationSplit: 0.2,
|
|
24
|
-
batchSize: 2,
|
|
25
|
-
modelCompileData: {
|
|
26
|
-
optimizer: 'sgd',
|
|
27
|
-
loss: 'binaryCrossentropy',
|
|
28
|
-
metrics: ['accuracy']
|
|
29
|
-
},
|
|
30
|
-
learningRate: 0.001,
|
|
31
|
-
threshold: 2,
|
|
32
|
-
IMAGE_H: 100,
|
|
33
|
-
IMAGE_W: 100,
|
|
34
|
-
preprocessFunctions: [],
|
|
35
|
-
LABEL_LIST: ['COVID-Positive', 'COVID-Negative'],
|
|
36
|
-
NUM_CLASSES: 2,
|
|
37
|
-
dataType: 'image',
|
|
38
|
-
aggregateImagesById: true,
|
|
39
|
-
scheme: 'Decentralized'
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
function model(imageHeight, imageWidth, imageChannels, numOutputClasses) {
|
|
43
|
-
if (imageHeight === void 0) { imageHeight = 100; }
|
|
44
|
-
if (imageWidth === void 0) { imageWidth = 100; }
|
|
45
|
-
if (imageChannels === void 0) { imageChannels = 3; }
|
|
46
|
-
if (numOutputClasses === void 0) { numOutputClasses = 2; }
|
|
47
|
-
var model = tf.sequential();
|
|
48
|
-
// In the first layer of our convolutional neural network we have
|
|
49
|
-
// to specify the input shape. Then we specify some parameters for
|
|
50
|
-
// the convolution operation that takes place in this layer.
|
|
51
|
-
model.add(tf.layers.conv2d({
|
|
52
|
-
inputShape: [imageHeight, imageWidth, imageChannels],
|
|
53
|
-
kernelSize: 5,
|
|
54
|
-
filters: 8,
|
|
55
|
-
strides: 1,
|
|
56
|
-
activation: 'relu',
|
|
57
|
-
kernelInitializer: 'varianceScaling'
|
|
58
|
-
}));
|
|
59
|
-
// The MaxPooling layer acts as a sort of downsampling using max values
|
|
60
|
-
// in a region instead of averaging.
|
|
61
|
-
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
|
|
62
|
-
// Repeat another conv2d + maxPooling stack.
|
|
63
|
-
// Note that we have more filters in the convolution.
|
|
64
|
-
model.add(tf.layers.conv2d({
|
|
65
|
-
kernelSize: 5,
|
|
66
|
-
filters: 16,
|
|
67
|
-
strides: 1,
|
|
68
|
-
activation: 'relu',
|
|
69
|
-
kernelInitializer: 'varianceScaling'
|
|
70
|
-
}));
|
|
71
|
-
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
|
|
72
|
-
// Now we flatten the output from the 2D filters into a 1D vector to prepare
|
|
73
|
-
// it for input into our last layer. This is common practice when feeding
|
|
74
|
-
// higher dimensional data to a final classification output layer.
|
|
75
|
-
model.add(tf.layers.flatten());
|
|
76
|
-
// Our last layer is a dense layer which has 10 output units, one for each
|
|
77
|
-
// output class (i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
|
|
78
|
-
model.add(tf.layers.dense({
|
|
79
|
-
units: numOutputClasses,
|
|
80
|
-
kernelInitializer: 'varianceScaling',
|
|
81
|
-
activation: 'softmax'
|
|
82
|
-
}));
|
|
83
|
-
return model;
|
|
84
|
-
}
|
|
85
|
-
exports.model = model;
|
package/dist/tasks/mnist.d.ts
DELETED
package/dist/tasks/mnist.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.model = exports.task = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var tf = (0, tslib_1.__importStar)(require("@tensorflow/tfjs"));
|
|
6
|
-
exports.task = {
|
|
7
|
-
taskID: 'mnist',
|
|
8
|
-
displayInformation: {
|
|
9
|
-
taskTitle: 'MNIST',
|
|
10
|
-
summary: {
|
|
11
|
-
preview: "Test our platform by using a publicly available <b>image</b> dataset. <br><br> Download the classic MNIST imagebank of hand-written numbers <a class='underline text-primary-dark dark:text-primary-light' href='https://www.kaggle.com/scolianni/mnistasjpg'>here</a>. <br> This model learns to identify hand written numbers.",
|
|
12
|
-
overview: 'The MNIST handwritten digit classification problem is a standard dataset used in computer vision and deep learning. Although the dataset is effectively solved, we use it to test our Decentralised Learning algorithms and platform.'
|
|
13
|
-
},
|
|
14
|
-
model: 'The current model is a very simple CNN and its main goal is to test the app and the Decentralizsed Learning functionality.',
|
|
15
|
-
tradeoffs: 'We are using a simple model, first a 2d convolutional layer > max pooling > 2d convolutional layer > max pooling > convolutional layer > 2 dense layers.',
|
|
16
|
-
dataFormatInformation: 'This model is trained on images corresponding to digits 0 to 9. You can upload each digit image of your dataset in the box corresponding to its label. The model taskes images of size 28x28 as input.',
|
|
17
|
-
dataExampleText: 'Below you can find an example of an expected image representing the digit 9.',
|
|
18
|
-
dataExampleImage: './9-mnist-example.png'
|
|
19
|
-
},
|
|
20
|
-
trainingInformation: {
|
|
21
|
-
modelID: 'mnist-model',
|
|
22
|
-
epochs: 10,
|
|
23
|
-
roundDuration: 10,
|
|
24
|
-
validationSplit: 0.2,
|
|
25
|
-
batchSize: 30,
|
|
26
|
-
modelCompileData: {
|
|
27
|
-
optimizer: 'rmsprop',
|
|
28
|
-
loss: 'categoricalCrossentropy',
|
|
29
|
-
metrics: ['accuracy']
|
|
30
|
-
},
|
|
31
|
-
threshold: 1,
|
|
32
|
-
dataType: 'image',
|
|
33
|
-
IMAGE_H: 28,
|
|
34
|
-
IMAGE_W: 28,
|
|
35
|
-
preprocessFunctions: [],
|
|
36
|
-
LABEL_LIST: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
37
|
-
aggregateImagesById: false,
|
|
38
|
-
scheme: 'Decentralized'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function model() {
|
|
42
|
-
var model = tf.sequential();
|
|
43
|
-
model.add(tf.layers.conv2d({
|
|
44
|
-
inputShape: [28, 28, 3],
|
|
45
|
-
kernelSize: 3,
|
|
46
|
-
filters: 16,
|
|
47
|
-
activation: 'relu'
|
|
48
|
-
}));
|
|
49
|
-
model.add(tf.layers.maxPooling2d({ poolSize: 2, strides: 2 }));
|
|
50
|
-
model.add(tf.layers.conv2d({ kernelSize: 3, filters: 32, activation: 'relu' }));
|
|
51
|
-
model.add(tf.layers.maxPooling2d({ poolSize: 2, strides: 2 }));
|
|
52
|
-
model.add(tf.layers.conv2d({ kernelSize: 3, filters: 32, activation: 'relu' }));
|
|
53
|
-
model.add(tf.layers.flatten({}));
|
|
54
|
-
model.add(tf.layers.dense({ units: 64, activation: 'relu' }));
|
|
55
|
-
model.add(tf.layers.dense({ units: 10, activation: 'softmax' }));
|
|
56
|
-
return model;
|
|
57
|
-
}
|
|
58
|
-
exports.model = model;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.model = exports.task = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var tf = (0, tslib_1.__importStar)(require("@tensorflow/tfjs"));
|
|
6
|
-
exports.task = {
|
|
7
|
-
taskID: 'simple_face',
|
|
8
|
-
displayInformation: {
|
|
9
|
-
taskTitle: 'Simple Face',
|
|
10
|
-
summary: {
|
|
11
|
-
preview: 'Can you detect if the person in a picture is a child or an adult?',
|
|
12
|
-
overview: 'Simple face is a small subset of face_task from Kaggle'
|
|
13
|
-
},
|
|
14
|
-
limitations: 'The training data is limited to small images of size 200x200.',
|
|
15
|
-
tradeoffs: 'Training success strongly depends on label distribution',
|
|
16
|
-
dataFormatInformation: '',
|
|
17
|
-
dataExampleText: 'Below you find an example',
|
|
18
|
-
dataExampleImage: './simple_face-example.png'
|
|
19
|
-
},
|
|
20
|
-
trainingInformation: {
|
|
21
|
-
modelID: 'simple_face-model',
|
|
22
|
-
epochs: 50,
|
|
23
|
-
roundDuration: 1,
|
|
24
|
-
validationSplit: 0.2,
|
|
25
|
-
batchSize: 10,
|
|
26
|
-
preprocessFunctions: [],
|
|
27
|
-
learningRate: 0.001,
|
|
28
|
-
modelCompileData: {
|
|
29
|
-
optimizer: 'sgd',
|
|
30
|
-
loss: 'categoricalCrossentropy',
|
|
31
|
-
metrics: ['accuracy']
|
|
32
|
-
},
|
|
33
|
-
dataType: 'image',
|
|
34
|
-
csvLabels: false,
|
|
35
|
-
IMAGE_H: 200,
|
|
36
|
-
IMAGE_W: 200,
|
|
37
|
-
LABEL_LIST: ['child', 'adult'],
|
|
38
|
-
scheme: 'Federated'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function model(imageHeight, imageWidth, imageChannels, numOutputClasses) {
|
|
42
|
-
if (imageHeight === void 0) { imageHeight = 200; }
|
|
43
|
-
if (imageWidth === void 0) { imageWidth = 200; }
|
|
44
|
-
if (imageChannels === void 0) { imageChannels = 3; }
|
|
45
|
-
if (numOutputClasses === void 0) { numOutputClasses = 2; }
|
|
46
|
-
var model = tf.sequential();
|
|
47
|
-
// In the first layer of our convolutional neural network we have
|
|
48
|
-
// to specify the input shape. Then we specify some parameters for
|
|
49
|
-
// the convolution operation that takes place in this layer.
|
|
50
|
-
model.add(tf.layers.conv2d({
|
|
51
|
-
inputShape: [imageHeight, imageWidth, imageChannels],
|
|
52
|
-
kernelSize: 5,
|
|
53
|
-
filters: 8,
|
|
54
|
-
strides: 1,
|
|
55
|
-
activation: 'relu',
|
|
56
|
-
kernelInitializer: 'varianceScaling'
|
|
57
|
-
}));
|
|
58
|
-
// The MaxPooling layer acts as a sort of downsampling using max values
|
|
59
|
-
// in a region instead of averaging.
|
|
60
|
-
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
|
|
61
|
-
// Repeat another conv2d + maxPooling stack.
|
|
62
|
-
// Note that we have more filters in the convolution.
|
|
63
|
-
model.add(tf.layers.conv2d({
|
|
64
|
-
kernelSize: 5,
|
|
65
|
-
filters: 16,
|
|
66
|
-
strides: 1,
|
|
67
|
-
activation: 'relu',
|
|
68
|
-
kernelInitializer: 'varianceScaling'
|
|
69
|
-
}));
|
|
70
|
-
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
|
|
71
|
-
// Now we flatten the output from the 2D filters into a 1D vector to prepare
|
|
72
|
-
// it for input into our last layer. This is common practice when feeding
|
|
73
|
-
// higher dimensional data to a final classification output layer.
|
|
74
|
-
model.add(tf.layers.flatten());
|
|
75
|
-
// Our last layer is a dense layer which has 10 output units, one for each
|
|
76
|
-
// output class (i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
|
|
77
|
-
model.add(tf.layers.dense({
|
|
78
|
-
units: numOutputClasses,
|
|
79
|
-
kernelInitializer: 'varianceScaling',
|
|
80
|
-
activation: 'softmax'
|
|
81
|
-
}));
|
|
82
|
-
return model;
|
|
83
|
-
}
|
|
84
|
-
exports.model = model;
|
package/dist/tasks/titanic.d.ts
DELETED
package/dist/tasks/titanic.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.model = exports.task = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var tf = (0, tslib_1.__importStar)(require("@tensorflow/tfjs"));
|
|
6
|
-
exports.task = {
|
|
7
|
-
taskID: 'titanic',
|
|
8
|
-
displayInformation: {
|
|
9
|
-
taskTitle: 'Titanic',
|
|
10
|
-
summary: {
|
|
11
|
-
preview: "Test our platform by using a publicly available <b>tabular</b> dataset. <br><br> Download the passenger list from the Titanic shipwreck here: <a class='underline text-primary-dark dark:text-primary-light' href='http://s3.amazonaws.com/assets.datacamp.com/course/Kaggle/train.csv'>train.csv</a> and <a class='underline text-primary-dark dark:text-primary-light' href='http://s3.amazonaws.com/assets.datacamp.com/course/Kaggle/train.csv'>test.csv</a> (more info <a class='underline text-primary-dark dark:text-primary-light' href='https://www.kaggle.com/c/titanic'>here</a>). <br> This model predicts the type of person most likely to survive/die in the historic ship accident, based on their characteristics (sex, age, class etc.).",
|
|
12
|
-
overview: 'We all know the unfortunate story of the Titanic: this flamboyant new transatlantic boat that sunk in 1912 in the North Atlantic Ocean. Today, we revist this tragedy by trying to predict the survival odds of the passenger given some basic features.'
|
|
13
|
-
},
|
|
14
|
-
model: 'The current model does not normalize the given data and applies only a very simple pre-processing of the data.',
|
|
15
|
-
tradeoffs: 'We are using a small model for this task: 4 fully connected layers with few neurons. This allows fast training but can yield to reduced accuracy.',
|
|
16
|
-
dataFormatInformation: 'This model takes as input a CSV file with 12 columns. The features are general information about the passenger (sex, age, name, etc.) and specific related Titanic data such as the ticket class bought by the passenger, its cabin number, etc.<br><br>pclass: A proxy for socio-economic status (SES)<br>1st = Upper<br>2nd = Middle<br>3rd = Lower<br><br>age: Age is fractional if less than 1. If the age is estimated, it is in the form of xx.5<br><br>sibsp: The dataset defines family relations in this way:<br>Sibling = brother, sister, stepbrother, stepsister<br>Spouse = husband, wife (mistresses and fiancés were ignored)<br><br>parch: The dataset defines family relations in this way:<br>Parent = mother, father<br>Child = daughter, son, stepdaughter, stepson<br>Some children travelled only with a nanny, therefore parch=0 for them.<br><br>The first line of the CSV contains the header:<br> PassengerId, Survived, Pclass, Name, Sex, Age, SibSp, Parch, Ticket, Fare, Cabin, Embarked<br><br>Each susequent row contains the corresponding data.',
|
|
17
|
-
dataExampleText: 'Below one can find an example of a datapoint taken as input by our model. In this datapoint, the person is young man named Owen Harris that unfortunnalty perished with the Titanic. He boarded the boat in South Hamptons and was a 3rd class passenger. On the testing & validation page, the data should not contain the label column (Survived).',
|
|
18
|
-
dataExample: [
|
|
19
|
-
{ columnName: 'PassengerId', columnData: '1' },
|
|
20
|
-
{ columnName: 'Survived', columnData: '0' },
|
|
21
|
-
{ columnName: 'Name', columnData: 'Braund, Mr. Owen Harris' },
|
|
22
|
-
{ columnName: 'Sex', columnData: 'male' },
|
|
23
|
-
{ columnName: 'Age', columnData: '22' },
|
|
24
|
-
{ columnName: 'SibSp', columnData: '1' },
|
|
25
|
-
{ columnName: 'Parch', columnData: '0' },
|
|
26
|
-
{ columnName: 'Ticket', columnData: '1/5 21171' },
|
|
27
|
-
{ columnName: 'Fare', columnData: '7.25' },
|
|
28
|
-
{ columnName: 'Cabin', columnData: 'E46' },
|
|
29
|
-
{ columnName: 'Embarked', columnData: 'S' },
|
|
30
|
-
{ columnName: 'Pclass', columnData: '3' }
|
|
31
|
-
],
|
|
32
|
-
headers: [
|
|
33
|
-
'PassengerId',
|
|
34
|
-
'Survived',
|
|
35
|
-
'Name',
|
|
36
|
-
'Sex',
|
|
37
|
-
'Age',
|
|
38
|
-
'SibSp',
|
|
39
|
-
'Parch',
|
|
40
|
-
'Ticket',
|
|
41
|
-
'Fare',
|
|
42
|
-
'Cabin',
|
|
43
|
-
'Embarked',
|
|
44
|
-
'Pclass'
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
trainingInformation: {
|
|
48
|
-
modelID: 'titanic-model',
|
|
49
|
-
epochs: 20,
|
|
50
|
-
roundDuration: 10,
|
|
51
|
-
validationSplit: 0,
|
|
52
|
-
batchSize: 30,
|
|
53
|
-
preprocessFunctions: [],
|
|
54
|
-
modelCompileData: {
|
|
55
|
-
optimizer: 'rmsprop',
|
|
56
|
-
loss: 'binaryCrossentropy',
|
|
57
|
-
metrics: ['accuracy']
|
|
58
|
-
},
|
|
59
|
-
receivedMessagesThreshold: 1,
|
|
60
|
-
dataType: 'tabular',
|
|
61
|
-
inputColumns: [
|
|
62
|
-
'PassengerId',
|
|
63
|
-
'Age',
|
|
64
|
-
'SibSp',
|
|
65
|
-
'Parch',
|
|
66
|
-
'Fare',
|
|
67
|
-
'Pclass'
|
|
68
|
-
],
|
|
69
|
-
outputColumns: [
|
|
70
|
-
'Survived'
|
|
71
|
-
],
|
|
72
|
-
scheme: 'Federated'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function model() {
|
|
76
|
-
var model = tf.sequential();
|
|
77
|
-
model.add(tf.layers.dense({
|
|
78
|
-
inputShape: [6],
|
|
79
|
-
units: 124,
|
|
80
|
-
activation: 'relu',
|
|
81
|
-
kernelInitializer: 'leCunNormal'
|
|
82
|
-
}));
|
|
83
|
-
model.add(tf.layers.dense({ units: 64, activation: 'relu' }));
|
|
84
|
-
model.add(tf.layers.dense({ units: 32, activation: 'relu' }));
|
|
85
|
-
model.add(tf.layers.dense({ units: 1, activation: 'sigmoid' }));
|
|
86
|
-
return model;
|
|
87
|
-
}
|
|
88
|
-
exports.model = model;
|
package/dist/tfjs.d.ts
DELETED
package/dist/tfjs.js
DELETED
package/dist/training/disco.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Memory } from '@/memory';
|
|
2
|
-
import { Client, dataset, Logger, Task, TrainingInformant, TrainingSchemes } from '..';
|
|
3
|
-
import { TrainerLog } from '../logging/trainer_logger';
|
|
4
|
-
export declare class Disco {
|
|
5
|
-
readonly task: Task;
|
|
6
|
-
readonly logger: Logger;
|
|
7
|
-
readonly memory: Memory;
|
|
8
|
-
private readonly client;
|
|
9
|
-
private readonly trainer;
|
|
10
|
-
constructor(task: Task, logger: Logger, memory: Memory, scheme: TrainingSchemes, informant: TrainingInformant, client: Client);
|
|
11
|
-
startTraining(dataTuple: dataset.DataTuple): Promise<void>;
|
|
12
|
-
stopTraining(): Promise<void>;
|
|
13
|
-
getTrainerLog(): Promise<TrainerLog>;
|
|
14
|
-
}
|
package/dist/training/disco.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Disco = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var __1 = require("..");
|
|
6
|
-
var trainer_builder_1 = require("./trainer/trainer_builder");
|
|
7
|
-
// Handles the training loop, server communication & provides the user with feedback.
|
|
8
|
-
var Disco = /** @class */ (function () {
|
|
9
|
-
// client need to be connected
|
|
10
|
-
function Disco(task, logger, memory, scheme, informant, client) {
|
|
11
|
-
this.task = task;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.memory = memory;
|
|
14
|
-
this.client = client;
|
|
15
|
-
if (client.task !== task) {
|
|
16
|
-
throw new Error('client not setup for given task');
|
|
17
|
-
}
|
|
18
|
-
if (informant.taskID !== task.taskID) {
|
|
19
|
-
throw new Error('informant not setup for given task');
|
|
20
|
-
}
|
|
21
|
-
var trainerBuilder = new trainer_builder_1.TrainerBuilder(this.memory, this.task, informant);
|
|
22
|
-
this.trainer = trainerBuilder.build(this.client, scheme !== __1.TrainingSchemes.LOCAL);
|
|
23
|
-
}
|
|
24
|
-
Disco.prototype.startTraining = function (dataTuple) {
|
|
25
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
26
|
-
var valDataset;
|
|
27
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
28
|
-
switch (_a.label) {
|
|
29
|
-
case 0:
|
|
30
|
-
this.logger.success('Thank you for your contribution. Data preprocessing has started');
|
|
31
|
-
valDataset = dataTuple.validation !== undefined ? dataTuple.validation.dataset : dataTuple.train.dataset;
|
|
32
|
-
return [4 /*yield*/, this.trainer];
|
|
33
|
-
case 1: return [4 /*yield*/, (_a.sent()).trainModel(dataTuple.train.dataset, valDataset)];
|
|
34
|
-
case 2:
|
|
35
|
-
_a.sent();
|
|
36
|
-
return [2 /*return*/];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
// Stops the training function
|
|
42
|
-
//
|
|
43
|
-
// do not disconnect given client
|
|
44
|
-
Disco.prototype.stopTraining = function () {
|
|
45
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
46
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, this.trainer];
|
|
49
|
-
case 1: return [4 /*yield*/, (_a.sent()).stopTraining()];
|
|
50
|
-
case 2:
|
|
51
|
-
_a.sent();
|
|
52
|
-
this.logger.success('Training was successfully interrupted.');
|
|
53
|
-
return [2 /*return*/];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
Disco.prototype.getTrainerLog = function () {
|
|
59
|
-
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
60
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0: return [4 /*yield*/, this.trainer];
|
|
63
|
-
case 1: return [2 /*return*/, (_a.sent()).getTrainerLog()];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
return Disco;
|
|
69
|
-
}());
|
|
70
|
-
exports.Disco = Disco;
|