{
  "id": 271214,
  "title": "Changing Random Seeds can get you from 0.540 to 0.710 in no time",
  "url": "/competitions/rsna-miccai-brain-tumor-radiogenomic-classification/discussion/271214",
  "author_name": "",
  "post_date": "2021-09-09T07:24:32.716440Z",
  "votes": 43,
  "comment_count": 21,
  "views": 0,
  "content": "<h3><a href=\"https://www.kaggle.com/sauravmaheshkar/rsna-miccai-the-random-seed-fluke/\" target=\"_blank\"><strong>Link to the Kernel to Reproduce Experiments</strong></a></h3>\n<p>For an in-depth comparison of the various models such as <strong>b0 vs b1 vs b2</strong> or <strong>b0 with different seeds</strong>, head over to the <a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy\" target=\"_blank\"><strong>accompanying wandb report</strong></a>. </p>\n<p>I've attached some proof here of some of my experiments using the same code as the \"<a href=\"https://www.kaggle.com/rluethy/efficientnet3d-with-one-mri-type\" target=\"_blank\"><strong>Efficientnet3D with one MRI type</strong></a>\" kernel (with some minor changes for <strong><code>wandb</code></strong> logging) which proves that much of what we're doing is nothing but a random fluke. </p>\n<p>The motivation for these experiments come from <a href=\"https://youtu.be/udw-uSV66EQ\" target=\"_blank\"><strong>Chai Time Kaggle Talks with Anjum Sayed (Datasaurus)</strong></a> Video on the <a href=\"https://www.youtube.com/WeightsBiases\" target=\"_blank\"><strong>Weights and Biases Channel</strong></a>. Anjum mentioned that a good way to check if the models are learning anything is to just change the random seeds and see if it affects the performance.</p>\n<h2><a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy\" target=\"_blank\"><strong>Weights and Biases Report ⭐️</strong></a> | <a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI\" target=\"_blank\"><strong>Weights and Biases Project</strong></a></h2>\n<hr>\n<h1>Models Don't Learn 🤷🏻</h1>\n<p><img src=\"https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Training-Loss.svg\" alt=\"\"></p>\n<p><img src=\"https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Validation-Loss.svg\" alt=\"\"></p>\n<p>Naming Convention - <code>arch-seed</code></p>\n<table>\n<thead>\n<tr>\n<th><strong>Name</strong></th>\n<th><strong>Training Loss</strong></th>\n<th><strong>Validation Loss</strong></th>\n<th><strong>EPOCHS</strong></th>\n<th><strong>BATCH_SIZE</strong></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>baseline-efficientnet3d-b0-42</td>\n<td>0.6814</td>\n<td>0.5914</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-12</td>\n<td>0.6913</td>\n<td>0.6420</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>augment-efficientnet3d-b2-42</td>\n<td>0.7125</td>\n<td>5.6498</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-2021</td>\n<td>0.7293</td>\n<td>0.6019</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b2-12</td>\n<td>0.7431</td>\n<td>0.8652</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b1-12</td>\n<td>0.7461</td>\n<td>0.5110</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-21</td>\n<td>0.7643</td>\n<td>0.7170</td>\n<td>10</td>\n<td>4</td>\n</tr>\n</tbody>\n</table>",
  "messages": [
    {
      "id": "1507421",
      "postDate": "09/09/2021 07:24:32",
      "content": "<h3><a href=\"https://www.kaggle.com/sauravmaheshkar/rsna-miccai-the-random-seed-fluke/\" target=\"_blank\"><strong>Link to the Kernel to Reproduce Experiments</strong></a></h3>\n<p>For an in-depth comparison of the various models such as <strong>b0 vs b1 vs b2</strong> or <strong>b0 with different seeds</strong>, head over to the <a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy\" target=\"_blank\"><strong>accompanying wandb report</strong></a>. </p>\n<p>I've attached some proof here of some of my experiments using the same code as the \"<a href=\"https://www.kaggle.com/rluethy/efficientnet3d-with-one-mri-type\" target=\"_blank\"><strong>Efficientnet3D with one MRI type</strong></a>\" kernel (with some minor changes for <strong><code>wandb</code></strong> logging) which proves that much of what we're doing is nothing but a random fluke. </p>\n<p>The motivation for these experiments come from <a href=\"https://youtu.be/udw-uSV66EQ\" target=\"_blank\"><strong>Chai Time Kaggle Talks with Anjum Sayed (Datasaurus)</strong></a> Video on the <a href=\"https://www.youtube.com/WeightsBiases\" target=\"_blank\"><strong>Weights and Biases Channel</strong></a>. Anjum mentioned that a good way to check if the models are learning anything is to just change the random seeds and see if it affects the performance.</p>\n<h2><a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy\" target=\"_blank\"><strong>Weights and Biases Report ⭐️</strong></a> | <a href=\"https://wandb.ai/sauravmaheshkar/RSNA-MICCAI\" target=\"_blank\"><strong>Weights and Biases Project</strong></a></h2>\n<hr>\n<h1>Models Don't Learn 🤷🏻</h1>\n<p><img src=\"https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Training-Loss.svg\" alt=\"\"></p>\n<p><img src=\"https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Validation-Loss.svg\" alt=\"\"></p>\n<p>Naming Convention - <code>arch-seed</code></p>\n<table>\n<thead>\n<tr>\n<th><strong>Name</strong></th>\n<th><strong>Training Loss</strong></th>\n<th><strong>Validation Loss</strong></th>\n<th><strong>EPOCHS</strong></th>\n<th><strong>BATCH_SIZE</strong></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>baseline-efficientnet3d-b0-42</td>\n<td>0.6814</td>\n<td>0.5914</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-12</td>\n<td>0.6913</td>\n<td>0.6420</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>augment-efficientnet3d-b2-42</td>\n<td>0.7125</td>\n<td>5.6498</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-2021</td>\n<td>0.7293</td>\n<td>0.6019</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b2-12</td>\n<td>0.7431</td>\n<td>0.8652</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b1-12</td>\n<td>0.7461</td>\n<td>0.5110</td>\n<td>10</td>\n<td>4</td>\n</tr>\n<tr>\n<td>baseline-efficientnet3d-b0-21</td>\n<td>0.7643</td>\n<td>0.7170</td>\n<td>10</td>\n<td>4</td>\n</tr>\n</tbody>\n</table>",
      "rawMarkdown": "### [**Link to the Kernel to Reproduce Experiments**](https://www.kaggle.com/sauravmaheshkar/rsna-miccai-the-random-seed-fluke/)\n\nFor an in-depth comparison of the various models such as **b0 vs b1 vs b2** or **b0 with different seeds**, head over to the [**accompanying wandb report**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy). \n\nI've attached some proof here of some of my experiments using the same code as the \"[**Efficientnet3D with one MRI type**](https://www.kaggle.com/rluethy/efficientnet3d-with-one-mri-type)\" kernel (with some minor changes for **`wandb`** logging) which proves that much of what we're doing is nothing but a random fluke. \n\nThe motivation for these experiments come from [**Chai Time Kaggle Talks with Anjum Sayed (Datasaurus)**](https://youtu.be/udw-uSV66EQ) Video on the [**Weights and Biases Channel**](https://www.youtube.com/WeightsBiases). Anjum mentioned that a good way to check if the models are learning anything is to just change the random seeds and see if it affects the performance.\n\n## [**Weights and Biases Report ⭐️**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy) | [**Weights and Biases Project**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI)\n\n---\n\n# Models Don't Learn 🤷🏻\n\n![](https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Training-Loss.svg)\n\n![](https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Validation-Loss.svg)\n\nNaming Convention - `arch-seed`\n\n|**Name**                           |**Training Loss**|**Validation Loss**|**EPOCHS**|**BATCH_SIZE**|\n|-------------------------------|-------------|---------------|:------:|:----------:|\n|baseline-efficientnet3d-b0-42  |0.6814|0.5914|10    |4         |64        |\n|baseline-efficientnet3d-b0-12  |0.6913|0.6420|10    |4         |64        |\n|augment-efficientnet3d-b2-42   |0.7125|5.6498|10    |4         |64        |\n|baseline-efficientnet3d-b0-2021|0.7293|0.6019|10    |4         |64        |\n|baseline-efficientnet3d-b2-12  |0.7431|0.8652|10    |4         |64        |\n|baseline-efficientnet3d-b1-12  |0.7461|0.5110|10    |4         |64        |\n|baseline-efficientnet3d-b0-21  |0.7643|0.7170|10    |4         |64        |",
      "votes": null
    },
    {
      "id": "1507450",
      "postDate": "09/09/2021 08:03:36",
      "content": "<p>Very interesting point. Actually, the mentioned kernel does not learn at all - the output scores vary in [0.4,0.6] range, which on average give the graded 0.642.  A well-trained model shall give values in a wider range, close to 0 and 1.</p>",
      "rawMarkdown": "Very interesting point. Actually, the mentioned kernel does not learn at all - the output scores vary in [0.4,0.6] range, which on average give the graded 0.642.  A well-trained model shall give values in a wider range, close to 0 and 1.",
      "votes": null
    },
    {
      "id": "1507797",
      "postDate": "09/09/2021 14:43:57",
      "content": "<p>The mentioned kernel has several flaws - wrong sorting of the input files, missing sigmoid layer, and what is more important - problematic model. The used batch normalization layers are imported from the functional API, and they don't work well in the eval mode. Therefore, the obtained predictions are worthless and you can rely on neither loss nor auc. I recommend switching onto implementations provided by Monai - they use batch normalization layers from torch.nn package. The code is available here: <a href=\"https://www.kaggle.com/mikecho/monai-v060-deep-learning-in-healthcare-imaging\" target=\"_blank\">monai</a></p>",
      "rawMarkdown": "The mentioned kernel has several flaws - wrong sorting of the input files, missing sigmoid layer, and what is more important - problematic model. The used batch normalization layers are imported from the functional API, and they don't work well in the eval mode. Therefore, the obtained predictions are worthless and you can rely on neither loss nor auc. I recommend switching onto implementations provided by Monai - they use batch normalization layers from torch.nn package. The code is available here: [monai](https://www.kaggle.com/mikecho/monai-v060-deep-learning-in-healthcare-imaging)",
      "votes": null
    },
    {
      "id": "1507830",
      "postDate": "09/09/2021 15:20:21",
      "content": "<p>Exactly, the missing activation layer was bugging me a lot too !!</p>\n<p>PS: Already working on another pipeline using monai 😁</p>",
      "rawMarkdown": "Exactly, the missing activation layer was bugging me a lot too !!\n\nPS: Already working on another pipeline using monai 😁",
      "votes": null
    },
    {
      "id": "1508119",
      "postDate": "09/09/2021 21:39:53",
      "content": "<p>Where does it use functional batch norms? I'm not seeing it.</p>",
      "rawMarkdown": "Where does it use functional batch norms? I'm not seeing it.",
      "votes": null
    },
    {
      "id": "1508257",
      "postDate": "09/10/2021 03:45:29",
      "content": "<p>I think <a href=\"https://www.kaggle.com/mikecho\" target=\"_blank\">@mikecho</a>, is referring to the codebase of the <code>EfficientNet-PyTorch-3D</code> library, which uses <code>nn.BatchNorm3d</code> in the module definitions. For example, </p>\n<pre><code>class MBConvBlock3D(nn.Module):\n            ...\n            self._bn0 = nn.BatchNorm3d(...)\n</code></pre>",
      "rawMarkdown": "I think @mikecho, is referring to the codebase of the `EfficientNet-PyTorch-3D` library, which uses `nn.BatchNorm3d` in the module definitions. For example, \n\n```\nclass MBConvBlock3D(nn.Module):\n            ...\n            self._bn0 = nn.BatchNorm3d(...)\n```",
      "votes": null
    },
    {
      "id": "1508258",
      "postDate": "09/10/2021 03:46:30",
      "content": "<p>Have made the \"Reproducibility Kernel\" Public now. </p>",
      "rawMarkdown": "Have made the \"Reproducibility Kernel\" Public now.",
      "votes": null
    },
    {
      "id": "1508457",
      "postDate": "09/10/2021 08:46:19",
      "content": "<p>Sorry, actually <a href=\"https://www.kaggle.com/returnofsputnik\" target=\"_blank\">@returnofsputnik</a> is right. Only adaptive_avg_pool3d is from the functional API. I was analyzing that some time ago and I mixed up those two layers.<br>\nAnyway, I used the implementation of Monai and the problem was exactly the same. It works only when I change track_running_stats to False on each batchnorm layer, so maybe this is also a way to run the above implementation.<br>\nDoes anyone know why it is necessary to set this parameter? Without this, the network returns the same probabilities per batch in the eval mode. When the network is reloaded (weights stored and loaded from file), the problem disappears though.</p>",
      "rawMarkdown": "Sorry, actually @returnofsputnik is right. Only adaptive_avg_pool3d is from the functional API. I was analyzing that some time ago and I mixed up those two layers.\nAnyway, I used the implementation of Monai and the problem was exactly the same. It works only when I change track_running_stats to False on each batchnorm layer, so maybe this is also a way to run the above implementation.\nDoes anyone know why it is necessary to set this parameter? Without this, the network returns the same probabilities per batch in the eval mode. When the network is reloaded (weights stored and loaded from file), the problem disappears though.",
      "votes": null
    },
    {
      "id": "1508486",
      "postDate": "09/10/2021 09:20:50",
      "content": "<p><a href=\"https://www.kaggle.com/jhasanov\" target=\"_blank\">@jhasanov</a> it is not that these models don't learn at all, but rather that the loss and auc calculated in the validation epochs are worthless. As I mentioned above, there is a problem with the batchnorm layers in the used architecture that doesn't work well in the eval mode without setting track_running_stats to False on each of the batchnorm modules. When you do it, the network starts to produce a meaningful output in the eval mode during training. However, you need to remember to include sigmoid layer, and remove rounding the probabilities to 0/1 for auc calculation</p>",
      "rawMarkdown": "jhasanov it is not that these models don't learn at all, but rather that the loss and auc calculated in the validation epochs are worthless. As I mentioned above, there is a problem with the batchnorm layers in the used architecture that doesn't work well in the eval mode without setting track_running_stats to False on each of the batchnorm modules. When you do it, the network starts to produce a meaningful output in the eval mode during training. However, you need to remember to include sigmoid layer, and remove rounding the probabilities to 0/1 for auc calculation",
      "votes": null
    },
    {
      "id": "1508545",
      "postDate": "09/10/2021 10:30:46",
      "content": "<p>Nice sharing..</p>",
      "rawMarkdown": "Nice sharing..",
      "votes": null
    },
    {
      "id": "1508584",
      "postDate": "09/10/2021 11:12:41",
      "content": "<p>Thank you for sharing.</p>",
      "rawMarkdown": "Thank you for sharing.",
      "votes": null
    },
    {
      "id": "1509300",
      "postDate": "09/11/2021 05:48:59",
      "content": "<p>Appreciate the feedback 😁</p>",
      "rawMarkdown": "Appreciate the feedback 😁",
      "votes": null
    },
    {
      "id": "1509301",
      "postDate": "09/11/2021 05:49:04",
      "content": "<p>Appreciate the feedback 😁</p>",
      "rawMarkdown": "Appreciate the feedback 😁",
      "votes": null
    },
    {
      "id": "1509927",
      "postDate": "09/11/2021 19:37:15",
      "content": "<p>HI <a href=\"https://www.kaggle.com/sauravmaheshkar\" target=\"_blank\">@sauravmaheshkar</a>, I have just published a <a href=\"https://www.kaggle.com/mikecho/rsna-miccai-monai-ensemble?scriptVersionId=74508923\" target=\"_blank\">notebook</a> based on Monai and Densenet121 that fixes the errors of the kernel that you are mentioning. In the current version, there is a bit too much overfiting as the amount of data is quite small, and no augmentation is implemented at this point. I will be uploading new versions soon.</p>",
      "rawMarkdown": "HI @sauravmaheshkar, I have just published a [notebook](https://www.kaggle.com/mikecho/rsna-miccai-monai-ensemble?scriptVersionId=74508923) based on Monai and Densenet121 that fixes the errors of the kernel that you are mentioning. In the current version, there is a bit too much overfiting as the amount of data is quite small, and no augmentation is implemented at this point. I will be uploading new versions soon.",
      "votes": null
    },
    {
      "id": "1510094",
      "postDate": "09/12/2021 05:20:03",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/mikecho\" target=\"_blank\">@mikecho</a>, seems like you beat me to it 😅. Even I was working on a pipeline using monai. I think it's enough that a simple DenseNet121 achieves a better score than EfficientNet3D-b2. Hopefully, we'll see an improvement in learning from now on. I'll be uploading newer kernels as well. </p>",
      "rawMarkdown": "Hey @mikecho, seems like you beat me to it 😅. Even I was working on a pipeline using monai. I think it's enough that a simple DenseNet121 achieves a better score than EfficientNet3D-b2. Hopefully, we'll see an improvement in learning from now on. I'll be uploading newer kernels as well.",
      "votes": null
    },
    {
      "id": "1511085",
      "postDate": "09/13/2021 05:22:32",
      "content": "<p>Thanks for pointing out in detail. </p>",
      "rawMarkdown": "Thanks for pointing out in detail.",
      "votes": null
    },
    {
      "id": "1513001",
      "postDate": "09/14/2021 18:13:37",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/sauravmaheshkar\" target=\"_blank\">@sauravmaheshkar</a> for pointing this out and for these ensuing insightful discussions!</p>",
      "rawMarkdown": "Thanks @sauravmaheshkar for pointing this out and for these ensuing insightful discussions!",
      "votes": null
    },
    {
      "id": "1513273",
      "postDate": "09/15/2021 03:09:56",
      "content": "<p>Thanks for the feedback 😁</p>",
      "rawMarkdown": "Thanks for the feedback 😁",
      "votes": null
    },
    {
      "id": "1513365",
      "postDate": "09/15/2021 05:42:14",
      "content": "<p>Hello, which version is you refered?</p>",
      "rawMarkdown": "Hello, which version is you refered?",
      "votes": null
    },
    {
      "id": "1513950",
      "postDate": "09/15/2021 14:45:24",
      "content": "<p>Version Number of what ? The kernel in question, my reproducibility kernel ,… ?</p>",
      "rawMarkdown": "Version Number of what ? The kernel in question, my reproducibility kernel ,... ?",
      "votes": null
    },
    {
      "id": "1515490",
      "postDate": "09/17/2021 06:53:30",
      "content": "<p>thanks very good👍👍👍</p>",
      "rawMarkdown": "thanks very good👍👍👍",
      "votes": null
    },
    {
      "id": "1515854",
      "postDate": "09/17/2021 15:02:45",
      "content": "<p>Thanks for the feedback 😁</p>",
      "rawMarkdown": "Thanks for the feedback 😁",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1507450,
      "author_name": "jhasanov",
      "author_url": "",
      "post_date": "09/09/2021 08:03:36",
      "content": "<p>Very interesting point. Actually, the mentioned kernel does not learn at all - the output scores vary in [0.4,0.6] range, which on average give the graded 0.642.  A well-trained model shall give values in a wider range, close to 0 and 1.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1508486,
          "author_name": "mikecho",
          "author_url": "",
          "post_date": "09/10/2021 09:20:50",
          "content": "<p><a href=\"https://www.kaggle.com/jhasanov\" target=\"_blank\">@jhasanov</a> it is not that these models don't learn at all, but rather that the loss and auc calculated in the validation epochs are worthless. As I mentioned above, there is a problem with the batchnorm layers in the used architecture that doesn't work well in the eval mode without setting track_running_stats to False on each of the batchnorm modules. When you do it, the network starts to produce a meaningful output in the eval mode during training. However, you need to remember to include sigmoid layer, and remove rounding the probabilities to 0/1 for auc calculation</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1511085,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/13/2021 05:22:32",
          "content": "<p>Thanks for pointing out in detail. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1507797,
      "author_name": "mikecho",
      "author_url": "",
      "post_date": "09/09/2021 14:43:57",
      "content": "<p>The mentioned kernel has several flaws - wrong sorting of the input files, missing sigmoid layer, and what is more important - problematic model. The used batch normalization layers are imported from the functional API, and they don't work well in the eval mode. Therefore, the obtained predictions are worthless and you can rely on neither loss nor auc. I recommend switching onto implementations provided by Monai - they use batch normalization layers from torch.nn package. The code is available here: <a href=\"https://www.kaggle.com/mikecho/monai-v060-deep-learning-in-healthcare-imaging\" target=\"_blank\">monai</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 1507830,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/09/2021 15:20:21",
          "content": "<p>Exactly, the missing activation layer was bugging me a lot too !!</p>\n<p>PS: Already working on another pipeline using monai 😁</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1508119,
          "author_name": "returnofsputnik",
          "author_url": "",
          "post_date": "09/09/2021 21:39:53",
          "content": "<p>Where does it use functional batch norms? I'm not seeing it.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1508257,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/10/2021 03:45:29",
          "content": "<p>I think <a href=\"https://www.kaggle.com/mikecho\" target=\"_blank\">@mikecho</a>, is referring to the codebase of the <code>EfficientNet-PyTorch-3D</code> library, which uses <code>nn.BatchNorm3d</code> in the module definitions. For example, </p>\n<pre><code>class MBConvBlock3D(nn.Module):\n            ...\n            self._bn0 = nn.BatchNorm3d(...)\n</code></pre>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1508457,
          "author_name": "mikecho",
          "author_url": "",
          "post_date": "09/10/2021 08:46:19",
          "content": "<p>Sorry, actually <a href=\"https://www.kaggle.com/returnofsputnik\" target=\"_blank\">@returnofsputnik</a> is right. Only adaptive_avg_pool3d is from the functional API. I was analyzing that some time ago and I mixed up those two layers.<br>\nAnyway, I used the implementation of Monai and the problem was exactly the same. It works only when I change track_running_stats to False on each batchnorm layer, so maybe this is also a way to run the above implementation.<br>\nDoes anyone know why it is necessary to set this parameter? Without this, the network returns the same probabilities per batch in the eval mode. When the network is reloaded (weights stored and loaded from file), the problem disappears though.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1508258,
      "author_name": "sauravmaheshkar",
      "author_url": "",
      "post_date": "09/10/2021 03:46:30",
      "content": "<p>Have made the \"Reproducibility Kernel\" Public now. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1508545,
      "author_name": "hawkeat",
      "author_url": "",
      "post_date": "09/10/2021 10:30:46",
      "content": "<p>Nice sharing..</p>",
      "votes": null,
      "replies": [
        {
          "id": 1509301,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/11/2021 05:49:04",
          "content": "<p>Appreciate the feedback 😁</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1508584,
      "author_name": "dhruvkhatri",
      "author_url": "",
      "post_date": "09/10/2021 11:12:41",
      "content": "<p>Thank you for sharing.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1509300,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/11/2021 05:48:59",
          "content": "<p>Appreciate the feedback 😁</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1509927,
      "author_name": "mikecho",
      "author_url": "",
      "post_date": "09/11/2021 19:37:15",
      "content": "<p>HI <a href=\"https://www.kaggle.com/sauravmaheshkar\" target=\"_blank\">@sauravmaheshkar</a>, I have just published a <a href=\"https://www.kaggle.com/mikecho/rsna-miccai-monai-ensemble?scriptVersionId=74508923\" target=\"_blank\">notebook</a> based on Monai and Densenet121 that fixes the errors of the kernel that you are mentioning. In the current version, there is a bit too much overfiting as the amount of data is quite small, and no augmentation is implemented at this point. I will be uploading new versions soon.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1510094,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/12/2021 05:20:03",
          "content": "<p>Hey <a href=\"https://www.kaggle.com/mikecho\" target=\"_blank\">@mikecho</a>, seems like you beat me to it 😅. Even I was working on a pipeline using monai. I think it's enough that a simple DenseNet121 achieves a better score than EfficientNet3D-b2. Hopefully, we'll see an improvement in learning from now on. I'll be uploading newer kernels as well. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1513001,
      "author_name": "conandoyle",
      "author_url": "",
      "post_date": "09/14/2021 18:13:37",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/sauravmaheshkar\" target=\"_blank\">@sauravmaheshkar</a> for pointing this out and for these ensuing insightful discussions!</p>",
      "votes": null,
      "replies": [
        {
          "id": 1513273,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/15/2021 03:09:56",
          "content": "<p>Thanks for the feedback 😁</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1513365,
      "author_name": "zekun98",
      "author_url": "",
      "post_date": "09/15/2021 05:42:14",
      "content": "<p>Hello, which version is you refered?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1513950,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/15/2021 14:45:24",
          "content": "<p>Version Number of what ? The kernel in question, my reproducibility kernel ,… ?</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1515490,
      "author_name": "saliblue",
      "author_url": "",
      "post_date": "09/17/2021 06:53:30",
      "content": "<p>thanks very good👍👍👍</p>",
      "votes": null,
      "replies": [
        {
          "id": 1515854,
          "author_name": "sauravmaheshkar",
          "author_url": "",
          "post_date": "09/17/2021 15:02:45",
          "content": "<p>Thanks for the feedback 😁</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1507421": "### [**Link to the Kernel to Reproduce Experiments**](https://www.kaggle.com/sauravmaheshkar/rsna-miccai-the-random-seed-fluke/)\n\nFor an in-depth comparison of the various models such as **b0 vs b1 vs b2** or **b0 with different seeds**, head over to the [**accompanying wandb report**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy). \n\nI've attached some proof here of some of my experiments using the same code as the \"[**Efficientnet3D with one MRI type**](https://www.kaggle.com/rluethy/efficientnet3d-with-one-mri-type)\" kernel (with some minor changes for **`wandb`** logging) which proves that much of what we're doing is nothing but a random fluke. \n\nThe motivation for these experiments come from [**Chai Time Kaggle Talks with Anjum Sayed (Datasaurus)**](https://youtu.be/udw-uSV66EQ) Video on the [**Weights and Biases Channel**](https://www.youtube.com/WeightsBiases). Anjum mentioned that a good way to check if the models are learning anything is to just change the random seeds and see if it affects the performance.\n\n## [**Weights and Biases Report ⭐️**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI/reports/The-Fluke--VmlldzoxMDA2MDQy) | [**Weights and Biases Project**](https://wandb.ai/sauravmaheshkar/RSNA-MICCAI)\n\n---\n\n# Models Don't Learn 🤷🏻\n\n![](https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Training-Loss.svg)\n\n![](https://raw.githubusercontent.com/SauravMaheshkar/SauravMaheshkar/main/assets/RSNA-MICCAI/Fluke-Validation-Loss.svg)\n\nNaming Convention - `arch-seed`\n\n|**Name**                           |**Training Loss**|**Validation Loss**|**EPOCHS**|**BATCH_SIZE**|\n|-------------------------------|-------------|---------------|:------:|:----------:|\n|baseline-efficientnet3d-b0-42  |0.6814|0.5914|10    |4         |64        |\n|baseline-efficientnet3d-b0-12  |0.6913|0.6420|10    |4         |64        |\n|augment-efficientnet3d-b2-42   |0.7125|5.6498|10    |4         |64        |\n|baseline-efficientnet3d-b0-2021|0.7293|0.6019|10    |4         |64        |\n|baseline-efficientnet3d-b2-12  |0.7431|0.8652|10    |4         |64        |\n|baseline-efficientnet3d-b1-12  |0.7461|0.5110|10    |4         |64        |\n|baseline-efficientnet3d-b0-21  |0.7643|0.7170|10    |4         |64        |",
    "1507450": "Very interesting point. Actually, the mentioned kernel does not learn at all - the output scores vary in [0.4,0.6] range, which on average give the graded 0.642.  A well-trained model shall give values in a wider range, close to 0 and 1.",
    "1507797": "The mentioned kernel has several flaws - wrong sorting of the input files, missing sigmoid layer, and what is more important - problematic model. The used batch normalization layers are imported from the functional API, and they don't work well in the eval mode. Therefore, the obtained predictions are worthless and you can rely on neither loss nor auc. I recommend switching onto implementations provided by Monai - they use batch normalization layers from torch.nn package. The code is available here: [monai](https://www.kaggle.com/mikecho/monai-v060-deep-learning-in-healthcare-imaging)",
    "1507830": "Exactly, the missing activation layer was bugging me a lot too !!\n\nPS: Already working on another pipeline using monai 😁",
    "1508119": "Where does it use functional batch norms? I'm not seeing it.",
    "1508257": "I think @mikecho, is referring to the codebase of the `EfficientNet-PyTorch-3D` library, which uses `nn.BatchNorm3d` in the module definitions. For example, \n\n```\nclass MBConvBlock3D(nn.Module):\n            ...\n            self._bn0 = nn.BatchNorm3d(...)\n```",
    "1508258": "Have made the \"Reproducibility Kernel\" Public now.",
    "1508457": "Sorry, actually @returnofsputnik is right. Only adaptive_avg_pool3d is from the functional API. I was analyzing that some time ago and I mixed up those two layers.\nAnyway, I used the implementation of Monai and the problem was exactly the same. It works only when I change track_running_stats to False on each batchnorm layer, so maybe this is also a way to run the above implementation.\nDoes anyone know why it is necessary to set this parameter? Without this, the network returns the same probabilities per batch in the eval mode. When the network is reloaded (weights stored and loaded from file), the problem disappears though.",
    "1508486": "jhasanov it is not that these models don't learn at all, but rather that the loss and auc calculated in the validation epochs are worthless. As I mentioned above, there is a problem with the batchnorm layers in the used architecture that doesn't work well in the eval mode without setting track_running_stats to False on each of the batchnorm modules. When you do it, the network starts to produce a meaningful output in the eval mode during training. However, you need to remember to include sigmoid layer, and remove rounding the probabilities to 0/1 for auc calculation",
    "1508545": "Nice sharing..",
    "1508584": "Thank you for sharing.",
    "1509300": "Appreciate the feedback 😁",
    "1509301": "Appreciate the feedback 😁",
    "1509927": "HI @sauravmaheshkar, I have just published a [notebook](https://www.kaggle.com/mikecho/rsna-miccai-monai-ensemble?scriptVersionId=74508923) based on Monai and Densenet121 that fixes the errors of the kernel that you are mentioning. In the current version, there is a bit too much overfiting as the amount of data is quite small, and no augmentation is implemented at this point. I will be uploading new versions soon.",
    "1510094": "Hey @mikecho, seems like you beat me to it 😅. Even I was working on a pipeline using monai. I think it's enough that a simple DenseNet121 achieves a better score than EfficientNet3D-b2. Hopefully, we'll see an improvement in learning from now on. I'll be uploading newer kernels as well.",
    "1511085": "Thanks for pointing out in detail.",
    "1513001": "Thanks @sauravmaheshkar for pointing this out and for these ensuing insightful discussions!",
    "1513273": "Thanks for the feedback 😁",
    "1513365": "Hello, which version is you refered?",
    "1513950": "Version Number of what ? The kernel in question, my reproducibility kernel ,... ?",
    "1515490": "thanks very good👍👍👍",
    "1515854": "Thanks for the feedback 😁"
  },
  "source": "meta"
}