{
  "id": 131865,
  "title": "Cutmix for single channel images?",
  "url": "/competitions/bengaliai-cv19/discussion/131865",
  "author_name": "",
  "post_date": "2020-02-22T08:06:48.486744Z",
  "votes": 2,
  "comment_count": 6,
  "views": 0,
  "content": "<p>i tried to use cutmix/mixup using code shared in this <a href=\"https://www.kaggle.com/c/bengaliai-cv19/discussion/126504\">POST</a> </p>\n\n<p>i tried mixup and it works fine for me,but when i tried mixup and cutmix all together i got this error : \n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2034058%2F6553d71008d94c2c23886b7884bc3a00%2Fcutmix.PNG?generation=1582358733604782&amp;alt=media\" alt=\"\"></p>\n\n<p>without changing CNN architecture,where to change in cutmix to make this work for single channel images? it would be highly appreciated if you share cutmix/mixup pytorch implementation for single channel images,thanks in advance.</p>\n\n<h1>Happy_kaggling :)</h1>",
  "messages": [
    {
      "id": "753460",
      "postDate": "02/22/2020 08:06:48",
      "content": "<p>i tried to use cutmix/mixup using code shared in this <a href=\"https://www.kaggle.com/c/bengaliai-cv19/discussion/126504\">POST</a> </p>\n\n<p>i tried mixup and it works fine for me,but when i tried mixup and cutmix all together i got this error : \n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2034058%2F6553d71008d94c2c23886b7884bc3a00%2Fcutmix.PNG?generation=1582358733604782&amp;alt=media\" alt=\"\"></p>\n\n<p>without changing CNN architecture,where to change in cutmix to make this work for single channel images? it would be highly appreciated if you share cutmix/mixup pytorch implementation for single channel images,thanks in advance.</p>\n\n<h1>Happy_kaggling :)</h1>",
      "rawMarkdown": "i tried to use cutmix/mixup using code shared in this [POST](https://www.kaggle.com/c/bengaliai-cv19/discussion/126504) \n\ni tried mixup and it works fine for me,but when i tried mixup and cutmix all together i got this error : \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2034058%2F6553d71008d94c2c23886b7884bc3a00%2Fcutmix.PNG?generation=1582358733604782&amp;alt=media)\n\nwithout changing CNN architecture,where to change in cutmix to make this work for single channel images? it would be highly appreciated if you share cutmix/mixup pytorch implementation for single channel images,thanks in advance.\n#Happy_kaggling :)",
      "votes": null
    },
    {
      "id": "753465",
      "postDate": "02/22/2020 08:12:39",
      "content": "<p>The input dimensions should be BxCxHxW, even in the case of 1 channel: Bx1xHxW. Check your input dimension, I think the channel dim is missing (BxHxW). In this case try something like this: <code>input = input.unsqueeze(1)</code>\nOr if input is ndarray instead of tensor:<code>input  = np.expand_dims(input, axis=1)</code></p>",
      "rawMarkdown": "The input dimensions should be BxCxHxW, even in the case of 1 channel: Bx1xHxW. Check your input dimension, I think the channel dim is missing (BxHxW). In this case try something like this: `input = input.unsqueeze(1)`\nOr if input is ndarray instead of tensor:`input  = np.expand_dims(input, axis=1)`",
      "votes": null
    },
    {
      "id": "753559",
      "postDate": "02/22/2020 11:10:27",
      "content": "<p>Hi <a href=\"/pestipeti\">@pestipeti</a> \nthank you for your reply,if you check the screenshot carefully you can see i have used this : \n<strong>outputs1,outputs2,outputs3 = model(inputs.unsqueeze(1).float())</strong></p>\n\n<p>but for mixup i don't get any error,i get error only for cutmix</p>",
      "rawMarkdown": "Hi @pestipeti \nthank you for your reply,if you check the screenshot carefully you can see i have used this : \n**outputs1,outputs2,outputs3 = model(inputs.unsqueeze(1).float())**\n\nbut for mixup i don't get any error,i get error only for cutmix",
      "votes": null
    },
    {
      "id": "753562",
      "postDate": "02/22/2020 11:17:38",
      "content": "<p>cutmix needs the proper dimensions as well, you have to do unsqueeze before cutmix.</p>",
      "rawMarkdown": "cutmix needs the proper dimensions as well, you have to do unsqueeze before cutmix.",
      "votes": null
    },
    {
      "id": "753581",
      "postDate": "02/22/2020 12:15:57",
      "content": "<p><a href=\"/pestipeti\">@pestipeti</a> thank you\ni will give it a try and will let you know</p>",
      "rawMarkdown": "pestipeti thank you\ni will give it a try and will let you know",
      "votes": null
    },
    {
      "id": "753776",
      "postDate": "02/22/2020 16:33:42",
      "content": "<p>it works <a href=\"/pestipeti\">@pestipeti</a> \nthank you a lot for your help</p>",
      "rawMarkdown": "it works @pestipeti \nthank you a lot for your help",
      "votes": null
    },
    {
      "id": "753781",
      "postDate": "02/22/2020 16:41:06",
      "content": "<p>You're welcome.</p>",
      "rawMarkdown": "You're welcome.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 753465,
      "author_name": "pestipeti",
      "author_url": "",
      "post_date": "02/22/2020 08:12:39",
      "content": "<p>The input dimensions should be BxCxHxW, even in the case of 1 channel: Bx1xHxW. Check your input dimension, I think the channel dim is missing (BxHxW). In this case try something like this: <code>input = input.unsqueeze(1)</code>\nOr if input is ndarray instead of tensor:<code>input  = np.expand_dims(input, axis=1)</code></p>",
      "votes": null,
      "replies": [
        {
          "id": 753559,
          "author_name": "mobassir",
          "author_url": "",
          "post_date": "02/22/2020 11:10:27",
          "content": "<p>Hi <a href=\"/pestipeti\">@pestipeti</a> \nthank you for your reply,if you check the screenshot carefully you can see i have used this : \n<strong>outputs1,outputs2,outputs3 = model(inputs.unsqueeze(1).float())</strong></p>\n\n<p>but for mixup i don't get any error,i get error only for cutmix</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 753562,
          "author_name": "pestipeti",
          "author_url": "",
          "post_date": "02/22/2020 11:17:38",
          "content": "<p>cutmix needs the proper dimensions as well, you have to do unsqueeze before cutmix.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 753581,
          "author_name": "mobassir",
          "author_url": "",
          "post_date": "02/22/2020 12:15:57",
          "content": "<p><a href=\"/pestipeti\">@pestipeti</a> thank you\ni will give it a try and will let you know</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 753776,
          "author_name": "mobassir",
          "author_url": "",
          "post_date": "02/22/2020 16:33:42",
          "content": "<p>it works <a href=\"/pestipeti\">@pestipeti</a> \nthank you a lot for your help</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 753781,
          "author_name": "pestipeti",
          "author_url": "",
          "post_date": "02/22/2020 16:41:06",
          "content": "<p>You're welcome.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "753460": "i tried to use cutmix/mixup using code shared in this [POST](https://www.kaggle.com/c/bengaliai-cv19/discussion/126504) \n\ni tried mixup and it works fine for me,but when i tried mixup and cutmix all together i got this error : \n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2034058%2F6553d71008d94c2c23886b7884bc3a00%2Fcutmix.PNG?generation=1582358733604782&amp;alt=media)\n\nwithout changing CNN architecture,where to change in cutmix to make this work for single channel images? it would be highly appreciated if you share cutmix/mixup pytorch implementation for single channel images,thanks in advance.\n#Happy_kaggling :)",
    "753465": "The input dimensions should be BxCxHxW, even in the case of 1 channel: Bx1xHxW. Check your input dimension, I think the channel dim is missing (BxHxW). In this case try something like this: `input = input.unsqueeze(1)`\nOr if input is ndarray instead of tensor:`input  = np.expand_dims(input, axis=1)`",
    "753559": "Hi @pestipeti \nthank you for your reply,if you check the screenshot carefully you can see i have used this : \n**outputs1,outputs2,outputs3 = model(inputs.unsqueeze(1).float())**\n\nbut for mixup i don't get any error,i get error only for cutmix",
    "753562": "cutmix needs the proper dimensions as well, you have to do unsqueeze before cutmix.",
    "753581": "pestipeti thank you\ni will give it a try and will let you know",
    "753776": "it works @pestipeti \nthank you a lot for your help",
    "753781": "You're welcome."
  },
  "source": "meta"
}