Node.js和JS的灵活神经网络库:mind
一个适用于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; } };
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!