Node.js和JS的靈活神經網絡庫:mind

jopen 9年前發布 | 75K 次閱讀 mind 神經網絡

68747470733a2f2f636c6475702e636f6d2f4431795566427a3749752e706e67.png
一個適用于Node.js和瀏覽器的靈活神經網絡庫。利用Mind構建的一個電影推薦引擎在線 demo

特性

  • Vectorized - uses a matrix implementation to efficiently process training data
  • Transformable - apply transforms so you can pass in diverse datasets
  • Configurable - allows you to customize the network topology
  • Pluggable - download/upload minds that have already learned

安裝

$ npm install node-mind

用法

var Mind = require('node-mind');

/**
 * Letters.
 *
 * - Imagine these # and . represent black and white pixels.
 */

var a = character(
  '.####.' +
  '#....#' +
  '#....#' +
  '######' +
  '#....#' +
  '#....#' +
  '#....#'
);

var b = character(
  '#####.' +
  '#....#' +
  '#....#' +
  '#####.' +
  '#....#' +
  '#....#' +
  '#####.'
);

var c = character(
  '######' +
  '#.....' +
  '#.....' +
  '#.....' +
  '#.....' +
  '#.....' +
  '######'
);

/**
 * Learn the letters A through C.
 */

var mind = Mind()
  .learn([
    { input: a, output: [ 0.1 ] },
    { input: b, output: [ 0.2 ] },
    { input: c, output: [ 0.3 ] }
  ]);

/**
 * Predict the letter C, even with a pixel off.
 */

var result = mind.predict(character(
  '######' +
  '#.....' +
  '#.....' +
  '#.....' +
  '#.....' +
  '##....' +
  '######'
));

console.log(result); // ~ 0.3

/**
 * Turn the # into 1s and . into 0s.
 */

function character(string) {
  return string
    .trim()
    .split('')
    .map(integer);

  function integer(symbol) {
    if ('#' === symbol) return 1;
    if ('.' === symbol) return 0;
  }
};

項目主頁:http://www.baiduhome.net/lib/view/home/1438160917472

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!