{
  "id": 173057,
  "title": "Noise augmentation problem",
  "url": "/competitions/birdsong-recognition/discussion/173057",
  "author_name": "Araik Tamazian",
  "post_date": "2020-08-07T16:57:57.680000",
  "votes": 1,
  "comment_count": 7,
  "views": 0,
  "content": "<p>I have a problem of adding a noise augmentation to the <a href=\"https://www.kaggle.com/ttahara/training-birdsong-baseline-resnest50-fast\">baseline model</a>. I've added data augmentation based on <a href=\"https://github.com/iver56/audiomentations\">audiomentations</a> library as following by this\n<code>\naugmenter = Compose([\n    AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=.5)\n])\n</code>\nand this\n```\ndef get_loaders_for_training(\n    args_dataset: tp.Dict, args_loader: tp.Dict,\n    train_file_list: tp.List[str], val_file_list: tp.List[str]\n):\n    # # make dataset\n    train_dataset = SpectrogramDataset(train_file_list, waveform_transforms=augmenter, **args_dataset)\n    val_dataset = SpectrogramDataset(val_file_list, **args_dataset)\n    # # make dataloader\n    train_loader = data.DataLoader(train_dataset, **args_loader[\"train\"])\n    val_loader = data.DataLoader(val_dataset, **args_loader[\"val\"])</p>\n\n<pre><code>return train_loader, val_loader\n</code></pre>\n\n<p>```</p>\n\n<p>However, I get the following error <code>RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 4700] at entry 0 and [3, 224, 2114] at entry 1</code>. \nCan anybody tell me why it isn't working?</p>",
  "messages": [
    {
      "id": 962299,
      "postDate": "2020-08-08T03:00:36.607Z",
      "content": "<p>FYI. Usually we are dealing with pink noise in nature. If your intention is to create realistic, lower SNR signals, you should add pink noise.</p>",
      "rawMarkdown": "FYI. Usually we are dealing with pink noise in nature. If your intention is to create realistic, lower SNR signals, you should add pink noise.",
      "votes": 6,
      "replies": [
        {
          "id": 962603,
          "postDate": "2020-08-08T09:12:01.493Z",
          "content": "<p>I see, thanks for your reply.</p>",
          "rawMarkdown": "I see, thanks for your reply."
        }
      ]
    },
    {
      "id": 962094,
      "postDate": "2020-08-07T19:50:20.140Z",
      "content": "<p>i had the same. I fix this with this np.array(sound) + noise</p>",
      "rawMarkdown": "i had the same. I fix this with this np.array(sound) + noise",
      "votes": 1,
      "replies": [
        {
          "id": 962112,
          "postDate": "2020-08-07T20:24:54.907Z",
          "content": "<p>Thanks, I'll try it.</p>",
          "rawMarkdown": "Thanks, I'll try it."
        },
        {
          "id": 962644,
          "postDate": "2020-08-08T10:04:49.590Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    },
    {
      "id": 961961,
      "postDate": "2020-08-07T16:57:57.680Z",
      "content": "<p>I have a problem of adding a noise augmentation to the <a href=\"https://www.kaggle.com/ttahara/training-birdsong-baseline-resnest50-fast\">baseline model</a>. I've added data augmentation based on <a href=\"https://github.com/iver56/audiomentations\">audiomentations</a> library as following by this\n<code>\naugmenter = Compose([\n    AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=.5)\n])\n</code>\nand this\n```\ndef get_loaders_for_training(\n    args_dataset: tp.Dict, args_loader: tp.Dict,\n    train_file_list: tp.List[str], val_file_list: tp.List[str]\n):\n    # # make dataset\n    train_dataset = SpectrogramDataset(train_file_list, waveform_transforms=augmenter, **args_dataset)\n    val_dataset = SpectrogramDataset(val_file_list, **args_dataset)\n    # # make dataloader\n    train_loader = data.DataLoader(train_dataset, **args_loader[\"train\"])\n    val_loader = data.DataLoader(val_dataset, **args_loader[\"val\"])</p>\n\n<pre><code>return train_loader, val_loader\n</code></pre>\n\n<p>```</p>\n\n<p>However, I get the following error <code>RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 4700] at entry 0 and [3, 224, 2114] at entry 1</code>. \nCan anybody tell me why it isn't working?</p>",
      "rawMarkdown": "I have a problem of adding a noise augmentation to the [baseline model](https://www.kaggle.com/ttahara/training-birdsong-baseline-resnest50-fast). I've added data augmentation based on [audiomentations](https://github.com/iver56/audiomentations) library as following by this\n```\naugmenter = Compose([\n    AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=.5)\n])\n```\nand this\n```\ndef get_loaders_for_training(\n    args_dataset: tp.Dict, args_loader: tp.Dict,\n    train_file_list: tp.List[str], val_file_list: tp.List[str]\n):\n    # # make dataset\n    train_dataset = SpectrogramDataset(train_file_list, waveform_transforms=augmenter, **args_dataset)\n    val_dataset = SpectrogramDataset(val_file_list, **args_dataset)\n    # # make dataloader\n    train_loader = data.DataLoader(train_dataset, **args_loader[\"train\"])\n    val_loader = data.DataLoader(val_dataset, **args_loader[\"val\"])\n    \n    return train_loader, val_loader\n```\n\nHowever, I get the following error `RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 4700] at entry 0 and [3, 224, 2114] at entry 1`. \nCan anybody tell me why it isn't working?",
      "votes": 1
    },
    {
      "id": 962017,
      "postDate": "2020-08-07T18:03:44.637Z",
      "content": "<p>your images are different sizes. The first one is of size 224x4700 in the RGB channels, and the second one is of size 224x2114 in the RGB channels. To solve this issue, the images need to be all the same size (eg all images could be 224x224, or whatever else size you want)</p>",
      "rawMarkdown": "your images are different sizes. The first one is of size 224x4700 in the RGB channels, and the second one is of size 224x2114 in the RGB channels. To solve this issue, the images need to be all the same size (eg all images could be 224x224, or whatever else size you want)",
      "votes": 2,
      "replies": [
        {
          "id": 962077,
          "postDate": "2020-08-07T19:25:08.330Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 962299,
      "author_name": "Holger Klinck",
      "author_url": "",
      "post_date": "2020-08-08T03:00:36.607000",
      "content": "<p>FYI. Usually we are dealing with pink noise in nature. If your intention is to create realistic, lower SNR signals, you should add pink noise.</p>",
      "votes": 6,
      "replies": [
        {
          "id": 962603,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2020-08-08T09:12:01.493000",
          "content": "<p>I see, thanks for your reply.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 962094,
      "author_name": "Manh Lab",
      "author_url": "",
      "post_date": "2020-08-07T19:50:20.140000",
      "content": "<p>i had the same. I fix this with this np.array(sound) + noise</p>",
      "votes": 1,
      "replies": [
        {
          "id": 962112,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2020-08-07T20:24:54.907000",
          "content": "<p>Thanks, I'll try it.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 962644,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-08-08T10:04:49.590000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 962017,
      "author_name": "CoreyJamesLevinson",
      "author_url": "",
      "post_date": "2020-08-07T18:03:44.637000",
      "content": "<p>your images are different sizes. The first one is of size 224x4700 in the RGB channels, and the second one is of size 224x2114 in the RGB channels. To solve this issue, the images need to be all the same size (eg all images could be 224x224, or whatever else size you want)</p>",
      "votes": 2,
      "replies": [
        {
          "id": 962077,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-08-07T19:25:08.330000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "962299": "FYI. Usually we are dealing with pink noise in nature. If your intention is to create realistic, lower SNR signals, you should add pink noise.",
    "962094": "i had the same. I fix this with this np.array(sound) + noise",
    "961961": "I have a problem of adding a noise augmentation to the [baseline model](https://www.kaggle.com/ttahara/training-birdsong-baseline-resnest50-fast). I've added data augmentation based on [audiomentations](https://github.com/iver56/audiomentations) library as following by this\n```\naugmenter = Compose([\n    AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=.5)\n])\n```\nand this\n```\ndef get_loaders_for_training(\n    args_dataset: tp.Dict, args_loader: tp.Dict,\n    train_file_list: tp.List[str], val_file_list: tp.List[str]\n):\n    # # make dataset\n    train_dataset = SpectrogramDataset(train_file_list, waveform_transforms=augmenter, **args_dataset)\n    val_dataset = SpectrogramDataset(val_file_list, **args_dataset)\n    # # make dataloader\n    train_loader = data.DataLoader(train_dataset, **args_loader[\"train\"])\n    val_loader = data.DataLoader(val_dataset, **args_loader[\"val\"])\n    \n    return train_loader, val_loader\n```\n\nHowever, I get the following error `RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 4700] at entry 0 and [3, 224, 2114] at entry 1`. \nCan anybody tell me why it isn't working?",
    "962017": "your images are different sizes. The first one is of size 224x4700 in the RGB channels, and the second one is of size 224x2114 in the RGB channels. To solve this issue, the images need to be all the same size (eg all images could be 224x224, or whatever else size you want)"
  }
}