A high level util of neural net in javascript
Getting Started
Follow these steps:
Install
$ npm install neuron-fiber --save
Usage
Nodejs environment
Browser environment
const number0 = '*****' + '* *' + '* *' + '*****' /** * Imagine looks like number: 1 */const number1 = '* ' + '* ' + '* ' + '* ' /** * Imagine looks like number: 2 */const number2 = '*****' + ' ** ' + ' ** ' + '*****' /** * Imagine looks like number: 7 */const number3 = '** ' + ' * ' + ' * ' + ' ' /** * Imagine looks like number: 7 from different position */ const number4 = ' ' + ' **' + ' *' + ' *' /** * Imagine looks like number: 7 */const number5 = ' ** ' + ' * ' + ' * ' + ' ' { return string} // Flattern inputsconst inputs = const outputs = 100 010 001 011 011 011 // Map outputs to one hot vector{ const n = JSON } // Build neural netconst neuronNet = inputs outputs 20000 neuronNet link15'sigmoid' link20'sigmoid' link15'sigmoid' link8'sigmoid' link5'sigmoid' linkoutputs0length'sigmoid' // Begin to trainneuronNet // Summary all params of neural layersneuronNetsummary const data1 = '*****' + '*** *' + '* *' + '*****' const data2 = ' ' + ' ** ' + ' * ' + ' * ' // Export neural net paramsneuronNet // Predict dataconst result1 = neuronNet const result2 = neuronNet // Result 0console // Result 7console
API
new NeuronNet(inputs, outputs, iteration)
inputs
:the data sample of inputsoutputs
:the data sample of outputsiteration
:the number of training times
.link(options)
The options is a object obtain a layer of neural layer
.train()
Begin to train and modify the weight of each neural layer
.predict(input)
This will return results
input
: The data should to be predicted
.export(fileName)
fileName
: (default 'neural-params.json') The model will export .json into project root in nodejs environment(In browser will download a json file)
.summary()
The infomation about every layer print
.loadModel(options)
options
params
: The model what using export to make uppath
(nodejs environment only): The model file's path(.json,.text,*)
new NeuronLayer(neuronNumber,activatorType)
neuronNumber
: the amount of neurons in this neural layeractivatorType
: 'sigmoid'
Algorithm
- Sigmoid
- Softmax(WIP)
- ReLU(WIP)
- Tanh(WIP)
License
MIT. © 2017 lau stone