dataset-types 3.4.2 → 3.5.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.
@@ -0,0 +1,28 @@
1
+
2
+
3
+ export interface INode {
4
+ id: string;
5
+ name: string;
6
+ nodetype: NODETYPE_TYPE;
7
+ x: number;
8
+ y: number;
9
+ }
10
+ export interface ILink {
11
+ id?: string;
12
+ source: string;
13
+ target: string;
14
+ }
15
+
16
+ export interface INodeLink {
17
+ id: string;
18
+ source: INode;
19
+ target: INode;
20
+ }
21
+
22
+
23
+ export interface ITopology {
24
+ nodes: INode[];
25
+ links: INodeLink[];
26
+ }
27
+
28
+ export type NODETYPE_TYPE = "s" | "t" | "a" | undefined;
@@ -0,0 +1,259 @@
1
+
2
+ /// Vector / Matrix
3
+
4
+ import { ITopology } from "./topology";
5
+
6
+ export type IVector = number[];
7
+ export type IMatrix = number[][];
8
+
9
+
10
+ /// Value Data
11
+
12
+ export interface IExpression {
13
+ valuedata?: boolean;
14
+ data?: number;
15
+ grad?: number;
16
+ label?: string;
17
+ description?: string;
18
+ op?: string;
19
+ scalar?: number;
20
+ // valueExprs?: IExpression[];
21
+ values?: IValueData[] | IExpression[];
22
+ // leftExpr?: IExpression;
23
+ left?: IValueData | IExpression;
24
+ // rightExpr?: IExpression;
25
+ right?: IValueData | IExpression;
26
+ output?: number;
27
+ layer?: number;
28
+ level?: number;
29
+ parameter?: boolean;
30
+ type?: string; //parameter, input, output
31
+ // prev?: IValueData[]|IExpression[];
32
+ node?: any;
33
+ metadata?: IValueMetadata;
34
+ }
35
+
36
+ export interface IValueMetadata {
37
+ i?: number; //The row index of the value in the matrix
38
+ j?: number; //The column index of the value in the matrix
39
+ layer?: number;
40
+ name?: string; //The name of the architectural component this value is associated with (typically the layer name)"
41
+ predecessor?: string; //The name of the architectural component that is the predecessor of this value
42
+ }
43
+
44
+ export interface IValueData {
45
+ valuedata: boolean;
46
+ defaultDataString: string;
47
+ dataString: string;
48
+ data: number;
49
+ grad: number;
50
+ label: string;
51
+ description?: string;
52
+ layer: number;
53
+ op: string;
54
+ level: number;
55
+ parameter: boolean;
56
+ type: string; //parameter, input, output
57
+ batchValues: number[];
58
+ batchGradient: number[];
59
+ values: IValueData[];
60
+ metadata?: IValueMetadata;
61
+ learn: number;
62
+ node?: any;
63
+ }
64
+
65
+ export interface IValueMatrix {
66
+ name: string;
67
+ rows: number;
68
+ cols: number;
69
+ matrix: IValueData[][];
70
+ predecessors: IValueMatrix[];
71
+ }
72
+
73
+ /// Network
74
+
75
+ export interface INetwork {
76
+ initialize: () => void;
77
+ initializeWorking: () => void;
78
+ initializeGradients: () => void;
79
+ forward: () => void;
80
+ backward: () => void;
81
+ tree: () => IValueData[];
82
+ valueMatrix: () => IValueMatrix[];
83
+ valueTopology: () => ITopology;
84
+ valueTable: () => ITable;
85
+ toFullString: () => string;
86
+ toShape: () => string;
87
+ }
88
+
89
+ export interface INNValue extends INetwork, INNTrainable {}
90
+
91
+ export interface IValueNetworkDisplayOption {
92
+ initialize?: boolean;
93
+ bump?: boolean;
94
+ grad?: boolean;
95
+ layer?: boolean;
96
+ backward?: boolean;
97
+ matrixview?: boolean;
98
+
99
+ defaultForward?: boolean;
100
+
101
+ input: boolean;
102
+ output: boolean;
103
+ operation: boolean;
104
+ parameter: boolean;
105
+ target: boolean;
106
+ loss: boolean;
107
+ activation: boolean;
108
+ constant: boolean;
109
+ }
110
+
111
+ export interface INNLayer extends INetwork, INNTrainable {
112
+ layer?: number;
113
+ layers?: INNLayer[];
114
+ neurons?: INeuron[];
115
+ inputsSet: (xs: number[]) => void;
116
+ set: (label: string, v: number) => void;
117
+ get: (label: string) => number;
118
+ }
119
+
120
+ export interface INNMatrix extends INetwork, INNTrainable {
121
+ x: IValueData[][];
122
+ o: IValueData[][];
123
+ inputsSet: (xs: number[][]) => void;
124
+ }
125
+
126
+ ///// Neuron
127
+
128
+ export interface INeuron extends INetwork, INNLayer {
129
+ out: IValueData;
130
+ }
131
+
132
+
133
+ //////// NN Architecture
134
+
135
+ export interface INNSpecification {
136
+ type: string;
137
+ // neurontype: string;
138
+ // hiddenneurontype:string;
139
+ architecture: string;
140
+ layer: number;
141
+ }
142
+
143
+ export interface IMatrixSpecification {
144
+ type?: string;
145
+ neurontype: string;
146
+ embedding_size: number;
147
+ context_size: number;
148
+ shape_out: number;
149
+ name_in: string;
150
+ name_out: string;
151
+ }
152
+
153
+
154
+ /// Learning
155
+
156
+ export interface INNTrainable {
157
+ inputs: () => IValueData[];
158
+ parameters: () => IValueData[];
159
+ outputs: () => IValueData[];
160
+ }
161
+
162
+ export interface ITrainingExample {
163
+ id: number;
164
+ inputs: number[];
165
+ outputs: number[];
166
+ }
167
+
168
+ export interface ITrainingDataSet {
169
+ samples: ITrainingExample[];
170
+ }
171
+
172
+ export type IOptimizer = (
173
+ weight: number,
174
+ loss: number,
175
+ grad: number,
176
+ learning_rate: number,
177
+ ) => number;
178
+
179
+ export interface ILearningConfig {
180
+ batchSize: number;
181
+ learningRate: number;
182
+ epochs: number;
183
+ optimizer?: IOptimizer;
184
+ }
185
+
186
+
187
+ export interface ILearnable {
188
+ inputsSet: (i: number[]) => void;
189
+ targetsSet: (t: number[]) => void;
190
+
191
+ forward: () => void;
192
+ backward: () => void;
193
+
194
+ lossValue: () => IValueData;
195
+ lossNetwork: () => INetwork;
196
+
197
+ reset: () => void;
198
+
199
+ toFullString: () => string;
200
+
201
+ train: (
202
+ eventcollector: any,
203
+ startcycle: number,
204
+ epochs: number,
205
+ batchSize: number,
206
+ maxBatch: number,
207
+ learningRate: number,
208
+ ) => void;
209
+ }
210
+
211
+ export type IEventCollector = (events: any[]) => void;
212
+
213
+
214
+ //////// Transformer
215
+
216
+ export interface ITransformerSpecification {
217
+ VOCAB_LENGTH: number;
218
+ EMBEDDING_LENGTH: number;
219
+ CONTEXT_LENGTH: number;
220
+
221
+ KQ_LENGTH: number;
222
+
223
+ V_UP_DOWN_LENGTH: number;
224
+
225
+ OUTPUT_UP_LENGTH: number;
226
+ OUTPUT_DOWN_LENGTH: number;
227
+
228
+ ATTENTION_HEADS_SIZE: number;
229
+ }
230
+
231
+ export interface IValueTransformer {
232
+ wte: IValueData[][];
233
+ wpe: IValueData[][];
234
+
235
+ q_spec: IMatrixSpecification;
236
+ k_spec: IMatrixSpecification;
237
+ attn_q?: INNMatrix;
238
+ attn_k?: INNMatrix;
239
+
240
+ v_down_spec: IMatrixSpecification;
241
+ v_up_spec: IMatrixSpecification;
242
+ attn_v_down?: INNMatrix;
243
+ attn_v_up?: INNMatrix;
244
+ // kq?: INNMatrix;
245
+ // v_up_down?: INNMatrix;
246
+ // output_up?: INNMatrix;
247
+ // output_down?: INNMatrix;
248
+ // attention_heads?: INNMatrix;
249
+ }
250
+
251
+ export interface IValueTransformerInstance {
252
+ specification: ITransformerSpecification;
253
+ model: IValueTransformer;
254
+ }
255
+
256
+ export interface ITable {
257
+ columns: string[]
258
+ rows: any[]
259
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
5
+ "module": "commonjs",
6
+ "target": "es2019",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true
11
+ },
12
+ "include": ["src/**/*", "test/**/*"],
13
+ "exclude": ["node_modules", "**/*.spec.ts"]
14
+ }
package/attention2.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/topology.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/valuedata.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- /// Vector / Matrix
3
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes
File without changes
File without changes