{
  "id": 310105,
  "title": "9 Computer Vision Tricks to Improve Performance",
  "url": "/competitions/happy-whale-and-dolphin/discussion/310105",
  "author_name": "Sanyam Bhutani",
  "post_date": "2022-02-27T15:19:39.992000",
  "votes": 168,
  "comment_count": 31,
  "views": 0,
  "content": "<p>Hello! </p>\n<p>I wanted to create a post sharing some general tips &amp; suggestions that might help improve training speeds &amp; accuracy, I have learned these via courses, reading top writeups, or papers, and plan to try all of these in this comp.</p>\n<p>Without further ado:</p>\n<h3>1. Start with Smaller Resolution:</h3>\n<p>The first two tips are focused on allowing faster prototyping-the more ideas you can try, the more chances you have to score better. To iterate faster, we need to start small to keep our training times small:</p>\n<p>Ayush has kindly created a Datasets thread <a href=\"https://www.kaggle.com/c/happy-whale-and-dolphin/discussion/309691\" target=\"_blank\">here</a> that points to all the datasets shared. Starting with a small dataset size allows you to iterate faster. </p>\n<p>Since you'll be working with smaller GPU memory usage, you can increase <code>batch_size</code> and also iterate faster. Once you're confident in your ideas and see consistent score improvements, you can scale to larger image sizes.</p>\n<h3>2. Start with subsets of Data:</h3>\n<p>Continuing with the previous line, you should start with just a small number of classes or examples and validate your training models there. </p>\n<p>Ex: Train on 10 classes, check if it improves CV -&gt; Submit<br>\nScale idea to 20 classes, check CV, and submit again </p>\n<p>If all goes well, train on the complete dataset.</p>\n<h3>3. Use FP16 or Half-Precision Training:</h3>\n<p>Who doesn't want up to 50% faster training? </p>\n<p>NVIDIA GPUs have Tensor-Cores which offer huge speedups when using \"Half-Precision\" Tensors. I have written a more detailed blog <a href=\"https://hackernoon.com/rtx-2080ti-vs-gtx-1080ti-fastai-mixed-precision-training-comparisons-on-cifar-100-761d8f615d7f\" target=\"_blank\">here</a>, the short version is to try using <code>fp_16</code> training to observe speedups on any GPU (and TPU!)</p>\n<h3>4. Use TPUs:</h3>\n<p>Kaggle offers 20 hours of TPUs every week. TPUs have 8 cores, which allow your batch_sizes to be scaled by a factor of 8. This allows for much faster training and faster iteration. </p>\n<p>Note: I have recently discovered Hugging Face Accelerate which claims to give you easy workflow on TPUs with PyTorch too</p>\n<h3>5. Progressive Resizing:</h3>\n<p>This idea IIRC was introduced in the Efficientnet papers and also taught in the fastai courses. </p>\n<p>Chris Deotte has a fantastic <a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/160147\" target=\"_blank\">post</a> talking about CNN Input image sizes. <a href=\"https://medium.com/analytics-vidhya/novel-techniques-to-win-an-image-classification-hackathon-part-2-e33bf0ad5fe6\" target=\"_blank\">This</a> blog teaches you how progressive resizing works in fastai. TL;DR:</p>\n<ul>\n<li>Train model on size: small</li>\n<li>Save weights and re-train model on larger image size</li>\n<li>Save weights again and re-train on final image sizes</li>\n</ul>\n<p>This process allows much faster convergence and better performance </p>\n<h3>6. Experiment: Depthwise Convs instead of Regular Convs:</h3>\n<p>I believe this <a href=\"https://paperswithcode.com/method/depthwise-convolution\" target=\"_blank\">concept</a> was introduced in the MobileNet paper first and I saw it resurface in a recent discussion related to ConvNext architectures. Depthwise Convolutions have fewer filters and hence train faster. </p>\n<p><a href=\"https://discuss.pytorch.org/t/how-to-modify-a-conv2d-to-depthwise-separable-convolution/15843/4\" target=\"_blank\">See here</a> for some tips on making it work in PyTorch</p>\n<h3>7. LR Scheduler:</h3>\n<p>Changing your <code>learning_rate</code> during the training of your model:</p>\n<p>A slow lr takes too long and fast lr might not help your model converge, using this logic, we should use dynamic learning rates.</p>\n<p>There are many schedulers that allow this: I would recommend using <code>fastai</code> and its <code>fine_tune()</code> or <code>fit_one_cycle()</code> function. See <a href=\"https://forums.fast.ai/t/fine-tune-vs-fit-one-cycle/66029\" target=\"_blank\">here</a> for more details. </p>\n<h3>8. LR Warmup:</h3>\n<p>This one is in-line with the previous one:</p>\n<p>From the paper, <a href=\"https://arxiv.org/pdf/1812.01187.pdf\" target=\"_blank\">\"Bag of Tricks\"</a>, one of the ticks highlights using LR warmup:</p>\n<p>When you start training a model, it has more \"randomness\" as it's just starting to learn features, hence starting with a smaller <code>learning_rate</code> first allows it to pick details, and later you can increase it to the expected schedule or value after the \"warmup\" epochs are done and your model has learned some details.</p>\n<h3>9. Image Augmentations:</h3>\n<p>NNs benefit from more data. A slight change in an image can really help a model improve its understanding of features inside of an image. </p>\n<p>Using correct image augmentations can really help your model. I had posted a nb sharing fastai image augmentations tutorial, I will be sharing an updated one for this competition soon if it's helpful.</p>\n<p>Chris Deotte in his recent <a href=\"https://www.youtube.com/watch?v=XXmujwhjyIo\" target=\"_blank\">CTDS interview</a> shared some secrets. Qishen Ha, whose team had won the TF GBR competition also shared <a href=\"https://www.youtube.com/watch?v=8e-EIilkvL0\" target=\"_blank\">some tips</a> of making these work</p>\n<p>TL;DR of both: Try a lot of experiments and try as many augmentations. Start with augmentations off and then add them one by one to see if your training improves. </p>\n<p>Also, visualise results as you train models to make sure they're learning about the whales and not backgrounds!</p>\n<p>I have two more bonus suggestions for anyone that has read this far :) </p>\n<h3>Bonus Tip #1: Use Timm or Tfimm:</h3>\n<p><a href=\"https://github.com/rwightman/pytorch-image-models\" target=\"_blank\">Timm</a> and <a href=\"https://github.com/martinsbruveris/tensorflow-image-models\" target=\"_blank\">Tfimm</a>, the latter being a TF-port of the former is a fantastic resource! Ross, posts almost all the cutting edge model weights along with <em>extremely</em> optimised training methods. I would highly recommend also spending time digging into their source code but at the least using the library is a solid suggestion for anyone working on CV problems</p>\n<h3>Bonus Tip #2: Use NGC Containers for Local training:</h3>\n<p>I understand many people are using Kaggle kernels and Colab for training. However, if you've invested in local hardware, <a href=\"https://twitter.com/wightmanr\" target=\"_blank\">Ross</a> had taught in a thread on Twitter that the <a href=\"https://catalog.ngc.nvidia.com\" target=\"_blank\">NGC Containers</a> for PyTorch are very optimised and offer speedups</p>\n<p>I hope you find these helpful and also find some training or score boosts! :)</p>\n<p>Happy Kaggling!</p>",
  "messages": [
    {
      "id": 1706561,
      "postDate": "2022-02-27T15:19:39.993Z",
      "content": "<p>Hello! </p>\n<p>I wanted to create a post sharing some general tips &amp; suggestions that might help improve training speeds &amp; accuracy, I have learned these via courses, reading top writeups, or papers, and plan to try all of these in this comp.</p>\n<p>Without further ado:</p>\n<h3>1. Start with Smaller Resolution:</h3>\n<p>The first two tips are focused on allowing faster prototyping-the more ideas you can try, the more chances you have to score better. To iterate faster, we need to start small to keep our training times small:</p>\n<p>Ayush has kindly created a Datasets thread <a href=\"https://www.kaggle.com/c/happy-whale-and-dolphin/discussion/309691\" target=\"_blank\">here</a> that points to all the datasets shared. Starting with a small dataset size allows you to iterate faster. </p>\n<p>Since you'll be working with smaller GPU memory usage, you can increase <code>batch_size</code> and also iterate faster. Once you're confident in your ideas and see consistent score improvements, you can scale to larger image sizes.</p>\n<h3>2. Start with subsets of Data:</h3>\n<p>Continuing with the previous line, you should start with just a small number of classes or examples and validate your training models there. </p>\n<p>Ex: Train on 10 classes, check if it improves CV -&gt; Submit<br>\nScale idea to 20 classes, check CV, and submit again </p>\n<p>If all goes well, train on the complete dataset.</p>\n<h3>3. Use FP16 or Half-Precision Training:</h3>\n<p>Who doesn't want up to 50% faster training? </p>\n<p>NVIDIA GPUs have Tensor-Cores which offer huge speedups when using \"Half-Precision\" Tensors. I have written a more detailed blog <a href=\"https://hackernoon.com/rtx-2080ti-vs-gtx-1080ti-fastai-mixed-precision-training-comparisons-on-cifar-100-761d8f615d7f\" target=\"_blank\">here</a>, the short version is to try using <code>fp_16</code> training to observe speedups on any GPU (and TPU!)</p>\n<h3>4. Use TPUs:</h3>\n<p>Kaggle offers 20 hours of TPUs every week. TPUs have 8 cores, which allow your batch_sizes to be scaled by a factor of 8. This allows for much faster training and faster iteration. </p>\n<p>Note: I have recently discovered Hugging Face Accelerate which claims to give you easy workflow on TPUs with PyTorch too</p>\n<h3>5. Progressive Resizing:</h3>\n<p>This idea IIRC was introduced in the Efficientnet papers and also taught in the fastai courses. </p>\n<p>Chris Deotte has a fantastic <a href=\"https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/160147\" target=\"_blank\">post</a> talking about CNN Input image sizes. <a href=\"https://medium.com/analytics-vidhya/novel-techniques-to-win-an-image-classification-hackathon-part-2-e33bf0ad5fe6\" target=\"_blank\">This</a> blog teaches you how progressive resizing works in fastai. TL;DR:</p>\n<ul>\n<li>Train model on size: small</li>\n<li>Save weights and re-train model on larger image size</li>\n<li>Save weights again and re-train on final image sizes</li>\n</ul>\n<p>This process allows much faster convergence and better performance </p>\n<h3>6. Experiment: Depthwise Convs instead of Regular Convs:</h3>\n<p>I believe this <a href=\"https://paperswithcode.com/method/depthwise-convolution\" target=\"_blank\">concept</a> was introduced in the MobileNet paper first and I saw it resurface in a recent discussion related to ConvNext architectures. Depthwise Convolutions have fewer filters and hence train faster. </p>\n<p><a href=\"https://discuss.pytorch.org/t/how-to-modify-a-conv2d-to-depthwise-separable-convolution/15843/4\" target=\"_blank\">See here</a> for some tips on making it work in PyTorch</p>\n<h3>7. LR Scheduler:</h3>\n<p>Changing your <code>learning_rate</code> during the training of your model:</p>\n<p>A slow lr takes too long and fast lr might not help your model converge, using this logic, we should use dynamic learning rates.</p>\n<p>There are many schedulers that allow this: I would recommend using <code>fastai</code> and its <code>fine_tune()</code> or <code>fit_one_cycle()</code> function. See <a href=\"https://forums.fast.ai/t/fine-tune-vs-fit-one-cycle/66029\" target=\"_blank\">here</a> for more details. </p>\n<h3>8. LR Warmup:</h3>\n<p>This one is in-line with the previous one:</p>\n<p>From the paper, <a href=\"https://arxiv.org/pdf/1812.01187.pdf\" target=\"_blank\">\"Bag of Tricks\"</a>, one of the ticks highlights using LR warmup:</p>\n<p>When you start training a model, it has more \"randomness\" as it's just starting to learn features, hence starting with a smaller <code>learning_rate</code> first allows it to pick details, and later you can increase it to the expected schedule or value after the \"warmup\" epochs are done and your model has learned some details.</p>\n<h3>9. Image Augmentations:</h3>\n<p>NNs benefit from more data. A slight change in an image can really help a model improve its understanding of features inside of an image. </p>\n<p>Using correct image augmentations can really help your model. I had posted a nb sharing fastai image augmentations tutorial, I will be sharing an updated one for this competition soon if it's helpful.</p>\n<p>Chris Deotte in his recent <a href=\"https://www.youtube.com/watch?v=XXmujwhjyIo\" target=\"_blank\">CTDS interview</a> shared some secrets. Qishen Ha, whose team had won the TF GBR competition also shared <a href=\"https://www.youtube.com/watch?v=8e-EIilkvL0\" target=\"_blank\">some tips</a> of making these work</p>\n<p>TL;DR of both: Try a lot of experiments and try as many augmentations. Start with augmentations off and then add them one by one to see if your training improves. </p>\n<p>Also, visualise results as you train models to make sure they're learning about the whales and not backgrounds!</p>\n<p>I have two more bonus suggestions for anyone that has read this far :) </p>\n<h3>Bonus Tip #1: Use Timm or Tfimm:</h3>\n<p><a href=\"https://github.com/rwightman/pytorch-image-models\" target=\"_blank\">Timm</a> and <a href=\"https://github.com/martinsbruveris/tensorflow-image-models\" target=\"_blank\">Tfimm</a>, the latter being a TF-port of the former is a fantastic resource! Ross, posts almost all the cutting edge model weights along with <em>extremely</em> optimised training methods. I would highly recommend also spending time digging into their source code but at the least using the library is a solid suggestion for anyone working on CV problems</p>\n<h3>Bonus Tip #2: Use NGC Containers for Local training:</h3>\n<p>I understand many people are using Kaggle kernels and Colab for training. However, if you've invested in local hardware, <a href=\"https://twitter.com/wightmanr\" target=\"_blank\">Ross</a> had taught in a thread on Twitter that the <a href=\"https://catalog.ngc.nvidia.com\" target=\"_blank\">NGC Containers</a> for PyTorch are very optimised and offer speedups</p>\n<p>I hope you find these helpful and also find some training or score boosts! :)</p>\n<p>Happy Kaggling!</p>",
      "rawMarkdown": "Hello! \n\nI wanted to create a post sharing some general tips & suggestions that might help improve training speeds & accuracy, I have learned these via courses, reading top writeups, or papers, and plan to try all of these in this comp.\n\nWithout further ado:\n\n### 1. Start with Smaller Resolution:\n\nThe first two tips are focused on allowing faster prototyping-the more ideas you can try, the more chances you have to score better. To iterate faster, we need to start small to keep our training times small:\n\nAyush has kindly created a Datasets thread [here](https://www.kaggle.com/c/happy-whale-and-dolphin/discussion/309691) that points to all the datasets shared. Starting with a small dataset size allows you to iterate faster. \n\nSince you'll be working with smaller GPU memory usage, you can increase `batch_size` and also iterate faster. Once you're confident in your ideas and see consistent score improvements, you can scale to larger image sizes.\n\n### 2. Start with subsets of Data:\n\nContinuing with the previous line, you should start with just a small number of classes or examples and validate your training models there. \n\nEx: Train on 10 classes, check if it improves CV -> Submit\nScale idea to 20 classes, check CV, and submit again \n\nIf all goes well, train on the complete dataset.\n\n### 3. Use FP16 or Half-Precision Training:\n\nWho doesn't want up to 50% faster training? \n\nNVIDIA GPUs have Tensor-Cores which offer huge speedups when using \"Half-Precision\" Tensors. I have written a more detailed blog [here](https://hackernoon.com/rtx-2080ti-vs-gtx-1080ti-fastai-mixed-precision-training-comparisons-on-cifar-100-761d8f615d7f), the short version is to try using `fp_16` training to observe speedups on any GPU (and TPU!)\n\n### 4. Use TPUs:\n\nKaggle offers 20 hours of TPUs every week. TPUs have 8 cores, which allow your batch_sizes to be scaled by a factor of 8. This allows for much faster training and faster iteration. \n\nNote: I have recently discovered Hugging Face Accelerate which claims to give you easy workflow on TPUs with PyTorch too\n\n### 5. Progressive Resizing:\n\nThis idea IIRC was introduced in the Efficientnet papers and also taught in the fastai courses. \n\nChris Deotte has a fantastic [post](https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/160147) talking about CNN Input image sizes. [This](https://medium.com/analytics-vidhya/novel-techniques-to-win-an-image-classification-hackathon-part-2-e33bf0ad5fe6) blog teaches you how progressive resizing works in fastai. TL;DR:\n\n- Train model on size: small\n- Save weights and re-train model on larger image size\n- Save weights again and re-train on final image sizes\n\nThis process allows much faster convergence and better performance \n\n### 6. Experiment: Depthwise Convs instead of Regular Convs:\n\nI believe this [concept](https://paperswithcode.com/method/depthwise-convolution) was introduced in the MobileNet paper first and I saw it resurface in a recent discussion related to ConvNext architectures. Depthwise Convolutions have fewer filters and hence train faster. \n\n[See here](https://discuss.pytorch.org/t/how-to-modify-a-conv2d-to-depthwise-separable-convolution/15843/4) for some tips on making it work in PyTorch\n\n### 7. LR Scheduler:\n\nChanging your `learning_rate` during the training of your model:\n\nA slow lr takes too long and fast lr might not help your model converge, using this logic, we should use dynamic learning rates.\n\nThere are many schedulers that allow this: I would recommend using `fastai` and its `fine_tune()` or `fit_one_cycle()` function. See [here](https://forums.fast.ai/t/fine-tune-vs-fit-one-cycle/66029) for more details. \n\n### 8. LR Warmup:\n\nThis one is in-line with the previous one:\n\nFrom the paper, [\"Bag of Tricks\"](https://arxiv.org/pdf/1812.01187.pdf), one of the ticks highlights using LR warmup:\n\nWhen you start training a model, it has more \"randomness\" as it's just starting to learn features, hence starting with a smaller `learning_rate` first allows it to pick details, and later you can increase it to the expected schedule or value after the \"warmup\" epochs are done and your model has learned some details.\n\n### 9. Image Augmentations:\n\nNNs benefit from more data. A slight change in an image can really help a model improve its understanding of features inside of an image. \n\nUsing correct image augmentations can really help your model. I had posted a nb sharing fastai image augmentations tutorial, I will be sharing an updated one for this competition soon if it's helpful.\n\nChris Deotte in his recent [CTDS interview](https://www.youtube.com/watch?v=XXmujwhjyIo) shared some secrets. Qishen Ha, whose team had won the TF GBR competition also shared [some tips](https://www.youtube.com/watch?v=8e-EIilkvL0) of making these work\n\nTL;DR of both: Try a lot of experiments and try as many augmentations. Start with augmentations off and then add them one by one to see if your training improves. \n\nAlso, visualise results as you train models to make sure they're learning about the whales and not backgrounds!\n\nI have two more bonus suggestions for anyone that has read this far :) \n\n### Bonus Tip #1: Use Timm or Tfimm:\n\n[Timm](https://github.com/rwightman/pytorch-image-models) and [Tfimm](https://github.com/martinsbruveris/tensorflow-image-models), the latter being a TF-port of the former is a fantastic resource! Ross, posts almost all the cutting edge model weights along with *extremely* optimised training methods. I would highly recommend also spending time digging into their source code but at the least using the library is a solid suggestion for anyone working on CV problems\n\n### Bonus Tip #2: Use NGC Containers for Local training: \n\nI understand many people are using Kaggle kernels and Colab for training. However, if you've invested in local hardware, [Ross](https://twitter.com/wightmanr) had taught in a thread on Twitter that the [NGC Containers](https://catalog.ngc.nvidia.com) for PyTorch are very optimised and offer speedups\n\nI hope you find these helpful and also find some training or score boosts! :)\n\nHappy Kaggling!",
      "votes": 168
    },
    {
      "id": 2185594,
      "postDate": "2023-03-17T07:18:03.950Z",
      "content": "<p>Your observation is excellent <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> </p>",
      "rawMarkdown": "Your observation is excellent @init27 ",
      "votes": 2
    },
    {
      "id": 1709782,
      "postDate": "2022-03-02T13:39:22.903Z",
      "content": "<p>One more idea about <strong>Image Augmentations</strong> is that , you can also use <code>Image Augmentations</code> during inference. Its very helpful for Objcet Detection tasks. I have found that by using few variants of validation image and then combining all the predicted bouding boxes, I could extract much better results from the same model.  </p>",
      "rawMarkdown": "One more idea about **Image Augmentations** is that , you can also use `Image Augmentations` during inference. Its very helpful for Objcet Detection tasks. I have found that by using few variants of validation image and then combining all the predicted bouding boxes, I could extract much better results from the same model.  ",
      "votes": 1,
      "replies": [
        {
          "id": 1711492,
          "postDate": "2022-03-04T03:43:33.687Z",
          "content": "<p>I think you are referring to TTA(Test Time Augmentation). In my experiments TTA doesn't work every time, if your data is too noisy.</p>",
          "rawMarkdown": "I think you are referring to TTA(Test Time Augmentation). In my experiments TTA doesn't work every time, if your data is too noisy.",
          "votes": 1
        }
      ]
    },
    {
      "id": 1707312,
      "postDate": "2022-02-28T10:05:52.470Z",
      "content": "<p>Nice work! I wish there more posts that share a lot of tricks in a single thread.</p>",
      "rawMarkdown": "Nice work! I wish there more posts that share a lot of tricks in a single thread.",
      "votes": 1,
      "replies": [
        {
          "id": 1711858,
          "postDate": "2022-03-04T11:30:58.810Z",
          "content": "<p>Thank you, CroDoc! 🙏</p>\n<p>I've found many posts scattered across different competitions, I'll try my best to collect ideas like so or maybe even livestream with some chai if time permits. </p>\n<p>These tricks are however really simple compared to the incredible ones shared by Kagglers in competitions</p>",
          "rawMarkdown": "Thank you, CroDoc! 🙏\n\nI've found many posts scattered across different competitions, I'll try my best to collect ideas like so or maybe even livestream with some chai if time permits. \n\nThese tricks are however really simple compared to the incredible ones shared by Kagglers in competitions",
          "votes": 1
        },
        {
          "id": 1711921,
          "postDate": "2022-03-04T13:22:30.093Z",
          "content": "<p>Ask <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> to be on Chai again and share the best general tricks for computer vision 🤓</p>",
          "rawMarkdown": "Ask @cdeotte to be on Chai again and share the best general tricks for computer vision 🤓"
        }
      ]
    },
    {
      "id": 1711488,
      "postDate": "2022-03-04T03:40:26.910Z",
      "content": "<p>Great points <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a>  as always!<br>\nbut I am quite skeptical of your 2nd point, that is use less classes then use more. I don't think it is a good idea, I think it will confuse the model when we will introduce more number of classes later. <br>\nAlthough I am not sure, can you a bit describe  it more. Thanks</p>",
      "rawMarkdown": "Great points @init27  as always!\nbut I am quite skeptical of your 2nd point, that is use less classes then use more. I don't think it is a good idea, I think it will confuse the model when we will introduce more number of classes later. \nAlthough I am not sure, can you a bit describe  it more. Thanks",
      "votes": 2,
      "replies": [
        {
          "id": 1711861,
          "postDate": "2022-03-04T11:36:06.833Z",
          "content": "<p>Thank you!</p>\n<p>Actually, maybe I didn't I explain it well-I'm not suggesting doing transfer learning with the weights. </p>\n<p>I was envisioning this:</p>\n<p>Let's say I want to try model X + Y tricks/augmentations/preprocessing: start on just 10 classes and submit to LB. </p>\n<p>Then train the same pipeline (no transfer learning, train again) on 15 classes, resubmit-is there an improvement? Yes, then that means the idea works and ideally, this would really speed up the iteration speed compared to training on a large number of classes.</p>\n<p>This is again a small suggestion to change your iteration speed from training on complete dataset to the speed required to train on subsets. </p>",
          "rawMarkdown": "Thank you!\n\nActually, maybe I didn't I explain it well-I'm not suggesting doing transfer learning with the weights. \n\nI was envisioning this:\n\nLet's say I want to try model X + Y tricks/augmentations/preprocessing: start on just 10 classes and submit to LB. \n\nThen train the same pipeline (no transfer learning, train again) on 15 classes, resubmit-is there an improvement? Yes, then that means the idea works and ideally, this would really speed up the iteration speed compared to training on a large number of classes.\n\nThis is again a small suggestion to change your iteration speed from training on complete dataset to the speed required to train on subsets. ",
          "votes": 3
        },
        {
          "id": 1712515,
          "postDate": "2022-03-05T02:37:25.763Z",
          "content": "<p>Ahh now I get it, thanks for the explanation, I think I should apply this.</p>",
          "rawMarkdown": "Ahh now I get it, thanks for the explanation, I think I should apply this."
        }
      ]
    },
    {
      "id": 3213583,
      "postDate": "2025-05-30T07:52:40.070Z",
      "content": "<p>This is packed with practical gold. I love the tips on progressive resizing and FP16. It is super helpful for speeding up experimentation without sacrificing performance. Thanks for sharing this! </p>",
      "rawMarkdown": "This is packed with practical gold. I love the tips on progressive resizing and FP16. It is super helpful for speeding up experimentation without sacrificing performance. Thanks for sharing this! "
    },
    {
      "id": 3088500,
      "postDate": "2025-01-04T18:27:31.850Z",
      "content": "<p>How many data is augmented? I think if we augmented all, it could memorize instead of learning pattern, right?</p>",
      "rawMarkdown": "How many data is augmented? I think if we augmented all, it could memorize instead of learning pattern, right?"
    },
    {
      "id": 2512647,
      "postDate": "2023-11-04T18:08:02.290Z",
      "content": "<p>Useful Info. Thanks for sharing these highly informative points.</p>",
      "rawMarkdown": "Useful Info. Thanks for sharing these highly informative points."
    },
    {
      "id": 1943550,
      "postDate": "2022-09-17T15:35:57.097Z",
      "content": "<p>Thanks for sharing. It is very helpful !</p>",
      "rawMarkdown": "Thanks for sharing. It is very helpful !"
    },
    {
      "id": 1936530,
      "postDate": "2022-09-12T20:12:18.600Z",
      "content": "<p>Informative, I will apply in future.</p>",
      "rawMarkdown": "Informative, I will apply in future."
    },
    {
      "id": 1869398,
      "postDate": "2022-07-24T18:00:30.867Z",
      "content": "<p>Really useful tips, thanks for sharing !</p>",
      "rawMarkdown": "Really useful tips, thanks for sharing !"
    },
    {
      "id": 1725404,
      "postDate": "2022-03-17T04:25:26.800Z",
      "content": "<p>Thank you thank you so much for sharing it. Really Helpful!!!!</p>",
      "rawMarkdown": "Thank you thank you so much for sharing it. Really Helpful!!!!"
    },
    {
      "id": 1710695,
      "postDate": "2022-03-03T08:44:13.147Z",
      "content": "<p>Interesting post. Thanks for sharing..:)</p>",
      "rawMarkdown": "Interesting post. Thanks for sharing..:)"
    },
    {
      "id": 1710015,
      "postDate": "2022-03-02T17:42:22.677Z",
      "content": "<p>Thanks for sharing these tricks and tips , it will really help us <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> </p>",
      "rawMarkdown": "Thanks for sharing these tricks and tips , it will really help us @init27 "
    },
    {
      "id": 1709627,
      "postDate": "2022-03-02T11:28:31.367Z",
      "content": "<p>Interesting post. Thanks for sharing..:)</p>",
      "rawMarkdown": "Interesting post. Thanks for sharing..:)"
    },
    {
      "id": 1709023,
      "postDate": "2022-03-01T22:22:09.113Z",
      "content": "<p>Amazing tips!</p>",
      "rawMarkdown": "Amazing tips!"
    },
    {
      "id": 1708830,
      "postDate": "2022-03-01T18:25:55.707Z",
      "content": "<p>Thanks for sharing these tricks. <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> 👍</p>",
      "rawMarkdown": "Thanks for sharing these tricks. @init27 👍"
    },
    {
      "id": 1714033,
      "postDate": "2022-03-06T15:10:39.490Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 1710836,
      "postDate": "2022-03-03T11:38:40.353Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 3505915,
      "postDate": "2026-07-30T17:21:36.143Z",
      "content": "<p>Thanks for sharing</p>",
      "rawMarkdown": "Thanks for sharing"
    },
    {
      "id": 1720037,
      "postDate": "2022-03-12T12:02:25.700Z",
      "content": "<p>Thanks for sharing</p>",
      "rawMarkdown": "Thanks for sharing"
    },
    {
      "id": 1714303,
      "postDate": "2022-03-06T19:09:36.567Z",
      "content": "<p>Thanks for sharing</p>",
      "rawMarkdown": "Thanks for sharing"
    },
    {
      "id": 1713712,
      "postDate": "2022-03-06T09:58:12.683Z",
      "content": "<p>Thanks for sharing.</p>",
      "rawMarkdown": "Thanks for sharing."
    },
    {
      "id": 1712898,
      "postDate": "2022-03-05T13:12:05.007Z",
      "content": "<p>Thanks for sharing. </p>",
      "rawMarkdown": "Thanks for sharing. "
    },
    {
      "id": 1709597,
      "postDate": "2022-03-02T10:57:35.670Z",
      "content": "<p>Thanks for sharing! 💯</p>",
      "rawMarkdown": "Thanks for sharing! 💯"
    },
    {
      "id": 1709047,
      "postDate": "2022-03-01T22:56:43.927Z",
      "content": "<p>I learned a lot. Thank you!</p>",
      "rawMarkdown": "I learned a lot. Thank you!"
    },
    {
      "id": 1707530,
      "postDate": "2022-02-28T14:47:26.450Z",
      "content": "<p>Thanks for these tricks.</p>",
      "rawMarkdown": "Thanks for these tricks."
    }
  ],
  "comments": [
    {
      "id": 2185594,
      "author_name": "Yeakub Sadlil",
      "author_url": "",
      "post_date": "2023-03-17T07:18:03.950000",
      "content": "<p>Your observation is excellent <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> </p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 1709782,
      "author_name": "Subhendu",
      "author_url": "",
      "post_date": "2022-03-02T13:39:22.903000",
      "content": "<p>One more idea about <strong>Image Augmentations</strong> is that , you can also use <code>Image Augmentations</code> during inference. Its very helpful for Objcet Detection tasks. I have found that by using few variants of validation image and then combining all the predicted bouding boxes, I could extract much better results from the same model.  </p>",
      "votes": 1,
      "replies": [
        {
          "id": 1711492,
          "author_name": "DeepUnderstanding",
          "author_url": "",
          "post_date": "2022-03-04T03:43:33.687000",
          "content": "<p>I think you are referring to TTA(Test Time Augmentation). In my experiments TTA doesn't work every time, if your data is too noisy.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1707312,
      "author_name": "CroDoc",
      "author_url": "",
      "post_date": "2022-02-28T10:05:52.470000",
      "content": "<p>Nice work! I wish there more posts that share a lot of tricks in a single thread.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1711858,
          "author_name": "Sanyam Bhutani",
          "author_url": "",
          "post_date": "2022-03-04T11:30:58.810000",
          "content": "<p>Thank you, CroDoc! 🙏</p>\n<p>I've found many posts scattered across different competitions, I'll try my best to collect ideas like so or maybe even livestream with some chai if time permits. </p>\n<p>These tricks are however really simple compared to the incredible ones shared by Kagglers in competitions</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1711921,
          "author_name": "CroDoc",
          "author_url": "",
          "post_date": "2022-03-04T13:22:30.093000",
          "content": "<p>Ask <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> to be on Chai again and share the best general tricks for computer vision 🤓</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1711488,
      "author_name": "DeepUnderstanding",
      "author_url": "",
      "post_date": "2022-03-04T03:40:26.910000",
      "content": "<p>Great points <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a>  as always!<br>\nbut I am quite skeptical of your 2nd point, that is use less classes then use more. I don't think it is a good idea, I think it will confuse the model when we will introduce more number of classes later. <br>\nAlthough I am not sure, can you a bit describe  it more. Thanks</p>",
      "votes": 2,
      "replies": [
        {
          "id": 1711861,
          "author_name": "Sanyam Bhutani",
          "author_url": "",
          "post_date": "2022-03-04T11:36:06.833000",
          "content": "<p>Thank you!</p>\n<p>Actually, maybe I didn't I explain it well-I'm not suggesting doing transfer learning with the weights. </p>\n<p>I was envisioning this:</p>\n<p>Let's say I want to try model X + Y tricks/augmentations/preprocessing: start on just 10 classes and submit to LB. </p>\n<p>Then train the same pipeline (no transfer learning, train again) on 15 classes, resubmit-is there an improvement? Yes, then that means the idea works and ideally, this would really speed up the iteration speed compared to training on a large number of classes.</p>\n<p>This is again a small suggestion to change your iteration speed from training on complete dataset to the speed required to train on subsets. </p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 1712515,
          "author_name": "DeepUnderstanding",
          "author_url": "",
          "post_date": "2022-03-05T02:37:25.763000",
          "content": "<p>Ahh now I get it, thanks for the explanation, I think I should apply this.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 3213583,
      "author_name": "Cedric Ogiesoba-Eguakun",
      "author_url": "",
      "post_date": "2025-05-30T07:52:40.070000",
      "content": "<p>This is packed with practical gold. I love the tips on progressive resizing and FP16. It is super helpful for speeding up experimentation without sacrificing performance. Thanks for sharing this! </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3088500,
      "author_name": "Thomas Artemius",
      "author_url": "",
      "post_date": "2025-01-04T18:27:31.850000",
      "content": "<p>How many data is augmented? I think if we augmented all, it could memorize instead of learning pattern, right?</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2512647,
      "author_name": "Nithiyashree Venkatachalam Kannan",
      "author_url": "",
      "post_date": "2023-11-04T18:08:02.290000",
      "content": "<p>Useful Info. Thanks for sharing these highly informative points.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1943550,
      "author_name": "HanHungHsun",
      "author_url": "",
      "post_date": "2022-09-17T15:35:57.097000",
      "content": "<p>Thanks for sharing. It is very helpful !</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1936530,
      "author_name": "Ahsan Zafar Mehmood",
      "author_url": "",
      "post_date": "2022-09-12T20:12:18.600000",
      "content": "<p>Informative, I will apply in future.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1869398,
      "author_name": "Mehdi Elion",
      "author_url": "",
      "post_date": "2022-07-24T18:00:30.867000",
      "content": "<p>Really useful tips, thanks for sharing !</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1725404,
      "author_name": "Dev Khant",
      "author_url": "",
      "post_date": "2022-03-17T04:25:26.800000",
      "content": "<p>Thank you thank you so much for sharing it. Really Helpful!!!!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1710695,
      "author_name": "Nouran Elsayed(target)",
      "author_url": "",
      "post_date": "2022-03-03T08:44:13.147000",
      "content": "<p>Interesting post. Thanks for sharing..:)</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1710015,
      "author_name": "Fozan",
      "author_url": "",
      "post_date": "2022-03-02T17:42:22.677000",
      "content": "<p>Thanks for sharing these tricks and tips , it will really help us <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1709627,
      "author_name": "Aadil Hussain",
      "author_url": "",
      "post_date": "2022-03-02T11:28:31.367000",
      "content": "<p>Interesting post. Thanks for sharing..:)</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1709023,
      "author_name": "Junming Gao",
      "author_url": "",
      "post_date": "2022-03-01T22:22:09.113000",
      "content": "<p>Amazing tips!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1708830,
      "author_name": "Ishan Mehta115",
      "author_url": "",
      "post_date": "2022-03-01T18:25:55.707000",
      "content": "<p>Thanks for sharing these tricks. <a href=\"https://www.kaggle.com/init27\" target=\"_blank\">@init27</a> 👍</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1714033,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-03-06T15:10:39.490000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1710836,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-03-03T11:38:40.353000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3505915,
      "author_name": "bluebblll",
      "author_url": "",
      "post_date": "2026-07-30T17:21:36.143000",
      "content": "<p>Thanks for sharing</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1720037,
      "author_name": "cwh094",
      "author_url": "",
      "post_date": "2022-03-12T12:02:25.700000",
      "content": "<p>Thanks for sharing</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1714303,
      "author_name": "younis shaik",
      "author_url": "",
      "post_date": "2022-03-06T19:09:36.567000",
      "content": "<p>Thanks for sharing</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1713712,
      "author_name": "BoxuanZhang",
      "author_url": "",
      "post_date": "2022-03-06T09:58:12.683000",
      "content": "<p>Thanks for sharing.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1712898,
      "author_name": "İlker Kara",
      "author_url": "",
      "post_date": "2022-03-05T13:12:05.007000",
      "content": "<p>Thanks for sharing. </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1709597,
      "author_name": "Mạnh Đỗ",
      "author_url": "",
      "post_date": "2022-03-02T10:57:35.670000",
      "content": "<p>Thanks for sharing! 💯</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1709047,
      "author_name": "Moyashii",
      "author_url": "",
      "post_date": "2022-03-01T22:56:43.927000",
      "content": "<p>I learned a lot. Thank you!</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1707530,
      "author_name": "Artem Burenok",
      "author_url": "",
      "post_date": "2022-02-28T14:47:26.450000",
      "content": "<p>Thanks for these tricks.</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1706561": "Hello! \n\nI wanted to create a post sharing some general tips & suggestions that might help improve training speeds & accuracy, I have learned these via courses, reading top writeups, or papers, and plan to try all of these in this comp.\n\nWithout further ado:\n\n### 1. Start with Smaller Resolution:\n\nThe first two tips are focused on allowing faster prototyping-the more ideas you can try, the more chances you have to score better. To iterate faster, we need to start small to keep our training times small:\n\nAyush has kindly created a Datasets thread [here](https://www.kaggle.com/c/happy-whale-and-dolphin/discussion/309691) that points to all the datasets shared. Starting with a small dataset size allows you to iterate faster. \n\nSince you'll be working with smaller GPU memory usage, you can increase `batch_size` and also iterate faster. Once you're confident in your ideas and see consistent score improvements, you can scale to larger image sizes.\n\n### 2. Start with subsets of Data:\n\nContinuing with the previous line, you should start with just a small number of classes or examples and validate your training models there. \n\nEx: Train on 10 classes, check if it improves CV -> Submit\nScale idea to 20 classes, check CV, and submit again \n\nIf all goes well, train on the complete dataset.\n\n### 3. Use FP16 or Half-Precision Training:\n\nWho doesn't want up to 50% faster training? \n\nNVIDIA GPUs have Tensor-Cores which offer huge speedups when using \"Half-Precision\" Tensors. I have written a more detailed blog [here](https://hackernoon.com/rtx-2080ti-vs-gtx-1080ti-fastai-mixed-precision-training-comparisons-on-cifar-100-761d8f615d7f), the short version is to try using `fp_16` training to observe speedups on any GPU (and TPU!)\n\n### 4. Use TPUs:\n\nKaggle offers 20 hours of TPUs every week. TPUs have 8 cores, which allow your batch_sizes to be scaled by a factor of 8. This allows for much faster training and faster iteration. \n\nNote: I have recently discovered Hugging Face Accelerate which claims to give you easy workflow on TPUs with PyTorch too\n\n### 5. Progressive Resizing:\n\nThis idea IIRC was introduced in the Efficientnet papers and also taught in the fastai courses. \n\nChris Deotte has a fantastic [post](https://www.kaggle.com/c/siim-isic-melanoma-classification/discussion/160147) talking about CNN Input image sizes. [This](https://medium.com/analytics-vidhya/novel-techniques-to-win-an-image-classification-hackathon-part-2-e33bf0ad5fe6) blog teaches you how progressive resizing works in fastai. TL;DR:\n\n- Train model on size: small\n- Save weights and re-train model on larger image size\n- Save weights again and re-train on final image sizes\n\nThis process allows much faster convergence and better performance \n\n### 6. Experiment: Depthwise Convs instead of Regular Convs:\n\nI believe this [concept](https://paperswithcode.com/method/depthwise-convolution) was introduced in the MobileNet paper first and I saw it resurface in a recent discussion related to ConvNext architectures. Depthwise Convolutions have fewer filters and hence train faster. \n\n[See here](https://discuss.pytorch.org/t/how-to-modify-a-conv2d-to-depthwise-separable-convolution/15843/4) for some tips on making it work in PyTorch\n\n### 7. LR Scheduler:\n\nChanging your `learning_rate` during the training of your model:\n\nA slow lr takes too long and fast lr might not help your model converge, using this logic, we should use dynamic learning rates.\n\nThere are many schedulers that allow this: I would recommend using `fastai` and its `fine_tune()` or `fit_one_cycle()` function. See [here](https://forums.fast.ai/t/fine-tune-vs-fit-one-cycle/66029) for more details. \n\n### 8. LR Warmup:\n\nThis one is in-line with the previous one:\n\nFrom the paper, [\"Bag of Tricks\"](https://arxiv.org/pdf/1812.01187.pdf), one of the ticks highlights using LR warmup:\n\nWhen you start training a model, it has more \"randomness\" as it's just starting to learn features, hence starting with a smaller `learning_rate` first allows it to pick details, and later you can increase it to the expected schedule or value after the \"warmup\" epochs are done and your model has learned some details.\n\n### 9. Image Augmentations:\n\nNNs benefit from more data. A slight change in an image can really help a model improve its understanding of features inside of an image. \n\nUsing correct image augmentations can really help your model. I had posted a nb sharing fastai image augmentations tutorial, I will be sharing an updated one for this competition soon if it's helpful.\n\nChris Deotte in his recent [CTDS interview](https://www.youtube.com/watch?v=XXmujwhjyIo) shared some secrets. Qishen Ha, whose team had won the TF GBR competition also shared [some tips](https://www.youtube.com/watch?v=8e-EIilkvL0) of making these work\n\nTL;DR of both: Try a lot of experiments and try as many augmentations. Start with augmentations off and then add them one by one to see if your training improves. \n\nAlso, visualise results as you train models to make sure they're learning about the whales and not backgrounds!\n\nI have two more bonus suggestions for anyone that has read this far :) \n\n### Bonus Tip #1: Use Timm or Tfimm:\n\n[Timm](https://github.com/rwightman/pytorch-image-models) and [Tfimm](https://github.com/martinsbruveris/tensorflow-image-models), the latter being a TF-port of the former is a fantastic resource! Ross, posts almost all the cutting edge model weights along with *extremely* optimised training methods. I would highly recommend also spending time digging into their source code but at the least using the library is a solid suggestion for anyone working on CV problems\n\n### Bonus Tip #2: Use NGC Containers for Local training: \n\nI understand many people are using Kaggle kernels and Colab for training. However, if you've invested in local hardware, [Ross](https://twitter.com/wightmanr) had taught in a thread on Twitter that the [NGC Containers](https://catalog.ngc.nvidia.com) for PyTorch are very optimised and offer speedups\n\nI hope you find these helpful and also find some training or score boosts! :)\n\nHappy Kaggling!",
    "2185594": "Your observation is excellent @init27 ",
    "1709782": "One more idea about **Image Augmentations** is that , you can also use `Image Augmentations` during inference. Its very helpful for Objcet Detection tasks. I have found that by using few variants of validation image and then combining all the predicted bouding boxes, I could extract much better results from the same model.  ",
    "1707312": "Nice work! I wish there more posts that share a lot of tricks in a single thread.",
    "1711488": "Great points @init27  as always!\nbut I am quite skeptical of your 2nd point, that is use less classes then use more. I don't think it is a good idea, I think it will confuse the model when we will introduce more number of classes later. \nAlthough I am not sure, can you a bit describe  it more. Thanks",
    "3213583": "This is packed with practical gold. I love the tips on progressive resizing and FP16. It is super helpful for speeding up experimentation without sacrificing performance. Thanks for sharing this! ",
    "3088500": "How many data is augmented? I think if we augmented all, it could memorize instead of learning pattern, right?",
    "2512647": "Useful Info. Thanks for sharing these highly informative points.",
    "1943550": "Thanks for sharing. It is very helpful !",
    "1936530": "Informative, I will apply in future.",
    "1869398": "Really useful tips, thanks for sharing !",
    "1725404": "Thank you thank you so much for sharing it. Really Helpful!!!!",
    "1710695": "Interesting post. Thanks for sharing..:)",
    "1710015": "Thanks for sharing these tricks and tips , it will really help us @init27 ",
    "1709627": "Interesting post. Thanks for sharing..:)",
    "1709023": "Amazing tips!",
    "1708830": "Thanks for sharing these tricks. @init27 👍",
    "1714033": "",
    "1710836": "",
    "3505915": "Thanks for sharing",
    "1720037": "Thanks for sharing",
    "1714303": "Thanks for sharing",
    "1713712": "Thanks for sharing.",
    "1712898": "Thanks for sharing. ",
    "1709597": "Thanks for sharing! 💯",
    "1709047": "I learned a lot. Thank you!",
    "1707530": "Thanks for these tricks."
  }
}