Skip to content

Instantly share code, notes, and snippets.

@RoyTakanen
Created April 12, 2021 17:30
Show Gist options
  • Save RoyTakanen/2a22ad90efd008f2a45e898bd7d9c843 to your computer and use it in GitHub Desktop.
Save RoyTakanen/2a22ad90efd008f2a45e898bd7d9c843 to your computer and use it in GitHub Desktop.
Little script that is able to sum two numbers.
const limdu = require('limdu');
const dd = new limdu.classifiers.NeuralNetwork();
dd.trainBatch([
{
input: {
a: 1,
b: 2
},
output: 0.3
},
{
input: {
a: 3,
b: 1
},
output: 0.3
},
{
input: {
a: 4,
b: 1
},
output: 0.5
},
{
input: {
a: 1,
b: 4
},
output: 0.5
},
{
input: {
a: 1,
b: 7
},
output: 0.8
},
{
input: {
a: 7,
b: 1
},
output: 0.8
},
{
input: {
a: 4,
b: 4
},
output: 0.8
},
{
input: {
a: 1,
b: 1
},
output: 0.2
},
{
input: {
a: 2,
b: 3
},
output: 0.5
},
{
input: {
a: 3,
b: 2
},
output: 0.5
},
{
input: {
a: 1,
b: 9
},
output: 1
},
{
input: {
a: 9,
b: 1
},
output: 1
},
{
input: {
a: 4,
b: 6
},
output: 1
},
{
input: {
a: 6,
b: 4
},
output: 1
},
{
input: {
a: 2,
b: 2
},
output: 0.4
},
{
input: {
a: 0,
b: 0
},
output: 0
},
]);
console.log(Math.round(dd.classify({ a:3, b:2 })[0] * 10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment