Deep Neural Network Library for JavaScript.
npm install dannjs
Train a neural network with your data & save its trained state!
Demo •
Installation •
Documentation •
Contribute •
Discord •
License
html
`
$3
`
npm i dannjs
`
dannjs on npmjs.com
Getting started
$3
Components from the library can be imported like this
`js
const { Dann } = require('dannjs');
`
$3
Setting up a small (4,6,6,2) neural network.
`js
const nn = new Dann(4, 2);
nn.addHiddenLayer(6, 'leakyReLU');
nn.addHiddenLayer(6, 'leakyReLU');
nn.outputActivation('tanH');
nn.makeWeights();
nn.lr = 0.0001;
nn.log({details:true});
`
$3
Training with a dataset.
`js
//XOR 2 inputs, 1 output
const dataset = [
{
input: [0, 0],
output: [0]
},
{
input: [1, 0],
output: [1]
},
{
input: [0, 1],
output: [1]
},
{
input: [1, 1],
output: [0]
}
];
//train 1 epoch
for (data of dataset) {
nn.backpropagate(data.input, data.output);
console.log(nn.loss);
}
`
$3
For neuroevolution simulations. Works best with small models & large population size.
`js
const populationSize = 1000;
let newGeneration = [];
for (let i = 0; i < populationSize; i++) {
// parentNN would be the best nn from past generation.
const childNN = parentNN;
childNN.mutateRandom(0.01, 0.65);
newGeneration.push(childNN);
}
`
$3
Convert a Neural Network to a JS function that can output predictions without the library.
`js
let strfunc = nn.toFunction();
console.log(strfunc);
`
$3
`js
let json = nn.toJSON();
console.log(json);
``
Matias Vazquez-Levi 💻 📖 ⚠️ ✅ |
Francesco Ciulla 📢 |
Labnan 🐛 💻 ⚠️ |
sharkAce 💻 |
Hasnain Iqbal 💻 ⚠️ |
EL Ramos 🐛 ⚠️ 💻 |
viabhinav ✅ |
and1can 💻 ⚠️ |