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

Output values #294

Open talvasconcelos opened 6 years ago

talvasconcelos commented 6 years ago

If my output is 0.75, 0.5 or 0.25 (for H, D, A) when testing the outcome of the NN prediction how does the value relates to the output i want? How do i interpret the values that the NN outputs? A value of 0.66 tends to what? is it just a matter of dividing the range in 3?

BTW why does changing the cost to cross entropy increases the error output from 0.03(MSE) to 0.69?

ghost commented 6 years ago

The cost function is just a way to interpret the outcome. The Binary cost function usually has a very bad error like 0.5 but it still predicts just fine as your internal NN does not really care about that. The cost function help us to determine when we should stop the training at a point we feel is good enough. Stick with MSE until you are happy with the NN, than you can try the other cost functions later and see if they help you (not the NN) to tune the network training and testing (prediction performance and time spent).

With the 3 outcomes you would simply post-process the outcome and classify it. 0.66 is more close to 0.75 so you got a H which you backprop. You want to improve your training and see that the outcome would preferable be more close to 0.75, which is where you optimize your network, which takes hours and hours of testing. Try to create a batch file with different training parameters, size of hidden layers etc. to see which parameters work best. I usually test ten-thousands of parameters with a batch file overnight and have to decide prediction performance against time spent to choose the parameters I need.

talvasconcelos commented 6 years ago

Haven't got much luck i guess. My NN is at an error of about 0.02 but when activate i get around 50% right. Probabily my rounding is not going so well. Also increasing the targets to [0.333], [0.666] and [0.5] makes them possibly not so far apart that i can be accurate. I'm trying going for 2 outputs on the format [0.333, 0.333], [0.666, 0.666] and [0.5, 0.5]. My error is dropping to 0.0184. Maybe i'll get more accuracy when refitting the activate output. I'm train testing with 50000 iterations. How many iterations are too much?

Running 2 scenarios:

  1. Perceptron(3, 5, 2)
    train(trainingSet.slice(trainingSet.length - 13000), { //have about 18k entries just lowering down for testing
    rate: 0.005,
    iterations: 50000,
    error: 0.005,
    log: 1000,
    })

2.LSTM(3, 4, 2, 2)

train(trainingSet.slice(trainingSet.length - 15000), { 
    rate: [0.008, 0.005],
    iterations: 50000,
    error: 0.005,
    log: 1000,
})
ghost commented 6 years ago

Stick with LSTM only:

trainer = new synaptic.Trainer(net);

var trainer_settings = { rate: 0.5, iterations: 100000, error: 0.000001, shuffle: false, log: 100, cost: synaptic.Trainer.cost.MSE };

If you see in the log output that the MSE is not going down in big steps, abort and test again with different amount of training/test data and maybe larger hidden neurons. You should get a prediction rate of 80-90% if your data has a true underlying connection. If you like to share your training data I can try to develop a model for you.

talvasconcelos commented 6 years ago

Hi, testing your recommendations as i type. For now not much difference...

I have to lower the rate to 0.005 to see some improvements.

Sure you can have a look at the data: https://gist.github.com/talvasconcelos/a4439d4439907ae406a958c945453ce4

ghost commented 6 years ago

How is the training data structured ? Maybe strip it down to a csv file which only has the numbers we read into Synaptic.