{
  "id": 163679,
  "title": "train loss larger than valid loss",
  "url": "/competitions/global-wheat-detection/discussion/163679",
  "author_name": "",
  "post_date": "2020-07-03T03:38:14.749086700Z",
  "votes": null,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hi,\nIf my loss curves look like this, does that mean that I have a problem with, say, the model being underfitted to the data, because the train loss is larger than the valid loss?</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F390015%2Fd3b5f9715441298304c26d9649a7063d%2FScreen%20Shot%202020-07-03%20at%2011.33.39.png?generation=1593747254593479&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "913183",
      "postDate": "07/03/2020 03:38:14",
      "content": "<p>Hi,\nIf my loss curves look like this, does that mean that I have a problem with, say, the model being underfitted to the data, because the train loss is larger than the valid loss?</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F390015%2Fd3b5f9715441298304c26d9649a7063d%2FScreen%20Shot%202020-07-03%20at%2011.33.39.png?generation=1593747254593479&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Hi,\nIf my loss curves look like this, does that mean that I have a problem with, say, the model being underfitted to the data, because the train loss is larger than the valid loss?\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F390015%2Fd3b5f9715441298304c26d9649a7063d%2FScreen%20Shot%202020-07-03%20at%2011.33.39.png?generation=1593747254593479&amp;alt=media)",
      "votes": null
    },
    {
      "id": "913214",
      "postDate": "07/03/2020 04:26:58",
      "content": "<p>I think normally train loss usually will fall below val loss eventually. </p>",
      "rawMarkdown": "I think normally train loss usually will fall below val loss eventually.",
      "votes": null
    },
    {
      "id": "913217",
      "postDate": "07/03/2020 04:30:03",
      "content": "<p>I’d guess that your validation set in imbalanced. How did you split it?</p>",
      "rawMarkdown": "I’d guess that your validation set in imbalanced. How did you split it?",
      "votes": null
    },
    {
      "id": "913270",
      "postDate": "07/03/2020 05:08:09",
      "content": "<p>I used the same way that Alex Shonenkov showed in his <a href=\"https://www.kaggle.com/shonenkov/training-efficientdet\">[Training] EfficientDet notebook</a>, but just keeping fold 0.  So, my train set is fold 0's train set, and my valid set is fold 0's valid set.  It might be imbalanced in terms of the <code>stratify_group</code> used to produce the folds because I think I saw some warnings about this from <code>StratifiedKFold</code>.</p>",
      "rawMarkdown": "I used the same way that Alex Shonenkov showed in his [[Training] EfficientDet notebook](https://www.kaggle.com/shonenkov/training-efficientdet), but just keeping fold 0.  So, my train set is fold 0's train set, and my valid set is fold 0's valid set.  It might be imbalanced in terms of the `stratify_group` used to produce the folds because I think I saw some warnings about this from `StratifiedKFold`.",
      "votes": null
    },
    {
      "id": "916888",
      "postDate": "07/06/2020 05:11:05",
      "content": "<p>You should definitely check your code for bugs. Having said that, there can be cases where your validation loss is less than training loss. One reason can be that your validation data is much easier than your training data. For detailed post, you can <a href=\"https://www.pyimagesearch.com/2019/10/14/why-is-my-validation-loss-lower-than-my-training-loss/\">look here</a>. <br>\nBut as mentioned by <a href=\"/bopengiowa\">@bopengiowa</a> if you train long enough, your model will eventually overfit.</p>",
      "rawMarkdown": "You should definitely check your code for bugs. Having said that, there can be cases where your validation loss is less than training loss. One reason can be that your validation data is much easier than your training data. For detailed post, you can [look here](https://www.pyimagesearch.com/2019/10/14/why-is-my-validation-loss-lower-than-my-training-loss/).  \nBut as mentioned by @bopengiowa if you train long enough, your model will eventually overfit.",
      "votes": null
    },
    {
      "id": "917118",
      "postDate": "07/06/2020 08:52:53",
      "content": "<p>If you are following Alex Shonenkov's notebook, then it may be that the validation doesn't include the augmentation, so the task is easier on the validation set than the test set.\nFor my training using a D5 effdet I only see the training set meet the validation set after quite a number of epochs because of this, also using 5 fold stratifiedkfold.</p>",
      "rawMarkdown": "If you are following Alex Shonenkov's notebook, then it may be that the validation doesn't include the augmentation, so the task is easier on the validation set than the test set.\nFor my training using a D5 effdet I only see the training set meet the validation set after quite a number of epochs because of this, also using 5 fold stratifiedkfold.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 913214,
      "author_name": "bopengiowa",
      "author_url": "",
      "post_date": "07/03/2020 04:26:58",
      "content": "<p>I think normally train loss usually will fall below val loss eventually. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 913217,
      "author_name": "matthewmasters",
      "author_url": "",
      "post_date": "07/03/2020 04:30:03",
      "content": "<p>I’d guess that your validation set in imbalanced. How did you split it?</p>",
      "votes": null,
      "replies": [
        {
          "id": 913270,
          "author_name": "jackchungchiehyu",
          "author_url": "",
          "post_date": "07/03/2020 05:08:09",
          "content": "<p>I used the same way that Alex Shonenkov showed in his <a href=\"https://www.kaggle.com/shonenkov/training-efficientdet\">[Training] EfficientDet notebook</a>, but just keeping fold 0.  So, my train set is fold 0's train set, and my valid set is fold 0's valid set.  It might be imbalanced in terms of the <code>stratify_group</code> used to produce the folds because I think I saw some warnings about this from <code>StratifiedKFold</code>.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 916888,
      "author_name": "ashwan1",
      "author_url": "",
      "post_date": "07/06/2020 05:11:05",
      "content": "<p>You should definitely check your code for bugs. Having said that, there can be cases where your validation loss is less than training loss. One reason can be that your validation data is much easier than your training data. For detailed post, you can <a href=\"https://www.pyimagesearch.com/2019/10/14/why-is-my-validation-loss-lower-than-my-training-loss/\">look here</a>. <br>\nBut as mentioned by <a href=\"/bopengiowa\">@bopengiowa</a> if you train long enough, your model will eventually overfit.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 917118,
      "author_name": "researn",
      "author_url": "",
      "post_date": "07/06/2020 08:52:53",
      "content": "<p>If you are following Alex Shonenkov's notebook, then it may be that the validation doesn't include the augmentation, so the task is easier on the validation set than the test set.\nFor my training using a D5 effdet I only see the training set meet the validation set after quite a number of epochs because of this, also using 5 fold stratifiedkfold.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "913183": "Hi,\nIf my loss curves look like this, does that mean that I have a problem with, say, the model being underfitted to the data, because the train loss is larger than the valid loss?\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F390015%2Fd3b5f9715441298304c26d9649a7063d%2FScreen%20Shot%202020-07-03%20at%2011.33.39.png?generation=1593747254593479&amp;alt=media)",
    "913214": "I think normally train loss usually will fall below val loss eventually.",
    "913217": "I’d guess that your validation set in imbalanced. How did you split it?",
    "913270": "I used the same way that Alex Shonenkov showed in his [[Training] EfficientDet notebook](https://www.kaggle.com/shonenkov/training-efficientdet), but just keeping fold 0.  So, my train set is fold 0's train set, and my valid set is fold 0's valid set.  It might be imbalanced in terms of the `stratify_group` used to produce the folds because I think I saw some warnings about this from `StratifiedKFold`.",
    "916888": "You should definitely check your code for bugs. Having said that, there can be cases where your validation loss is less than training loss. One reason can be that your validation data is much easier than your training data. For detailed post, you can [look here](https://www.pyimagesearch.com/2019/10/14/why-is-my-validation-loss-lower-than-my-training-loss/).  \nBut as mentioned by @bopengiowa if you train long enough, your model will eventually overfit.",
    "917118": "If you are following Alex Shonenkov's notebook, then it may be that the validation doesn't include the augmentation, so the task is easier on the validation set than the test set.\nFor my training using a D5 effdet I only see the training set meet the validation set after quite a number of epochs because of this, also using 5 fold stratifiedkfold."
  },
  "source": "meta"
}