Search code examples
matlabneural-network

How to know if I am not overfitting my neural network?


I am trying to build a neural network on MATLAB using NNTool. I have a huge data set, with more than 20k samples. It has 3 input parameters and 1 output.

Here is a data sample: U varies at 0.5 step until 10 (0.2 ; 0.5 ; 1.0 ... 10). n varies from 0 to 1 and m varies from 0 until it equals n.

Here is a data sample: U varies at 0.5 step until 10 (0.2 ; 0.5 ; 1.0 ... 10). n varies from 0 to 1 and m varies from 0 until it equals n.

I'm using the Levenberg-Marquartd algorithm and have been playing with number of neurons and hidden layers. Despise that, I have done nothing in other parameters.

How can I know if I am achieving a good performance without ovetfitting with such a huge data set?

Here's what MATLAB tell me about the performance:

peformance


Solution

  • I suggest doing the following:

    (1) Break your sample data into training/testing sets. Try 30% / 70% for example.

    (2) Choose a configuration: number of hidden layers and the number of neurons per layer.

    (3) Train your network.

    (4) Compare your training error with your testing error.

    (5) Choose another network configuration.

    (6) Do steps (3) and (4).

    Keep doing this process until you get a better feeling for your data. If you have very small training error relative to your testing error, chances are the configuration of your network is overfitting your dataset.