Train output to not be in specific range using brainjs

Viewed 106

I am new to the neural networks and I am trying to train several simple data points. I have training inputs x and y and I want output c to be: c<x & c>y. I tried choosing x and y as features but c was not always in the range I wanted. What other features can I use? I am using brain.js library in javascript.

1 Answers

You should transform your data format by yourself. It looks like brain.js will automatic detect normalized data in range from 0 to 1 and will not apply any modifications before training. The article about data format is provided here

Data format For training with NeuralNetwork Each training pattern should have an input and an output, both of which can be either an > array of numbers from 0 to 1 or a hash of numbers from 0 to 1.

const net = new brain.NeuralNetwork();

net.train([
  { input: { r: 0.03, g: 0.7, b: 0.5 }, output: { black: 1 } },
  { input: { r: 0.16, g: 0.09, b: 0.2 }, output: { white: 1 } },
  { input: { r: 0.5, g: 0.5, b: 1.0 }, output: { white: 1 } },
]);

const output = net.run({ r: 1, g: 0.4, b: 0 }); // { white: 0.99, black: 0.002 }
Related