fann-lite
pure javascript version of fann (fast artificial neural net library) with zero npm-dependencies (compiled from emscripten)
documentation (original c-api)
http://leenissen.dk/fann/html/files2/gettingstarted-txt.html
- currently only tested to work in chrome browser
live test-server
git-branch : | master | beta | alpha |
---|---|---|---|
test-server : | ![]() |
![]() |
![]() |
coverage : | |||
build-artifacts : | ![]() |
![]() |
![]() |
master branch
- stable branch
- HEAD should be tagged, npm-published package
beta branch
- semi-stable branch
- HEAD should be latest, npm-published package
alpha branch
- unstable branch
- HEAD is arbitrary
- commit history may be rewritten
quickstart web example
to run this example, follow the instruction in the script below
- example.js
/*example.js this node script will serve a web-page with an interactive neural net instruction 1. save this script as example.js 2. run the shell command: $ npm install fann-lite && node example.js 3. open a browser to http://localhost:1337 4. edit or paste script in browser to interact with the neural net*/ /*jslint browser: true, maxerr: 8, maxlen: 96, node: true, nomen: true, stupid: true*/ { 'use strict'; // run node js-env code { // require modules localfs = ; localhttp = ; localpath = ; localurl = ; // init assets local'/' = String + /* jslint-ignore-begin */'<!DOCTYPE html>\n' +'<html>\n' +'<head>\n' + '<meta charset="UTF-8">\n' + '<title>\n' + 'fann-lite [2015.6.1-a]\n' + '</title>\n' + '<link rel="stylesheet" href="/assets/utility2.css">\n' + '<style>\n' + '* {\n' + 'box-sizing: border-box;\n' + '}\n' + 'body {\n' + 'background-color: #fff;\n' + 'font-family: Helvetical Neue, Helvetica, Arial, sans-serif;\n' + '}\n' + 'body > div {\n' + 'margin-top: 20px;\n' + '}\n' + 'textarea {\n' + 'font-family: monospace;\n' + 'height: 32em;\n' + 'width: 100%;\n' + '}\n' + '.csslintOutputPre {\n' + 'color: #f00;\n' + '}\n' + '.fannOutputPre {\n' + 'color: #f00;\n' + '}\n' + '.testReportDiv {\n' + 'display: none;\n' + '}\n' + '</style>\n' + '</head>\n' +'<body>\n' + '<div class="ajaxProgressDiv" style="display: none;">\n' + '<div class="ajaxProgressBarDiv ajaxProgressBarDivLoading" >loading</div>\n' + '</div>\n' + '<h1 >fann-lite [2015.6.1-a]</h1>\n' + '<h3>pure javascript version of fann (fast artificial neural net library) with zero npm-dependencies (compiled from emscripten)</h3>\n' + '<div>edit or paste script below to\n' + '<a href="http://leenissen.dk/fann/html/files2/gettingstarted-txt.html" target="_blank">\n' + 'eval</a>\n' + '</div>\n' +'<textarea class="fannInputTextarea">\n' +'// test\n' +'local.ann = local.fann.create_standard(3, 2, 3, 1);\n' +'local.data = local.fann\n' + '.create_train_from_array(4, 2, 1, [-1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, -1]);\n' +'local.fann\n' + '.set_activation_function_hidden(local.ann, local.fann.ACTIVATION_SIGMOID_SYMMETRIC);\n' +'local.fann.set_activation_function_output(local.ann, 5);\n' +'local.fann.train_on_data(local.ann, local.data, 5000, 1000, 0.001);\n' +'console.log("1 xor 1 -> " + local.fann.run(local.ann, [1, 1]));\n' +'console.log("1 xor 0 -> " + local.fann.run(local.ann, [1, -1]));\n' +'console.log("0 xor 1 -> " + local.fann.run(local.ann, [-1, 1]));\n' +'</textarea>\n' + '<pre class="fannOutputPre"></pre>\n' + '<div class="testReportDiv"></div>\n' + '<script src="/assets/fann.js"></script>\n' + '<script src="/assets/utility2.js"></script>\n' + '<script>\n' + 'window.utility2 = window.utility2 || {};\n' + 'window.utility2.envDict = {\n' + 'npm_package_description: "pure javascript version of fann (fast artificial neural net library) with zero npm-dependencies (compiled from emscripten)",\n' + 'npm_package_name: "fann-lite",\n' + 'npm_package_version: "2015.6.1-a"\n' + '};\n' + 'document.querySelector(\n' + '".fannInputTextarea"\n' + ').addEventListener("keyup", window.fann.fannInputTextarea);\n' + 'window.fann.fannInputTextarea();\n' + '</script>\n' + '<script src="/test/test.js"></script>\n' + '</body>\n' +'</html>\n' +/* jslint-ignore-end */ String; local'/assets/fann.js' = localfann'/assets/fann.js'; local'/assets/utility2.css' = ''; local'/assets/utility2.js' = ''; local'/test/test.js' = ''; // create server localserver = localhttp; if processenvnpm_config_server_port return; // start server localserverPort = 1337; console; localserver; };} { 'use strict'; var local; // run shared js-env code { // init local local = {}; localmodeJs = { try return moduleexports && typeof processversionsnode === 'string' && typeof createServer === 'function' && 'node'; catch errorCaughtNode return typeof navigatoruserAgent === 'string' && typeof document === 'object' && 'browser'; }; // init global localglobal = localmodeJs === 'browser' ? window : global; // init fann-lite localfann = localmodeJs === 'browser' ? windowfann : { try return ; catch errorCaught return ; }; // export local moduleexports = local; }; return local;};
output from shell
output from phantomjs-lite
npm-dependencies
- none
package-listing
package.json
todo
- add meaningful tests
- fix demo failure in firefox
- none
change since 4931707a
- npm publish 2015.8.1
- update README.md
- none
changelog of last 50 commits
internal build-script
- build.sh
# build.sh # this shell script will run the build for this package shBuild # save exit-code EXIT_CODE=$?# create package-listing MODE_BUILD=gitLsTree shRunScreenCapture shGitLsTree || exit $?# create recent changelog of last 50 commits MODE_BUILD=gitLog shRunScreenCapture git log -50 --pretty="%ai\u000a%B" || exit $?# if running legacy-node, then do not continue [ "$(node --version)" \< "v0.12" ] && exit $EXIT_CODE# upload build-artifacts to github, and if number of commits > 16, then squash older commits COMMIT_LIMIT=16 shBuildGithubUpload || exit $?exit $EXIT_CODE