1
$\begingroup$

I am a bit confused about the general strategy to adopt for the set up of a ML learning algorithm, in the case for example of a neural network, and I have not been able to find resources (books or articles) to answer my questions.

Let us consider a neural network where the variables that are tunable are the numbers of layers, the sizes of the layers and the connections between layers (for example relu, sigmoid, pooling, convolutions...) and that I have a training set, a validation set and a test set.

From what I have understood about the subject, a general strategy could be the following: I choose a neural network architecture (as described above) and I train my neural network, in the sense that with an iterative method (like gradient descent), weights (biases included) are iteratively computed in order to minimize the discrepancy (in some given norm) between the actual values $y_{train}$ and the output given by the neural network $\hat y_{train}$. Then, at each iteration, I use the validation set to compute the discrepancy between the actual values $y_{val}$ and the output given by the neural network $\hat y_{val}$.

So my questions are:

1) Should I tune the parameters (number of layers, sizes of layers, type of connections) in order to minimize the error between $y_{val}$ and $\hat y_{val}$ ?

2) Isn't doing 1) considered data snooping ?

3) If I pursue the strategy described in 1), suppose I obtain after tuning the neural network a very low error between $y_{val}$ and $\hat y_{val}$. Then I use the test set to compute the error between $y_{test}$ and $\hat y_{test}$ and find out that the error is larger than the validation error.

So what should I do ? Change the parameters of the neural network ? I suppose that would be again data snooping and/or that it would limit the further ability of the neural network to make correct predictions of new data ? And how much larger with respect to the validation set error is the test set error considered too large ?

4) More generally, could someone describe the strategy that is generally accepted in the ML/DL community to tune the parameters of a neural network in the case described above (in the sense where I can tune the number of layers, the sizes of layers, the type of connections and I have training, validation and test sets) ?

$\endgroup$
3
  • $\begingroup$ while I don't have anything against the training-validation-test set approach, is there a specific reason why you're not considering cross-validation at all? $\endgroup$
    – DeltaIV
    Nov 7, 2017 at 10:08
  • 1
    $\begingroup$ sorry I didn't notice you're new to the site. Then, welcome to Cross Validated. Please take the tour before posting. Your question is well-written (IMO), however you should search if similar questions have been asked in the past, before asking a new question. The search tuning neural network returns 143 hits at the moment of writing this comment: stats.stackexchange.com/search?q=tuning+neural+network some of which are highly relevant to your question. $\endgroup$
    – DeltaIV
    Nov 7, 2017 at 10:17
  • $\begingroup$ Also, if you know what cross-validation and early stopping are, have a look at this and this. Early stopping can be seen as a method to tune a particular hyperparameter, i.e., the number of training steps. See Ian Goodfellow's et al. Deep Learning book. $\endgroup$
    – DeltaIV
    Nov 7, 2017 at 10:24

1 Answer 1

2
$\begingroup$

1) Should I tune the parameters (number of layers, sizes of layers, type of connections) in order to minimize the error between $y_{val}$ and $\hat y_{val}$ ?

Yes, all hyperparameters (including those governing network architecture) can be tuned using the validation set.

2) Isn't doing 1) considered data snooping ?

No, this isn't snooping/peeking because the final performance should be measured using an independent test set (distinct from the training and validation sets).

3) If I pursue the strategy described in 1), suppose I obtain after tuning the neural network a very low error between $y_{val}$ and $\hat y_{val}$. Then I use the test set to compute the error between $y_{test}$ and $\hat y_{test}$ and find out that the error is larger than the validation error. So what should I do ? Change the parameters of the neural network ?

No, you should never perform any fitting or model selection using the test set. This would constitute peeking, and would give an overoptimistic estimate of performance. Keep the test set under lock and key, and don't let it influence the model in any way (including deciding to try another method until you're happy with it).

The test set error might be larger than the validation set error. If that's the case, then so be it; this is an honest estimate of the performance of your entire learning algorithm (which includes model selection/hyperparameter tuning). If the test set error is larger, it might simply reflect random fluctuations in the dataset, or it could be that you're overfitting the validation set. If you suspect the latter might be an issue, you can use nested cross validation to make more efficient use of your data (and/or gather more data; training large networks can require very large datasets). A simpler network and/or more restricted tuning procedure could also help if it's possible to make sensible choices. As above, any decisions along these lines should not be made by looking at the test set.

4) More generally, could someone describe the strategy that is generally accepted in the ML/DL community to tune the parameters of a neural network in the case described above (in the sense where I can tune the number of layers, the sizes of layers, the type of connections and I have training, validation and test sets) ?

It sounds like you already have the gist of this. For large datasets, split the data into fixed training/validation/test sets. Fit weights using the training set, tune hyperparameters using the validation set, and estimate performance using the test set. For smaller datasets, use nested cross validation instead of fixed training/validation/test sets. This will give improved estimates at the cost of more computation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.