{"id":13602764,"url":"https://github.com/stevenmiller888/mind","last_synced_at":"2025-05-15T12:02:13.464Z","repository":{"id":43421702,"uuid":"38644039","full_name":"stevenmiller888/mind","owner":"stevenmiller888","description":"A neural network library built in JavaScript","archived":false,"fork":false,"pushed_at":"2022-03-16T22:53:44.000Z","size":139,"stargazers_count":1508,"open_issues_count":8,"forks_count":111,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-14T19:43:52.402Z","etag":null,"topics":["mind","neural-network","prediction"],"latest_commit_sha":null,"homepage":"http://stevenmiller888.github.io/mindjs.net/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevenmiller888.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-06T20:26:32.000Z","updated_at":"2025-04-19T13:45:20.000Z","dependencies_parsed_at":"2022-07-11T03:47:31.398Z","dependency_job_id":null,"html_url":"https://github.com/stevenmiller888/mind","commit_stats":{"total_commits":59,"total_committers":8,"mean_commits":7.375,"dds":"0.38983050847457623","last_synced_commit":"4b7cdc391f1655664c9a7b127f57edf136124be1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenmiller888%2Fmind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenmiller888%2Fmind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenmiller888%2Fmind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenmiller888%2Fmind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevenmiller888","download_url":"https://codeload.github.com/stevenmiller888/mind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"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","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":["mind","neural-network","prediction"],"created_at":"2024-08-01T18:01:37.284Z","updated_at":"2025-05-15T12:02:13.193Z","avatar_url":"https://github.com/stevenmiller888.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Machine Learning","Neural network","Machine Learning [🔝](#readme)","JavaScript Tools, Libraries, and Frameworks","机器学习"],"sub_categories":["Runner","JavaScript Libraries for Machine Learning","运行器","运行器e2e测试"],"readme":"[![](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)\n\n![Mind Logo](https://cldup.com/D1yUfBz7Iu.png)\n\n[![CircleCI](https://circleci.com/gh/stevenmiller888/mind.svg?style=svg)](https://circleci.com/gh/stevenmiller888/mind)\n\nA flexible neural network library for Node.js and the browser. Check out a live [demo](http://stevenmiller888.github.io/mindjs.net/) of a movie recommendation engine built with Mind.\n\n## Features\n\n- Vectorized - uses a matrix implementation to process training data\n- Configurable - allows you to customize the network topology\n- Pluggable - download/upload minds that have already learned\n\n## Installation\n\n```bash\n$ yarn add node-mind\n```\n\n## Usage\n\n```js\nconst Mind = require('node-mind');\n\n/**\n * Letters.\n *\n * - Imagine these # and . represent black and white pixels.\n */\n\nconst a = character(\n  '.#####.' +\n  '#.....#' +\n  '#.....#' +\n  '#######' +\n  '#.....#' +\n  '#.....#' +\n  '#.....#'\n)\n\nconst b = character(\n  '######.' +\n  '#.....#' +\n  '#.....#' +\n  '######.' +\n  '#.....#' +\n  '#.....#' +\n  '######.'\n)\n\nconst c = character(\n  '#######' +\n  '#......' +\n  '#......' +\n  '#......' +\n  '#......' +\n  '#......' +\n  '#######'\n)\n\n/**\n * Learn the letters A through C.\n */\n\nconst mind = new Mind({ activator: 'sigmoid' })\n  .learn([\n    { input: a, output: map('a') },\n    { input: b, output: map('b') },\n    { input: c, output: map('c') }\n  ])\n\n/**\n * Predict the letter C, even with a pixel off.\n */\n\nconst result = mind.predict(character(\n  '#######' +\n  '#......' +\n  '#......' +\n  '#......' +\n  '#......' +\n  '##.....' +\n  '#######'\n))\n\nconsole.log(result) // ~ 0.5\n\n/**\n * Turn the # into 1s and . into 0s.\n */\n\nfunction character(string) {\n  return string\n    .trim()\n    .split('')\n    .map(integer)\n\n  function integer(symbol) {\n    if ('#' === symbol) return 1\n    if ('.' === symbol) return 0\n  }\n}\n\n/**\n * Map letter to a number.\n */\n\nfunction map(letter) {\n  if (letter === 'a') return [ 0.1 ]\n  if (letter === 'b') return [ 0.3 ]\n  if (letter === 'c') return [ 0.5 ]\n  return 0\n}\n```\n\n## Plugins\n\nUse plugins created by the Mind community to configure pre-trained networks that can go straight to making predictions.\n\nHere's a cool example of the way you could use a hypothetical `mind-ocr` plugin:\n\n```js\nconst Mind = require('node-mind')\nconst ocr = require('mind-ocr')\n\nconst mind = Mind()\n  .upload(ocr)\n  .predict(\n    '.#####.' +\n    '#.....#' +\n    '#.....#' +\n    '#######' +\n    '#.....#' +\n    '#.....#' +\n    '#.....#'\n  )\n```\n\nTo create a plugin, simply call `download` on your trained mind:\n\n```js\nconst Mind = require('node-mind')\n\nconst mind = Mind()\n  .learn([\n    { input: [0, 0], output: [ 0 ] },\n    { input: [0, 1], output: [ 1 ] },\n    { input: [1, 0], output: [ 1 ] },\n    { input: [1, 1], output: [ 0 ] }\n  ]);\n\nconst xor = mind.download()\n```\n\nHere's a list of available plugins:\n\n- [xor](https://github.com/stevenmiller888/mind-xor)\n\n## API\n\n### Mind(options)\nCreate a new instance of Mind that can learn to make predictions.\n\nThe available options are:\n* `activator`: the activation function to use, `sigmoid` or `htan`\n* `learningRate`: the speed at which the network will learn\n* `hiddenUnits`: the number of units in the hidden layer/s\n* `iterations`: the number of iterations to run\n* `hiddenLayers`: the number of hidden layers\n\n#### .learn()\n\nLearn from training data:\n\n```js\nmind.learn([\n  { input: [0, 0], output: [ 0 ] },\n  { input: [0, 1], output: [ 1 ] },\n  { input: [1, 0], output: [ 1 ] },\n  { input: [1, 1], output: [ 0 ] }\n])\n```\n\n#### .predict()\n\nMake a prediction:\n\n```js\nmind.predict([0, 1])\n```\n\n#### .download()\n\nDownload a mind:\n\n```js\nconst xor = mind.download()\n```\n\n#### .upload()\n\nUpload a mind:\n\n```js\nmind.upload(xor)\n```\n\n#### .on()\n\nListen for the 'data' event, which is fired with each iteration:\n\n```js\nmind.on('data', (iteration, errors, results) =\u003e {\n  // ...\n})\n```\n\n## Releasing / Publishing\n\nCircleCI will handle publishing to npm. To cut a new release, just do:\n\n```\n$ git changelog --tag \u003cversion\u003e\n$ vim package.json # enter \u003cversion\u003e\n$ git release \u003cversion\u003e\n```\n\nWhere `\u003cversion\u003e` follows the [semver](http://semver.org/) spec.\n\n## Note\n\nIf you're interested in learning more, I wrote a blog post on how to build your own neural network:\n\n- [How to Build a Neural Network](http://stevenmiller888.github.io/mind-how-to-build-a-neural-network/)\n\nAlso, here are some fantastic libraries you can check out:\n\n- [convnetjs](https://github.com/karpathy/convnetjs)\n- [synaptic](https://github.com/cazala/synaptic)\n- [brain](https://github.com/harthur-org/brain.js)\n\n## License\n\n[MIT](https://tldrlegal.com/license/mit-license)\n\n---\n\n\u003e [stevenmiller888.github.io](https://stevenmiller888.github.io) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@stevenmiller888](https://github.com/stevenmiller888) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@stevenmiller888](https://twitter.com/stevenmiller888)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmiller888%2Fmind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenmiller888%2Fmind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmiller888%2Fmind/lists"}