0

I'm learning about neural networks.

I have a script that takes in some data and creates a model via a neural network. When I test the model against a validation data set, I get some results. If I re-test it against the same validation set several more times, I keep getting different results.

Is this an intended behavior or am I likely doing something wrong?

For whatever its worth, I'm using Node v7.10.0 with this library.

Sir Robert
  • 4,686
  • 7
  • 41
  • 57
  • 1
    Somewhere down the line, your value of seed is changing (random values) whenever you re-validate. Set a seed and you'll get same result. – Kshitiz Jul 19 '17 at 21:46

1 Answers1

1

Neural networks are usually trained with mini-batch gradient descent where a mini-batch of training examples are randomly selected to perform a gradient descent step. This adds some randomness to the training.

Moreover the weights and bias of a neural networks are usually randomly initialized (in your code it is done at these lines: https://github.com/harthur/brain/blob/master/lib/neuralnetwork.js#L36 and https://github.com/harthur/brain/blob/master/lib/neuralnetwork.js#L42), which also adds some randomness to the training.

In order to fix the randomness we usually use a seed (cf What is a seed in terms of generating a random number?). Unfortunately it is not possible to set a seed for the javascript random number generator (cf Seeding the random number generator in Javascript) but it seems possible to create your own random number generator.

Finally it is normal to get different results but these results should not be too different from the first you obtained.

fonfonx
  • 1,475
  • 21
  • 30