{
  "id": 155107,
  "title": "I need a little help with my Regression Model",
  "url": "/competitions/prostate-cancer-grade-assessment/discussion/155107",
  "author_name": "Claudio Fanconi",
  "post_date": "2020-05-31T11:22:17.086000",
  "votes": 2,
  "comment_count": 4,
  "views": 0,
  "content": "<p>Hi dear competitors :)\nI am currently stuck, and I need your help...</p>\n\n<p>I am currently trying to train a regression model based on a EfficientNetB0 backbone. I use 12 tiles of the medium resolution images. Each of my inputs has size 224x224. \nI have added a Kappa optimizer to my code, such that I can keep track of my Kappa score. However, when I tried training it for some epochs, the loss and validation loss decreased, but my <strong>Kappa Score fluctuated around 0 (random score)</strong>. I cannot quite figure out why??</p>\n\n<p>i have tried the exact same settings for data preprocessing on a classification model, and that worked very well. It reach a single fold CV of 0.75 in very little time. Thus, I believe my mistake must be within either my <strong>Regression model (Maybe the SmoothL1Loss?)</strong>, or with my <strong>Kappa Score calculator</strong>...</p>\n\n<p>I have gone over my code several times, but couldn't find my mistake. If you don't mind giving a quick read through my code, I would be extremely grateful if you can point me out the (maybe obvious) bug/mistake I am making?</p>\n\n<p>You can find my notebook here:\n<a href=\"https://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression\">https://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression</a></p>\n\n<p>I value your time for going through it a lot and appreciate any comment :)\nThanks guys.</p>",
  "messages": [
    {
      "id": 869181,
      "postDate": "2020-05-31T19:50:14.410Z",
      "content": "<p><strong>Edit:</strong> after looking at it some more I see you get the following results:</p>\n\n<p>```\n0.06272697101320956 </p>\n\n<p>[[  0 233 345   0   0   0]\n [  0 191 342   0   0   0]\n [  0  87 182   0   0   0]\n [  0  68 180   0   0   0]\n [  0  79 171   0   0   0]\n [  0  49 196   0   0   0]] </p>\n\n<p>[0.5, 1.5, 2.5, 3.5, 4.5]\n```</p>\n\n<p>I also found another one of your notebooks here: <a href=\"https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression\">https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression</a></p>\n\n<p>This notebook does seem to work (outside of a bug where you had too few thresholds)</p>\n\n<p>What is the difference between that notebook, and your current faulty one?\nIn my eyes, the only difference is the SmoothL1loss (and adding another threshold in the kappa optimizer), so my guess is that the SmoothL1loss is giving undesirable results. </p>\n\n<p>You could try debugging it by using the old notebook which still worked, run it again for a sanity check (so you know nothing else happened with data processing) , and then add the SmoothL1 loss to the old notebook to see what the difference is.</p>",
      "rawMarkdown": "**Edit:** after looking at it some more I see you get the following results:\n\n```\n0.06272697101320956 \n\n[[  0 233 345   0   0   0]\n [  0 191 342   0   0   0]\n [  0  87 182   0   0   0]\n [  0  68 180   0   0   0]\n [  0  79 171   0   0   0]\n [  0  49 196   0   0   0]] \n\n[0.5, 1.5, 2.5, 3.5, 4.5]\n```\n\nI also found another one of your notebooks here: https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression\n\nThis notebook does seem to work (outside of a bug where you had too few thresholds)\n\nWhat is the difference between that notebook, and your current faulty one?\nIn my eyes, the only difference is the SmoothL1loss (and adding another threshold in the kappa optimizer), so my guess is that the SmoothL1loss is giving undesirable results. \n\nYou could try debugging it by using the old notebook which still worked, run it again for a sanity check (so you know nothing else happened with data processing) , and then add the SmoothL1 loss to the old notebook to see what the difference is.",
      "votes": 1,
      "replies": [
        {
          "id": 869221,
          "postDate": "2020-05-31T20:47:42.510Z",
          "content": "<p>Hey  <a href=\"/stephanovich\">@stephanovich</a> Thank you so much for looking at it. I really appreciate that :)</p>\n\n<p>Exactly, that's why I am a little confused, as it seemed to learn well in the first Kernel. I only changed the data loader class, for higher resolution images. However, that class works for my classification model. Hence, I also believe that may SmoothL1Loss might not be the wisest choice. I will try to back engineer it from there.</p>\n\n<p>Again, thanks so much!</p>",
          "rawMarkdown": "Hey  @stephanovich Thank you so much for looking at it. I really appreciate that :)\n\nExactly, that's why I am a little confused, as it seemed to learn well in the first Kernel. I only changed the data loader class, for higher resolution images. However, that class works for my classification model. Hence, I also believe that may SmoothL1Loss might not be the wisest choice. I will try to back engineer it from there.\n\nAgain, thanks so much!",
          "votes": 1
        },
        {
          "id": 869273,
          "postDate": "2020-05-31T22:09:38.907Z",
          "content": "<p>So, I did the following things and now it's working again\n- Changed the Optimizer from RAdam to Over9000\n- Changed the loss from SmoothL1Loss to MSELossFlat\n- Changed the label format from float16 to int</p>\n\n<p>I somehow believe the last point was the culprit, but I wasn't patient enough to test them all singly.\nThanks again :)</p>",
          "rawMarkdown": "So, I did the following things and now it's working again\n- Changed the Optimizer from RAdam to Over9000\n- Changed the loss from SmoothL1Loss to MSELossFlat\n- Changed the label format from float16 to int\n\nI somehow believe the last point was the culprit, but I wasn't patient enough to test them all singly.\nThanks again :)",
          "votes": 1
        },
        {
          "id": 869276,
          "postDate": "2020-05-31T22:17:25.500Z",
          "content": "<p>Good to hear!</p>\n\n<p>Given the extra information that you changed the DataLoader class that might indeed have been it, but it would be strange, given that regression losses are supposed to deal with float values to start with. Maybe something strange happens in the casting? \nI'm using Tensorflow myself so I know that you have to be very careful with casting.</p>\n\n<p>In any case, I'm glad to hear you've solved it. Good luck with the rest of the competition.</p>",
          "rawMarkdown": "Good to hear!\n\nGiven the extra information that you changed the DataLoader class that might indeed have been it, but it would be strange, given that regression losses are supposed to deal with float values to start with. Maybe something strange happens in the casting? \nI'm using Tensorflow myself so I know that you have to be very careful with casting.\n\nIn any case, I'm glad to hear you've solved it. Good luck with the rest of the competition.\n\n",
          "votes": 1
        }
      ]
    },
    {
      "id": 868611,
      "postDate": "2020-05-31T11:22:17.087Z",
      "content": "<p>Hi dear competitors :)\nI am currently stuck, and I need your help...</p>\n\n<p>I am currently trying to train a regression model based on a EfficientNetB0 backbone. I use 12 tiles of the medium resolution images. Each of my inputs has size 224x224. \nI have added a Kappa optimizer to my code, such that I can keep track of my Kappa score. However, when I tried training it for some epochs, the loss and validation loss decreased, but my <strong>Kappa Score fluctuated around 0 (random score)</strong>. I cannot quite figure out why??</p>\n\n<p>i have tried the exact same settings for data preprocessing on a classification model, and that worked very well. It reach a single fold CV of 0.75 in very little time. Thus, I believe my mistake must be within either my <strong>Regression model (Maybe the SmoothL1Loss?)</strong>, or with my <strong>Kappa Score calculator</strong>...</p>\n\n<p>I have gone over my code several times, but couldn't find my mistake. If you don't mind giving a quick read through my code, I would be extremely grateful if you can point me out the (maybe obvious) bug/mistake I am making?</p>\n\n<p>You can find my notebook here:\n<a href=\"https://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression\">https://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression</a></p>\n\n<p>I value your time for going through it a lot and appreciate any comment :)\nThanks guys.</p>",
      "rawMarkdown": "Hi dear competitors :)\nI am currently stuck, and I need your help...\n\nI am currently trying to train a regression model based on a EfficientNetB0 backbone. I use 12 tiles of the medium resolution images. Each of my inputs has size 224x224. \nI have added a Kappa optimizer to my code, such that I can keep track of my Kappa score. However, when I tried training it for some epochs, the loss and validation loss decreased, but my **Kappa Score fluctuated around 0 (random score)**. I cannot quite figure out why??\n\ni have tried the exact same settings for data preprocessing on a classification model, and that worked very well. It reach a single fold CV of 0.75 in very little time. Thus, I believe my mistake must be within either my **Regression model (Maybe the SmoothL1Loss?)**, or with my **Kappa Score calculator**...\n\nI have gone over my code several times, but couldn't find my mistake. If you don't mind giving a quick read through my code, I would be extremely grateful if you can point me out the (maybe obvious) bug/mistake I am making?\n\nYou can find my notebook here:\nhttps://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression\n\nI value your time for going through it a lot and appreciate any comment :)\nThanks guys.",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 869181,
      "author_name": "Stephan",
      "author_url": "",
      "post_date": "2020-05-31T19:50:14.410000",
      "content": "<p><strong>Edit:</strong> after looking at it some more I see you get the following results:</p>\n\n<p>```\n0.06272697101320956 </p>\n\n<p>[[  0 233 345   0   0   0]\n [  0 191 342   0   0   0]\n [  0  87 182   0   0   0]\n [  0  68 180   0   0   0]\n [  0  79 171   0   0   0]\n [  0  49 196   0   0   0]] </p>\n\n<p>[0.5, 1.5, 2.5, 3.5, 4.5]\n```</p>\n\n<p>I also found another one of your notebooks here: <a href=\"https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression\">https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression</a></p>\n\n<p>This notebook does seem to work (outside of a bug where you had too few thresholds)</p>\n\n<p>What is the difference between that notebook, and your current faulty one?\nIn my eyes, the only difference is the SmoothL1loss (and adding another threshold in the kappa optimizer), so my guess is that the SmoothL1loss is giving undesirable results. </p>\n\n<p>You could try debugging it by using the old notebook which still worked, run it again for a sanity check (so you know nothing else happened with data processing) , and then add the SmoothL1 loss to the old notebook to see what the difference is.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 869221,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-31T20:47:42.510000",
          "content": "<p>Hey  <a href=\"/stephanovich\">@stephanovich</a> Thank you so much for looking at it. I really appreciate that :)</p>\n\n<p>Exactly, that's why I am a little confused, as it seemed to learn well in the first Kernel. I only changed the data loader class, for higher resolution images. However, that class works for my classification model. Hence, I also believe that may SmoothL1Loss might not be the wisest choice. I will try to back engineer it from there.</p>\n\n<p>Again, thanks so much!</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 869273,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-31T22:09:38.907000",
          "content": "<p>So, I did the following things and now it's working again\n- Changed the Optimizer from RAdam to Over9000\n- Changed the loss from SmoothL1Loss to MSELossFlat\n- Changed the label format from float16 to int</p>\n\n<p>I somehow believe the last point was the culprit, but I wasn't patient enough to test them all singly.\nThanks again :)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 869276,
          "author_name": "Stephan",
          "author_url": "",
          "post_date": "2020-05-31T22:17:25.500000",
          "content": "<p>Good to hear!</p>\n\n<p>Given the extra information that you changed the DataLoader class that might indeed have been it, but it would be strange, given that regression losses are supposed to deal with float values to start with. Maybe something strange happens in the casting? \nI'm using Tensorflow myself so I know that you have to be very careful with casting.</p>\n\n<p>In any case, I'm glad to hear you've solved it. Good luck with the rest of the competition.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "869181": "**Edit:** after looking at it some more I see you get the following results:\n\n```\n0.06272697101320956 \n\n[[  0 233 345   0   0   0]\n [  0 191 342   0   0   0]\n [  0  87 182   0   0   0]\n [  0  68 180   0   0   0]\n [  0  79 171   0   0   0]\n [  0  49 196   0   0   0]] \n\n[0.5, 1.5, 2.5, 3.5, 4.5]\n```\n\nI also found another one of your notebooks here: https://www.kaggle.com/fanconic/panda-training-for-effnetb0-regression\n\nThis notebook does seem to work (outside of a bug where you had too few thresholds)\n\nWhat is the difference between that notebook, and your current faulty one?\nIn my eyes, the only difference is the SmoothL1loss (and adding another threshold in the kappa optimizer), so my guess is that the SmoothL1loss is giving undesirable results. \n\nYou could try debugging it by using the old notebook which still worked, run it again for a sanity check (so you know nothing else happened with data processing) , and then add the SmoothL1 loss to the old notebook to see what the difference is.",
    "868611": "Hi dear competitors :)\nI am currently stuck, and I need your help...\n\nI am currently trying to train a regression model based on a EfficientNetB0 backbone. I use 12 tiles of the medium resolution images. Each of my inputs has size 224x224. \nI have added a Kappa optimizer to my code, such that I can keep track of my Kappa score. However, when I tried training it for some epochs, the loss and validation loss decreased, but my **Kappa Score fluctuated around 0 (random score)**. I cannot quite figure out why??\n\ni have tried the exact same settings for data preprocessing on a classification model, and that worked very well. It reach a single fold CV of 0.75 in very little time. Thus, I believe my mistake must be within either my **Regression model (Maybe the SmoothL1Loss?)**, or with my **Kappa Score calculator**...\n\nI have gone over my code several times, but couldn't find my mistake. If you don't mind giving a quick read through my code, I would be extremely grateful if you can point me out the (maybe obvious) bug/mistake I am making?\n\nYou can find my notebook here:\nhttps://www.kaggle.com/fanconic/panda-tile-list-training-for-effnetb0-regression\n\nI value your time for going through it a lot and appreciate any comment :)\nThanks guys."
  }
}