Answers.Body: <p>Idea is to optimize with regards to unseen data in each step in order to avoid <strong>overfitting</strong> and <strong>data leakage</strong> so that the final network will be most generalizable to novel data.</p>
  <p>First, you initialize your network weights randomly. For those weights, training data is unseen so network is optimized with regards to loss function that is calculated using training data. This was the first step.</p>
  <p>Second, you would like to optimize hyperparameters, the parameters you use to train your network in first step. The network already worked hard to do its best in the first step while learning weights. If you use the same dataset in this step, it will have even more flexibility to fit even better to training data. But this will result in <strong>high variance</strong>, and network will perform poorly on unseen data.</p>
  <p>For this reason, you split your data into train, dev and test. Train network with train data, optimize it with dev data and finally, evaluate with test data, never touching it until the very last step.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-28T11:44:04.287Z
Answers.Text: Why would the use of the training data for hyper-parameter tuning result in high variance? You should probably elaborate on this part because it's not clear the variance of which random variable you're referring to and why that's even the case.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-28T12:49:14.540Z
Answers.Text: @crinix so you mean that dividing the training set and dev set allows overfitting to be reduced?
Answers.UserDisplayName: Omar Zayed
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-28T22:04:51.387Z
Answers.Text: @nbro Optimizing hyper-parameters wrt trainingset causes high-variance and overfitting yes. It provides the model with more means to reduce the loss on training data, while increasing loss for unseen data.
  OmarZayed yes.
Answers.UserDisplayName: meliksahturker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-28T11:40:00.953Z
Answers.LastActivityDate: 2021-07-28T11:40:00.953Z
Answers.UserDisplayName: meliksahturker
Answers.Body: <p>I think this is best explained using an analogy. Also you seen to have the misconception that you don't tune hyper-parameters for training data. You want to increase the accuracy of the training set AND validation set at the same time, but the validation set is more important so you want to maximise that accuracy more.</p>
  <p>Imagine you had a toddler, and you were trying to teach them what an apple looks like. You have 10 pictures of apples, and for 45 years you sit them in a room and show them these apples. After all this time they will get to know the apples so well, that even the minutest differences in the photos would be noticed. When you try to see how the toddler generalised (how well it can use what it saw in training to evaluate real examples), it's absolutely terrible, because after all that time how could anything be an apple but the 10 it had seen?</p>
  <p>So to combat this, you might think to reduce the number of years you spent showing the toddler the <strong>training set</strong> (the 10 apples), maybe that will allow them to generalise better (prevent over-fitting)? But you need a way to <strong>validate</strong> that this is actually helping, on unseen data (novel apples). That's where the 5 unseen apples come in to play (the <strong>validation set</strong>). You measure the accuracy of this unseen data to get an actual idea of how the toddler has learnt, because in a real example, the toddler isn't going to have seen the apple before, so it's important to know how it will handle unseen data.</p>
  <p>That brings us finally to the <strong>testing set</strong>. The issue with what I've described above is maybe there's some kind of bias in the <strong>validation set</strong>, maybe those apples are slightly more round than usual. Of course you want the maximum accuracy on the validation set, so you tune everything to increase this accuracy, but this incurs a bias to the validation set. Maybe the parameters you chose are good <strong>only for this validation set</strong>. To make sure this isn't the case, you try and increase your accuracy as much as possible on the validation set, then after that you test the true accuracy on the testing set. This ensures you can't just tune your hyper-parameters to the validation set and call it a day. You need real generalisation to increase both validation AND testing set accuracy.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-29T01:57:06.807Z
Answers.LastActivityDate: 2021-07-29T01:57:06.807Z
Answers.UserDisplayName: Recessive
Body: <p>If the validation set is used to tune the hyperparameters and the training set adjusts the weights, why don't they be one thing as they have a similar role, as in improving the model?</p>
  
Tags: <neural-networks><deep-learning><comparison><training-datasets><validation-datasets>
Title: Why not make the training set and validation set one if their roles are similar?
UserDisplayName: Omar Zayed
ThreadText: # Why not make the training set and validation set one if their roles are similar?
  
  (Asked by: username_0 on 2021-07-28)
  
  If the validation set is used to tune the hyperparameters and the training set adjusts the weights, why don't they be one thing as they have a similar role, as in improving the model?
  
  **Tags:** neural-networks, deep-learning, comparison, training-datasets, validation-datasets
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-07-28. Score: 1
  
  Idea is to optimize with regards to unseen data in each step in order to avoid **overfitting** and **data leakage** so that the final network will be most generalizable to novel data.
  
  First, you initialize your network weights randomly. For those weights, training data is unseen so network is optimized with regards to loss function that is calculated using training data. This was the first step.
  
  Second, you would like to optimize hyperparameters, the parameters you use to train your network in first step. The network already worked hard to do its best in the first step while learning weights. If you use the same dataset in this step, it will have even more flexibility to fit even better to training data. But this will result in **high variance**, and network will perform poorly on unseen data.
  
  For this reason, you split your data into train, dev and test. Train network with train data, optimize it with dev data and finally, evaluate with test data, never touching it until the very last step.
  
  > **Comments:**
  > **username_2**: Why would the use of the training data for hyper-parameter tuning result in high variance? You should probably elaborate on this part because it's not clear the variance of which random variable you're referring to and why that's even the case.  
  > **username_0**: @crinix so you mean that dividing the training set and dev set allows overfitting to be reduced?  
  > **username_1**: @nbro Optimizing hyper-parameters wrt trainingset causes high-variance and overfitting yes. It provides the model with more means to reduce the loss on training data, while increasing loss for unseen data. OmarZayed yes.  
  
  ---
  
  ### Answer by username_3 on 2021-07-29. Score: 1
  
  I think this is best explained using an analogy. Also you seen to have the misconception that you don't tune hyper-parameters for training data. You want to increase the accuracy of the training set AND validation set at the same time, but the validation set is more important so you want to maximise that accuracy more.
  
  Imagine you had a toddler, and you were trying to teach them what an apple looks like. You have 10 pictures of apples, and for 45 years you sit them in a room and show them these apples. After all this time they will get to know the apples so well, that even the minutest differences in the photos would be noticed. When you try to see how the toddler generalised (how well it can use what it saw in training to evaluate real examples), it's absolutely terrible, because after all that time how could anything be an apple but the 10 it had seen?
  
  So to combat this, you might think to reduce the number of years you spent showing the toddler the **training set** (the 10 apples), maybe that will allow them to generalise better (prevent over-fitting)? But you need a way to **validate** that this is actually helping, on unseen data (novel apples). That's where the 5 unseen apples come in to play (the **validation set**). You measure the accuracy of this unseen data to get an actual idea of how the toddler has learnt, because in a real example, the toddler isn't going to have seen the apple before, so it's important to know how it will handle unseen data.
  
  That brings us finally to the **testing set**. The issue with what I've described above is maybe there's some kind of bias in the **validation set**, maybe those apples are slightly more round than usual. Of course you want the maximum accuracy on the validation set, so you tune everything to increase this accuracy, but this incurs a bias to the validation set. Maybe the parameters you chose are good **only for this validation set**. To make sure this isn't the case, you try and increase your accuracy as much as possible on the validation set, then after that you test the true accuracy on the testing set. This ensures you can't just tune your hyper-parameters to the validation set and call it a day. You need real generalisation to increase both validation AND testing set accuracy.
  
  
  ---
  
  