2.4.1-e • Published 2 years ago

dannjs v2.4.1-e

Weekly downloads
13
License
ISC
Repository
github
Last release
2 years ago

Installation

CDN :

<script src="https://cdn.jsdelivr.net/gh/matiasvlevi/dann@v2.4.1e/build/dann.min.js"></script>

Node :

npm i dannjs

dannjs on npmjs.com

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:

https://dannjs.org/sandbox

Socials

Graph Dann models with this library

Dann-p5

Stickers

Get Dannjs stickers!

Contributors

Any contributions are welcome! See CONTRIBUTING.md.

License

MIT

2.4.1-e

2 years ago

2.4.1-d

2 years ago

2.4.1

2 years ago

2.4.1-c

2 years ago

2.4.1-b

2 years ago

2.4.0-b

2 years ago

2.4.0

2 years ago

2.3.14

2 years ago

2.3.13

3 years ago

2.3.12

3 years ago

2.3.11

3 years ago

2.2.11

3 years ago

2.2.10

3 years ago

2.2.9

3 years ago

2.2.8

3 years ago

2.2.7

3 years ago

2.2.5

3 years ago

2.2.6

3 years ago

2.2.6-b

3 years ago

2.2.6-e

3 years ago

2.2.6-d

3 years ago

2.2.6-c

3 years ago

2.2.5-b

3 years ago

2.2.4-f

3 years ago

2.2.4-e

3 years ago

2.2.4-d

3 years ago

2.2.4-c

3 years ago

2.2.4-b

3 years ago

2.2.4

3 years ago

2.2.3-d

3 years ago

2.2.3-c

3 years ago

2.2.3-b

3 years ago

2.2.3

3 years ago

2.2.2-f

3 years ago

2.2.2-e

3 years ago

2.2.2-d

3 years ago

2.2.2-c

3 years ago

2.2.2-b

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.1-b

3 years ago

2.2.0

3 years ago

2.1.9-d

3 years ago

2.1.9-b

3 years ago

2.1.9-c

3 years ago

2.1.9

3 years ago

2.1.8-f

3 years ago

2.1.8-e

3 years ago

2.1.8-d

3 years ago

2.1.8

3 years ago

2.1.7-d

3 years ago

2.1.7-e

3 years ago

2.1.7-c

3 years ago

2.1.7-b

3 years ago

2.1.7

3 years ago

2.1.6-d

3 years ago

2.1.6-c

3 years ago

2.1.6-b

3 years ago

2.1.6

3 years ago

2.1.5-b

3 years ago

2.1.4-c

3 years ago

2.1.4-b

3 years ago

2.1.3-c

3 years ago

2.1.4

3 years ago

2.1.5

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0-c

3 years ago

2.1.0-b

3 years ago

2.0.6-f

3 years ago

2.0.6-e

3 years ago

2.0.6-d

3 years ago

2.0.6-c

3 years ago

2.0.6-b

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.2

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago