@dxo/train 0.0.0 → 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 +35 -1
- package/package.json +40 -8
package/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
1
|
# @dxo/train
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Developer preview — API unstable (`0.0.x`).**
|
|
4
|
+
|
|
5
|
+
Async training loop over `@dxo/core` / `@dxo/nn` / `@dxo/optimizer` / `@dxo/data` / `@dxo/serialize`.
|
|
6
|
+
|
|
7
|
+
## Contract (0.0.7 / G5)
|
|
8
|
+
|
|
9
|
+
| API | Behavior |
|
|
10
|
+
|-----|----------|
|
|
11
|
+
| `Trainer` | Owns model + optimizer + batch factory + epoch count |
|
|
12
|
+
| `fitIter` / `run` | `AsyncGenerator<TrainEvent>`; respects `AbortSignal` |
|
|
13
|
+
| `fit` | Consumes the event stream; returns a short summary |
|
|
14
|
+
| Checkpoint | Emits `encodeLinearState(model.state())` documents (no FS I/O) |
|
|
15
|
+
| Device | **CPU-only** in this slice (GPU spike not required for this gate) |
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { batch, dataset } from '@dxo/data';
|
|
19
|
+
import { Linear } from '@dxo/nn';
|
|
20
|
+
import { SGD } from '@dxo/optimizer';
|
|
21
|
+
import { Trainer } from '@dxo/train';
|
|
22
|
+
|
|
23
|
+
const model = new Linear(2, 1);
|
|
24
|
+
const trainer = new Trainer({
|
|
25
|
+
model,
|
|
26
|
+
optimizer: new SGD(0.1),
|
|
27
|
+
epochs: 5,
|
|
28
|
+
batches: () => batch(dataset(samples), { batchSize: 8 }),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
for await (const event of trainer.fitIter({ signal })) {
|
|
32
|
+
if (event.type === 'batch') console.log(event.loss);
|
|
33
|
+
if (event.type === 'checkpoint') /* persist event.document */;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Not included: multi-GPU, distributed, early-stopping policies, `@dxo/inspect` adapters, real MNIST download.
|
package/package.json
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
2
|
+
"name": "@dxo/train",
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "DXO training loop — fitIter / TrainEvent / checkpoint (developer preview, API unstable)",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@dxo/core": "0.0.5",
|
|
24
|
+
"@dxo/data": "0.0.5",
|
|
25
|
+
"@dxo/nn": "0.0.5",
|
|
26
|
+
"@dxo/optimizer": "0.0.5",
|
|
27
|
+
"@dxo/serialize": "0.0.5"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"dxo",
|
|
31
|
+
"trainer",
|
|
32
|
+
"training",
|
|
33
|
+
"typescript"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/ai4waifu/dxo-framework.git"
|
|
41
|
+
}
|
|
10
42
|
}
|