Skip to content

Add optimizers, more activations, dropout, early stopping, model save/load, dark mode - #255

Open
EyobelG wants to merge 1 commit into
tensorflow:masterfrom
EyobelG:feat/optimizers-activations-regularization
Open

EyobelG wants to merge 1 commit into
tensorflow:masterfrom
EyobelG:feat/optimizers-activations-regularization

Conversation

@EyobelG

@EyobelG EyobelG commented Oct 22, 2026

Copy link
Copy Markdown

Summary

  • nn.ts: pluggable optimizer (SGD / Momentum / RMSProp / Adam) with gradient clipping and learning-rate decay, replacing the plain-SGD-only update step. Adds LeakyReLU/ELU/Swish activations, inverted dropout on hidden layers during training, an EarlyStopping helper, and JSON serialize/deserialize for a trained network's weights and biases.
  • state.ts / playground.ts / index.html: wires all of the above into the UI — optimizer dropdown, dropout slider, early-stopping checkbox, save/load-model buttons (File/Blob APIs) — plus a dark-mode toggle persisted to localStorage.
  • styles.css: dark mode via a page-wide invert filter, with the classification/regression color-coded regions (heatmap, network diagram, dataset thumbnails, loss chart, color legend) counter-inverted so their colors keep their original meaning.

All changes are additive: every new control defaults to the prior behavior (optimizer defaults to sgd, dropout defaults to 0, early stopping defaults off, theme defaults to light), so existing shared URLs/state render identically to before.

Scoped out

  • Multi-class classification/cross-entropy+softmax: would require rebuilding the single-output network architecture, the decision-boundary heatmap, and the dataset generators. Left as a follow-up if there's interest.
  • Custom CSV/JSON dataset import.

Test plan

  • npx browserify src/playground.ts -p "[tsify]" -o dist/bundle.js compiles clean with the project's existing TS 2.9/tsify toolchain.
  • Manually exercised in a local browser session: optimizer dropdown (trained the circle dataset with Adam, converged to ~0 loss in <200 epochs), dropout slider, early-stopping checkbox, dark-mode toggle (verified data-encoded colors stay correct), and save-model/load-model round trip (exported JSON, reset the network, re-imported, confirmed identical weights/loss).
  • No console errors during the above session.

Happy to split this into smaller PRs per feature if that's easier to review.

@google-cla

google-cla Bot commented Oct 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@EyobelG

EyobelG commented Oct 23, 2026

Copy link
Copy Markdown
Author

recheck

@EyobelG

EyobelG commented Oct 23, 2026

Copy link
Copy Markdown
Author

I signed it!

…/load, dark mode

- nn.ts: pluggable optimizer (SGD/Momentum/RMSProp/Adam) with gradient
  clipping and learning-rate decay, replacing the plain SGD-only update
  step. Adds LeakyReLU/ELU/Swish activations, inverted dropout on hidden
  layers during training, an EarlyStopping helper, and JSON
  serialize/deserialize for a trained network's weights and biases.
- state.ts/playground.ts/index.html: wire the above into the UI (optimizer
  dropdown, dropout slider, early-stopping checkbox, save/load model
  buttons using File/Blob APIs) and add a dark mode toggle persisted to
  localStorage.
- styles.css: dark mode via a page-wide invert filter, with the
  classification/regression color-coded regions (heatmap, network
  diagram, dataset thumbnails, loss chart, color legend) counter-inverted
  so their colors keep their original meaning.

Multi-class classification support and CSV/JSON dataset import were
scoped out of this change: multi-class would require rebuilding the
single-output network architecture, decision-boundary heatmap and
dataset generators, and dataset import was dropped as an unnecessary
file-handling attack surface for this pass.
@EyobelG
EyobelG force-pushed the feat/optimizers-activations-regularization branch from 82e2113 to 351723d Compare October 23, 2026 00:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant