@epfml/discojs 2.2.1 → 3.0.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 +9 -48
- package/dist/aggregator/base.js +8 -69
- package/dist/aggregator/get.d.ts +23 -11
- package/dist/aggregator/get.js +40 -23
- package/dist/aggregator/index.d.ts +1 -1
- package/dist/aggregator/index.js +1 -1
- package/dist/aggregator/mean.d.ts +25 -6
- package/dist/aggregator/mean.js +62 -17
- package/dist/aggregator/secure.d.ts +2 -2
- package/dist/aggregator/secure.js +4 -7
- package/dist/client/base.d.ts +3 -3
- package/dist/client/base.js +6 -8
- package/dist/client/decentralized/base.d.ts +27 -10
- package/dist/client/decentralized/base.js +123 -86
- package/dist/client/decentralized/peer.js +7 -12
- package/dist/client/decentralized/peer_pool.js +6 -2
- package/dist/client/event_connection.d.ts +1 -1
- package/dist/client/event_connection.js +3 -3
- package/dist/client/federated/base.d.ts +5 -21
- package/dist/client/federated/base.js +38 -61
- package/dist/client/federated/messages.d.ts +2 -10
- package/dist/client/federated/messages.js +0 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/local.d.ts +3 -1
- package/dist/client/local.js +4 -1
- package/dist/client/messages.d.ts +1 -2
- package/dist/client/messages.js +8 -3
- package/dist/client/utils.d.ts +4 -2
- package/dist/client/utils.js +18 -3
- package/dist/dataset/data/data.d.ts +1 -1
- package/dist/dataset/data/data.js +13 -2
- package/dist/dataset/data/preprocessing/image_preprocessing.js +6 -4
- package/dist/default_tasks/cifar10.js +1 -2
- package/dist/default_tasks/lus_covid.js +0 -5
- package/dist/default_tasks/mnist.js +15 -14
- package/dist/default_tasks/simple_face.js +0 -2
- package/dist/default_tasks/titanic.js +2 -4
- package/dist/default_tasks/wikitext.js +7 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/models/gpt/config.js +1 -1
- package/dist/privacy.d.ts +8 -10
- package/dist/privacy.js +25 -40
- package/dist/task/task_handler.js +10 -2
- package/dist/task/training_information.d.ts +7 -4
- package/dist/task/training_information.js +25 -6
- package/dist/training/disco.d.ts +30 -28
- package/dist/training/disco.js +75 -73
- package/dist/training/index.d.ts +1 -1
- package/dist/training/index.js +1 -0
- package/dist/training/trainer.d.ts +16 -0
- package/dist/training/trainer.js +72 -0
- package/dist/types.d.ts +0 -2
- package/dist/weights/weights_container.d.ts +0 -5
- package/dist/weights/weights_container.js +0 -7
- package/package.json +1 -1
- package/dist/async_informant.d.ts +0 -15
- package/dist/async_informant.js +0 -42
- package/dist/training/trainer/distributed_trainer.d.ts +0 -20
- package/dist/training/trainer/distributed_trainer.js +0 -41
- package/dist/training/trainer/local_trainer.d.ts +0 -12
- package/dist/training/trainer/local_trainer.js +0 -24
- package/dist/training/trainer/trainer.d.ts +0 -32
- package/dist/training/trainer/trainer.js +0 -61
- package/dist/training/trainer/trainer_builder.d.ts +0 -23
- package/dist/training/trainer/trainer_builder.js +0 -47
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { DistributedTrainer } from './distributed_trainer.js';
|
|
2
|
-
import { LocalTrainer } from './local_trainer.js';
|
|
3
|
-
/**
|
|
4
|
-
* A class that helps build the Trainer and auxiliary classes.
|
|
5
|
-
*/
|
|
6
|
-
export class TrainerBuilder {
|
|
7
|
-
memory;
|
|
8
|
-
task;
|
|
9
|
-
constructor(memory, task) {
|
|
10
|
-
this.memory = memory;
|
|
11
|
-
this.task = task;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Builds a trainer object.
|
|
15
|
-
*
|
|
16
|
-
* @param client client to share weights with (either distributed or federated)
|
|
17
|
-
* @param distributed whether to build a distributed or local trainer
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
async build(client, distributed = false) {
|
|
21
|
-
const model = await this.getModel(client);
|
|
22
|
-
if (distributed) {
|
|
23
|
-
return new DistributedTrainer(this.task, this.memory, model, client);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return new LocalTrainer(this.task, this.memory, model);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* If a model exists in memory, load it, otherwise load model from server
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
async getModel(client) {
|
|
34
|
-
const modelID = this.task.trainingInformation?.modelID;
|
|
35
|
-
if (modelID === undefined) {
|
|
36
|
-
throw new TypeError('model ID is undefined');
|
|
37
|
-
}
|
|
38
|
-
const info = {
|
|
39
|
-
type: 'working',
|
|
40
|
-
taskID: this.task.id,
|
|
41
|
-
name: modelID,
|
|
42
|
-
tensorBackend: 'gpt'
|
|
43
|
-
};
|
|
44
|
-
const model = await (await this.memory.contains(info) ? this.memory.getModel(info) : client.getLatestModel());
|
|
45
|
-
return model;
|
|
46
|
-
}
|
|
47
|
-
}
|