neurler
v2.1.0
Published
Neural Network module for Pattern Recognition and Function Approximation
Downloads
12
Maintainers
Readme
Neurler
Neural Network module for Pattern Recognition and Function Approximation
neurler
is a Neural Network library built for performance and ease of use and can be used for tasks such as pattern recognition and function approximation.
#Install
npm install neurler
#Test
jasmine-node specs/ --verbose
#Usage
var Neurler = require('neurler')
var neurler = new Neurler()
// this example shows how we could train it to approximate sin(x)
// from a random set of input/output data.
net.train([
{ input: [ 0.5248588903807104 ], output: [ 0.5010908941521808 ] },
{ input: [ 0 ], output: [ 0 ] },
{ input: [ 0.03929789311951026 ], output: [ 0.03928777911794752 ] },
{ input: [ 0.07391509227454662 ], output: [ 0.07384780553540908 ] },
{ input: [ 0.11062344848178328 ], output: [ 0.1103979598825075 ] },
{ input: [ 0.14104655454866588 ], output: [ 0.14057935309092454 ] },
{ input: [ 0.06176552915712819 ], output: [ 0.06172626426511784 ] },
{ input: [ 0.23915000406559558 ], output: [ 0.2368769073277496 ] },
{ input: [ 0.27090200221864513 ], output: [ 0.267600651550329 ] },
{ input: [ 0.15760037200525404 ], output: [ 0.1569487719674096 ] },
{ input: [ 0.19391102618537845 ], output: [ 0.19269808506017222 ] },
{ input: [ 0.42272064974531537 ], output: [ 0.4102431360805792 ] },
{ input: [ 0.5248469677288086 ], output: [ 0.5010805763172892 ] },
{ input: [ 0.4685300185577944 ], output: [ 0.45157520770441445 ] },
{ input: [ 0.6920387226855382 ], output: [ 0.6381082150316612 ] },
{ input: [ 0.40666140150278807 ], output: [ 0.3955452139761714 ] },
{ input: [ 0.011600911058485508 ], output: [ 0.011600650849602313 ] },
{ input: [ 0.404806485096924 ], output: [ 0.39384089298297537 ] },
{ input: [ 0.13447276877705008 ], output: [ 0.13406785820465852 ] },
{ input: [ 0.22471809106646107 ], output: [ 0.222831550102815 ] }
])
// send it a new input to see its trained output
var output = net.predict([ 0.5 ]) // => 0.48031129953896595
#methods
##var net = neurler(opts)
Creates a Neural Network instance. Pass in an optional opts
object to configure the instance. Any values specified in opts
will override the corresponding defaults.
The default configuration is shown below:
{
// hidden layers eg. [ 4, 3 ] => 2 hidden layers, with 4 neurons in the first, and 3 in the second.
layers: [ 3 ],
// maximum training epochs to perform on the training data
iterations: 20000,
// maximum acceptable error threshold
errorThresh: 0.0005,
// activation function ('logistic' and 'hyperbolic' supported)
activation: 'logistic',
// learning rate
learningRate: 0.4,
// learning momentum
momentum: 0.5,
// logging frequency to show training progress. 0 = never, 10 = every 10 iterations.
log: 0
}
##net.train(trainingData)
Train your nn
instance, using trainingData
. You can pass in a single training entry as an object with input
and output
keys, or an array of training entries. The network will train itself from the supplied training data, until the error threshold has been reached, or the max number of iterations has been reached.
##net.predict(input)
Sends your neural network the input data and returns its output. input
is an array of numbers. Typically you'll call this function after training your network.
This library is an minified/improved version of Tezel's nn module.
License
(The MIT License)
Copyright (c) by Manish Shivanandhan [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.