1.0.1 • Published 3 years ago

@issacto/simple-neural-network v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Simple Neural Network

  • Lightweight Tanh neural network
  • Includes a callback funtion that returns weights and bias of all nodes inside the model

On Node.js

npm i @issacto/simple-neural-network

Basics

var NeuralNetwork = require('@issacto/simple-neural-network').NeuralNetwork;

1. Create

//first index is the input size
//last index, the output layer, should always equal one
var network = new NeuralNetwork([3,3,3,1])   
  • Default counter value for bias and weights initilization values are 0.5.
  • Change it by adding the corresponding paraemters
//Counter value for bias is 0.6
//Counter value for weight is 0.7
var network = new NeuralNetwork([input_size,...,1], 0.6, 0.7)   

2. Train

trainInputs =[[1,0,0],[1,1,1],[1,0,1],[1,1,0],[2,1,0],[1,1,0]]
trainOutputs =[0,1,1,0,0,0]
var epoch = 100
var learningRate =0.1
network.train(trainInputs,trainOutputs, epoch,learningRate)

3. GetErrors

var errors = network.getErrors()

4. Predict

predictInput =[[1,0,0]] 
var prediction = network.predict(testInputs)

5. Get Weights

var weights = network.getWeights()

6. Get Bias

var bias = network.getBias()

Reference

  1. https://towardsdatascience.com/math-neural-network-from-scratch-in-python-d6da9f29ce65
1.0.1

3 years ago

1.0.0

3 years ago