Rikard
Rikard

Reputation: 7805

Simple deep-learning prediction

I'm starting to learn about deep-learning and found synaptic.js.

I would like to create a prediction system where I have a input of numbers and would like the AI to understand the pattern.

My training data would be a array of 2 numbers, and the output I want to validate is [x, y, z] where x and z are kind of booleans for even/odd, and y is the sum of both numbers in the imput.

So:

var trainingSet = [{
    'input': [20, 34],
    'output': [1, 54, 0]
}, {
    'input': [22, 33],
    'output': [1, 55, 1]
},{
    'input': [24, 35],
    'output': [1, 59, 1]
},{
    'input': [23, 36],
    'output': [0, 59, 0]
}];

and I would like the AI to know the answer if I input [20, 31].

How would I set up such logic?

I started a jsFiddle based on a YouTube talk but don't understand what the code does actually...

Made a loop to generate trainig data in this jsFiddle that basically is:

// training data generator:
var trainingSet = [];
for (var i = 0; i < 500; i++) {
    var obj = {};
    obj.input = [
        Math.random() * 10,
        Math.random() * 10
    ].map(Math.round);
    obj.output = [
        Number(obj.input[0] % 2 == 0),
        obj.input[0] + obj.input[1],
        Number(obj.input[1] % 2 == 1)
    ]
	trainingSet.push(obj);
}

document.body.innerHTML = JSON.stringify(trainingSet);

Upvotes: 0

Views: 374

Answers (1)

Lukasz Tracewski
Lukasz Tracewski

Reputation: 11377

Unless the generator you build is simply to explain the problem to us, there's no way the problem can be solved. More formally, no function exists such that you can recover the input from the output. The generator produces random numbers and what is preserved is whether they were odd / even and the sum. There exists an infinite set of numbers that fulfills these criteria. From your example: 54 = 20 + 34 = 18 + 36 = 16 + 38 ... If there was a process driving this, it can be done. But it's random. Your neural network can never learn a pattern because there is no pattern.

Upvotes: 1

Related Questions