@almadar/patterns 2.38.2 → 2.38.4
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/component-mapping.json +11 -11
- package/dist/event-contracts.json +1 -6
- package/dist/index.d.ts +2007 -460
- package/dist/index.js +1908 -288
- package/dist/index.js.map +1 -1
- package/dist/ml-registry.json +714 -0
- package/dist/pattern-embeddings.json +123651 -123651
- package/dist/patterns-registry.json +1896 -271
- package/dist/registry.json +1896 -271
- package/package.json +1 -1
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"description": "Layer definitions for ML architecture trees. Source of truth for what layers exist, their parameters, and shape rules.",
|
|
4
|
+
"layers": {
|
|
5
|
+
"linear": {
|
|
6
|
+
"category": "core",
|
|
7
|
+
"description": "Fully connected (dense) layer",
|
|
8
|
+
"params": {
|
|
9
|
+
"in": { "type": "number", "required": true, "description": "Input features" },
|
|
10
|
+
"out": { "type": "number", "required": true, "description": "Output features" },
|
|
11
|
+
"bias": { "type": "boolean", "default": true, "description": "Include bias term" }
|
|
12
|
+
},
|
|
13
|
+
"input-shape": ["batch", "in"],
|
|
14
|
+
"output-shape": ["batch", "out"],
|
|
15
|
+
"pytorch": "nn.Linear"
|
|
16
|
+
},
|
|
17
|
+
"bilinear": {
|
|
18
|
+
"category": "core",
|
|
19
|
+
"description": "Bilinear layer (two inputs)",
|
|
20
|
+
"params": {
|
|
21
|
+
"in1": { "type": "number", "required": true, "description": "First input features" },
|
|
22
|
+
"in2": { "type": "number", "required": true, "description": "Second input features" },
|
|
23
|
+
"out": { "type": "number", "required": true, "description": "Output features" }
|
|
24
|
+
},
|
|
25
|
+
"input-shape": [["batch", "in1"], ["batch", "in2"]],
|
|
26
|
+
"output-shape": ["batch", "out"],
|
|
27
|
+
"pytorch": "nn.Bilinear"
|
|
28
|
+
},
|
|
29
|
+
"embedding": {
|
|
30
|
+
"category": "core",
|
|
31
|
+
"description": "Embedding lookup table (integer indices to dense vectors)",
|
|
32
|
+
"params": {
|
|
33
|
+
"num": { "type": "number", "required": true, "description": "Vocabulary size" },
|
|
34
|
+
"dim": { "type": "number", "required": true, "description": "Embedding dimension" },
|
|
35
|
+
"padding-idx": { "type": "number", "default": null, "description": "Index to zero out" }
|
|
36
|
+
},
|
|
37
|
+
"input-shape": ["batch", "seq"],
|
|
38
|
+
"output-shape": ["batch", "seq", "dim"],
|
|
39
|
+
"pytorch": "nn.Embedding"
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
"conv1d": {
|
|
43
|
+
"category": "vision",
|
|
44
|
+
"description": "1D convolution (sequences, time series)",
|
|
45
|
+
"params": {
|
|
46
|
+
"in-channels": { "type": "number", "required": true },
|
|
47
|
+
"out-channels": { "type": "number", "required": true },
|
|
48
|
+
"kernel": { "type": "number", "required": true },
|
|
49
|
+
"stride": { "type": "number", "default": 1 },
|
|
50
|
+
"padding": { "type": "number|string", "default": 0 }
|
|
51
|
+
},
|
|
52
|
+
"input-shape": ["batch", "in-channels", "length"],
|
|
53
|
+
"output-shape": ["batch", "out-channels", "length*"],
|
|
54
|
+
"pytorch": "nn.Conv1d"
|
|
55
|
+
},
|
|
56
|
+
"conv2d": {
|
|
57
|
+
"category": "vision",
|
|
58
|
+
"description": "2D convolution (images)",
|
|
59
|
+
"params": {
|
|
60
|
+
"in-channels": { "type": "number", "required": true },
|
|
61
|
+
"out-channels": { "type": "number", "required": true },
|
|
62
|
+
"kernel": { "type": "number", "required": true },
|
|
63
|
+
"stride": { "type": "number", "default": 1 },
|
|
64
|
+
"padding": { "type": "number|string", "default": 0 }
|
|
65
|
+
},
|
|
66
|
+
"input-shape": ["batch", "in-channels", "height", "width"],
|
|
67
|
+
"output-shape": ["batch", "out-channels", "height*", "width*"],
|
|
68
|
+
"pytorch": "nn.Conv2d"
|
|
69
|
+
},
|
|
70
|
+
"conv3d": {
|
|
71
|
+
"category": "vision",
|
|
72
|
+
"description": "3D convolution (video, volumetric)",
|
|
73
|
+
"params": {
|
|
74
|
+
"in-channels": { "type": "number", "required": true },
|
|
75
|
+
"out-channels": { "type": "number", "required": true },
|
|
76
|
+
"kernel": { "type": "number", "required": true },
|
|
77
|
+
"stride": { "type": "number", "default": 1 },
|
|
78
|
+
"padding": { "type": "number|string", "default": 0 }
|
|
79
|
+
},
|
|
80
|
+
"input-shape": ["batch", "in-channels", "depth", "height", "width"],
|
|
81
|
+
"output-shape": ["batch", "out-channels", "depth*", "height*", "width*"],
|
|
82
|
+
"pytorch": "nn.Conv3d"
|
|
83
|
+
},
|
|
84
|
+
"conv-transpose2d": {
|
|
85
|
+
"category": "vision",
|
|
86
|
+
"description": "2D transposed convolution (upsampling)",
|
|
87
|
+
"params": {
|
|
88
|
+
"in-channels": { "type": "number", "required": true },
|
|
89
|
+
"out-channels": { "type": "number", "required": true },
|
|
90
|
+
"kernel": { "type": "number", "required": true },
|
|
91
|
+
"stride": { "type": "number", "default": 1 },
|
|
92
|
+
"padding": { "type": "number|string", "default": 0 },
|
|
93
|
+
"output-padding": { "type": "number", "default": 0 }
|
|
94
|
+
},
|
|
95
|
+
"input-shape": ["batch", "in-channels", "height", "width"],
|
|
96
|
+
"output-shape": ["batch", "out-channels", "height*", "width*"],
|
|
97
|
+
"pytorch": "nn.ConvTranspose2d"
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
"lstm": {
|
|
101
|
+
"category": "recurrent",
|
|
102
|
+
"description": "Long Short-Term Memory (bidirectional optional)",
|
|
103
|
+
"params": {
|
|
104
|
+
"input-size": { "type": "number", "required": true },
|
|
105
|
+
"hidden-size": { "type": "number", "required": true },
|
|
106
|
+
"num-layers": { "type": "number", "default": 1 },
|
|
107
|
+
"bidirectional": { "type": "boolean", "default": false },
|
|
108
|
+
"dropout": { "type": "number", "default": 0 },
|
|
109
|
+
"batch-first": { "type": "boolean", "default": true }
|
|
110
|
+
},
|
|
111
|
+
"input-shape": ["batch", "seq", "input-size"],
|
|
112
|
+
"output-shape": ["batch", "seq", "hidden-size * (2 if bidirectional else 1)"],
|
|
113
|
+
"pytorch": "nn.LSTM"
|
|
114
|
+
},
|
|
115
|
+
"gru": {
|
|
116
|
+
"category": "recurrent",
|
|
117
|
+
"description": "Gated Recurrent Unit (bidirectional optional)",
|
|
118
|
+
"params": {
|
|
119
|
+
"input-size": { "type": "number", "required": true },
|
|
120
|
+
"hidden-size": { "type": "number", "required": true },
|
|
121
|
+
"num-layers": { "type": "number", "default": 1 },
|
|
122
|
+
"bidirectional": { "type": "boolean", "default": false },
|
|
123
|
+
"dropout": { "type": "number", "default": 0 },
|
|
124
|
+
"batch-first": { "type": "boolean", "default": true }
|
|
125
|
+
},
|
|
126
|
+
"input-shape": ["batch", "seq", "input-size"],
|
|
127
|
+
"output-shape": ["batch", "seq", "hidden-size * (2 if bidirectional else 1)"],
|
|
128
|
+
"pytorch": "nn.GRU"
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
"multi-head-attention": {
|
|
132
|
+
"category": "attention",
|
|
133
|
+
"description": "Multi-head scaled dot-product attention",
|
|
134
|
+
"params": {
|
|
135
|
+
"embed-dim": { "type": "number", "required": true },
|
|
136
|
+
"num-heads": { "type": "number", "required": true },
|
|
137
|
+
"dropout": { "type": "number", "default": 0 },
|
|
138
|
+
"batch-first": { "type": "boolean", "default": true }
|
|
139
|
+
},
|
|
140
|
+
"input-shape": ["batch", "seq", "embed-dim"],
|
|
141
|
+
"output-shape": ["batch", "seq", "embed-dim"],
|
|
142
|
+
"pytorch": "nn.MultiheadAttention"
|
|
143
|
+
},
|
|
144
|
+
"scaled-dot-attention": {
|
|
145
|
+
"category": "attention",
|
|
146
|
+
"description": "Scaled dot-product attention (functional, no learned params)",
|
|
147
|
+
"params": {},
|
|
148
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
149
|
+
"output-shape": ["batch", "seq", "dim"],
|
|
150
|
+
"pytorch": "F.scaled_dot_product_attention"
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
"relu": {
|
|
154
|
+
"category": "activation",
|
|
155
|
+
"description": "ReLU: max(0, x)",
|
|
156
|
+
"params": {},
|
|
157
|
+
"input-shape": "passthrough",
|
|
158
|
+
"output-shape": "passthrough",
|
|
159
|
+
"pytorch": "nn.ReLU"
|
|
160
|
+
},
|
|
161
|
+
"gelu": {
|
|
162
|
+
"category": "activation",
|
|
163
|
+
"description": "GELU: Gaussian Error Linear Unit",
|
|
164
|
+
"params": {
|
|
165
|
+
"approximate": { "type": "string", "default": "none", "description": "'none' or 'tanh'" }
|
|
166
|
+
},
|
|
167
|
+
"input-shape": "passthrough",
|
|
168
|
+
"output-shape": "passthrough",
|
|
169
|
+
"pytorch": "nn.GELU"
|
|
170
|
+
},
|
|
171
|
+
"silu": {
|
|
172
|
+
"category": "activation",
|
|
173
|
+
"description": "SiLU (Swish): x * sigmoid(x)",
|
|
174
|
+
"params": {},
|
|
175
|
+
"input-shape": "passthrough",
|
|
176
|
+
"output-shape": "passthrough",
|
|
177
|
+
"pytorch": "nn.SiLU"
|
|
178
|
+
},
|
|
179
|
+
"tanh": {
|
|
180
|
+
"category": "activation",
|
|
181
|
+
"description": "Tanh: (e^x - e^-x) / (e^x + e^-x)",
|
|
182
|
+
"params": {},
|
|
183
|
+
"input-shape": "passthrough",
|
|
184
|
+
"output-shape": "passthrough",
|
|
185
|
+
"pytorch": "nn.Tanh"
|
|
186
|
+
},
|
|
187
|
+
"sigmoid": {
|
|
188
|
+
"category": "activation",
|
|
189
|
+
"description": "Sigmoid: 1 / (1 + e^-x)",
|
|
190
|
+
"params": {},
|
|
191
|
+
"input-shape": "passthrough",
|
|
192
|
+
"output-shape": "passthrough",
|
|
193
|
+
"pytorch": "nn.Sigmoid"
|
|
194
|
+
},
|
|
195
|
+
"softmax": {
|
|
196
|
+
"category": "activation",
|
|
197
|
+
"description": "Softmax: normalize to probability distribution",
|
|
198
|
+
"params": {
|
|
199
|
+
"dim": { "type": "number", "default": -1, "description": "Dimension to apply softmax" }
|
|
200
|
+
},
|
|
201
|
+
"input-shape": "passthrough",
|
|
202
|
+
"output-shape": "passthrough",
|
|
203
|
+
"pytorch": "nn.Softmax"
|
|
204
|
+
},
|
|
205
|
+
"leaky-relu": {
|
|
206
|
+
"category": "activation",
|
|
207
|
+
"description": "Leaky ReLU: max(negative_slope * x, x)",
|
|
208
|
+
"params": {
|
|
209
|
+
"negative-slope": { "type": "number", "default": 0.01 }
|
|
210
|
+
},
|
|
211
|
+
"input-shape": "passthrough",
|
|
212
|
+
"output-shape": "passthrough",
|
|
213
|
+
"pytorch": "nn.LeakyReLU"
|
|
214
|
+
},
|
|
215
|
+
"elu": {
|
|
216
|
+
"category": "activation",
|
|
217
|
+
"description": "ELU: Exponential Linear Unit",
|
|
218
|
+
"params": {
|
|
219
|
+
"alpha": { "type": "number", "default": 1.0 }
|
|
220
|
+
},
|
|
221
|
+
"input-shape": "passthrough",
|
|
222
|
+
"output-shape": "passthrough",
|
|
223
|
+
"pytorch": "nn.ELU"
|
|
224
|
+
},
|
|
225
|
+
"mish": {
|
|
226
|
+
"category": "activation",
|
|
227
|
+
"description": "Mish: x * tanh(softplus(x))",
|
|
228
|
+
"params": {},
|
|
229
|
+
"input-shape": "passthrough",
|
|
230
|
+
"output-shape": "passthrough",
|
|
231
|
+
"pytorch": "nn.Mish"
|
|
232
|
+
},
|
|
233
|
+
"swiglu": {
|
|
234
|
+
"category": "activation",
|
|
235
|
+
"description": "SwiGLU: gated linear unit with SiLU (used in LLaMA)",
|
|
236
|
+
"params": {
|
|
237
|
+
"dim": { "type": "number", "required": true, "description": "Input/output dimension" },
|
|
238
|
+
"ff-dim": { "type": "number", "required": true, "description": "Intermediate dimension" }
|
|
239
|
+
},
|
|
240
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
241
|
+
"output-shape": ["batch", "seq", "dim"],
|
|
242
|
+
"pytorch": "custom"
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
"batch-norm": {
|
|
246
|
+
"category": "normalization",
|
|
247
|
+
"description": "Batch normalization (auto-selects 1d/2d based on input rank)",
|
|
248
|
+
"params": {
|
|
249
|
+
"num-features": { "type": "number", "required": true },
|
|
250
|
+
"momentum": { "type": "number", "default": 0.1 },
|
|
251
|
+
"eps": { "type": "number", "default": 1e-5 }
|
|
252
|
+
},
|
|
253
|
+
"input-shape": "passthrough",
|
|
254
|
+
"output-shape": "passthrough",
|
|
255
|
+
"pytorch": "nn.BatchNorm1d/2d"
|
|
256
|
+
},
|
|
257
|
+
"layer-norm": {
|
|
258
|
+
"category": "normalization",
|
|
259
|
+
"description": "Layer normalization",
|
|
260
|
+
"params": {
|
|
261
|
+
"normalized-shape": { "type": "number|array", "required": true },
|
|
262
|
+
"eps": { "type": "number", "default": 1e-5 }
|
|
263
|
+
},
|
|
264
|
+
"input-shape": "passthrough",
|
|
265
|
+
"output-shape": "passthrough",
|
|
266
|
+
"pytorch": "nn.LayerNorm"
|
|
267
|
+
},
|
|
268
|
+
"group-norm": {
|
|
269
|
+
"category": "normalization",
|
|
270
|
+
"description": "Group normalization",
|
|
271
|
+
"params": {
|
|
272
|
+
"num-groups": { "type": "number", "required": true },
|
|
273
|
+
"num-channels": { "type": "number", "required": true },
|
|
274
|
+
"eps": { "type": "number", "default": 1e-5 }
|
|
275
|
+
},
|
|
276
|
+
"input-shape": "passthrough",
|
|
277
|
+
"output-shape": "passthrough",
|
|
278
|
+
"pytorch": "nn.GroupNorm"
|
|
279
|
+
},
|
|
280
|
+
"instance-norm": {
|
|
281
|
+
"category": "normalization",
|
|
282
|
+
"description": "Instance normalization",
|
|
283
|
+
"params": {
|
|
284
|
+
"num-features": { "type": "number", "required": true }
|
|
285
|
+
},
|
|
286
|
+
"input-shape": "passthrough",
|
|
287
|
+
"output-shape": "passthrough",
|
|
288
|
+
"pytorch": "nn.InstanceNorm1d/2d"
|
|
289
|
+
},
|
|
290
|
+
"rms-norm": {
|
|
291
|
+
"category": "normalization",
|
|
292
|
+
"description": "RMS normalization (no mean subtraction, used in LLaMA)",
|
|
293
|
+
"params": {
|
|
294
|
+
"dim": { "type": "number", "required": true },
|
|
295
|
+
"eps": { "type": "number", "default": 1e-5 }
|
|
296
|
+
},
|
|
297
|
+
"input-shape": "passthrough",
|
|
298
|
+
"output-shape": "passthrough",
|
|
299
|
+
"pytorch": "custom"
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
"dropout": {
|
|
303
|
+
"category": "regularization",
|
|
304
|
+
"description": "Dropout: randomly zero elements during training",
|
|
305
|
+
"params": {
|
|
306
|
+
"rate": { "type": "number", "default": 0.5 }
|
|
307
|
+
},
|
|
308
|
+
"input-shape": "passthrough",
|
|
309
|
+
"output-shape": "passthrough",
|
|
310
|
+
"pytorch": "nn.Dropout"
|
|
311
|
+
},
|
|
312
|
+
"dropout2d": {
|
|
313
|
+
"category": "regularization",
|
|
314
|
+
"description": "2D dropout: zero entire channels",
|
|
315
|
+
"params": {
|
|
316
|
+
"rate": { "type": "number", "default": 0.5 }
|
|
317
|
+
},
|
|
318
|
+
"input-shape": "passthrough",
|
|
319
|
+
"output-shape": "passthrough",
|
|
320
|
+
"pytorch": "nn.Dropout2d"
|
|
321
|
+
},
|
|
322
|
+
"alpha-dropout": {
|
|
323
|
+
"category": "regularization",
|
|
324
|
+
"description": "Alpha dropout: maintains self-normalizing property (for SELU)",
|
|
325
|
+
"params": {
|
|
326
|
+
"rate": { "type": "number", "default": 0.5 }
|
|
327
|
+
},
|
|
328
|
+
"input-shape": "passthrough",
|
|
329
|
+
"output-shape": "passthrough",
|
|
330
|
+
"pytorch": "nn.AlphaDropout"
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
"max-pool2d": {
|
|
334
|
+
"category": "pooling",
|
|
335
|
+
"description": "2D max pooling",
|
|
336
|
+
"params": {
|
|
337
|
+
"kernel": { "type": "number", "required": true },
|
|
338
|
+
"stride": { "type": "number", "default": null, "description": "Defaults to kernel size" },
|
|
339
|
+
"padding": { "type": "number", "default": 0 }
|
|
340
|
+
},
|
|
341
|
+
"input-shape": ["batch", "channels", "height", "width"],
|
|
342
|
+
"output-shape": ["batch", "channels", "height/stride", "width/stride"],
|
|
343
|
+
"pytorch": "nn.MaxPool2d"
|
|
344
|
+
},
|
|
345
|
+
"avg-pool2d": {
|
|
346
|
+
"category": "pooling",
|
|
347
|
+
"description": "2D average pooling",
|
|
348
|
+
"params": {
|
|
349
|
+
"kernel": { "type": "number", "required": true },
|
|
350
|
+
"stride": { "type": "number", "default": null },
|
|
351
|
+
"padding": { "type": "number", "default": 0 }
|
|
352
|
+
},
|
|
353
|
+
"input-shape": ["batch", "channels", "height", "width"],
|
|
354
|
+
"output-shape": ["batch", "channels", "height/stride", "width/stride"],
|
|
355
|
+
"pytorch": "nn.AvgPool2d"
|
|
356
|
+
},
|
|
357
|
+
"adaptive-avg-pool": {
|
|
358
|
+
"category": "pooling",
|
|
359
|
+
"description": "Adaptive average pooling (specify output size, not kernel)",
|
|
360
|
+
"params": {
|
|
361
|
+
"output-size": { "type": "number|array", "required": true }
|
|
362
|
+
},
|
|
363
|
+
"input-shape": ["batch", "channels", "...spatial"],
|
|
364
|
+
"output-shape": ["batch", "channels", "...output-size"],
|
|
365
|
+
"pytorch": "nn.AdaptiveAvgPool1d/2d"
|
|
366
|
+
},
|
|
367
|
+
"global-mean-pool": {
|
|
368
|
+
"category": "pooling",
|
|
369
|
+
"description": "Global mean pooling (collapse spatial dims to 1)",
|
|
370
|
+
"params": {},
|
|
371
|
+
"input-shape": ["batch", "channels", "...spatial"],
|
|
372
|
+
"output-shape": ["batch", "channels"],
|
|
373
|
+
"pytorch": "custom"
|
|
374
|
+
},
|
|
375
|
+
"global-max-pool": {
|
|
376
|
+
"category": "pooling",
|
|
377
|
+
"description": "Global max pooling (collapse spatial dims to 1)",
|
|
378
|
+
"params": {},
|
|
379
|
+
"input-shape": ["batch", "channels", "...spatial"],
|
|
380
|
+
"output-shape": ["batch", "channels"],
|
|
381
|
+
"pytorch": "custom"
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
"flatten": {
|
|
385
|
+
"category": "shape",
|
|
386
|
+
"description": "Flatten all dimensions after batch",
|
|
387
|
+
"params": {
|
|
388
|
+
"start-dim": { "type": "number", "default": 1 },
|
|
389
|
+
"end-dim": { "type": "number", "default": -1 }
|
|
390
|
+
},
|
|
391
|
+
"input-shape": ["batch", "...dims"],
|
|
392
|
+
"output-shape": ["batch", "product(dims)"],
|
|
393
|
+
"pytorch": "nn.Flatten"
|
|
394
|
+
},
|
|
395
|
+
"reshape": {
|
|
396
|
+
"category": "shape",
|
|
397
|
+
"description": "Reshape tensor to target shape",
|
|
398
|
+
"params": {
|
|
399
|
+
"shape": { "type": "array", "required": true, "description": "Target shape (batch dim excluded)" }
|
|
400
|
+
},
|
|
401
|
+
"input-shape": ["batch", "...dims"],
|
|
402
|
+
"output-shape": ["batch", "...shape"],
|
|
403
|
+
"pytorch": "view"
|
|
404
|
+
},
|
|
405
|
+
"select-token": {
|
|
406
|
+
"category": "shape",
|
|
407
|
+
"description": "Select a single token from a sequence (e.g., CLS token at index 0, or last token at -1)",
|
|
408
|
+
"params": {
|
|
409
|
+
"index": { "type": "number", "required": true, "description": "Token index (0 for CLS, -1 for last)" }
|
|
410
|
+
},
|
|
411
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
412
|
+
"output-shape": ["batch", "dim"],
|
|
413
|
+
"pytorch": "indexing"
|
|
414
|
+
},
|
|
415
|
+
"select-hidden": {
|
|
416
|
+
"category": "shape",
|
|
417
|
+
"description": "Select hidden state from recurrent output (last, mean, max)",
|
|
418
|
+
"params": {
|
|
419
|
+
"method": { "type": "string", "required": true, "description": "'last', 'mean', or 'max'" }
|
|
420
|
+
},
|
|
421
|
+
"input-shape": ["batch", "seq", "hidden"],
|
|
422
|
+
"output-shape": ["batch", "hidden"],
|
|
423
|
+
"pytorch": "indexing"
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
"sequential": {
|
|
427
|
+
"category": "composition",
|
|
428
|
+
"description": "Stack layers in order. Output of each feeds into the next.",
|
|
429
|
+
"params": {
|
|
430
|
+
"layers": { "type": "array", "required": true, "description": "Ordered list of layers" }
|
|
431
|
+
},
|
|
432
|
+
"input-shape": "first layer's input",
|
|
433
|
+
"output-shape": "last layer's output",
|
|
434
|
+
"pytorch": "nn.Sequential"
|
|
435
|
+
},
|
|
436
|
+
"parallel": {
|
|
437
|
+
"category": "composition",
|
|
438
|
+
"description": "Run multiple branches on the same input, merge results",
|
|
439
|
+
"params": {
|
|
440
|
+
"branches": { "type": "array", "required": true, "description": "List of branch layer trees" },
|
|
441
|
+
"merge": { "type": "string", "required": true, "description": "'concat', 'add', 'mul', 'mean', 'max', 'none'" },
|
|
442
|
+
"names": { "type": "array", "description": "Named outputs when merge='none'" }
|
|
443
|
+
},
|
|
444
|
+
"input-shape": "shared input to all branches",
|
|
445
|
+
"output-shape": "depends on merge mode",
|
|
446
|
+
"pytorch": "custom"
|
|
447
|
+
},
|
|
448
|
+
"residual": {
|
|
449
|
+
"category": "composition",
|
|
450
|
+
"description": "Skip connection: output = block(x) + shortcut(x)",
|
|
451
|
+
"params": {
|
|
452
|
+
"block": { "type": "layer", "required": true, "description": "Main computation block" },
|
|
453
|
+
"shortcut": { "type": "string", "default": "identity", "description": "'identity' or 'projection' (auto 1x1 conv if dims differ)" }
|
|
454
|
+
},
|
|
455
|
+
"input-shape": "block's input",
|
|
456
|
+
"output-shape": "block's output (must match shortcut output for add)",
|
|
457
|
+
"pytorch": "custom"
|
|
458
|
+
},
|
|
459
|
+
"repeat": {
|
|
460
|
+
"category": "composition",
|
|
461
|
+
"description": "Repeat a block N times (optionally sharing weights)",
|
|
462
|
+
"params": {
|
|
463
|
+
"count": { "type": "number", "required": true, "description": "Number of repetitions" },
|
|
464
|
+
"block": { "type": "layer", "required": true, "description": "Block to repeat" },
|
|
465
|
+
"share-weights": { "type": "boolean", "default": false }
|
|
466
|
+
},
|
|
467
|
+
"input-shape": "block's input",
|
|
468
|
+
"output-shape": "block's output (must be compatible with block's input for chaining)",
|
|
469
|
+
"pytorch": "custom"
|
|
470
|
+
},
|
|
471
|
+
|
|
472
|
+
"positional-encoding": {
|
|
473
|
+
"category": "embedding",
|
|
474
|
+
"description": "Add positional information to token embeddings",
|
|
475
|
+
"params": {
|
|
476
|
+
"dim": { "type": "number", "required": true, "description": "Embedding dimension" },
|
|
477
|
+
"max-len": { "type": "number", "required": true, "description": "Maximum sequence length" },
|
|
478
|
+
"type": { "type": "string", "default": "sinusoidal", "description": "'sinusoidal', 'learned', or 'rope'" }
|
|
479
|
+
},
|
|
480
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
481
|
+
"output-shape": ["batch", "seq", "dim"],
|
|
482
|
+
"pytorch": "custom"
|
|
483
|
+
},
|
|
484
|
+
"patch-embedding": {
|
|
485
|
+
"category": "embedding",
|
|
486
|
+
"description": "Split image into patches and project to embedding dimension (ViT)",
|
|
487
|
+
"params": {
|
|
488
|
+
"image-size": { "type": "number", "required": true },
|
|
489
|
+
"patch-size": { "type": "number", "required": true },
|
|
490
|
+
"in-channels": { "type": "number", "default": 3 },
|
|
491
|
+
"embed-dim": { "type": "number", "required": true }
|
|
492
|
+
},
|
|
493
|
+
"input-shape": ["batch", "in-channels", "image-size", "image-size"],
|
|
494
|
+
"output-shape": ["batch", "(image-size/patch-size)^2", "embed-dim"],
|
|
495
|
+
"pytorch": "nn.Conv2d(kernel=patch, stride=patch) + reshape"
|
|
496
|
+
},
|
|
497
|
+
"prepend-cls-token": {
|
|
498
|
+
"category": "embedding",
|
|
499
|
+
"description": "Prepend a learnable CLS token to the sequence",
|
|
500
|
+
"params": {
|
|
501
|
+
"dim": { "type": "number", "required": true }
|
|
502
|
+
},
|
|
503
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
504
|
+
"output-shape": ["batch", "seq+1", "dim"],
|
|
505
|
+
"pytorch": "custom"
|
|
506
|
+
},
|
|
507
|
+
"token-type-embedding": {
|
|
508
|
+
"category": "embedding",
|
|
509
|
+
"description": "Segment embedding for sentence pair tasks (BERT)",
|
|
510
|
+
"params": {
|
|
511
|
+
"num": { "type": "number", "required": true, "description": "Number of segment types" },
|
|
512
|
+
"dim": { "type": "number", "required": true }
|
|
513
|
+
},
|
|
514
|
+
"input-shape": ["batch", "seq"],
|
|
515
|
+
"output-shape": ["batch", "seq", "dim"],
|
|
516
|
+
"pytorch": "nn.Embedding"
|
|
517
|
+
},
|
|
518
|
+
"pretrained": {
|
|
519
|
+
"category": "embedding",
|
|
520
|
+
"description": "Load a pretrained model (HuggingFace or local checkpoint)",
|
|
521
|
+
"params": {
|
|
522
|
+
"model": { "type": "string", "required": true, "description": "Model name or path" },
|
|
523
|
+
"freeze": { "type": "boolean", "default": true, "description": "Freeze pretrained weights" }
|
|
524
|
+
},
|
|
525
|
+
"input-shape": "model-dependent",
|
|
526
|
+
"output-shape": "model-dependent",
|
|
527
|
+
"pytorch": "transformers.AutoModel"
|
|
528
|
+
},
|
|
529
|
+
|
|
530
|
+
"transformer-encoder-block": {
|
|
531
|
+
"category": "organism",
|
|
532
|
+
"description": "One transformer encoder block: attention + FFN + residuals + norms",
|
|
533
|
+
"params": {
|
|
534
|
+
"embed-dim": { "type": "number", "required": true },
|
|
535
|
+
"num-heads": { "type": "number", "required": true },
|
|
536
|
+
"ff-dim": { "type": "number", "required": true },
|
|
537
|
+
"dropout": { "type": "number", "default": 0.1 },
|
|
538
|
+
"activation": { "type": "string", "default": "relu", "description": "'relu', 'gelu', 'swiglu'" },
|
|
539
|
+
"norm": { "type": "string", "default": "post", "description": "'pre' or 'post'" },
|
|
540
|
+
"norm-type": { "type": "string", "default": "layer-norm", "description": "'layer-norm' or 'rms-norm'" },
|
|
541
|
+
"causal-mask": { "type": "boolean", "default": false },
|
|
542
|
+
"positional": { "type": "string", "default": null, "description": "'rope', 'alibi', or null (no positional)" },
|
|
543
|
+
"rope-theta": { "type": "number", "default": 10000 }
|
|
544
|
+
},
|
|
545
|
+
"input-shape": ["batch", "seq", "embed-dim"],
|
|
546
|
+
"output-shape": ["batch", "seq", "embed-dim"],
|
|
547
|
+
"pytorch": "custom (expands to attention + ffn + residual + norm)"
|
|
548
|
+
},
|
|
549
|
+
"transformer-decoder-block": {
|
|
550
|
+
"category": "organism",
|
|
551
|
+
"description": "One transformer decoder block: causal self-attention + optional cross-attention + FFN",
|
|
552
|
+
"params": {
|
|
553
|
+
"embed-dim": { "type": "number", "required": true },
|
|
554
|
+
"num-heads": { "type": "number", "required": true },
|
|
555
|
+
"ff-dim": { "type": "number", "required": true },
|
|
556
|
+
"dropout": { "type": "number", "default": 0.1 },
|
|
557
|
+
"cross-attention": { "type": "boolean", "default": false },
|
|
558
|
+
"causal-mask": { "type": "boolean", "default": true },
|
|
559
|
+
"activation": { "type": "string", "default": "relu" },
|
|
560
|
+
"norm": { "type": "string", "default": "post" },
|
|
561
|
+
"norm-type": { "type": "string", "default": "layer-norm" },
|
|
562
|
+
"positional": { "type": "string", "default": null },
|
|
563
|
+
"rope-theta": { "type": "number", "default": 10000 },
|
|
564
|
+
"kv-heads": { "type": "number", "default": null, "description": "Grouped-query attention: KV heads < Q heads" },
|
|
565
|
+
"ff-type": { "type": "string", "default": "dense", "description": "'dense' or 'moe'" },
|
|
566
|
+
"moe": { "type": "object", "default": null, "description": "MoE config: num-experts, top-k, expert, router, load-balance-loss" }
|
|
567
|
+
},
|
|
568
|
+
"input-shape": ["batch", "seq", "embed-dim"],
|
|
569
|
+
"output-shape": ["batch", "seq", "embed-dim"],
|
|
570
|
+
"pytorch": "custom (expands to self-attn + cross-attn + ffn + residual + norm)"
|
|
571
|
+
},
|
|
572
|
+
"mlp": {
|
|
573
|
+
"category": "organism",
|
|
574
|
+
"description": "Multi-layer perceptron: convenience for feedforward stacks",
|
|
575
|
+
"params": {
|
|
576
|
+
"dims": { "type": "array", "required": true, "description": "Layer dimensions [in, hidden1, hidden2, ..., out]" },
|
|
577
|
+
"activation": { "type": "string", "default": "relu" },
|
|
578
|
+
"dropout": { "type": "number", "default": 0 },
|
|
579
|
+
"norm": { "type": "string", "default": null, "description": "'layer', 'batch', or null" }
|
|
580
|
+
},
|
|
581
|
+
"input-shape": ["batch", "dims[0]"],
|
|
582
|
+
"output-shape": ["batch", "dims[-1]"],
|
|
583
|
+
"pytorch": "custom (expands to Sequential of Linear + Norm + Activation + Dropout)"
|
|
584
|
+
},
|
|
585
|
+
"unet": {
|
|
586
|
+
"category": "organism",
|
|
587
|
+
"description": "U-Net encoder-decoder with skip connections",
|
|
588
|
+
"params": {
|
|
589
|
+
"encoder": { "type": "array", "required": true, "description": "Encoder stage configs" },
|
|
590
|
+
"bottleneck": { "type": "object", "required": true },
|
|
591
|
+
"decoder": { "type": "array", "required": true, "description": "Decoder stage configs" },
|
|
592
|
+
"skip-connections": { "type": "string", "default": "concat", "description": "'concat' or 'add'" },
|
|
593
|
+
"final": { "type": "layer", "required": true, "description": "Final output layer" },
|
|
594
|
+
"activation": { "type": "string", "default": "relu" },
|
|
595
|
+
"norm": { "type": "string", "default": "batch-norm" }
|
|
596
|
+
},
|
|
597
|
+
"input-shape": ["batch", "in-channels", "height", "width"],
|
|
598
|
+
"output-shape": ["batch", "out-channels", "height", "width"],
|
|
599
|
+
"pytorch": "custom"
|
|
600
|
+
},
|
|
601
|
+
"conditional-unet": {
|
|
602
|
+
"category": "organism",
|
|
603
|
+
"description": "Conditional U-Net for diffusion models (time + context conditioning)",
|
|
604
|
+
"params": {
|
|
605
|
+
"in-channels": { "type": "number", "required": true },
|
|
606
|
+
"out-channels": { "type": "number", "required": true },
|
|
607
|
+
"base-channels": { "type": "number", "required": true },
|
|
608
|
+
"channel-multipliers": { "type": "array", "required": true },
|
|
609
|
+
"num-res-blocks": { "type": "number", "default": 2 },
|
|
610
|
+
"attention-resolutions": { "type": "array", "default": [] },
|
|
611
|
+
"num-heads": { "type": "number", "default": 8 },
|
|
612
|
+
"context-dim": { "type": "number", "default": null, "description": "Cross-attention context dim (text embedding)" },
|
|
613
|
+
"time-embed-dim": { "type": "number", "default": null },
|
|
614
|
+
"conditioning": { "type": "object", "default": null }
|
|
615
|
+
},
|
|
616
|
+
"input-shape": ["batch", "in-channels", "height", "width"],
|
|
617
|
+
"output-shape": ["batch", "out-channels", "height", "width"],
|
|
618
|
+
"pytorch": "custom"
|
|
619
|
+
},
|
|
620
|
+
|
|
621
|
+
"gcn-conv": {
|
|
622
|
+
"category": "graph",
|
|
623
|
+
"description": "Graph Convolutional Network layer (Kipf & Welling)",
|
|
624
|
+
"params": {
|
|
625
|
+
"in": { "type": "number", "required": true },
|
|
626
|
+
"out": { "type": "number", "required": true }
|
|
627
|
+
},
|
|
628
|
+
"input-shape": { "x": ["num-nodes", "in"], "edge-index": [2, "num-edges"] },
|
|
629
|
+
"output-shape": { "x": ["num-nodes", "out"] },
|
|
630
|
+
"pytorch": "torch_geometric.nn.GCNConv"
|
|
631
|
+
},
|
|
632
|
+
"gat-conv": {
|
|
633
|
+
"category": "graph",
|
|
634
|
+
"description": "Graph Attention Network layer (Velickovic et al.)",
|
|
635
|
+
"params": {
|
|
636
|
+
"in": { "type": "number", "required": true },
|
|
637
|
+
"out": { "type": "number", "required": true },
|
|
638
|
+
"heads": { "type": "number", "default": 1 },
|
|
639
|
+
"dropout": { "type": "number", "default": 0 },
|
|
640
|
+
"concat": { "type": "boolean", "default": true, "description": "Concatenate heads (true) or average (false)" }
|
|
641
|
+
},
|
|
642
|
+
"input-shape": { "x": ["num-nodes", "in"], "edge-index": [2, "num-edges"] },
|
|
643
|
+
"output-shape": { "x": ["num-nodes", "out * heads (if concat) or out"] },
|
|
644
|
+
"pytorch": "torch_geometric.nn.GATConv"
|
|
645
|
+
},
|
|
646
|
+
"sage-conv": {
|
|
647
|
+
"category": "graph",
|
|
648
|
+
"description": "GraphSAGE layer (Hamilton et al.) for inductive learning",
|
|
649
|
+
"params": {
|
|
650
|
+
"in": { "type": "number", "required": true },
|
|
651
|
+
"out": { "type": "number", "required": true },
|
|
652
|
+
"aggregator": { "type": "string", "default": "mean", "description": "'mean', 'max', 'lstm'" }
|
|
653
|
+
},
|
|
654
|
+
"input-shape": { "x": ["num-nodes", "in"], "edge-index": [2, "num-edges"] },
|
|
655
|
+
"output-shape": { "x": ["num-nodes", "out"] },
|
|
656
|
+
"pytorch": "torch_geometric.nn.SAGEConv"
|
|
657
|
+
},
|
|
658
|
+
"gin-conv": {
|
|
659
|
+
"category": "graph",
|
|
660
|
+
"description": "Graph Isomorphism Network layer (Xu et al.) for maximum expressiveness",
|
|
661
|
+
"params": {
|
|
662
|
+
"in": { "type": "number", "required": true },
|
|
663
|
+
"out": { "type": "number", "required": true },
|
|
664
|
+
"train-eps": { "type": "boolean", "default": false }
|
|
665
|
+
},
|
|
666
|
+
"input-shape": { "x": ["num-nodes", "in"], "edge-index": [2, "num-edges"] },
|
|
667
|
+
"output-shape": { "x": ["num-nodes", "out"] },
|
|
668
|
+
"pytorch": "torch_geometric.nn.GINConv"
|
|
669
|
+
},
|
|
670
|
+
"edge-conv": {
|
|
671
|
+
"category": "graph",
|
|
672
|
+
"description": "Edge convolution layer (Wang et al., DGCNN)",
|
|
673
|
+
"params": {
|
|
674
|
+
"in": { "type": "number", "required": true },
|
|
675
|
+
"out": { "type": "number", "required": true }
|
|
676
|
+
},
|
|
677
|
+
"input-shape": { "x": ["num-nodes", "in"], "edge-index": [2, "num-edges"] },
|
|
678
|
+
"output-shape": { "x": ["num-nodes", "out"] },
|
|
679
|
+
"pytorch": "torch_geometric.nn.EdgeConv"
|
|
680
|
+
},
|
|
681
|
+
"graph-readout": {
|
|
682
|
+
"category": "graph",
|
|
683
|
+
"description": "Aggregate node features to a single graph-level vector",
|
|
684
|
+
"params": {
|
|
685
|
+
"method": { "type": "string", "required": true, "description": "'mean', 'max', 'sum', 'attention'" }
|
|
686
|
+
},
|
|
687
|
+
"input-shape": { "x": ["num-nodes", "dim"] },
|
|
688
|
+
"output-shape": ["batch", "dim"],
|
|
689
|
+
"pytorch": "torch_geometric.nn.global_mean_pool/max_pool/add_pool"
|
|
690
|
+
},
|
|
691
|
+
|
|
692
|
+
"pooler": {
|
|
693
|
+
"category": "utility",
|
|
694
|
+
"description": "Pool sequence output to a single vector (for classification heads)",
|
|
695
|
+
"params": {
|
|
696
|
+
"method": { "type": "string", "required": true, "description": "'cls-token', 'mean', 'max'" },
|
|
697
|
+
"dim": { "type": "number", "required": true }
|
|
698
|
+
},
|
|
699
|
+
"input-shape": ["batch", "seq", "dim"],
|
|
700
|
+
"output-shape": ["batch", "dim"],
|
|
701
|
+
"pytorch": "custom"
|
|
702
|
+
},
|
|
703
|
+
"reparameterize": {
|
|
704
|
+
"category": "utility",
|
|
705
|
+
"description": "VAE reparameterization trick: z = mu + eps * exp(0.5 * logvar)",
|
|
706
|
+
"params": {
|
|
707
|
+
"latent-dim": { "type": "number", "required": true }
|
|
708
|
+
},
|
|
709
|
+
"input-shape": { "mu": ["batch", "latent-dim"], "logvar": ["batch", "latent-dim"] },
|
|
710
|
+
"output-shape": ["batch", "latent-dim"],
|
|
711
|
+
"pytorch": "custom"
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|