https://github.com/issacto/simple-neural-network
A simple Nodejs neural network model
https://github.com/issacto/simple-neural-network
javascript nodejs
Last synced: 3 months ago
JSON representation
A simple Nodejs neural network model
- Host: GitHub
- URL: https://github.com/issacto/simple-neural-network
- Owner: issacto
- Created: 2021-04-01T12:48:47.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-24T19:55:44.000Z (about 4 years ago)
- Last Synced: 2025-02-16T23:02:21.894Z (3 months ago)
- Topics: javascript, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@issacto/simple-neural-network
- Size: 12.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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
```sh
npm i @issacto/simple-neural-network
```## Basics
```js
var NeuralNetwork = require('@issacto/simple-neural-network').NeuralNetwork;
```### 1. Create
```js
//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```js
//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
```js
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
```js getErrors
var errors = network.getErrors()
```### 4. Predict
```js
predictInput =[[1,0,0]]
var prediction = network.predict(testInputs)
```### 5. Get Weights
```js
var weights = network.getWeights()
```### 6. Get Bias
```js
var bias = network.getBias()
```## Reference
1. https://towardsdatascience.com/math-neural-network-from-scratch-in-python-d6da9f29ce65