cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.91k stars 666 forks source link

How to get value of error from each iteration ? #229

Open dfaustryjak opened 7 years ago

dfaustryjak commented 7 years ago

Hello :)

I would like to graph how much the error decreases and i need to get each value of error fro first to last iteration :) Is it possible ?

wagenaartje commented 7 years ago

You can use the schedule option to schedule tasks during training. In this example, the error is saved into an array:

var network = new synaptic.Architect.Perceptron(2, 4, 1);

var dataSet = [
  { input: [0,0], output: [0] },
  { input: [0,1], output: [1] },
  { input: [1,0], output: [1] },
  { input: [1,1], output: [0] }
];

var trainer = new synaptic.Trainer(network);

var errors = [];

trainer.train(dataSet, {
  log: 1,
  iterations: 1000,
  schedule: {
    every: 1,
    do: function(data){
            errors.push(data.error);
    }
  }
});

console.log(errors);

Run it here. So yes, possible ;)

dfaustryjak commented 7 years ago

Thanks 👍 my friend for quick help 💃