Description
Easy way to create neural networks in Javascript. Train a neural network with your dataset & save it's trained state!
Dannjs alternatives and similar libraries
Based on the "Machine Learning" category.
Alternatively, view Dannjs alternatives based on common mentions on social networks and blogs.
-
ConvNetJS
Deep Learning in Javascript. Train Convolutional Neural Networks (or ordinary ones) in your browser. -
m2cgen
Transform ML models into a native code (Java, C, Python, Go, JavaScript, Visual Basic, C#, R, PowerShell, PHP, Dart, Haskell, Ruby, F#, Rust) with zero dependencies -
TensorFlow.js
A JavaScript library for training and deploying ML models in the browser and on Node.js.
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Dannjs or a related project?
README
Deep Neural Network Library for Javascript Train a neural network with your data & save its trained state!
Demo • Installation • Documentation • Contribute • Discord • License
Installation
CDN :
<script src="https://cdn.jsdelivr.net/gh/matiasvlevi/[email protected]/build/dann.min.js"></script>
Node :
npm i dannjs
Getting started
Require package
Components from the library can be imported like this
const { Dann } = require('dannjs');
Basic model construction
Setting up a small (4,6,6,2) neural network.
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});
Train by backpropagation
Training with a dataset.
//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);
}
Train by mutation
For neuroevolution simulations. Works best with small models & large population size.
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);
}
Standalone function
Convert a Neural Network to a JS function that can output predictions without the library.
let strfunc = nn.toFunction();
console.log(strfunc);
Save JSON
let json = nn.toJSON();
console.log(json);
Demo:
AI predicts San-francisco Housing prices. more examples & demos here
Online editor:
Socials
Graph Dann models with this library
Stickers
Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> Matias Vazquez-Levi💻 📖 ⚠️ ✅ Francesco Ciulla📢 Labnan🐛 💻 ⚠️ sharkAce💻 Hasnain Iqbal💻 ⚠️ EL Ramos🐛 ⚠️ 💻 viabhinav✅ and1can💻 ⚠️
<!-- markdownlint-restore --> <!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
Any contributions are welcome! See CONTRIBUTING.md.
License
MIT
*Note that all licence references and agreements mentioned in the Dannjs README section above
are relevant to that project's source code only.