3

Disclaimer: I am new to machine learning. Please forgive me if I am asking a super dumb question.

Hi I am trying to find pattern in a set of numbers using brain.js.

I have expanded on the example in brain.js github page.

const net = new brain.recurrent.LSTMTimeStep({
  inputSize: 3,
  hiddenLayers: [10],
  outputSize: 3
});

net.train([
  [1, 1, 1],
  [2, 2, 2],
  [3, 3, 3],
  [4, 4, 4],
  [5, 5, 5],
  [6, 6, 6],
  [7, 7, 7],
  [8, 8, 8]
]);

const output = net.run([[7, 7, 7], [8, 8, 8]]); 

I was trying to get an output of [9, 9, 9], but I am mostly getting [8, 8, 8].

But if I try running const output = net.run([[5, 5, 5], [6, 6, 6]]); I am easily getting [7, 7, 7] & consecutive output with other numbers in the training data sequence.

Is there anyway to train it so that I can get the desired output and the use it for other patters?

PSN
  • 35
  • 6

1 Answers1

3

You are using a LSTM time step recurrent neural network trained using "supervised learning": https://en.wikipedia.org/wiki/Supervised_learning, which provides similar output values it has been given previously to the .run() call.

What it seems you want is a LSTM time step recurrent neural network trained using "reinforcement learning": https://en.wikipedia.org/wiki/Reinforcement_learning, which can output values it has seen before, but also new ones, using values it has never been given previously to the .run() call, based off exploitation and exploratory (random) findings.

Brain.js doesn't yet have a reinforcement learning API, although that will be the focus after v2 stabilizes.

Ty for providing a clear question and reproduction steps. I've included your sample, working in the browser so others can play with it: https://jsfiddle.net/robertleeplummerjr/4o2vcajt/1/

Robert Plummer
  • 634
  • 1
  • 5
  • 13