@openfluke/welvet 0.3.0 → 0.74.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/LICENSE +200 -200
- package/README.md +56 -357
- package/dist/benchmark_tiling.html +244 -0
- package/dist/benchmark_training.html +249 -0
- package/dist/benchmark_training_comparison.html +230 -0
- package/dist/cabi_verify.html +360 -0
- package/dist/dna_evo_benchmark.html +420 -0
- package/dist/index.d.ts +101 -35
- package/dist/index.js +135 -64
- package/dist/loader.browser.d.ts +2 -2
- package/dist/loader.browser.js +7 -8
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +12 -25
- package/dist/main.wasm +0 -0
- package/dist/src/index.d.ts +135 -0
- package/dist/src/index.js +181 -0
- package/dist/src/loader.browser.d.ts +5 -0
- package/dist/src/loader.browser.js +24 -0
- package/dist/src/loader.d.ts +5 -0
- package/dist/src/loader.js +26 -0
- package/dist/src/types.d.ts +299 -0
- package/dist/src/types.js +65 -0
- package/dist/tests/benchmark.d.ts +5 -0
- package/dist/tests/benchmark.js +139 -0
- package/dist/tests/benchmark.ts +148 -0
- package/dist/tests/cabi_verify.d.ts +5 -0
- package/dist/tests/cabi_verify.js +181 -0
- package/dist/tests/cabi_verify.ts +192 -0
- package/dist/types.d.ts +269 -171
- package/dist/types.js +63 -2
- package/dist/wasm_exec.js +575 -575
- package/package.json +58 -89
- package/dist/index.browser.d.ts +0 -32
- package/dist/index.browser.js +0 -39
package/README.md
CHANGED
|
@@ -1,410 +1,109 @@
|
|
|
1
|
-
# @openfluke/welvet
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
| | **Runtime Dependency** | **None** | Heavy | Light | Light | None |
|
|
16
|
-
| **Loading** | **Safetensors** | ✅ **Native** | ❌ | ❌ | ❌ | ✅ |
|
|
17
|
-
| | **Structure Inference** | ✅ **Auto-Detect** | ❌ | ❌ | ❌ | ❌ |
|
|
18
|
-
| **Training** | **Browser Training** | ✅ **Full** | ✅ (Slow) | ✅ | ❌ | ✅ |
|
|
19
|
-
| | **Neural Tweening** | ✅ **Hybrid Engine** | ❌ | ❌ | ❌ | ❌ |
|
|
20
|
-
| | **LR Schedulers** | ✅ **7 Types** | ✅ | ⚠️ | ❌ | ✅ |
|
|
21
|
-
| **Layer Support** | **Dense (MLP)** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
22
|
-
| | **Conv1D/2D** | ✅ **Native** | ✅ | ❌ | ✅ | ✅ |
|
|
23
|
-
| | **RNN / LSTM** | ✅ **Full Gate** | ✅ | ✅ | ✅ | ✅ |
|
|
24
|
-
| | **Transformer (MHA)** | ✅ (Explicit) | ✅ | ❌ | ✅ | ✅ |
|
|
25
|
-
| | **Parallel / MoE** | ✅ **Structure** | ❌ (Manual) | ❌ | ❌ | ❌ |
|
|
26
|
-
| | **Sequential Layers** | ✅ **Native** | ⚠️ | ⚠️ | ❌ | ⚠️ |
|
|
27
|
-
| **Advanced** | **Step-Based Forward** | ✅ **Unique** | ❌ | ❌ | ❌ | ❌ |
|
|
28
|
-
| | **Stitch Layers** | ✅ **Native** | ❌ | ❌ | ❌ | ❌ |
|
|
29
|
-
| | **K-Means / Stats** | ✅ **Parallel** | ❌ | ❌ | ❌ | ❌ |
|
|
30
|
-
| | **Cross-Lang ABI** | ✅ **Universal** | ❌ | ❌ | ❌ | ⚠️ |
|
|
31
|
-
| **Streaming** | **LLM Streaming** | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
32
|
-
| | **Pure Go Tokenizer** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
33
|
-
|
|
34
|
-
For detailed comparison, see [`docs/loom_assessment_comparison.md`](../docs/loom_assessment_comparison.md).
|
|
35
|
-
|
|
36
|
-
## 🌍 Cross-Ecosystem Compatibility
|
|
37
|
-
|
|
38
|
-
Models trained in TypeScript can be loaded instantly in Python, C#, Go, or other WASM environments. **Bit-for-bit identical results** across all platforms.
|
|
39
|
-
|
|
40
|
-
| Platform | Package | Install |
|
|
41
|
-
|:---------|:--------|:--------|
|
|
42
|
-
| **TypeScript/Node** | [NPM](https://www.npmjs.com/package/@openfluke/welvet) | `npm install @openfluke/welvet` |
|
|
43
|
-
| **Python** | [PyPI](https://pypi.org/project/welvet/) | `pip install welvet` |
|
|
44
|
-
| **C#/.NET** | [NuGet](https://www.nuget.org/packages/Welvet) | `dotnet add package Welvet` |
|
|
45
|
-
| **Go** | [GitHub](https://github.com/openfluke/loom) | `go get github.com/openfluke/loom` |
|
|
46
|
-
|
|
47
|
-
### Key Strengths
|
|
48
|
-
|
|
49
|
-
- **True Embeddability**: Single WASM binary. Works in Node.js and browsers with the same API.
|
|
50
|
-
- **Hybrid Gradient/Geometric Engine**: "Neural Tweening" combines geometric gap-closing with backpropagation-guided momentum.
|
|
51
|
-
- **Structural Parallelism**: Native support for Inception, ResNeXt, Siamese, and MoE architectures via `LayerParallel`.
|
|
52
|
-
- **Native Mixed-Precision**: Generic tensor backend supports `int8`, `uint16`, and `float32`.
|
|
53
|
-
- **Complete Evaluation Suite**: Deviation metrics, training milestones, and adaptation tracking.
|
|
54
|
-
- **Network Telemetry**: Runtime introspection with `GetMethodsJSON()` and `ExtractNetworkBlueprint()`.
|
|
1
|
+
# @openfluke/welvet
|
|
2
|
+
|
|
3
|
+
**M-POLY-VTD AI Engine (Loom v0.74.0)** — Isomorphic TypeScript/WASM library for building, training, and evolving neural networks with 21 numerical types, WebGPU acceleration, and DNA-based evolution.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@openfluke/welvet)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Isomorphic Architecture**: Runs seamlessly in Node.js, Bun, and the Browser (React/Frontend).
|
|
11
|
+
- **Multi-Precision Support**: Native support for 21 numerical types (FP64, FP32, FP16, BF16, FP8, INT8... all the way down to Binary/Ternary).
|
|
12
|
+
- **Hybrid Training**: standard Backprop, Target Propagation, and NEAT-style structural evolution in a single unified engine.
|
|
13
|
+
- **Hardware Acceleration**: WebGPU support for high-performance inference and training in the browser.
|
|
14
|
+
- **DNA Evolution**: Network "DNA" extraction and comparison for architectural analysis and genetic recombination.
|
|
55
15
|
|
|
56
16
|
## Installation
|
|
57
17
|
|
|
58
18
|
```bash
|
|
59
19
|
npm install @openfluke/welvet
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
**Using Bun:**
|
|
63
|
-
```bash
|
|
20
|
+
# or
|
|
64
21
|
bun add @openfluke/welvet
|
|
65
22
|
```
|
|
66
23
|
|
|
67
24
|
## Quick Start
|
|
68
25
|
|
|
69
|
-
###
|
|
26
|
+
### 1. Initialization
|
|
70
27
|
|
|
71
|
-
The
|
|
28
|
+
The engine initializes automatically after a single call to `init()`. It detects whether it's running in Node.js, Bun, or the Browser and loads the appropriate WASM environment.
|
|
72
29
|
|
|
73
30
|
```typescript
|
|
74
|
-
import { init
|
|
75
|
-
|
|
76
|
-
// Initialize LOOM WASM
|
|
77
|
-
await init();
|
|
78
|
-
|
|
79
|
-
// Create network from JSON config
|
|
80
|
-
const config = {
|
|
81
|
-
batch_size: 1,
|
|
82
|
-
grid_rows: 1,
|
|
83
|
-
grid_cols: 3,
|
|
84
|
-
layers_per_cell: 1,
|
|
85
|
-
layers: [
|
|
86
|
-
{ type: "dense", input_size: 8, output_size: 16, activation: "relu" },
|
|
87
|
-
{
|
|
88
|
-
type: "parallel",
|
|
89
|
-
combine_mode: "grid_scatter",
|
|
90
|
-
grid_output_rows: 3, grid_output_cols: 1, grid_output_layers: 1,
|
|
91
|
-
grid_positions: [
|
|
92
|
-
{ branch_index: 0, target_row: 0, target_col: 0, target_layer: 0 },
|
|
93
|
-
{ branch_index: 1, target_row: 1, target_col: 0, target_layer: 0 },
|
|
94
|
-
{ branch_index: 2, target_row: 2, target_col: 0, target_layer: 0 },
|
|
95
|
-
],
|
|
96
|
-
branches: [
|
|
97
|
-
{ type: "parallel", combine_mode: "add", branches: [
|
|
98
|
-
{ type: "dense", input_size: 16, output_size: 8, activation: "relu" },
|
|
99
|
-
{ type: "dense", input_size: 16, output_size: 8, activation: "gelu" },
|
|
100
|
-
]},
|
|
101
|
-
{ type: "lstm", input_size: 16, hidden_size: 8, seq_length: 1 },
|
|
102
|
-
{ type: "rnn", input_size: 16, hidden_size: 8, seq_length: 1 },
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
{ type: "dense", input_size: 24, output_size: 2, activation: "sigmoid" },
|
|
106
|
-
],
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const network = createNetworkFromJSON(JSON.stringify(config));
|
|
110
|
-
|
|
111
|
-
// Training
|
|
112
|
-
const batches = [
|
|
113
|
-
{ Input: [0.2, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8], Target: [1.0, 0.0] },
|
|
114
|
-
{ Input: [0.9, 0.9, 0.9, 0.9, 0.1, 0.1, 0.1, 0.1], Target: [0.0, 1.0] },
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
const trainingConfig = {
|
|
118
|
-
Epochs: 800,
|
|
119
|
-
LearningRate: 0.15,
|
|
120
|
-
LossType: "mse",
|
|
121
|
-
GradientClip: 1.0,
|
|
122
|
-
};
|
|
31
|
+
import { init } from "@openfluke/welvet";
|
|
123
32
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// Forward pass
|
|
127
|
-
const [output] = network.ForwardCPU(JSON.stringify([[0.2, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8]]));
|
|
128
|
-
console.log("Output:", JSON.parse(output)); // [0.95, 0.05]
|
|
129
|
-
|
|
130
|
-
// Save/Load
|
|
131
|
-
const [modelJSON] = network.SaveModelToString(JSON.stringify(["my_model"]));
|
|
132
|
-
const loadedNetwork = loadLoomNetwork(modelJSON, "my_model");
|
|
33
|
+
await init(); // Just works™
|
|
133
34
|
```
|
|
134
35
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
| Function | Description |
|
|
138
|
-
|:---------|:------------|
|
|
139
|
-
| `createNetworkFromJSON(config)` | Create network from JSON |
|
|
140
|
-
| `loadLoomNetwork(json, id)` | Load saved model |
|
|
141
|
-
| `network.ForwardCPU(input)` | Forward pass |
|
|
142
|
-
| `network.BackwardCPU(gradients)` | Backward pass |
|
|
143
|
-
| `network.Train(params)` | Train network |
|
|
144
|
-
| `network.SaveModelToString(id)` | Save to JSON string |
|
|
145
|
-
| `network.EvaluateNetwork(params)` | Evaluate with metrics |
|
|
36
|
+
> [!TIP]
|
|
37
|
+
> In browser environments, if your assets are served from a non-standard path, you can optionally pass a custom URL: `await init("/custom/path/to/main.wasm")`.
|
|
146
38
|
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
Execute networks one step at a time for online learning:
|
|
39
|
+
### 2. Create a Network
|
|
150
40
|
|
|
151
41
|
```typescript
|
|
152
|
-
import {
|
|
153
|
-
|
|
154
|
-
await init();
|
|
42
|
+
import { createNetwork, DType } from "@openfluke/welvet";
|
|
155
43
|
|
|
156
|
-
const
|
|
157
|
-
batch_size: 1,
|
|
44
|
+
const net = createNetwork({
|
|
158
45
|
layers: [
|
|
159
|
-
{ type: "
|
|
160
|
-
{ type: "
|
|
161
|
-
{ type: "dense", input_height: 12, output_height: 3, activation: "softmax" }
|
|
46
|
+
{ type: "Dense", input_height: 784, output_height: 256, activation: "ReLU", dtype: DType.FLOAT32 },
|
|
47
|
+
{ type: "Dense", input_height: 256, output_height: 10, activation: "Linear", dtype: DType.FLOAT16 }
|
|
162
48
|
]
|
|
163
49
|
});
|
|
164
50
|
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
// Training loop - update weights after EACH step
|
|
169
|
-
for (let step = 0; step < 100000; step++) {
|
|
170
|
-
state.setInput(new Float32Array([0.1, 0.2, 0.1, 0.3]));
|
|
171
|
-
state.stepForward();
|
|
172
|
-
const output = state.getOutput();
|
|
173
|
-
|
|
174
|
-
// Backward pass
|
|
175
|
-
const gradients = output.map((o, i) => o - target[i]);
|
|
176
|
-
state.stepBackward(gradients);
|
|
177
|
-
|
|
178
|
-
// Update weights immediately
|
|
179
|
-
network.ApplyGradients(JSON.stringify([learningRate]));
|
|
180
|
-
}
|
|
51
|
+
const input = new Float32Array(784).fill(0.5);
|
|
52
|
+
const output = net.sequentialForward(input);
|
|
53
|
+
console.log("Prediction:", output);
|
|
181
54
|
```
|
|
182
55
|
|
|
183
|
-
###
|
|
184
|
-
|
|
185
|
-
Direct weight adjustment without backpropagation:
|
|
56
|
+
### 3. Training
|
|
186
57
|
|
|
187
58
|
```typescript
|
|
188
|
-
import {
|
|
189
|
-
|
|
190
|
-
await init();
|
|
191
|
-
|
|
192
|
-
const network = createNetwork(config);
|
|
193
|
-
|
|
194
|
-
// Create tween state (with optional chain rule)
|
|
195
|
-
const tweenState: TweenState = network.createTweenState(true); // useChainRule=true
|
|
196
|
-
|
|
197
|
-
// Training loop - direct weight updates
|
|
198
|
-
for (let step = 0; step < 10000; step++) {
|
|
199
|
-
const loss = tweenState.TweenStep(
|
|
200
|
-
new Float32Array([0.1, 0.2, 0.3, 0.4]),
|
|
201
|
-
1, // targetClass
|
|
202
|
-
4, // outputSize
|
|
203
|
-
0.02 // learningRate
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### 📊 Adaptation Benchmark
|
|
59
|
+
import { trainNetwork } from "@openfluke/welvet";
|
|
209
60
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
cd example
|
|
214
|
-
bun run test18_adaptation.ts
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Tests **5 architectures × 3 depths × 5 training modes** (75 tests total):
|
|
218
|
-
- **Architectures:** Dense, Conv2D, RNN, LSTM, Attention
|
|
219
|
-
- **Depths:** 3, 5, 9 layers
|
|
220
|
-
- **Modes:** NormalBP, StepBP, Tween, TweenChain, StepTweenChain
|
|
221
|
-
|
|
222
|
-
## Complete Test Suite
|
|
223
|
-
|
|
224
|
-
The `universal_test.ts` example demonstrates all framework capabilities with **100% parity** to the Go/C core.
|
|
225
|
-
|
|
226
|
-
### Running in Browser (v0.3.0+)
|
|
227
|
-
|
|
228
|
-
The universal test suite now runs directly in the browser with a full DOM report:
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
cd typescript
|
|
232
|
-
python3 serve.py
|
|
233
|
-
# Open http://localhost:8081
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Running in Node/Bun
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
cd example
|
|
240
|
-
bun run universal_test.ts
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Test Coverage (2298 Tests):**
|
|
244
|
-
- ✅ **Serialization**: 12 Layer Types × 15 Data Types (2100 combinations)
|
|
245
|
-
- ✅ **In-Memory WASM**: SafeTensors without filesystem (144 tests)
|
|
246
|
-
- ✅ **Advanced Math**: K-Means, Correlation, Grafting, Ensembles
|
|
247
|
-
- ✅ **GPU Parity**: Determinism checks for forward/backward passes
|
|
248
|
-
- ✅ **Core**: Architecture generation, combinators, sequential layers
|
|
249
|
-
|
|
250
|
-
See [`example/universal_test.ts`](./example/universal_test.ts) for the complete test implementation.
|
|
251
|
-
|
|
252
|
-
## Layer Types
|
|
253
|
-
|
|
254
|
-
| Layer | Type String | Description |
|
|
255
|
-
|:------|:------------|:------------|
|
|
256
|
-
| Dense | `dense` | Fully connected layer |
|
|
257
|
-
| LSTM | `lstm` | Long Short-Term Memory |
|
|
258
|
-
| RNN | `rnn` | Recurrent Neural Network |
|
|
259
|
-
| GRU | `gru` | Gated Recurrent Unit |
|
|
260
|
-
| Conv2D | `conv2d` | 2D Convolution |
|
|
261
|
-
| Conv1D | `conv1d` | 1D Convolution |
|
|
262
|
-
| Multi-Head Attention | `multi_head_attention` | Transformer attention |
|
|
263
|
-
| LayerNorm | `layer_norm` | Layer normalization |
|
|
264
|
-
| RMSNorm | `rms_norm` | RMS normalization |
|
|
265
|
-
| SwiGLU | `swiglu` | SwiGLU activation layer |
|
|
266
|
-
| Softmax | `softmax` | Softmax classification |
|
|
267
|
-
| Embedding | `embedding` | Token embedding |
|
|
268
|
-
| Parallel | `parallel` | Branching with combine modes |
|
|
269
|
-
| Sequential | `sequential` | Grouped sub-layers |
|
|
270
|
-
|
|
271
|
-
**Parallel Combine Modes:** `add`, `concat`, `multiply`, `average`, `grid_scatter`, `filter`
|
|
272
|
-
|
|
273
|
-
## Activation Functions
|
|
274
|
-
|
|
275
|
-
`relu`, `sigmoid`, `tanh`, `softmax`, `gelu`, `swish`, `mish`, `leaky_relu`, `elu`, `selu`, `linear`
|
|
276
|
-
|
|
277
|
-
## API Reference
|
|
278
|
-
|
|
279
|
-
### Initialization
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
import { init, initBrowser, createNetwork, createNetworkFromJSON } from "@openfluke/welvet";
|
|
283
|
-
|
|
284
|
-
// Node.js
|
|
285
|
-
await init();
|
|
61
|
+
const batches = [
|
|
62
|
+
{ input: [0.1, 0.2, ...], target: [1, 0, ...] },
|
|
63
|
+
];
|
|
286
64
|
|
|
287
|
-
|
|
288
|
-
|
|
65
|
+
const result = trainNetwork(net, batches, 10, 0.001);
|
|
66
|
+
console.log("Final Loss:", result.final_loss);
|
|
289
67
|
```
|
|
290
68
|
|
|
291
|
-
###
|
|
292
|
-
|
|
293
|
-
All Network methods follow the WASM calling convention:
|
|
294
|
-
- **Input:** JSON string of an array of parameters
|
|
295
|
-
- **Return:** JSON string of an array of results
|
|
69
|
+
### 4. NEAT Evolution
|
|
296
70
|
|
|
297
71
|
```typescript
|
|
298
|
-
|
|
299
|
-
const info = network.GetNetworkInfo(JSON.stringify([]));
|
|
300
|
-
|
|
301
|
-
// Method with parameters
|
|
302
|
-
const result = network.Train(JSON.stringify([batches, config]));
|
|
303
|
-
|
|
304
|
-
// Save model
|
|
305
|
-
const saved = network.SaveModelToString(JSON.stringify(["my-model"]));
|
|
306
|
-
```
|
|
72
|
+
import { createNEATPopulation } from "@openfluke/welvet";
|
|
307
73
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
| Method | Parameters | Description |
|
|
311
|
-
|:-------|:-----------|:------------|
|
|
312
|
-
| `ForwardCPU` | `[inputs]` | CPU forward pass |
|
|
313
|
-
| `ForwardGPU` | `[inputs]` | GPU forward pass |
|
|
314
|
-
| `BackwardCPU` | `[gradients]` | CPU backward pass |
|
|
315
|
-
| `Train` | `[batches, config]` | Train network |
|
|
316
|
-
| `SaveModelToString` | `["modelID"]` | Save to JSON |
|
|
317
|
-
| `GetWeights` | `[row, col, layer]` | Get layer weights |
|
|
318
|
-
| `SetWeights` | `[row, col, layer, weights]` | Set layer weights |
|
|
319
|
-
| `GetBiases` | `[row, col, layer]` | Get layer biases |
|
|
320
|
-
| `SetBiases` | `[row, col, layer, biases]` | Set layer biases |
|
|
321
|
-
| `GetNetworkInfo` | `[]` | Get network info |
|
|
322
|
-
| `GetTotalParameters` | `[]` | Get parameter count |
|
|
323
|
-
| `Clone` | `[]` | Clone network |
|
|
324
|
-
| `TotalLayers` | `[]` | Get total layer count |
|
|
325
|
-
|
|
326
|
-
### Statistical Tools
|
|
74
|
+
const population = createNEATPopulation(net, 100);
|
|
75
|
+
const fitnesses = new Array(100).fill(0).map(() => Math.random());
|
|
327
76
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
// K-Means Clustering
|
|
332
|
-
const data = [[1, 1], [1.1, 1.1], [5, 5], [5.1, 5.1]];
|
|
333
|
-
const result = welvet.kmeans(data, 2, 100);
|
|
334
|
-
console.log(`Centroids: ${result.centroids}`);
|
|
335
|
-
console.log(`Silhouette Score: ${result.silhouette_score}`);
|
|
336
|
-
|
|
337
|
-
// Correlation Matrix
|
|
338
|
-
const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
|
339
|
-
const corr = welvet.correlation(matrix);
|
|
340
|
-
console.log(`Pearson: ${corr.pearson}`);
|
|
77
|
+
population.evolveWithFitnesses(fitnesses);
|
|
78
|
+
const bestNet = population.best();
|
|
79
|
+
console.log("Best Fitness:", population.bestFitness());
|
|
341
80
|
```
|
|
342
81
|
|
|
343
|
-
|
|
82
|
+
## Testing & Benchmarks
|
|
344
83
|
|
|
345
|
-
|
|
84
|
+
The package includes a built-in TypeScript testing suite suitable for both CI and environment verification.
|
|
346
85
|
|
|
347
|
-
|
|
348
|
-
const h1 = welvet.createKHandle(config);
|
|
349
|
-
const h2 = welvet.createKHandle(config);
|
|
86
|
+
### Run tests in Node.js:
|
|
350
87
|
|
|
351
|
-
|
|
352
|
-
|
|
88
|
+
```bash
|
|
89
|
+
npm test
|
|
353
90
|
```
|
|
354
91
|
|
|
355
|
-
|
|
356
|
-
|
|
92
|
+
Or individual suites:
|
|
357
93
|
```bash
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
# Grid Scatter Multi-Agent
|
|
361
|
-
bun run grid-scatter.ts
|
|
362
|
-
|
|
363
|
-
# Stepping Training (LSTM)
|
|
364
|
-
bun run step_train_v3.ts
|
|
365
|
-
|
|
366
|
-
# Adaptation Benchmark (75 tests)
|
|
367
|
-
bun run test18_adaptation.ts
|
|
368
|
-
|
|
369
|
-
# Full Test Suite (77 tests)
|
|
370
|
-
bun run universal_test.ts
|
|
94
|
+
npm run test:cabi # Check WASM exports and functional smoke tests
|
|
95
|
+
npm run test:bench # Run layer-by-layer performance benchmarks
|
|
371
96
|
```
|
|
372
97
|
|
|
373
|
-
|
|
98
|
+
### Integrate tests into Frontend/React:
|
|
374
99
|
|
|
375
100
|
```typescript
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
layers_per_cell?: number;
|
|
381
|
-
layers: LayerConfig[];
|
|
382
|
-
dtype?: "float32" | "float64" | "int32" | "int16" | "int8" | "uint8";
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
interface TrainingConfig {
|
|
386
|
-
Epochs: number;
|
|
387
|
-
LearningRate: number;
|
|
388
|
-
LossType?: string;
|
|
389
|
-
Verbose?: boolean;
|
|
390
|
-
UseGPU?: boolean;
|
|
391
|
-
GradientClip?: number;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
interface TrainingBatch {
|
|
395
|
-
Input: number[];
|
|
396
|
-
Target: number[];
|
|
397
|
-
}
|
|
101
|
+
import { runVerify } from "@openfluke/welvet/tests/cabi_verify";
|
|
102
|
+
|
|
103
|
+
// Run benchmarks or verification logic directly in your app's lifecycle
|
|
104
|
+
await runVerify();
|
|
398
105
|
```
|
|
399
106
|
|
|
400
107
|
## License
|
|
401
108
|
|
|
402
109
|
Apache-2.0
|
|
403
|
-
|
|
404
|
-
## Links
|
|
405
|
-
|
|
406
|
-
- **GitHub**: [github.com/openfluke/loom](https://github.com/openfluke/loom)
|
|
407
|
-
- **NPM**: [@openfluke/welvet](https://www.npmjs.com/package/@openfluke/welvet)
|
|
408
|
-
- **PyPI**: [welvet](https://pypi.org/project/welvet/)
|
|
409
|
-
- **NuGet**: [Welvet](https://www.nuget.org/packages/Welvet)
|
|
410
|
-
- **Documentation**: [`docs/loom_assessment_comparison.md`](../docs/loom_assessment_comparison.md)
|