dart_nn

Creator: coderz1093

Last updated:

0 purchases

dart_nn Image
dart_nn Images

Languages

Categories

Add to Cart

Description:

dart nn

dart_nn #

A Simple Neural Network library written in dart.
Inspired from Toy Neural Network library by Coding Train.
Usage #
Create a neural network brain with any number of inputs, hidden layers and output nodes.
// Use Layer to create a layer with x nodes and activation function
var brain = NeuralNetwork(2, [Layer(3, 'LeakyRelu'), Layer(2, 'LeakyRelu')], Layer(1, 'Sigmoid'));
copied to clipboard
You can also set the learning rate.
brain.setLearningRate(learning_rate: 0.01);
copied to clipboard
Pass in training data with inputs and outputs to the train function.
And run the loop for any arbitrary number of epochs.
// XOR training data
var train_data = [
{
'inputs': [1.0, 1.0],
'outputs': [0.0],
},
{
'inputs': [0.0, 0.0],
'outputs': [0.0],
},
{
'inputs': [0.0, 1.0],
'outputs': [1.0],
},
{
'inputs': [1.0, 0.0],
'outputs': [1.0],
}
];
var epoch = 50000;

var rnd = Random();
for (var i = 0; i < epoch; i++) {
var d = rnd.nextInt(4);
brain.train(train_data[d]['inputs'], train_data[d]['outputs']);
}
copied to clipboard
You can then test the NeuralNetwork by passing in the test data to the predict function.
for (var i = 0; i < train_data.length; i++) {
print("Test: In: ${train_data[i]['inputs']} Out: ${brain.predict(train_data[i]['inputs'])}");
}
copied to clipboard
You can clone the brain using the clone method.
var brain2 = brain.clone();
copied to clipboard
You can serialize the brain to save in a file. And later retrieve the brain using the deserialize method.
var brain2serialized = NeuralNetwork.serialize(brain2);
// You can save the `brain2serialized` string to any file.
var brain3 = NeuralNetwork.deserialize(brain2serialized);
copied to clipboard
License #
license.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.