{"id":30957274,"url":"https://github.com/betomorrow/reimprovejs","last_synced_at":"2026-05-22T16:02:19.635Z","repository":{"id":32461833,"uuid":"132782116","full_name":"BeTomorrow/ReImproveJS","owner":"BeTomorrow","description":"A framework using TensorFlow.js for Deep Reinforcement Learning","archived":false,"fork":false,"pushed_at":"2022-06-22T04:58:00.000Z","size":4211,"stargazers_count":122,"open_issues_count":20,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-02T06:13:35.652Z","etag":null,"topics":["deep-learning","javascript","reinforcement-learning","tensorflow","tfjs","typescript"],"latest_commit_sha":null,"homepage":"","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/BeTomorrow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-09T16:08:18.000Z","updated_at":"2025-12-24T14:48:41.000Z","dependencies_parsed_at":"2022-06-28T07:02:02.541Z","dependency_job_id":null,"html_url":"https://github.com/BeTomorrow/ReImproveJS","commit_stats":null,"previous_names":["pravez/furnishjs","pravez/reimprovejs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BeTomorrow/ReImproveJS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2FReImproveJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2FReImproveJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2FReImproveJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2FReImproveJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeTomorrow","download_url":"https://codeload.github.com/BeTomorrow/ReImproveJS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2FReImproveJS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33352384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"online","status_checked_at":"2026-05-22T02:00:06.671Z","response_time":265,"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":["deep-learning","javascript","reinforcement-learning","tensorflow","tfjs","typescript"],"created_at":"2025-09-11T13:45:10.722Z","updated_at":"2026-05-22T16:02:19.620Z","avatar_url":"https://github.com/BeTomorrow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This repository is deprecated. I cannot maintain it anymore, and cannot update issues.\n\n# ReImproveJS\n\n\u003e A framework using TensorFlow.js for Deep Reinforcement Learning\n\n[Documentation](docs/README.md) | [NPM](https://www.npmjs.com/package/reimprovejs) | [Wiki](https://github.com/Pravez/ReImproveJS/wiki) | [Changelog](CHANGELOG.md)\n\n[![npm version](https://badge.fury.io/js/reimprovejs.svg)](https://badge.fury.io/js/reimprovejs)\n[![Build Status](https://travis-ci.org/Pravez/ReImproveJS.svg?branch=master)](https://travis-ci.org/Pravez/ReImproveJS)\n\n`ReImproveJS` is a little library to create Reinforcement Learning environments with Javascript.\nIt currently implements DQN algorithm, but aims to allow users to change easily algorithms, like for instance A3C or Sarsa.\n\nThe library is using TensorFlow.js as a computing background, enabling the use of WebGL to empower computations.\n\nGetting started\n------------------\n\nInstallation\n------------\n\nReImproveJS is available as a standalone or as a NPM package.\nAs usual, you can use the CDN \n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/reimprovejs@0/dist/reimprove.js\"\u003e\u003c/script\u003e\n```\n\nor if you have your local version\n\n```html\n\u003cscript src=\"/path/to/your/lib/root/reimprove.js\"\u003e\u003c/script\u003e\n```\nYou can also install it through NPM.\n\n```bash\n$ npm install reimprovejs\n```\n\nUsage\n-----------\n\nWith ReImproveJS, you have an environment organized as if your agents were part of a \"school\". The idea is that you are managing\nan `Academy`, possessing `Teachers` and `Agents` (Students). You add `Teachers` and assign `Agents` to them. At each step of\nyour world, you just need to give the `Academy` each `Teacher`'s input, which will handle everything concerning learning.\n\nBecause you are in Reinforcement Learning, you need a Neural Network model in order for your agents to learn. TFJS's `Model` is\nembedded into a wrapper, and you just need to precise what type of layers you need, and that's all !\nFor instance :\n\n```javascript\n\nconst modelFitConfig = {              // Exactly the same idea here by using tfjs's model's\n    epochs: 1,                        // fit config.\n    stepsPerEpoch: 16\n};\n\nconst numActions = 2;                 // The number of actions your agent can choose to do\nconst inputSize = 100;                // Inputs size (10x10 image for instance)\nconst temporalWindow = 1;             // The window of data which will be sent yo your agent\n                                      // For instance the x previous inputs, and what actions the agent took\n\nconst totalInputSize = inputSize * temporalWindow + numActions * temporalWindow + inputSize;\n\nconst network = new ReImprove.NeuralNetwork();\nnetwork.InputShape = [totalInputSize];\nnetwork.addNeuralNetworkLayers([\n    {type: 'dense', units: 32, activation: 'relu'},\n    {type: 'dense', units: numActions, activation: 'softmax'}\n]);\n// Now we initialize our model, and start adding layers\nconst model = new ReImprove.Model.FromNetwork(network, modelFitConfig);\n\n// Finally compile the model, we also exactly use tfjs's optimizers and loss functions\n// (So feel free to choose one among tfjs's)\nmodel.compile({loss: 'meanSquaredError', optimizer: 'sgd'})\n\n```\n\nNow that our model is ready, let's create an agent...\n\n```javascript\n\n// Every single field here is optionnal, and has a default value. Be careful, it may not\n// fit your needs ...\n\nconst teacherConfig = {\n    lessonsQuantity: 10,                   // Number of training lessons before only testing agent\n    lessonsLength: 100,                    // The length of each lesson (in quantity of updates)\n    lessonsWithRandom: 2,                  // How many random lessons before updating epsilon's value\n    epsilon: 1,                            // Q-Learning values and so on ...\n    epsilonDecay: 0.995,                   // (Random factor epsilon, decaying over time)\n    epsilonMin: 0.05,\n    gamma: 0.8                             // (Gamma = 1 : agent cares really much about future rewards)\n};\n\nconst agentConfig = {\n    model: model,                          // Our model corresponding to the agent\n    agentConfig: {\n        memorySize: 5000,                      // The size of the agent's memory (Q-Learning)\n        batchSize: 128,                        // How many tensors will be given to the network when fit\n        temporalWindow: temporalWindow         // The temporal window giving previous inputs \u0026 actions\n    }\n};\n\nconst academy = new ReImprove.Academy();    // First we need an academy to host everything\nconst teacher = academy.addTeacher(teacherConfig);\nconst agent = academy.addAgent(agentConfig);\n\nacademy.assignTeacherToAgent(agent, teacher);\n\n```\n\nAnd that's it ! Now you just need to update during your world emulation if the agent gets rewards, and\nfeed inputs to it.\n\n```javascript\n// Nice event occuring during world emulation\nfunction OnSpecialGoodEvent() {\n    academy.addRewardToAgent(agent, 1.0)        // Give a nice reward if the agent did something nice !\n}\n\n// Bad event\nfunction OnSpecialBadEvent() {\n    academy.addRewardToAgent(agent, -1.0)        // Give a bad reward to the agent if he did something wrong\n}\n\n// Animation loop, update loop, whatever loop you want\nasync function step(time) {\n    \n    let inputs = getInputs();          // Need to give a number[] of your inputs for one teacher.\n    await academy.step([               // Let the magic operate ...\n        {teacherName: teacher, agentsInput: inputs}\n    ]);\n    \n}\n\n// Start your loop (/!\\ for your environment, not specific to ReImproveJS).\nrequestAnimationFrame(step);\n```\n\nRewards are reset to 0 at each new step.\n\n__Please be careful__ : Convolutional networks are implemented and operational as models, but currently not \nfully implemented and tested in the Reinforcement Learning, so please __do not use them__ for now.\n\nExemples\n-----------------\n\nHere an exemple made by [@RGBKnights](https://github.com/RGBKnights) : https://gist.github.com/RGBKnights/756b5f51465cc22d0ca39205979ad2a1\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetomorrow%2Freimprovejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetomorrow%2Freimprovejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetomorrow%2Freimprovejs/lists"}