← all repositories
harthur/brain

The JavaScript neural network that recommends its own replacements

It exists to run feed-forward neural networks in JavaScript and ship trained models as copy-pasteable functions with no library overhead.

8k stars JavaScript ML Frameworks
brain
Not currently ranked — collecting fresh signals.
star history

What it does

brain is a JavaScript library for feed-forward neural networks. You feed it labeled training patterns—arrays or hashes of numbers scaled from 0 to 1—and it trains in bulk until the error falls below a threshold or a maximum iteration count is reached. Once trained, it predicts outputs for new inputs in Node or the browser.

The interesting bit

The library’s most useful quirk is toFunction(), which compiles a trained network into a plain JavaScript function string you can copy and paste into any project. That turns a model into a zero-dependency artifact, which was a neat deployment trick for lightweight browser code. For Node, it also exposes a WriteStream so you can pipe training data incrementally rather than loading the entire dataset at once.

Key highlights

  • Feed-forward architecture with configurable hidden layers
  • Accepts training data as arrays or object hashes of normalized 0–1 values
  • toFunction() exports a trained model as a standalone JS function string, removing the runtime dependency
  • Node WriteStream support for streaming training data via pipe()
  • 7,990 GitHub stars, though the author has ended active development

Caveats

  • The author explicitly recommends against using it today; active development has ceased in favor of libraries like brain.js and convnetjs
  • Standard training requires the entire dataset in a single bulk call unless you use the streaming API
  • Training is computationally expensive and expected to run offline or in a Web Worker

Verdict

Browse the code if you are curious about early JavaScript machine-learning patterns or maintaining a legacy system. If you are starting a new project, follow the author’s own advice and look elsewhere.

Frequently asked

What is harthur/brain?
It exists to run feed-forward neural networks in JavaScript and ship trained models as copy-pasteable functions with no library overhead.
Is brain open source?
Yes — harthur/brain is open source, released under the MIT license.
What language is brain written in?
harthur/brain is primarily written in JavaScript.
How popular is brain?
harthur/brain has 8k stars on GitHub.
Where can I find brain?
harthur/brain is on GitHub at https://github.com/harthur/brain.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.