FANN (Fast Artificial Neural Network Library) bindings for Node.js

Overview

node-fann

node-fann is a FANN bindings for Node.js.

FANN (Fast Artificial Neural Network Library) is a free open source neural network library, which implements multilayer artificial neural networks with support for both fully connected and sparsely connected networks.

Installation

  1. Make sure you have glib2 and pkg-config installed.

    These are quite popular tools and should be available in your software repository/ports.

  2. You will need FANN library version >= 2.1.0 (libfann2).

  3. Run npm install fann to install this package.

Example

", net.run([0, 0])); console.log("xor test (1,0) -> ", net.run([1, 0])); console.log("xor test (0,1) -> ", net.run([0, 1])); console.log("xor test (1,1) -> ", net.run([1, 1]));">
var fann = require('fann');
var net = new fann.standard(2,3,1);

var data = [
    [[0, 0], [0]],
    [[0, 1], [1]],
    [[1, 0], [1]],
    [[1, 1], [0]],
];

net.train(data, {error: 0.00001});

console.log("xor test (0,0) -> ", net.run([0, 0]));
console.log("xor test (1,0) -> ", net.run([1, 0]));
console.log("xor test (0,1) -> ", net.run([0, 1]));
console.log("xor test (1,1) -> ", net.run([1, 1]));
Comments
  • Build issue on MAC OS

    Build issue on MAC OS

    Hi there! I've encountered an issue with installing your module. fann lib is installed via macports, and header files placed to /opt/local/include. It looks like that gyp isn't aware of it and reports about error:

    $ npm install fann
    
    > [email protected] install /whatever/node_modules/fann
    > node-gyp rebuild
    
      CXX(target) Release/obj.target/fann/src/fann-accs.o
    In file included from ../src/fann-accs.cc:7:
    In file included from ../src/node-fann.h:5:
    ../src/node-futil.h:7:10: fatal error: 'doublefann.h' file not found
    #include <doublefann.h>
             ^
    1 error generated.
    make: *** [Release/obj.target/fann/src/fann-accs.o] Error 1
    gyp ERR! build error
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/homedir/.nvm/v0.10.21/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
    gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
    gyp ERR! System Darwin 13.0.0
    gyp ERR! command "node" "/homedir/.nvm/v0.10.21/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /whatever/node_modules/fann
    gyp ERR! node -v v0.10.21
    gyp ERR! node-gyp -v v0.10.10
    gyp ERR! not ok
    npm ERR! weird error 1
    npm ERR! not ok code 0
    
    $ file /opt/local/include/doublefann.h
    /opt/local/include/doublefann.h: ASCII c program text
    

    Any ideas how to fix it?

    opened by runk 11
  • Header Include Path Issue

    Header Include Path Issue

    I am receiving the following error after calling $ npm install fann

    [email protected] install /Users/tylerpayne/Desktop/Node/node_modules/fann node-gyp rebuild

    CXX(target) Release/obj.target/fann/src/fann-accs.o In file included from ../src/fann-accs.cc:7: In file included from ../src/node-fann.h:5: ../src/node-futil.h:7:10: fatal error: 'doublefann.h' file not found

    include <doublefann.h>

         ^
    

    1 error generated. make: *** [Release/obj.target/fann/src/fann-accs.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12) gyp ERR! System Darwin 14.0.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/tylerpayne/Desktop/Node/node_modules/fann gyp ERR! node -v v0.10.32 gyp ERR! node-gyp -v v1.0.1 gyp ERR! not ok

    npm ERR! [email protected] install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is most likely a problem with the fann package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls fann npm ERR! There is likely additional logging output above. npm ERR! System Darwin 14.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "--save" "fann" npm ERR! cwd /Users/tylerpayne/Desktop/Node npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! code ELIFECYCLE npm ERR! not ok code 0

    I have FANN 2.2.0 and pkg-config and glib2 installed. I think I just need help including /usr/local/include in the GCC header search paths but have had no luck yet.

    opened by tylerpayne 4
  • Segmentation Fault in FANN When File Not Exist

    Segmentation Fault in FANN When File Not Exist

    I'm attempting to use fann.load to load a network, but there are times when that network my not exist. For that I've wrapped it in try/catch. Unfortunately, it appears that FANN is throwing a Segmentation Fault when the file doesn't exist, which Node doesn't catch.

    Possible fix could be wrapping the fann function to capture the seg fault, and throwing a catchable error.

    opened by anubisthejackle 3
  • node 0.12.2: Module did not self-register.

    node 0.12.2: Module did not self-register.

    I'm testing node-fann inside the aooj/fann docker image and it works well with the preinstalled node v0.10.26 and node-fann v1.0.0. But after I've updated node to the latest version 0.12.2 the following error occurred:

    module.js:355
      Module._extensions[extension](this, filename);
                                   ^
    Error: Module did not self-register.
        at Error (native)
        at Module.load (module.js:355:32)
        at Function.Module._load (module.js:310:12)
        at Module.require (module.js:365:17)
        at require (module.js:384:17)
        at Object.<anonymous> (/node_modules/fann/index.js:1:80)
        at Module._compile (module.js:460:26)
        at Object.Module._extensions..js (module.js:478:10)
        at Module.load (module.js:355:32)
        at Function.Module._load (module.js:310:12)
    
    opened by joernroeder 2
  • Add an

    Add an "engines" property to warn node 0.11/0.12 users

    As we know (#15), this package won’t work on node 0.11 and 0.12.

    This small pull request adds an appropriate engines property in package.json to warn people which attempt to install it on these versions of node, saving them some googling after a build failure.

    For example, on my machine this produces something like:

    $ npm install ~/src/node-fann
    npm WARN engine [email protected]: wanted: {"node":"<0.11"} (current: {"node":"0.12.2","npm":"2.7.5"})
    
    > [email protected] install /Users/gh/tmp/node_modules/fann
    > node-gyp rebuild
    
    …
    

    This restriction should be removed once the 0.11 support is ready.

    opened by hristozov 2
  • Doesn't work on node 0.11

    Doesn't work on node 0.11

    Just a tracking issue...

    Need to support both node 0.10 and 0.11, so we'll have to use https://github.com/rvagg/nan

    And bump this library to 1.0.0 while we're at it.

    opened by rlidwka 1
  • Momento on the Network

    Momento on the Network

    Having issues getting the load method to work on a serialized network (configuration).

    When using the load, I am seeing a nodejs process abort. After investigating, I can bypass the abort by editing the NNet::CreateFromFile method in the fan-create class impl.

    Handle<Value> NNet::CreateFromFile(const Arguments &args)
    {
        HandleScope scope;
        if (args.Length() != 1 || !args[0]->IsString())
            return VException("usage: new FANN.load(\"filename.nnet\")");
    
        char name[4096];
        String::Cast(*args[0])->WriteAscii(name, 0, 4096);
        // name[4095] = 0;  <=== comment this out!  
    
        FANN = fann_create_from_file(name); 
    
        return Undefined();
    }
    

    Beyond this, once the wrapped fann instance is available in Node, i get segment faults when attempting to interact with it:

    PID 47970 received SIGSEGV for address: 0x11
    0   segfault-handler-native.node        0x0000000100ca4b8b _ZL16segfault_handleriP9__siginfoPv + 191
    1   libsystem_c.dylib                   0x00007fff8d92094a _sigtramp + 26
    2   node                                0x000000010031e2f7 _ZN2v88internal9Assembler4movqENS0_8RegisterENS0_6HandleINS0_6ObjectEEENS0_9RelocInfo4ModeE + 199
    3   fann.node                           0x0000000100caac8d _ZN4NNet3RunERKN2v89ArgumentsE + 283
    4   node                                0x0000000100147038 _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 456
    5   ???                                 0x00002a6a8070618e 0x0 + 46636909748622
    6   ???                                 0x00002a6a8078e71e 0x0 + 46636910307102
    

    Has anyone on the author team attempted to read/write a network?

    opened by toddpi314 1
  • NPM Installation error on Debian

    NPM Installation error on Debian

    npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is most likely a problem with the fann package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild || (node-waf configure && node-waf clean && node-w af build)

    opened by soulcyon 1
  • Error on install node-fann on Linux Mint

    Error on install node-fann on Linux Mint

    sudo npm inpm http GET https://registry.npmjs.org/fann npm http 304 https://registry.npmjs.org/fann

    [email protected] install /home/mike/projects/node-fann-example/node_modules/fann node-gyp rebuild

    gyp: Call to 'pkg-config --atleast-version=2.1.0 fann' returned exit status 1. gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12) gyp ERR! System Linux 3.11.0-12-generic gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/mike/projects/node-fann-example/node_modules/fann gyp ERR! node -v v0.10.26 gyp ERR! node-gyp -v v0.12.2 gyp ERR! not ok npm ERR! [email protected] install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is most likely a problem with the fann package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls fann npm ERR! There is likely additional logging output above.

    npm ERR! System Linux 3.11.0-12-generic npm ERR! command "/usr/bin/node" "/usr/bin/npm" "i" npm ERR! cwd /home/mike/projects/node-fann-example npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/mike/projects/node-fann-example/npm-debug.log npm ERR! not ok code 0

    opened by MikeBazhenov 0
  • Installing on MAC (10.7)

    Installing on MAC (10.7)

    I got the following error - /bin/sh: pkg-config: command not found

    Needed to install glib2 from mac ports and pkg-config from http://www.freedesktop.org/wiki/Software/pkg-config/

    Just a heads up.

    opened by silentrob 0
  • can't install - log attached

    can't install - log attached

    272 verbose stack Error: [email protected] install: node-gyp rebuild 272 verbose stack Exit status 1 272 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) 272 verbose stack at emitTwo (events.js:106:13) 272 verbose stack at EventEmitter.emit (events.js:191:7) 272 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14) 272 verbose stack at emitTwo (events.js:106:13) 272 verbose stack at ChildProcess.emit (events.js:191:7) 272 verbose stack at maybeClose (internal/child_process.js:877:16) 272 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 273 verbose pkgid [email protected] 274 verbose cwd /Users/drowne/projects/nn_mastering 275 error Darwin 15.6.0 276 error argv "/usr/local/Cellar/node/6.6.0/bin/node" "/usr/local/bin/npm" "install" "fann" 277 error node v6.6.0 278 error npm v3.10.7 279 error code ELIFECYCLE 280 error [email protected] install: node-gyp rebuild 280 error Exit status 1 281 error Failed at the [email protected] install script 'node-gyp rebuild'. 281 error Make sure you have the latest version of node.js and npm installed. 281 error If you do, this is most likely a problem with the fann package, 281 error not with npm itself. 281 error Tell the author that this fails on your system: 281 error node-gyp rebuild 281 error You can get information on how to open an issue for this project with: 281 error npm bugs fann 281 error Or if that isn't available, you can get their info via: 281 error npm owner ls fann 281 error There is likely additional logging output above. 282 verbose exit [ 1, true ]

    opened by drowne 3
  • Failed at the fann@1.0.0 install script 'node-gyp rebuild'

    Failed at the [email protected] install script 'node-gyp rebuild'

    Hi, i cant install node-fann

    make: Entering directory '/home/yyy/xxx/node_modules/fann/build' CXX(target) Release/obj.target/fann/src/fann-accs.o In file included from ../src/node-futil.h:8:0, from ../src/node-fann.h:5, from ../src/fann-accs.cc:7: ../../nan/nan.h:261:25: error: redefinition of 'template v8::Local _NanEnsureLocal(v8::Local)' NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) { ^ ../../nan/nan.h:256:25: note: 'template v8::Local _NanEnsureLocal(v8::Handle)' previously declared here NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) { ^ ../../nan/nan.h:473:20: error: variable or field 'NanAddGCEpilogueCallback' declared void v8::Isolate::GCEpilogueCallback callback ^

    opened by atway 2
  • Error when sudo npm install fann

    Error when sudo npm install fann

    Hi,

    I try to install this package but I get this error, I already have installed glib2 and pkg-config ///////////////////////////////////////////////////////////////////////////////////////////////////// /

    [email protected] install /home/saman/node_modules/fann node-gyp rebuild

    gyp: Call to 'pkg-config --atleast-version=2.1.0 fann' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Linux 3.11.0-26-generic gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /home/saman/node_modules/fann gyp ERR! node -v v4.4.2 gyp ERR! node-gyp -v v3.3.1 gyp ERR! not ok npm ERR! Linux 3.11.0-26-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "fann" npm ERR! node v4.4.2 npm ERR! npm v2.15.0 npm ERR! code ELIFECYCLE

    npm ERR! [email protected] install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. npm ERR! This is most likely a problem with the fann package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs fann npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm ERR! npm owner ls fann npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request: npm ERR! /home/saman/FANN/npm-debug.log

    /////////////////////////////////////////////////////////////////////////////////////////////////////

    Thanks

    opened by SamanShafigh 1
Owner
Alex Kocharin
Alex Kocharin
Powerful Neural Network for Node.js

NeuralN Powerful Neural Network for Node.js NeuralN is a C++ Neural Network library for Node.js with multiple advantages compared to existing solution

TOTEMS::Tech 275 Dec 15, 2022
A neural network library built in JavaScript

A flexible neural network library for Node.js and the browser. Check out a live demo of a movie recommendation engine built with Mind. Features Vector

Steven Miller 1.5k Dec 31, 2022
[UNMAINTAINED] Simple feed-forward neural network in JavaScript

This project has reached the end of its development as a simple neural network library. Feel free to browse the code, but please use other JavaScript

Heather 8k Dec 26, 2022
Deep Neural Network Sandbox for JavaScript.

Deep Neural Network Sandbox for Javascript Train a neural network with your data & save it's trained state! Demo • Installation • Getting started • Do

Matias Vazquez-Levi 420 Jan 4, 2023
Visualizer for neural network, deep learning, and machine learning models

Netron is a viewer for neural network, deep learning and machine learning models. Netron supports ONNX, TensorFlow Lite, Caffe, Keras, Darknet, Paddle

Lutz Roeder 21k Jan 5, 2023
A lightweight library for neural networks that runs anywhere

Synapses A lightweight library for neural networks that runs anywhere! Getting Started Why Sypapses? It's easy Add one dependency to your project. Wri

Dimos Michailidis 65 Nov 9, 2022
Deep Learning in Javascript. Train Convolutional Neural Networks (or ordinary ones) in your browser.

ConvNetJS ConvNetJS is a Javascript implementation of Neural networks, together with nice browser-based demos. It currently supports: Common Neural Ne

Andrej 10.4k Dec 31, 2022
DN2A - Digital Neural Networks Architecture

DN2A (JavaScript) Digital Neural Networks Architecture About DN2A is a set of highly decoupled JavaScript modules for Neural Networks and Artificial I

Antonio De Luca 464 Jan 1, 2023
DN2A - Digital Neural Networks Architecture

DN2A (JavaScript) Digital Neural Networks Architecture About DN2A is a set of highly decoupled JavaScript modules for Neural Networks and Artificial I

Antonio De Luca 464 Jan 1, 2023
DN2A - Digital Neural Networks Architecture in JavaScript

DN2A (JavaScript) Digital Neural Networks Architecture About DN2A is a set of highly decoupled JavaScript modules for Neural Networks and Artificial I

Antonio De Luca 464 Jan 1, 2023
Machine Learning library for node.js

shaman Machine Learning library for node.js Linear Regression shaman supports both simple linear regression and multiple linear regression. It support

Luc Castera 108 Feb 26, 2021
general natural language facilities for node

natural "Natural" is a general natural language facility for nodejs. It offers a broad range of functionalities for natural language processing. Docum

null 10k Jan 9, 2023
Machine-learning for Node.js

Limdu.js Limdu is a machine-learning framework for Node.js. It supports multi-label classification, online learning, and real-time classification. The

Erel Segal-Halevi 1k Dec 16, 2022
Run XGBoost model and make predictions in Node.js

XGBoost-Node eXtreme Gradient Boosting Package in Node.js XGBoost-Node is a Node.js interface of XGBoost. XGBoost is a library from DMLC. It is design

暖房 / nuan.io 31 Nov 15, 2022
Bayesian bandit implementation for Node and the browser.

#bayesian-bandit.js This is an adaptation of the Bayesian Bandit code from Probabilistic Programming and Bayesian Methods for Hackers, specifically d3

null 44 Aug 19, 2022
Latent Dirichlet allocation (LDA) topic modeling in javascript for node.js.

LDA Latent Dirichlet allocation (LDA) topic modeling in javascript for node.js. LDA is a machine learning algorithm that extracts topics and their rel

Kory Becker 279 Nov 4, 2022
Simple Javascript implementation of the k-means algorithm, for node.js and the browser

#kMeans.js Simple Javascript implementation of the k-means algorithm, for node.js and the browser ##Installation npm install kmeans-js ##Example (JS)

Emil Bay 44 Aug 19, 2022
Clustering algorithms implemented in Javascript for Node.js and the browser

Clustering.js ####Clustering algorithms implemented in Javascript for Node.js and the browser Examples License Copyright (c) 2013 Emil Bay github@tixz

Emil Bay 29 Aug 19, 2022
A JavaScript deep learning and reinforcement learning library.

neurojs is a JavaScript framework for deep learning in the browser. It mainly focuses on reinforcement learning, but can be used for any neural networ

Jan 4.4k Jan 4, 2023