{
  "id": 132935,
  "title": "How To - CutMix and MixUp on GPU/TPU",
  "url": "/competitions/flower-classification-with-tpus/discussion/132935",
  "author_name": "Chris Deotte",
  "post_date": "2020-02-28T20:14:20.143000",
  "votes": 73,
  "comment_count": 18,
  "views": 0,
  "content": "<h1>CutMix and MixUp Augmentation</h1>\n\n<p>I have posted a starter notebook <a href=\"https://www.kaggle.com/cdeotte/cutmix-and-mixup-on-gpu-tpu\">here</a> showing how to perform CutMix and MixUp on GPU/TPU using <code>TensorFlow.data.Dataset()</code>. Enjoy! \n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F999713370831a44bb5af627f96b42f76%2FScreen%20Shot%202020-02-28%20at%2012.09.49%20PM.png?generation=1582920604632237&amp;alt=media\" alt=\"\"></p>\n\n<h1>Data Augmentation</h1>\n\n<p>Data augmentation has repeatedly shown to improve model accuracy. Below is a list of some current literature on data augmentation techniques:</p>\n\n<h2>Basic - Flip, Rotation, Sheer, Zoom, Shift</h2>\n\n<p>Basic augmentation includes flipping, rotation, sheer, zoom, and shift. Starter notebook <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">here</a>. Next we can incorporate non-linear transformations like grid distortion and we can do color augmentation like brightness, contrast, hue, etc. See <a href=\"https://albumentations.readthedocs.io/en/latest/\">Albumentations</a> for ideas. </p>\n\n<h2>Cutout (Nov 2017)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1708.04552\">here</a>. Cutout randomly removes rectangular regions of the training images. It is similar to dropout. It teaches a network to use the entire image and not depend too much on certain regions or details in the image.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa75f1ff01f51be04efc3994511c14985%2FScreen%20Shot%202020-02-28%20at%2012.03.14%20PM.png?generation=1582920211872489&amp;alt=media\" alt=\"\"></p>\n\n<h2>Mixup (Apr 2018)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1710.09412\">here</a>. Mixup blends two images and their one hot encoded labels to create a new image. This helps a network generalize to the space of images they lie \"between\" the existing training images.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F0fd1c6f6c0d1b2c220748e1e8517dd42%2FScreen%20Shot%202020-02-28%20at%2012.04.14%20PM.png?generation=1582920270999369&amp;alt=media\" alt=\"\"></p>\n\n<h2>AutoAugment (Apr 2019)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1805.09501\">here</a>. List a variety of augmentation techniques. Use reinforcement learning to explore different combinations of augmentations and find the best.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa013e63820a9f2e5751fc954bd502561%2FScreen%20Shot%202020-02-28%20at%2012.05.08%20PM.png?generation=1582920325192602&amp;alt=media\" alt=\"\"></p>\n\n<h2>CutMix (Aug 2019)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1905.04899\">here</a>. This is cutout but we fill the blank rectangular space with a portion of another image. CutMix has the benefits of cutout (described above) and it expands the the space of images by creating new images (i.e. like a dog with a cat's head).\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa4d6d7b6132350ac39dbe5d3ce601b55%2FScreen%20Shot%202020-02-28%20at%2012.06.24%20PM.png?generation=1582920401462775&amp;alt=media\" alt=\"\"></p>\n\n<h2>AugMix (2020)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1912.02781\">here</a>. Randomly blend multiple images that have each been augmented themselves separately. And use a special consistency loss.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F2b79e1180f717408930554343b007881%2FScreen%20Shot%202020-02-28%20at%2012.07.34%20PM.png?generation=1582920469116799&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": 759268,
      "postDate": "2020-02-28T20:14:20.143Z",
      "content": "<h1>CutMix and MixUp Augmentation</h1>\n\n<p>I have posted a starter notebook <a href=\"https://www.kaggle.com/cdeotte/cutmix-and-mixup-on-gpu-tpu\">here</a> showing how to perform CutMix and MixUp on GPU/TPU using <code>TensorFlow.data.Dataset()</code>. Enjoy! \n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F999713370831a44bb5af627f96b42f76%2FScreen%20Shot%202020-02-28%20at%2012.09.49%20PM.png?generation=1582920604632237&amp;alt=media\" alt=\"\"></p>\n\n<h1>Data Augmentation</h1>\n\n<p>Data augmentation has repeatedly shown to improve model accuracy. Below is a list of some current literature on data augmentation techniques:</p>\n\n<h2>Basic - Flip, Rotation, Sheer, Zoom, Shift</h2>\n\n<p>Basic augmentation includes flipping, rotation, sheer, zoom, and shift. Starter notebook <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">here</a>. Next we can incorporate non-linear transformations like grid distortion and we can do color augmentation like brightness, contrast, hue, etc. See <a href=\"https://albumentations.readthedocs.io/en/latest/\">Albumentations</a> for ideas. </p>\n\n<h2>Cutout (Nov 2017)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1708.04552\">here</a>. Cutout randomly removes rectangular regions of the training images. It is similar to dropout. It teaches a network to use the entire image and not depend too much on certain regions or details in the image.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa75f1ff01f51be04efc3994511c14985%2FScreen%20Shot%202020-02-28%20at%2012.03.14%20PM.png?generation=1582920211872489&amp;alt=media\" alt=\"\"></p>\n\n<h2>Mixup (Apr 2018)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1710.09412\">here</a>. Mixup blends two images and their one hot encoded labels to create a new image. This helps a network generalize to the space of images they lie \"between\" the existing training images.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F0fd1c6f6c0d1b2c220748e1e8517dd42%2FScreen%20Shot%202020-02-28%20at%2012.04.14%20PM.png?generation=1582920270999369&amp;alt=media\" alt=\"\"></p>\n\n<h2>AutoAugment (Apr 2019)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1805.09501\">here</a>. List a variety of augmentation techniques. Use reinforcement learning to explore different combinations of augmentations and find the best.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa013e63820a9f2e5751fc954bd502561%2FScreen%20Shot%202020-02-28%20at%2012.05.08%20PM.png?generation=1582920325192602&amp;alt=media\" alt=\"\"></p>\n\n<h2>CutMix (Aug 2019)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1905.04899\">here</a>. This is cutout but we fill the blank rectangular space with a portion of another image. CutMix has the benefits of cutout (described above) and it expands the the space of images by creating new images (i.e. like a dog with a cat's head).\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa4d6d7b6132350ac39dbe5d3ce601b55%2FScreen%20Shot%202020-02-28%20at%2012.06.24%20PM.png?generation=1582920401462775&amp;alt=media\" alt=\"\"></p>\n\n<h2>AugMix (2020)</h2>\n\n<p>PDF <a href=\"https://arxiv.org/abs/1912.02781\">here</a>. Randomly blend multiple images that have each been augmented themselves separately. And use a special consistency loss.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F2b79e1180f717408930554343b007881%2FScreen%20Shot%202020-02-28%20at%2012.07.34%20PM.png?generation=1582920469116799&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "# CutMix and MixUp Augmentation\nI have posted a starter notebook [here][1] showing how to perform CutMix and MixUp on GPU/TPU using `TensorFlow.data.Dataset()`. Enjoy! \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F999713370831a44bb5af627f96b42f76%2FScreen%20Shot%202020-02-28%20at%2012.09.49%20PM.png?generation=1582920604632237&amp;alt=media)\n\n\n# Data Augmentation\nData augmentation has repeatedly shown to improve model accuracy. Below is a list of some current literature on data augmentation techniques:\n## Basic - Flip, Rotation, Sheer, Zoom, Shift\nBasic augmentation includes flipping, rotation, sheer, zoom, and shift. Starter notebook [here][2]. Next we can incorporate non-linear transformations like grid distortion and we can do color augmentation like brightness, contrast, hue, etc. See [Albumentations][8] for ideas. \n## Cutout (Nov 2017)\nPDF [here][3]. Cutout randomly removes rectangular regions of the training images. It is similar to dropout. It teaches a network to use the entire image and not depend too much on certain regions or details in the image.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa75f1ff01f51be04efc3994511c14985%2FScreen%20Shot%202020-02-28%20at%2012.03.14%20PM.png?generation=1582920211872489&amp;alt=media)\n\n\n## Mixup (Apr 2018)\nPDF [here][4]. Mixup blends two images and their one hot encoded labels to create a new image. This helps a network generalize to the space of images they lie \"between\" the existing training images.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F0fd1c6f6c0d1b2c220748e1e8517dd42%2FScreen%20Shot%202020-02-28%20at%2012.04.14%20PM.png?generation=1582920270999369&amp;alt=media)\n\n\n## AutoAugment (Apr 2019)\nPDF [here][5]. List a variety of augmentation techniques. Use reinforcement learning to explore different combinations of augmentations and find the best.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa013e63820a9f2e5751fc954bd502561%2FScreen%20Shot%202020-02-28%20at%2012.05.08%20PM.png?generation=1582920325192602&amp;alt=media)\n\n\n## CutMix (Aug 2019)\nPDF [here][6]. This is cutout but we fill the blank rectangular space with a portion of another image. CutMix has the benefits of cutout (described above) and it expands the the space of images by creating new images (i.e. like a dog with a cat's head).\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa4d6d7b6132350ac39dbe5d3ce601b55%2FScreen%20Shot%202020-02-28%20at%2012.06.24%20PM.png?generation=1582920401462775&amp;alt=media)\n\n\n## AugMix (2020)\nPDF [here][7]. Randomly blend multiple images that have each been augmented themselves separately. And use a special consistency loss.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F2b79e1180f717408930554343b007881%2FScreen%20Shot%202020-02-28%20at%2012.07.34%20PM.png?generation=1582920469116799&amp;alt=media)\n\n\n[1]: https://www.kaggle.com/cdeotte/cutmix-and-mixup-on-gpu-tpu\n[2]: https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\n[3]: https://arxiv.org/abs/1708.04552\n[4]: https://arxiv.org/abs/1710.09412\n[5]: https://arxiv.org/abs/1805.09501\n[6]: https://arxiv.org/abs/1905.04899\n[7]: https://arxiv.org/abs/1912.02781\n[8]: https://albumentations.readthedocs.io/en/latest/",
      "votes": 72
    },
    {
      "id": 772436,
      "postDate": "2020-03-15T13:42:11.250Z",
      "content": "<p>Great work!</p>",
      "rawMarkdown": "Great work!",
      "votes": 3
    },
    {
      "id": 765422,
      "postDate": "2020-03-06T16:01:37.773Z",
      "content": "<p>What I always liked in Chris that he always dives deep into the thing, trying not only understand <strong>how</strong> it works, but also understand <strong>why</strong> it works.</p>",
      "rawMarkdown": "What I always liked in Chris that he always dives deep into the thing, trying not only understand **how** it works, but also understand **why** it works.",
      "votes": 1,
      "replies": [
        {
          "id": 765473,
          "postDate": "2020-03-06T16:57:08.953Z",
          "content": "<p>Thanks Roman</p>",
          "rawMarkdown": "Thanks Roman"
        }
      ]
    },
    {
      "id": 760160,
      "postDate": "2020-02-29T23:13:03.683Z",
      "content": "<p>great dude</p>",
      "rawMarkdown": "great dude",
      "votes": 1
    },
    {
      "id": 759405,
      "postDate": "2020-02-29T02:00:55.243Z",
      "content": "<p>Now, this is amazing ! Thank you.</p>",
      "rawMarkdown": "Now, this is amazing ! Thank you.",
      "votes": 1
    },
    {
      "id": 759286,
      "postDate": "2020-02-28T20:59:31.947Z",
      "content": "<p>Oddsome topic (even with my poor knowledge I can appreciate it).</p>",
      "rawMarkdown": "Oddsome topic (even with my poor knowledge I can appreciate it).",
      "votes": 1
    },
    {
      "id": 1265698,
      "postDate": "2021-04-07T06:17:55.943Z",
      "content": "<p>is amazing</p>",
      "rawMarkdown": " is amazing"
    },
    {
      "id": 1076156,
      "postDate": "2020-11-12T09:45:22.700Z",
      "content": "<p>Thanks for such an awesome explanation. I have a query.. In medical data like chest Xray data, is it an good idea to add cutmix or augmix? </p>",
      "rawMarkdown": "Thanks for such an awesome explanation. I have a query.. In medical data like chest Xray data, is it an good idea to add cutmix or augmix? "
    },
    {
      "id": 843805,
      "postDate": "2020-05-12T09:18:39.930Z",
      "content": "<p>Thanks for sharing this! This was one of the highlights of this competition for me, I didn't know about those augmentation methods. </p>",
      "rawMarkdown": "Thanks for sharing this! This was one of the highlights of this competition for me, I didn't know about those augmentation methods. "
    },
    {
      "id": 777781,
      "postDate": "2020-03-17T23:46:20.387Z",
      "content": "<p>I tried using your cutmix implementation but instead train a network once and not in a cross validation way but I get memory error. What would be the problem in this situation ?</p>",
      "rawMarkdown": "I tried using your cutmix implementation but instead train a network once and not in a cross validation way but I get memory error. What would be the problem in this situation ?",
      "replies": [
        {
          "id": 777809,
          "postDate": "2020-03-18T00:45:39.610Z",
          "content": "<p>Are you using TPU or GPU? If GPU you can change the variable in code cell 3. Reduce the <code>AUG_BATCH</code> by 2. That will use less CPU RAM. If TPU, i'm surprised you have memory error.</p>\n\n<pre><code>AUG_BATCH = BATCH_SIZE//2\n</code></pre>\n\n<p>Also consider lower your <code>BATCH_SIZE</code></p>",
          "rawMarkdown": "Are you using TPU or GPU? If GPU you can change the variable in code cell 3. Reduce the `AUG_BATCH` by 2. That will use less CPU RAM. If TPU, i'm surprised you have memory error.\n\n    AUG_BATCH = BATCH_SIZE//2\n\nAlso consider lower your `BATCH_SIZE`"
        },
        {
          "id": 777812,
          "postDate": "2020-03-18T00:52:20.713Z",
          "content": "<p>No, its tpu. I am using the same batch size and aug batch which is 128.</p>",
          "rawMarkdown": "No, its tpu. I am using the same batch size and aug batch which is 128."
        },
        {
          "id": 777822,
          "postDate": "2020-03-18T01:10:45.207Z",
          "content": "<p>Ok interesting. Still try my suggestions above. Try reducing <code>AUG_BATCH</code> and/or <code>BATCH_SIZE</code>. <code>AUG_BATCH</code> is batch size for CutMix and <code>BATCH_SIZE</code> is batch size for CNN training. Augmentation occurs in TPU's CPU RAM. When i get time, i'll run the code and experiment more.</p>",
          "rawMarkdown": "Ok interesting. Still try my suggestions above. Try reducing `AUG_BATCH` and/or `BATCH_SIZE`. `AUG_BATCH` is batch size for CutMix and `BATCH_SIZE` is batch size for CNN training. Augmentation occurs in TPU's CPU RAM. When i get time, i'll run the code and experiment more.",
          "votes": 1
        },
        {
          "id": 796951,
          "postDate": "2020-04-04T05:38:50.833Z",
          "content": "<p>The problem was fixed after applying mixed precision training, i was able to train using 128 batch size using tpu. I was wondering though what is <code>AUG_BATCH</code> really for and what effect If i set it to be half the size of <code>BATCH_SIZE</code> ? </p>",
          "rawMarkdown": "The problem was fixed after applying mixed precision training, i was able to train using 128 batch size using tpu. I was wondering though what is ```AUG_BATCH``` really for and what effect If i set it to be half the size of ```BATCH_SIZE``` ? "
        }
      ]
    },
    {
      "id": 829896,
      "postDate": "2020-05-02T06:46:50.313Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 809115,
      "postDate": "2020-04-15T21:39:56.593Z",
      "rawMarkdown": "",
      "votes": 1,
      "isDeleted": true
    },
    {
      "id": 759803,
      "postDate": "2020-02-29T13:36:32.697Z",
      "content": "<p>Now, this is amazing ! Thank you.</p>",
      "rawMarkdown": "Now, this is amazing ! Thank you.\n\n",
      "votes": 1
    },
    {
      "id": 1126774,
      "postDate": "2020-12-25T23:19:39.070Z",
      "content": "<p>Thanks for the Great Explanation </p>",
      "rawMarkdown": "Thanks for the Great Explanation "
    }
  ],
  "comments": [
    {
      "id": 772436,
      "author_name": "podsyp",
      "author_url": "",
      "post_date": "2020-03-15T13:42:11.250000",
      "content": "<p>Great work!</p>",
      "votes": 3,
      "replies": []
    },
    {
      "id": 765422,
      "author_name": "Roman",
      "author_url": "",
      "post_date": "2020-03-06T16:01:37.773000",
      "content": "<p>What I always liked in Chris that he always dives deep into the thing, trying not only understand <strong>how</strong> it works, but also understand <strong>why</strong> it works.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 765473,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2020-03-06T16:57:08.953000",
          "content": "<p>Thanks Roman</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 760160,
      "author_name": "AmoP",
      "author_url": "",
      "post_date": "2020-02-29T23:13:03.683000",
      "content": "<p>great dude</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 759405,
      "author_name": "Martin Görner",
      "author_url": "",
      "post_date": "2020-02-29T02:00:55.243000",
      "content": "<p>Now, this is amazing ! Thank you.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 759286,
      "author_name": "Marília Prata",
      "author_url": "",
      "post_date": "2020-02-28T20:59:31.947000",
      "content": "<p>Oddsome topic (even with my poor knowledge I can appreciate it).</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1265698,
      "author_name": "dayoneistoday",
      "author_url": "",
      "post_date": "2021-04-07T06:17:55.943000",
      "content": "<p>is amazing</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1076156,
      "author_name": "Ritacheta Das",
      "author_url": "",
      "post_date": "2020-11-12T09:45:22.700000",
      "content": "<p>Thanks for such an awesome explanation. I have a query.. In medical data like chest Xray data, is it an good idea to add cutmix or augmix? </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 843805,
      "author_name": "Nicolas Petitclerc",
      "author_url": "",
      "post_date": "2020-05-12T09:18:39.930000",
      "content": "<p>Thanks for sharing this! This was one of the highlights of this competition for me, I didn't know about those augmentation methods. </p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 777781,
      "author_name": "Ibrahim Sherif",
      "author_url": "",
      "post_date": "2020-03-17T23:46:20.387000",
      "content": "<p>I tried using your cutmix implementation but instead train a network once and not in a cross validation way but I get memory error. What would be the problem in this situation ?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 777809,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2020-03-18T00:45:39.610000",
          "content": "<p>Are you using TPU or GPU? If GPU you can change the variable in code cell 3. Reduce the <code>AUG_BATCH</code> by 2. That will use less CPU RAM. If TPU, i'm surprised you have memory error.</p>\n\n<pre><code>AUG_BATCH = BATCH_SIZE//2\n</code></pre>\n\n<p>Also consider lower your <code>BATCH_SIZE</code></p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 777812,
          "author_name": "Ibrahim Sherif",
          "author_url": "",
          "post_date": "2020-03-18T00:52:20.713000",
          "content": "<p>No, its tpu. I am using the same batch size and aug batch which is 128.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 777822,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2020-03-18T01:10:45.207000",
          "content": "<p>Ok interesting. Still try my suggestions above. Try reducing <code>AUG_BATCH</code> and/or <code>BATCH_SIZE</code>. <code>AUG_BATCH</code> is batch size for CutMix and <code>BATCH_SIZE</code> is batch size for CNN training. Augmentation occurs in TPU's CPU RAM. When i get time, i'll run the code and experiment more.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 796951,
          "author_name": "Ibrahim Sherif",
          "author_url": "",
          "post_date": "2020-04-04T05:38:50.833000",
          "content": "<p>The problem was fixed after applying mixed precision training, i was able to train using 128 batch size using tpu. I was wondering though what is <code>AUG_BATCH</code> really for and what effect If i set it to be half the size of <code>BATCH_SIZE</code> ? </p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 829896,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-05-02T06:46:50.313000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 809115,
      "author_name": "",
      "author_url": "",
      "post_date": "2020-04-15T21:39:56.593000",
      "content": "",
      "votes": 1,
      "replies": []
    },
    {
      "id": 759803,
      "author_name": "Salih ACUR",
      "author_url": "",
      "post_date": "2020-02-29T13:36:32.697000",
      "content": "<p>Now, this is amazing ! Thank you.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1126774,
      "author_name": "Omar Zaghlol",
      "author_url": "",
      "post_date": "2020-12-25T23:19:39.070000",
      "content": "<p>Thanks for the Great Explanation </p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "759268": "# CutMix and MixUp Augmentation\nI have posted a starter notebook [here][1] showing how to perform CutMix and MixUp on GPU/TPU using `TensorFlow.data.Dataset()`. Enjoy! \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F999713370831a44bb5af627f96b42f76%2FScreen%20Shot%202020-02-28%20at%2012.09.49%20PM.png?generation=1582920604632237&amp;alt=media)\n\n\n# Data Augmentation\nData augmentation has repeatedly shown to improve model accuracy. Below is a list of some current literature on data augmentation techniques:\n## Basic - Flip, Rotation, Sheer, Zoom, Shift\nBasic augmentation includes flipping, rotation, sheer, zoom, and shift. Starter notebook [here][2]. Next we can incorporate non-linear transformations like grid distortion and we can do color augmentation like brightness, contrast, hue, etc. See [Albumentations][8] for ideas. \n## Cutout (Nov 2017)\nPDF [here][3]. Cutout randomly removes rectangular regions of the training images. It is similar to dropout. It teaches a network to use the entire image and not depend too much on certain regions or details in the image.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa75f1ff01f51be04efc3994511c14985%2FScreen%20Shot%202020-02-28%20at%2012.03.14%20PM.png?generation=1582920211872489&amp;alt=media)\n\n\n## Mixup (Apr 2018)\nPDF [here][4]. Mixup blends two images and their one hot encoded labels to create a new image. This helps a network generalize to the space of images they lie \"between\" the existing training images.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F0fd1c6f6c0d1b2c220748e1e8517dd42%2FScreen%20Shot%202020-02-28%20at%2012.04.14%20PM.png?generation=1582920270999369&amp;alt=media)\n\n\n## AutoAugment (Apr 2019)\nPDF [here][5]. List a variety of augmentation techniques. Use reinforcement learning to explore different combinations of augmentations and find the best.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa013e63820a9f2e5751fc954bd502561%2FScreen%20Shot%202020-02-28%20at%2012.05.08%20PM.png?generation=1582920325192602&amp;alt=media)\n\n\n## CutMix (Aug 2019)\nPDF [here][6]. This is cutout but we fill the blank rectangular space with a portion of another image. CutMix has the benefits of cutout (described above) and it expands the the space of images by creating new images (i.e. like a dog with a cat's head).\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2Fa4d6d7b6132350ac39dbe5d3ce601b55%2FScreen%20Shot%202020-02-28%20at%2012.06.24%20PM.png?generation=1582920401462775&amp;alt=media)\n\n\n## AugMix (2020)\nPDF [here][7]. Randomly blend multiple images that have each been augmented themselves separately. And use a special consistency loss.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1723677%2F2b79e1180f717408930554343b007881%2FScreen%20Shot%202020-02-28%20at%2012.07.34%20PM.png?generation=1582920469116799&amp;alt=media)\n\n\n[1]: https://www.kaggle.com/cdeotte/cutmix-and-mixup-on-gpu-tpu\n[2]: https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\n[3]: https://arxiv.org/abs/1708.04552\n[4]: https://arxiv.org/abs/1710.09412\n[5]: https://arxiv.org/abs/1805.09501\n[6]: https://arxiv.org/abs/1905.04899\n[7]: https://arxiv.org/abs/1912.02781\n[8]: https://albumentations.readthedocs.io/en/latest/",
    "772436": "Great work!",
    "765422": "What I always liked in Chris that he always dives deep into the thing, trying not only understand **how** it works, but also understand **why** it works.",
    "760160": "great dude",
    "759405": "Now, this is amazing ! Thank you.",
    "759286": "Oddsome topic (even with my poor knowledge I can appreciate it).",
    "1265698": " is amazing",
    "1076156": "Thanks for such an awesome explanation. I have a query.. In medical data like chest Xray data, is it an good idea to add cutmix or augmix? ",
    "843805": "Thanks for sharing this! This was one of the highlights of this competition for me, I didn't know about those augmentation methods. ",
    "777781": "I tried using your cutmix implementation but instead train a network once and not in a cross validation way but I get memory error. What would be the problem in this situation ?",
    "829896": "",
    "809115": "",
    "759803": "Now, this is amazing ! Thank you.\n\n",
    "1126774": "Thanks for the Great Explanation "
  }
}