{"id":31815585,"url":"https://github.com/mvrahden/recurrent-js","last_synced_at":"2025-10-11T09:18:19.433Z","repository":{"id":57349391,"uuid":"112183222","full_name":"mvrahden/recurrent-js","owner":"mvrahden","description":"[INACTIVE] Amazingly simple to build and train various neural networks. The library is an object-oriented neural network approach (baked with Typescript), containing stateless and stateful neural network architectures.","archived":false,"fork":false,"pushed_at":"2018-07-07T13:47:25.000Z","size":368,"stargazers_count":18,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T16:51:09.002Z","etag":null,"topics":["ai","artificial-intelligence","artificial-neural-networks","backpropagation","bayesian-network","deep-learning","deep-reinforcement-learning","dnn","feedforward-neural-network","graph","lstm","neural-network","npm","recurrent-js","recurrent-neural-networks","rnn","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/recurrent-js","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvrahden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-27T10:40:22.000Z","updated_at":"2023-06-24T15:31:03.000Z","dependencies_parsed_at":"2022-09-09T13:21:25.793Z","dependency_job_id":null,"html_url":"https://github.com/mvrahden/recurrent-js","commit_stats":null,"previous_names":["mvrahden/recurrent-ts"],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/mvrahden/recurrent-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvrahden%2Frecurrent-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvrahden%2Frecurrent-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvrahden%2Frecurrent-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvrahden%2Frecurrent-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvrahden","download_url":"https://codeload.github.com/mvrahden/recurrent-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvrahden%2Frecurrent-js/sbom","scorecard":{"id":669617,"data":{"date":"2025-08-11","repo":{"name":"github.com/mvrahden/recurrent-js","commit":"02341656454cb37054b3762a19740b3250ac1c41"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T19:30:17.582Z","repository_id":57349391,"created_at":"2025-08-21T19:30:17.583Z","updated_at":"2025-08-21T19:30:17.583Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006751,"owners_count":26084177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","artificial-neural-networks","backpropagation","bayesian-network","deep-learning","deep-reinforcement-learning","dnn","feedforward-neural-network","graph","lstm","neural-network","npm","recurrent-js","recurrent-neural-networks","rnn","typescript"],"created_at":"2025-10-11T09:18:15.525Z","updated_at":"2025-10-11T09:18:19.428Z","avatar_url":"https://github.com/mvrahden.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# recurrent-js\n[![Build Status](https://travis-ci.org/mvrahden/recurrent-js.svg?branch=master)](https://travis-ci.org/mvrahden/recurrent-js)\n[![Build status](https://ci.appveyor.com/api/projects/status/7qkcof8t6b0io44f/branch/master?svg=true)](https://ci.appveyor.com/project/mvrahden/recurrent-js/branch/master)\n[![js-google-style](https://img.shields.io/badge/code%20style-google-blue.svg)](https://google.github.io/styleguide/jsguide.html)\n[![dependency-free](https://img.shields.io/badge/dependencies-none-brightgreen.svg)]()\n\n[docs-utils]: https://github.com/mvrahden/recurrent-js/blob/master/docs/utils.md\n[docs-mat]: https://github.com/mvrahden/recurrent-js/blob/master/docs/mat.md\n[docs-mat-ops]: https://github.com/mvrahden/recurrent-js/blob/master/docs/mat-ops.md\n[docs-graph]: https://github.com/mvrahden/recurrent-js/blob/master/docs/graph.md\n[docs-net]: https://github.com/mvrahden/recurrent-js/blob/master/docs/fnn/net.md\n[docs-dnn]: https://github.com/mvrahden/recurrent-js/blob/master/docs/fnn/dnn.md\n[docs-bnn]: https://github.com/mvrahden/recurrent-js/blob/master/docs/fnn/bnn.md\n[docs-rnn]: https://github.com/mvrahden/recurrent-js/blob/master/docs/rnn/rnn.md\n[docs-lstm]: https://github.com/mvrahden/recurrent-js/blob/master/docs/rnn/lstm.md\n\n**Call For Volunteers:** Due to my lack of time, I'm desperately looking for voluntary help. Should you be interested in the training of neural networks (even though you're a newbie) and willing to develop this educational project a little further, please contact me :) There are some points on the agenda, that I'd still like to see implemented to make this project a nice library for abstract educational purposes.\n\n\u003e INACTIVE: Due to lack of time and help\n\n**The recurrent-js library** \u0026ndash; Various amazingly simple to build and train neural network architectures. This Library is for **educational purposes** only. The library is an object-oriented neural network approach (baked with [Typescript](https://github.com/Microsoft/TypeScript)), containing stateless and stateful neural network architectures. It is a redesigned and extended version of _Andrej Karpathy's_ RecurrentJS library that implements the following:\n\n* Vanilla Feedforward Neural Network (Net)\n* Deep **Recurrent Neural Networks** (RNN)\n* Deep **Long Short-Term Memory** Networks (LSTM) \n* **Bonus #1**: Deep **Feedforward Neural Networks** (DNN)\n* **Bonus #2**: Deep **Bayesian Neural Networks** (BNN)\n* In fact, the library is more general because it has functionality to construct arbitrary **expression graphs** over which the library can perform **automatic differentiation** similar to what you may find in Theano for Python, or in Torch etc. Currently, the code uses this very general functionality to implement RNN/LSTM, but one can build arbitrary Neural Networks and do automatic backprop.\n\n## For Production Use\n\n### What does the Library has to offer?\n\nThe following sections provide an overview of the available Classes and Interfaces.\nThe class names are linked to more detailed descriptions of the specific classes.\n\n#### Utility Classes:\n\n* **[Utils][docs-utils]** - Collection of Utility functions: Array creation \u0026 manipulation, Statistical evaluation methods etc.\n* **[Mat][docs-mat]** - Matrix Class holding weights and their derivatives for the neural networks.\n* **RandMat** - A convenient subclass of `Mat`. `RandMat` objects are automatically populated with random values on their creation.\n* **[MatOps][docs-mat-ops]** - Class with matrix operations (add, multiply, sigmoid etc.) and their respective derivative functions.\n* **[Graph][docs-graph]** - Graph memorizing the sequences of matrix operations and matching their respective derivative functions for backpropagation.\n* **NetOpts** - Standardized `Interface` for the initial configuration of all Neural Networks.\n\u003c!-- * **FNNModel** - Generalized Class containing the Weights (and `Graph`) for stateless `FNN`-models\n  * such as `DNN` or `BNN`.\n* **RNNModel** - Generalized Class containing the Weights (and `Graph`) for stateful `RNN`-models\n  * such as `RNN` or `LSTM`. --\u003e\n* **InnerState** - Standardized `Interface` for stateful networks memorizing the previous state of activations.\n\n#### Neural Network Classes:\n* stateless:\n  * **[Net][docs-net]** - shallow Vanilla Feedforward Neural Network (1 hidden layer).\n  * **[DNN][docs-dnn]** - Deep Feedforward Neural Network.\n  * **[BNN][docs-bnn]** - Deep Bayesian Neural Network.\n* stateful (*Still old API!*):\n  * **[RNN][docs-rnn]** - Deep Recurrent Neural Network.\n  * **[LSTM][docs-lstm]** - Long Short Term Memory Network.\n\n### How to install as dependency\n\nDownload available `@npm`: [recurrent-js](https://www.npmjs.com/package/recurrent-js)\n\nInstall via command line:\n```\nnpm install --save recurrent-js@latest\n```\n\nThe project directly ships with the transpiled Javascript code.\nFor TypeScript development it also contains Map-files and Declaration-files.\n\n### How to import?\n\nThe aforementioned classes can be imported from this `npm` module, e.g.:\n```typescript\nimport { NetOpts, DNN } from 'recurrent-js';\n```\n\nFor JavaScript usage `require` classes from this `npm` module as follows:\n```javascript\n// NetOpts is an interface (Typescript only), but it gives clues about the required Object-properties (keys)\nconst DNN = require('recurrent-js').DNN;\n```\n\n### How to train?\n\nTraining of neural networks is achieved by iteratively reinforcing wanted neural activations or by suppressing unwanted activation paths through adjusting their respective slopes.\nThe training is achieved via an expression `Graph`, which memorizes the sequence of matrix operations being executed during the forward-pass operation of a neural network.\nThe results of the Matrix operations are contained in `Mat`-objects, which contain the resulting values (`w`) and their corresponding derivatives (`dw`).\nThe `Graph`-object can be used to calculate the resulting gradient and propagate a loss value back into the memorized sequence of matrix operations.\nThe update of the weights of the neural connections will then lead to supporting wanted neural network activity and suppressing unwanted activation behavior.\nThe described backpropagation can be achieved as follows:\n\n```typescript\nimport { Graph, DNN } from 'recurrent-js';\n\n/* define network structure configuration */\nconst netOpts = {\n    architecture: { inputSize: 2, hiddenUnits: [2, 3], outputSize: 3 },\n    training: { loss: 1e-11 }\n  };\n\n/* instantiate network */\nconst net = new DNN(netOpts);\n\n/* make it trainable */\nnet.setTrainability(true);\n\n/** \n * Perform an iterative training by first forward passing an input\n * and second backward propagating the according target output.\n * You'll receive the squared loss, that gives you a hint of the networks\n * approximation quality.\n * Repeat this action until the quality of the output of the forward pass \n * suits your needs, or the mean squared error is small enough, e.g. \u003c 1.\n */\ndo {\n  const someInput = [0, 1]; /* an array of intput values */\n  const someExpectedOutput = [0, 1, 0]; /* an array of target output */\n\n  const someOutput = net.forward(someInput);\n  \n  net.backward(someExpectedOutput /* , alpha?: number */);\n  const squaredLoss = net.getSquaredLoss(someInput, someExpectedOutput);\n} while(squaredLoss \u003e 0.1);\n/**\n * --\u003e Keep in mind: you actually want a low MEAN squaredLoss, this is\n * left out in this example, to keep the focus on the important parts\n */\n\n```\n**HINT #1**: providing an additional *custom learning rate* (`alpha`) for the backpropagation can accelerate the training. For further info please consult the respective`test-examples.spec.ts` file.\n\n**HINT #2**: The *Recurrent Neural Network Architectures* (RNN, LSTM) are not yet updated to this new training API. Due to my current lack of time, this likely won't change for a while... (unless this repo gets some voluntary help). Please consult the README of the [commit v.1.6.2](https://github.com/mvrahden/recurrent-js/tree/4065e644a36a26ae31598070dd0197008fe1a88b) for the details of the former training style. Thanks!\n\nShould you want to get some deeper insights on \"how to train the network\", it is recommendable to have a look into the source of the DQN-Solver from the [reinforce-js](https://github.com/mvrahden/reinforce-js) library (`learnFromSarsaTuple`-Method).\n\n## Example Applications\n\nThis project is an integral part of the `reinforce-js` library.\nAs such it is vividly demonstrated in the `learning-agents` model.\n\n- [learning-agents](https://mvrahden.github.io/learning-agents) (GitHub Page)\n- [reinforce-js](https://github.com/mvrahden/reinforce-js) (GitHub Repository)\n\n\n## Community Contribution\n\nEverybody is more than welcome to contribute and extend the functionality!\n\nPlease feel free to contribute to this project as much as you wish to.\n\n1. clone from GitHub via `git clone https://github.com/mvrahden/recurrent-js.git`\n2. `cd` into the directory and `npm install` for initialization\n3. Try to `npm run test`. If everything is green, you're ready to go :sunglasses:\n\nBefore triggering a pull-request, please make sure that you've run all the tests via the *testing command*:\n\n```\nnpm run test\n```\n\nThis project relies on Visual Studio Codes built-in Typescript linting facilities. It primarily follows the [Google TypeScript Style-Guide](https://github.com/google/ts-style) through the provided *tslint-google.json* configuration file.\n\n## License\n\nAs of License-File: [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvrahden%2Frecurrent-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvrahden%2Frecurrent-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvrahden%2Frecurrent-js/lists"}