Browser demo
One SGD step, in your browser.
The hello_swarm step: a 4-to-2 linear model, mean squared error, its gradients and one SGD update with momentum and weight decay. Edit any value and the result updates.
Execution mode Interactive TypeScript model
Loss before
0.064512
Loss after
0.047298
Change
-26.7%
Predictions
| Output | Target | Before | Gradient | After |
|---|---|---|---|---|
| y0 | 0.500000 | 0.223396 | -0.276604 | 0.263157 |
| y1 | -0.250000 | -0.479160 | -0.229160 | -0.446216 |
Parameters and gradients
Weights are row-major by output, followed by the two biases.
| Parameter | Before | Gradient | After |
|---|---|---|---|
| w[0][0] | 0.241565 | -0.276604 | 0.255394 |
| w[0][1] | -0.340090 | 0.138302 | -0.347003 |
| w[0][2] | -0.221399 | -0.069151 | -0.217940 |
| w[0][3] | -0.155809 | -0.207453 | -0.145436 |
| w[1][0] | -0.461970 | -0.229160 | -0.450509 |
| w[1][1] | 0.368228 | 0.114580 | 0.362497 |
| w[1][2] | -0.281595 | -0.057290 | -0.278729 |
| w[1][3] | 0.300632 | -0.171870 | 0.309224 |
| b[0] | -0.016007 | -0.276604 | -0.002177 |
| b[1] | 0.011848 | -0.229160 | 0.023306 |
SafeTensors checkpoint round trip
Export, import and parameter comparison only run inside the SwarmTorch module.
Result record
{
"execution_mode": "typescript-model",
"source_revision": null,
"modelled_on_revision": "7a75c553c6356f35473d7dbaf6b8e256a86023a7",
"input_configuration": {
"input": [
1,
-0.5,
0.25,
0.75
],
"target": [
0.5,
-0.25
],
"seed": 42,
"learning_rate": 0.05,
"momentum": 0.9,
"weight_decay": 0.0001
},
"parameters_before": [
0.24156486988067627,
-0.3400896191596985,
-0.22139886021614075,
-0.15580928325653076,
-0.4619698226451874,
0.36822807788848877,
-0.28159481287002563,
0.30063188076019287,
-0.016006896272301674,
0.0118482057005167
],
"before": {
"predictions": [
0.22339610755443573,
-0.47916045784950256
],
"loss": 0.06451211124658585
},
"prediction_gradients": [
-0.2766038775444031,
-0.22916045784950256
],
"parameter_gradients": [
-0.2766038775444031,
0.13830193877220154,
-0.06915096938610077,
-0.2074529081583023,
-0.22916045784950256,
0.11458022892475128,
-0.05729011446237564,
-0.17187035083770752,
-0.2766038775444031,
-0.22916045784950256
],
"parameters_after": [
0.2553938627243042,
-0.3470030128955841,
-0.21794021129608154,
-0.1454358547925949,
-0.4505094885826111,
0.3624972105026245,
-0.2787289023399353,
0.30922389030456543,
-0.002176622161641717,
0.023306168615818024
],
"after": {
"predictions": [
0.26315680146217346,
-0.4462162256240845
],
"loss": 0.047297753393650055
},
"checkpoint": {
"status": "not_evaluated"
}
} How results are checked. The native example is run with cargo run --locked as its own acceptance check. The browser module and this TypeScript model are compared with a native run of the same wrapper code at an absolute tolerance of 1e-6. The label above changes to "SwarmTorch browser demo" only after the real module has loaded, validated its provenance and returned a result.