flockml 1.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/deep-profiling-report.html +119 -0
- package/dist/activations.d.ts +13 -0
- package/dist/activations.js +47 -0
- package/dist/break-test.d.ts +1 -0
- package/dist/break-test.js +249 -0
- package/dist/brutal-test.d.ts +1 -0
- package/dist/brutal-test.js +113 -0
- package/dist/client-node.d.ts +48 -0
- package/dist/client-node.js +174 -0
- package/dist/coordinator.d.ts +41 -0
- package/dist/coordinator.js +155 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -0
- package/dist/matrix.d.ts +67 -0
- package/dist/matrix.js +185 -0
- package/dist/micro-benchmark.d.ts +1 -0
- package/dist/micro-benchmark.js +215 -0
- package/dist/network.d.ts +32 -0
- package/dist/network.js +127 -0
- package/dist/privacy.d.ts +17 -0
- package/dist/privacy.js +70 -0
- package/dist/quantization.d.ts +33 -0
- package/dist/quantization.js +92 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +58 -0
- package/dist/worker.d.ts +15 -0
- package/dist/worker.js +95 -0
- package/package.json +21 -0
- package/src/activations.ts +45 -0
- package/src/break-test.ts +234 -0
- package/src/brutal-test.ts +103 -0
- package/src/client-node.ts +154 -0
- package/src/coordinator.ts +137 -0
- package/src/index.ts +5 -0
- package/src/messages.d.ts +429 -0
- package/src/messages.js +1173 -0
- package/src/messages.proto +30 -0
- package/src/micro-benchmark.ts +200 -0
- package/src/network.ts +113 -0
- package/src/privacy.ts +39 -0
- package/src/quantization.ts +82 -0
- package/src/test.ts +72 -0
- package/src/worker.ts +95 -0
- package/stress-report.html +190 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { NeuralNetwork } from './network';
|
|
2
|
+
import { Quantizer, QuantizedPayload } from './quantization';
|
|
3
|
+
import { flockml } from './messages';
|
|
4
|
+
import * as tf from '@tensorflow/tfjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Central Brain: FedAvg Coordinator.
|
|
8
|
+
*
|
|
9
|
+
* Powered by TFJS. Averages massive incoming weight tensors continuously
|
|
10
|
+
* using hardware acceleration.
|
|
11
|
+
*/
|
|
12
|
+
export class Coordinator {
|
|
13
|
+
globalModel: NeuralNetwork;
|
|
14
|
+
clientUpdates: {
|
|
15
|
+
weights_ih: tf.Tensor2D;
|
|
16
|
+
weights_ho: tf.Tensor2D;
|
|
17
|
+
bias_h: tf.Tensor2D;
|
|
18
|
+
bias_o: tf.Tensor2D;
|
|
19
|
+
}[];
|
|
20
|
+
|
|
21
|
+
constructor(inputNodes: number, hiddenNodes: number, outputNodes: number) {
|
|
22
|
+
this.globalModel = new NeuralNetwork(inputNodes, hiddenNodes, outputNodes);
|
|
23
|
+
this.clientUpdates = [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private mapFromProto(protoPayload: flockml.IQuantizedMatrix | null | undefined): QuantizedPayload {
|
|
27
|
+
if (!protoPayload) throw new Error("Missing payload section");
|
|
28
|
+
return {
|
|
29
|
+
data: protoPayload.data || new Uint8Array(),
|
|
30
|
+
min: protoPayload.min || 0,
|
|
31
|
+
max: protoPayload.max || 0,
|
|
32
|
+
rows: protoPayload.rows || 0,
|
|
33
|
+
cols: protoPayload.cols || 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Receives a binary protobuf payload from a browser client.
|
|
39
|
+
*/
|
|
40
|
+
receiveUpdate(binaryPayload: Uint8Array): void {
|
|
41
|
+
const message = flockml.GradientUpdate.decode(binaryPayload);
|
|
42
|
+
|
|
43
|
+
const weights_ih = Quantizer.dequantize(this.mapFromProto(message.weightsIh));
|
|
44
|
+
const weights_ho = Quantizer.dequantize(this.mapFromProto(message.weightsHo));
|
|
45
|
+
const bias_h = Quantizer.dequantize(this.mapFromProto(message.biasH));
|
|
46
|
+
const bias_o = Quantizer.dequantize(this.mapFromProto(message.biasO));
|
|
47
|
+
|
|
48
|
+
this.clientUpdates.push({
|
|
49
|
+
weights_ih,
|
|
50
|
+
weights_ho,
|
|
51
|
+
bias_h,
|
|
52
|
+
bias_o
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The Federated Averaging (FedAvg) Algorithm with Anomaly Detection.
|
|
58
|
+
*
|
|
59
|
+
* Averages all the incoming matrices. Because of Differential Privacy,
|
|
60
|
+
* the Laplacian noise mathematically cancels out to 0 here, leaving only
|
|
61
|
+
* the pure, learned signal from the crowdsourced devices.
|
|
62
|
+
*/
|
|
63
|
+
aggregate(): void {
|
|
64
|
+
if (this.clientUpdates.length === 0) return;
|
|
65
|
+
|
|
66
|
+
// 1. Anomaly Detection (Anti-Sybil / Data Poisoning)
|
|
67
|
+
// Runs mathematically on the GPU without downloading large buffers to CPU
|
|
68
|
+
const safeUpdates = this.clientUpdates.filter(update => {
|
|
69
|
+
return tf.tidy(() => {
|
|
70
|
+
const checkTensor = (t: tf.Tensor2D) => {
|
|
71
|
+
const hasNaN = tf.sum(tf.cast(tf.isNaN(t), 'int32')).dataSync()[0] > 0;
|
|
72
|
+
const maxAbs = tf.max(tf.abs(t)).dataSync()[0];
|
|
73
|
+
return !hasNaN && maxAbs <= 1000;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return checkTensor(update.weights_ih) &&
|
|
77
|
+
checkTensor(update.weights_ho) &&
|
|
78
|
+
checkTensor(update.bias_h) &&
|
|
79
|
+
checkTensor(update.bias_o);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (safeUpdates.length === 0) {
|
|
84
|
+
console.warn("[Coordinator] All received updates were flagged as anomalous and dropped.");
|
|
85
|
+
// Dispose the tensors since we are dropping them
|
|
86
|
+
for (const update of this.clientUpdates) {
|
|
87
|
+
update.weights_ih.dispose();
|
|
88
|
+
update.weights_ho.dispose();
|
|
89
|
+
update.bias_h.dispose();
|
|
90
|
+
update.bias_o.dispose();
|
|
91
|
+
}
|
|
92
|
+
this.clientUpdates = [];
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (safeUpdates.length < this.clientUpdates.length) {
|
|
97
|
+
console.warn(`[Coordinator] Dropped ${this.clientUpdates.length - safeUpdates.length} poisoned payloads.`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 2. Federated Averaging
|
|
101
|
+
const averageTensor = (matrixKey: 'weights_ih' | 'weights_ho' | 'bias_h' | 'bias_o', targetVar: tf.Variable) => {
|
|
102
|
+
tf.tidy(() => {
|
|
103
|
+
const tensors = safeUpdates.map(u => u[matrixKey]);
|
|
104
|
+
const stacked = tf.stack(tensors);
|
|
105
|
+
const mean = tf.mean(stacked, 0);
|
|
106
|
+
targetVar.assign(mean);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
averageTensor('weights_ih', this.globalModel.weights_ih);
|
|
111
|
+
averageTensor('weights_ho', this.globalModel.weights_ho);
|
|
112
|
+
averageTensor('bias_h', this.globalModel.bias_h);
|
|
113
|
+
averageTensor('bias_o', this.globalModel.bias_o);
|
|
114
|
+
|
|
115
|
+
// Dispose all client tensors after aggregation to prevent memory leaks
|
|
116
|
+
for (const update of this.clientUpdates) {
|
|
117
|
+
update.weights_ih.dispose();
|
|
118
|
+
update.weights_ho.dispose();
|
|
119
|
+
update.bias_h.dispose();
|
|
120
|
+
update.bias_o.dispose();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.clientUpdates = [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Broadcasts the current global model weights to all new clients.
|
|
128
|
+
*/
|
|
129
|
+
getGlobalWeightsForBroadcast() {
|
|
130
|
+
return {
|
|
131
|
+
weights_ih: Quantizer.quantize(this.globalModel.weights_ih as tf.Tensor2D),
|
|
132
|
+
weights_ho: Quantizer.quantize(this.globalModel.weights_ho as tf.Tensor2D),
|
|
133
|
+
bias_h: Quantizer.quantize(this.globalModel.bias_h as tf.Tensor2D),
|
|
134
|
+
bias_o: Quantizer.quantize(this.globalModel.bias_o as tf.Tensor2D)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import * as $protobuf from "protobufjs";
|
|
2
|
+
import Long = require("long");
|
|
3
|
+
|
|
4
|
+
/** Namespace flockml. */
|
|
5
|
+
export namespace flockml {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Properties of a QuantizedMatrix.
|
|
9
|
+
* @deprecated Use flockml.QuantizedMatrix.$Properties instead.
|
|
10
|
+
*/
|
|
11
|
+
interface IQuantizedMatrix extends flockml.QuantizedMatrix.$Properties {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Represents a QuantizedMatrix. */
|
|
15
|
+
class QuantizedMatrix {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a new QuantizedMatrix.
|
|
19
|
+
* @param [properties] Properties to set
|
|
20
|
+
*/
|
|
21
|
+
constructor(properties?: flockml.QuantizedMatrix.$Properties);
|
|
22
|
+
|
|
23
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
24
|
+
$unknowns?: Uint8Array[];
|
|
25
|
+
|
|
26
|
+
/** QuantizedMatrix data. */
|
|
27
|
+
data: Uint8Array;
|
|
28
|
+
|
|
29
|
+
/** QuantizedMatrix min. */
|
|
30
|
+
min: number;
|
|
31
|
+
|
|
32
|
+
/** QuantizedMatrix max. */
|
|
33
|
+
max: number;
|
|
34
|
+
|
|
35
|
+
/** QuantizedMatrix rows. */
|
|
36
|
+
rows: number;
|
|
37
|
+
|
|
38
|
+
/** QuantizedMatrix cols. */
|
|
39
|
+
cols: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new QuantizedMatrix instance using the specified properties.
|
|
43
|
+
* @param [properties] Properties to set
|
|
44
|
+
* @returns QuantizedMatrix instance
|
|
45
|
+
*/
|
|
46
|
+
static create(properties: flockml.QuantizedMatrix.$Shape): flockml.QuantizedMatrix & flockml.QuantizedMatrix.$Shape;
|
|
47
|
+
static create(properties?: flockml.QuantizedMatrix.$Properties): flockml.QuantizedMatrix;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Encodes the specified QuantizedMatrix message. Does not implicitly {@link flockml.QuantizedMatrix.verify|verify} messages.
|
|
51
|
+
* @param message QuantizedMatrix message or plain object to encode
|
|
52
|
+
* @param [writer] Writer to encode to
|
|
53
|
+
* @returns Writer
|
|
54
|
+
*/
|
|
55
|
+
static encode(message: flockml.QuantizedMatrix.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Encodes the specified QuantizedMatrix message, length delimited. Does not implicitly {@link flockml.QuantizedMatrix.verify|verify} messages.
|
|
59
|
+
* @param message QuantizedMatrix message or plain object to encode
|
|
60
|
+
* @param [writer] Writer to encode to
|
|
61
|
+
* @returns Writer
|
|
62
|
+
*/
|
|
63
|
+
static encodeDelimited(message: flockml.QuantizedMatrix.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Decodes a QuantizedMatrix message from the specified reader or buffer.
|
|
67
|
+
* @param reader Reader or buffer to decode from
|
|
68
|
+
* @param [length] Message length if known beforehand
|
|
69
|
+
* @returns {flockml.QuantizedMatrix & flockml.QuantizedMatrix.$Shape} QuantizedMatrix
|
|
70
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
71
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
72
|
+
*/
|
|
73
|
+
static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): flockml.QuantizedMatrix & flockml.QuantizedMatrix.$Shape;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Decodes a QuantizedMatrix message from the specified reader or buffer, length delimited.
|
|
77
|
+
* @param reader Reader or buffer to decode from
|
|
78
|
+
* @returns {flockml.QuantizedMatrix & flockml.QuantizedMatrix.$Shape} QuantizedMatrix
|
|
79
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
80
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
81
|
+
*/
|
|
82
|
+
static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): flockml.QuantizedMatrix & flockml.QuantizedMatrix.$Shape;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Verifies a QuantizedMatrix message.
|
|
86
|
+
* @param message Plain object to verify
|
|
87
|
+
* @returns `null` if valid, otherwise the reason why it is not
|
|
88
|
+
*/
|
|
89
|
+
static verify(message: { [k: string]: any }): (string|null);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates a QuantizedMatrix message from a plain object. Also converts values to their respective internal types.
|
|
93
|
+
* @param object Plain object
|
|
94
|
+
* @returns QuantizedMatrix
|
|
95
|
+
*/
|
|
96
|
+
static fromObject(object: { [k: string]: any }): flockml.QuantizedMatrix;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a plain object from a QuantizedMatrix message. Also converts values to other types if specified.
|
|
100
|
+
* @param message QuantizedMatrix
|
|
101
|
+
* @param [options] Conversion options
|
|
102
|
+
* @returns Plain object
|
|
103
|
+
*/
|
|
104
|
+
static toObject(message: flockml.QuantizedMatrix, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Converts this QuantizedMatrix to JSON.
|
|
108
|
+
* @returns JSON object
|
|
109
|
+
*/
|
|
110
|
+
toJSON(): { [k: string]: any };
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Gets the type url for QuantizedMatrix
|
|
114
|
+
* @param [prefix] Custom type url prefix, defaults to `"type.googleapis.com"`
|
|
115
|
+
* @returns The type url
|
|
116
|
+
*/
|
|
117
|
+
static getTypeUrl(prefix?: string): string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
namespace QuantizedMatrix {
|
|
121
|
+
|
|
122
|
+
/** Properties of a QuantizedMatrix. */
|
|
123
|
+
interface $Properties {
|
|
124
|
+
|
|
125
|
+
/** QuantizedMatrix data */
|
|
126
|
+
data?: (Uint8Array|null);
|
|
127
|
+
|
|
128
|
+
/** QuantizedMatrix min */
|
|
129
|
+
min?: (number|null);
|
|
130
|
+
|
|
131
|
+
/** QuantizedMatrix max */
|
|
132
|
+
max?: (number|null);
|
|
133
|
+
|
|
134
|
+
/** QuantizedMatrix rows */
|
|
135
|
+
rows?: (number|null);
|
|
136
|
+
|
|
137
|
+
/** QuantizedMatrix cols */
|
|
138
|
+
cols?: (number|null);
|
|
139
|
+
|
|
140
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
141
|
+
$unknowns?: Uint8Array[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Shape of a QuantizedMatrix. */
|
|
145
|
+
type $Shape = flockml.QuantizedMatrix.$Properties;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Properties of a GradientUpdate.
|
|
150
|
+
* @deprecated Use flockml.GradientUpdate.$Properties instead.
|
|
151
|
+
*/
|
|
152
|
+
interface IGradientUpdate extends flockml.GradientUpdate.$Properties {
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Represents a GradientUpdate. */
|
|
156
|
+
class GradientUpdate {
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Constructs a new GradientUpdate.
|
|
160
|
+
* @param [properties] Properties to set
|
|
161
|
+
*/
|
|
162
|
+
constructor(properties?: flockml.GradientUpdate.$Properties);
|
|
163
|
+
|
|
164
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
165
|
+
$unknowns?: Uint8Array[];
|
|
166
|
+
|
|
167
|
+
/** GradientUpdate weightsIh. */
|
|
168
|
+
weightsIh?: (flockml.QuantizedMatrix.$Properties|null);
|
|
169
|
+
|
|
170
|
+
/** GradientUpdate weightsHo. */
|
|
171
|
+
weightsHo?: (flockml.QuantizedMatrix.$Properties|null);
|
|
172
|
+
|
|
173
|
+
/** GradientUpdate biasH. */
|
|
174
|
+
biasH?: (flockml.QuantizedMatrix.$Properties|null);
|
|
175
|
+
|
|
176
|
+
/** GradientUpdate biasO. */
|
|
177
|
+
biasO?: (flockml.QuantizedMatrix.$Properties|null);
|
|
178
|
+
|
|
179
|
+
/** GradientUpdate batchSize. */
|
|
180
|
+
batchSize: number;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Creates a new GradientUpdate instance using the specified properties.
|
|
184
|
+
* @param [properties] Properties to set
|
|
185
|
+
* @returns GradientUpdate instance
|
|
186
|
+
*/
|
|
187
|
+
static create(properties: flockml.GradientUpdate.$Shape): flockml.GradientUpdate & flockml.GradientUpdate.$Shape;
|
|
188
|
+
static create(properties?: flockml.GradientUpdate.$Properties): flockml.GradientUpdate;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Encodes the specified GradientUpdate message. Does not implicitly {@link flockml.GradientUpdate.verify|verify} messages.
|
|
192
|
+
* @param message GradientUpdate message or plain object to encode
|
|
193
|
+
* @param [writer] Writer to encode to
|
|
194
|
+
* @returns Writer
|
|
195
|
+
*/
|
|
196
|
+
static encode(message: flockml.GradientUpdate.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Encodes the specified GradientUpdate message, length delimited. Does not implicitly {@link flockml.GradientUpdate.verify|verify} messages.
|
|
200
|
+
* @param message GradientUpdate message or plain object to encode
|
|
201
|
+
* @param [writer] Writer to encode to
|
|
202
|
+
* @returns Writer
|
|
203
|
+
*/
|
|
204
|
+
static encodeDelimited(message: flockml.GradientUpdate.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Decodes a GradientUpdate message from the specified reader or buffer.
|
|
208
|
+
* @param reader Reader or buffer to decode from
|
|
209
|
+
* @param [length] Message length if known beforehand
|
|
210
|
+
* @returns {flockml.GradientUpdate & flockml.GradientUpdate.$Shape} GradientUpdate
|
|
211
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
212
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
213
|
+
*/
|
|
214
|
+
static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): flockml.GradientUpdate & flockml.GradientUpdate.$Shape;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Decodes a GradientUpdate message from the specified reader or buffer, length delimited.
|
|
218
|
+
* @param reader Reader or buffer to decode from
|
|
219
|
+
* @returns {flockml.GradientUpdate & flockml.GradientUpdate.$Shape} GradientUpdate
|
|
220
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
221
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
222
|
+
*/
|
|
223
|
+
static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): flockml.GradientUpdate & flockml.GradientUpdate.$Shape;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Verifies a GradientUpdate message.
|
|
227
|
+
* @param message Plain object to verify
|
|
228
|
+
* @returns `null` if valid, otherwise the reason why it is not
|
|
229
|
+
*/
|
|
230
|
+
static verify(message: { [k: string]: any }): (string|null);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Creates a GradientUpdate message from a plain object. Also converts values to their respective internal types.
|
|
234
|
+
* @param object Plain object
|
|
235
|
+
* @returns GradientUpdate
|
|
236
|
+
*/
|
|
237
|
+
static fromObject(object: { [k: string]: any }): flockml.GradientUpdate;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Creates a plain object from a GradientUpdate message. Also converts values to other types if specified.
|
|
241
|
+
* @param message GradientUpdate
|
|
242
|
+
* @param [options] Conversion options
|
|
243
|
+
* @returns Plain object
|
|
244
|
+
*/
|
|
245
|
+
static toObject(message: flockml.GradientUpdate, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Converts this GradientUpdate to JSON.
|
|
249
|
+
* @returns JSON object
|
|
250
|
+
*/
|
|
251
|
+
toJSON(): { [k: string]: any };
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Gets the type url for GradientUpdate
|
|
255
|
+
* @param [prefix] Custom type url prefix, defaults to `"type.googleapis.com"`
|
|
256
|
+
* @returns The type url
|
|
257
|
+
*/
|
|
258
|
+
static getTypeUrl(prefix?: string): string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
namespace GradientUpdate {
|
|
262
|
+
|
|
263
|
+
/** Properties of a GradientUpdate. */
|
|
264
|
+
interface $Properties {
|
|
265
|
+
|
|
266
|
+
/** GradientUpdate weightsIh */
|
|
267
|
+
weightsIh?: (flockml.QuantizedMatrix.$Properties|null);
|
|
268
|
+
|
|
269
|
+
/** GradientUpdate weightsHo */
|
|
270
|
+
weightsHo?: (flockml.QuantizedMatrix.$Properties|null);
|
|
271
|
+
|
|
272
|
+
/** GradientUpdate biasH */
|
|
273
|
+
biasH?: (flockml.QuantizedMatrix.$Properties|null);
|
|
274
|
+
|
|
275
|
+
/** GradientUpdate biasO */
|
|
276
|
+
biasO?: (flockml.QuantizedMatrix.$Properties|null);
|
|
277
|
+
|
|
278
|
+
/** GradientUpdate batchSize */
|
|
279
|
+
batchSize?: (number|null);
|
|
280
|
+
|
|
281
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
282
|
+
$unknowns?: Uint8Array[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Shape of a GradientUpdate. */
|
|
286
|
+
type $Shape = flockml.GradientUpdate.$Properties;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Properties of a GlobalModel.
|
|
291
|
+
* @deprecated Use flockml.GlobalModel.$Properties instead.
|
|
292
|
+
*/
|
|
293
|
+
interface IGlobalModel extends flockml.GlobalModel.$Properties {
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Represents a GlobalModel. */
|
|
297
|
+
class GlobalModel {
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Constructs a new GlobalModel.
|
|
301
|
+
* @param [properties] Properties to set
|
|
302
|
+
*/
|
|
303
|
+
constructor(properties?: flockml.GlobalModel.$Properties);
|
|
304
|
+
|
|
305
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
306
|
+
$unknowns?: Uint8Array[];
|
|
307
|
+
|
|
308
|
+
/** GlobalModel weightsIh. */
|
|
309
|
+
weightsIh?: (flockml.QuantizedMatrix.$Properties|null);
|
|
310
|
+
|
|
311
|
+
/** GlobalModel weightsHo. */
|
|
312
|
+
weightsHo?: (flockml.QuantizedMatrix.$Properties|null);
|
|
313
|
+
|
|
314
|
+
/** GlobalModel biasH. */
|
|
315
|
+
biasH?: (flockml.QuantizedMatrix.$Properties|null);
|
|
316
|
+
|
|
317
|
+
/** GlobalModel biasO. */
|
|
318
|
+
biasO?: (flockml.QuantizedMatrix.$Properties|null);
|
|
319
|
+
|
|
320
|
+
/** GlobalModel version. */
|
|
321
|
+
version: number;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Creates a new GlobalModel instance using the specified properties.
|
|
325
|
+
* @param [properties] Properties to set
|
|
326
|
+
* @returns GlobalModel instance
|
|
327
|
+
*/
|
|
328
|
+
static create(properties: flockml.GlobalModel.$Shape): flockml.GlobalModel & flockml.GlobalModel.$Shape;
|
|
329
|
+
static create(properties?: flockml.GlobalModel.$Properties): flockml.GlobalModel;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Encodes the specified GlobalModel message. Does not implicitly {@link flockml.GlobalModel.verify|verify} messages.
|
|
333
|
+
* @param message GlobalModel message or plain object to encode
|
|
334
|
+
* @param [writer] Writer to encode to
|
|
335
|
+
* @returns Writer
|
|
336
|
+
*/
|
|
337
|
+
static encode(message: flockml.GlobalModel.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Encodes the specified GlobalModel message, length delimited. Does not implicitly {@link flockml.GlobalModel.verify|verify} messages.
|
|
341
|
+
* @param message GlobalModel message or plain object to encode
|
|
342
|
+
* @param [writer] Writer to encode to
|
|
343
|
+
* @returns Writer
|
|
344
|
+
*/
|
|
345
|
+
static encodeDelimited(message: flockml.GlobalModel.$Properties, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Decodes a GlobalModel message from the specified reader or buffer.
|
|
349
|
+
* @param reader Reader or buffer to decode from
|
|
350
|
+
* @param [length] Message length if known beforehand
|
|
351
|
+
* @returns {flockml.GlobalModel & flockml.GlobalModel.$Shape} GlobalModel
|
|
352
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
353
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
354
|
+
*/
|
|
355
|
+
static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): flockml.GlobalModel & flockml.GlobalModel.$Shape;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Decodes a GlobalModel message from the specified reader or buffer, length delimited.
|
|
359
|
+
* @param reader Reader or buffer to decode from
|
|
360
|
+
* @returns {flockml.GlobalModel & flockml.GlobalModel.$Shape} GlobalModel
|
|
361
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
362
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
363
|
+
*/
|
|
364
|
+
static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): flockml.GlobalModel & flockml.GlobalModel.$Shape;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Verifies a GlobalModel message.
|
|
368
|
+
* @param message Plain object to verify
|
|
369
|
+
* @returns `null` if valid, otherwise the reason why it is not
|
|
370
|
+
*/
|
|
371
|
+
static verify(message: { [k: string]: any }): (string|null);
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Creates a GlobalModel message from a plain object. Also converts values to their respective internal types.
|
|
375
|
+
* @param object Plain object
|
|
376
|
+
* @returns GlobalModel
|
|
377
|
+
*/
|
|
378
|
+
static fromObject(object: { [k: string]: any }): flockml.GlobalModel;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Creates a plain object from a GlobalModel message. Also converts values to other types if specified.
|
|
382
|
+
* @param message GlobalModel
|
|
383
|
+
* @param [options] Conversion options
|
|
384
|
+
* @returns Plain object
|
|
385
|
+
*/
|
|
386
|
+
static toObject(message: flockml.GlobalModel, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Converts this GlobalModel to JSON.
|
|
390
|
+
* @returns JSON object
|
|
391
|
+
*/
|
|
392
|
+
toJSON(): { [k: string]: any };
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Gets the type url for GlobalModel
|
|
396
|
+
* @param [prefix] Custom type url prefix, defaults to `"type.googleapis.com"`
|
|
397
|
+
* @returns The type url
|
|
398
|
+
*/
|
|
399
|
+
static getTypeUrl(prefix?: string): string;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
namespace GlobalModel {
|
|
403
|
+
|
|
404
|
+
/** Properties of a GlobalModel. */
|
|
405
|
+
interface $Properties {
|
|
406
|
+
|
|
407
|
+
/** GlobalModel weightsIh */
|
|
408
|
+
weightsIh?: (flockml.QuantizedMatrix.$Properties|null);
|
|
409
|
+
|
|
410
|
+
/** GlobalModel weightsHo */
|
|
411
|
+
weightsHo?: (flockml.QuantizedMatrix.$Properties|null);
|
|
412
|
+
|
|
413
|
+
/** GlobalModel biasH */
|
|
414
|
+
biasH?: (flockml.QuantizedMatrix.$Properties|null);
|
|
415
|
+
|
|
416
|
+
/** GlobalModel biasO */
|
|
417
|
+
biasO?: (flockml.QuantizedMatrix.$Properties|null);
|
|
418
|
+
|
|
419
|
+
/** GlobalModel version */
|
|
420
|
+
version?: (number|null);
|
|
421
|
+
|
|
422
|
+
/** Unknown fields preserved while decoding when enabled */
|
|
423
|
+
$unknowns?: Uint8Array[];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Shape of a GlobalModel. */
|
|
427
|
+
type $Shape = flockml.GlobalModel.$Properties;
|
|
428
|
+
}
|
|
429
|
+
}
|