This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Dann Object
Matias Vazquez-Levi edited this page Jan 31, 2021
·
30 revisions
const Dann = require('dannjs').dann;
When you create a neural network, you need to specify the size of the input & output layers.
const nn = new Dann(2,2);
This value represents the architecture of the model in the form of an array.
This defines the learning rate of the model. This value is set to 0.001
by default.
This is an empty value. This is meant for you to increase whenever you have completed one epoch. This serves as a way to save the number of epochs along with the weights in the dannData.json file.
This is the most recent loss value of the model. If the model has never been trained before, this value will be set to 0.
Here is a neural network training to solve XOR:
const Dann = require('dannjs').dann; //nodejs only
// XOR neural network
const nn = new Dann(2,1);
nn.addHiddenLayer(4,'tanH');
nn.outputActivation('sigmoid');
nn.makeWeights();
nn.lr = 0.1;
// feeding data to the model before training
nn.feedForward([0,0],{log:true});
// training the model
const epoch = 10000;
for (let e = 0; e < epoch; e++) {
nn.backpropagate([0,0],[0]);
nn.backpropagate([1,1],[0]);
nn.backpropagate([0,1],[1]);
nn.backpropagate([1,0],[1]);
}
// feeding data to the model after training
nn.feedForward([0,0],{log:true});