Creating Neural Network for un-encountered inputs

南楼画角 提交于 2019-12-06 07:53:27

As @runDOSrun said, your model seems to be overfitting the (training) data. To avoid this problem you could split your set (time series) in 3 parts.

Training Set

The first one could be the training set where you just train your network.

Validation Set

The second one is the validation set, where for each epoch of training, you test the neural network on the validation set and take the error and store this error in a variable and a copy of the neural network (clone). On the next epoch, you have to test the (modified) neural network and if the new error on the validation set is lower than the last you have tested, you store a new "validation neural network". It will provide for you a neural network which generalize better in a set which is not the training set. So you avoid to overfit the training set.

At the end of training you have two neural networks. The training neural network which is the best neural network for training set and the validation neural network, which can provide for you a neural network which generalize better out of training set.

Test Set

This last part, you just test your model in a unseen set and check the errors. The propose for test set is to check the behaviour of the neural network in the unseen test. A real test.

In general, you could slipt the all entire set in 3 equals parts, or for sample

  • 60% for training
  • 20% for validation
  • 20% for test

For sample, look the image bellow:

A sample of pseudo-code of how implement it could be:

int epochs = 1;
double error = 0;
double validationError = 10000;
object validationNetwork;
do
{
    // train your network

    error = getError(trainingSet);

    //validation part...

    var currentValidationError = getError(validationSet);
    if (currentValidationError < validationError)
    {
       validationError = currentValidationError;
       validationNeuralNetwork = neuralNetwork.Clone();
    }

} while (epochs < 2000 && error < 0.001);

Cross-Validation for Time Series

On the other hand, you also could try to do the cross-valdidation for time series. First you split your set in 6 parts (or more) and train neural networks to validate the model like this:

  • 1 : training [1], validate [2], test [3]
  • 2 : training [2], validate [3], test [4]
  • 3 : training [3], validate [4], test [5]
  • 4 : training [4], validate [5], test [6]

You could split in more parts if you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!