@dxo/nn 0.0.3 → 0.0.5
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/README.md +34 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @dxo/nn
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Developer preview — API unstable (`0.0.x`).**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Pure TypeScript modules over `@dxo/core`.
|
|
6
|
+
|
|
7
|
+
## Contract (G3 preview)
|
|
8
|
+
|
|
9
|
+
| Type | Behavior |
|
|
10
|
+
|------|----------|
|
|
11
|
+
| `Linear(in, out)` | **`y = x @ W + b` only** — no implicit ReLU |
|
|
12
|
+
| `Relu` / `relu(x)` | Explicit nonlinearity |
|
|
13
|
+
| `Sequential(layers)` | Chains `forward` |
|
|
14
|
+
| `parameters()` | Collects `Tensor` fields (and nested modules) in enumeration order |
|
|
15
|
+
| `zeroGrad()` | Calls `zeroGrad` on each parameter leaf |
|
|
16
|
+
| `Linear.loadParameters([W, b])` | Reassign leaves after `optimizer.step` |
|
|
17
|
+
| `Linear.state` / `loadState` | Plain `{ shape, data }` snapshots |
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Linear, Relu, Sequential } from '@dxo/nn';
|
|
21
|
+
import { SGD } from '@dxo/optimizer';
|
|
22
|
+
|
|
23
|
+
const model = new Sequential([new Linear(2, 4), new Relu(), new Linear(4, 1)]);
|
|
24
|
+
const opt = new SGD(0.05);
|
|
25
|
+
// ... loss.backward()
|
|
26
|
+
model.layers[0] // update Linear leaves via loadParameters after step
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Training step pattern:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
model.zeroGrad();
|
|
33
|
+
const loss = /* scalar Tensor */;
|
|
34
|
+
loss.backward();
|
|
35
|
+
const linear = model.layers[0] as Linear;
|
|
36
|
+
linear.loadParameters(opt.step(linear.parameters()));
|
|
37
|
+
```
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxo/nn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "DXO neural
|
|
5
|
+
"description": "DXO neural modules over @dxo/core (developer preview, API unstable)",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test:forward": "tsx ../../../scripts/test/nn-forward.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@dxo/core": "0.0.
|
|
24
|
+
"@dxo/core": "0.0.5"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"dxo",
|