{
  "id": 213065,
  "title": "Tensorflow beginner code for audio classification",
  "url": "/competitions/rfcx-species-audio-detection/discussion/213065",
  "author_name": "DimitreOliveira",
  "post_date": "2021-01-21T11:14:40.520000",
  "votes": 32,
  "comment_count": 18,
  "views": 0,
  "content": "<p>Hi everyone, I find that this competition could be a good opportunity to finally try to apply machine learning to audio data, there is already a lot of available public notebooks with very good scores, but even being familiar with deep learning and Tensorflow I was having a hard time to understand everything that was going on (sometimes Tensorflow does that). So I wrote a notebook that has the basics for audio classification with Tensorflow, putting everything together in a more organized way, and added documentation to some of the methods, you can find it here <a href=\"https://www.kaggle.com/dimitreoliveira/rainforest-audio-classification-tensorflow-starter/notebook\" target=\"_blank\">Rainforest - Audio classification Tensorflow starter</a></p>\n<p>I also made a workflow diagram to make things visual.</p>\n<pre><code>1. Load TFRecords\n2. Decode audio waveform\n3. Crop audio waveform\n4. Convert the waveform into spectrogram\n4. Resize spectrogram\n5. Turn grayscale spectrogram into RGB image\n6. Feed to the model\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2F473dfd70dd2d9e278dd5076310583766%2FRainforest%20diagram.jpg?generation=1611227361853675&amp;alt=media\" alt=\"\"></p>\n<hr>\n<h4>A few ideas for improvements</h4>\n<ul>\n<li>Add data augmentation</li>\n<li>Try different encoders (people seems to get good results with ResNet variants)</li>\n<li>Different losses</li>\n<li>Convert spectrogram to Mel-spectrogram</li>\n<li>Add more layers at the top of the encoder</li>\n<li>K-Fold</li>\n<li><a href=\"https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/200922\" target=\"_blank\">Better crop</a></li>\n<li>Some of the things discussed <a href=\"https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/208830\" target=\"_blank\">here</a></li>\n</ul>",
  "messages": [
    {
      "id": 1162825,
      "postDate": "2021-01-21T11:14:40.520Z",
      "content": "<p>Hi everyone, I find that this competition could be a good opportunity to finally try to apply machine learning to audio data, there is already a lot of available public notebooks with very good scores, but even being familiar with deep learning and Tensorflow I was having a hard time to understand everything that was going on (sometimes Tensorflow does that). So I wrote a notebook that has the basics for audio classification with Tensorflow, putting everything together in a more organized way, and added documentation to some of the methods, you can find it here <a href=\"https://www.kaggle.com/dimitreoliveira/rainforest-audio-classification-tensorflow-starter/notebook\" target=\"_blank\">Rainforest - Audio classification Tensorflow starter</a></p>\n<p>I also made a workflow diagram to make things visual.</p>\n<pre><code>1. Load TFRecords\n2. Decode audio waveform\n3. Crop audio waveform\n4. Convert the waveform into spectrogram\n4. Resize spectrogram\n5. Turn grayscale spectrogram into RGB image\n6. Feed to the model\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2F473dfd70dd2d9e278dd5076310583766%2FRainforest%20diagram.jpg?generation=1611227361853675&amp;alt=media\" alt=\"\"></p>\n<hr>\n<h4>A few ideas for improvements</h4>\n<ul>\n<li>Add data augmentation</li>\n<li>Try different encoders (people seems to get good results with ResNet variants)</li>\n<li>Different losses</li>\n<li>Convert spectrogram to Mel-spectrogram</li>\n<li>Add more layers at the top of the encoder</li>\n<li>K-Fold</li>\n<li><a href=\"https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/200922\" target=\"_blank\">Better crop</a></li>\n<li>Some of the things discussed <a href=\"https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/208830\" target=\"_blank\">here</a></li>\n</ul>",
      "rawMarkdown": "Hi everyone, I find that this competition could be a good opportunity to finally try to apply machine learning to audio data, there is already a lot of available public notebooks with very good scores, but even being familiar with deep learning and Tensorflow I was having a hard time to understand everything that was going on (sometimes Tensorflow does that). So I wrote a notebook that has the basics for audio classification with Tensorflow, putting everything together in a more organized way, and added documentation to some of the methods, you can find it here [Rainforest - Audio classification Tensorflow starter](https://www.kaggle.com/dimitreoliveira/rainforest-audio-classification-tensorflow-starter/notebook)\n\nI also made a workflow diagram to make things visual.\n```\n1. Load TFRecords\n2. Decode audio waveform\n3. Crop audio waveform\n4. Convert the waveform into spectrogram\n4. Resize spectrogram\n5. Turn grayscale spectrogram into RGB image\n6. Feed to the model\n```\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2F473dfd70dd2d9e278dd5076310583766%2FRainforest%20diagram.jpg?generation=1611227361853675&alt=media)\n\n---\n\n#### A few ideas for improvements\n- Add data augmentation\n- Try different encoders (people seems to get good results with ResNet variants)\n- Different losses\n- Convert spectrogram to Mel-spectrogram\n- Add more layers at the top of the encoder\n- K-Fold\n- [Better crop](https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/200922)\n- Some of the things discussed [here](https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/208830)",
      "votes": 32
    },
    {
      "id": 1199859,
      "postDate": "2021-02-14T06:43:30.950Z",
      "content": "<p>Good work, Congrats! :) </p>",
      "rawMarkdown": "Good work, Congrats! :) ",
      "votes": 1
    },
    {
      "id": 1168308,
      "postDate": "2021-01-24T21:18:43.257Z",
      "content": "<p>Thank you for sharing the great Discussion and Notebook!<br>\nTheses are helpful for me!</p>",
      "rawMarkdown": "Thank you for sharing the great Discussion and Notebook!\nTheses are helpful for me!",
      "votes": 1
    },
    {
      "id": 1163681,
      "postDate": "2021-01-21T21:01:59.660Z",
      "content": "<p>That is a very nice chart made specifically for this competition :)</p>",
      "rawMarkdown": "That is a very nice chart made specifically for this competition :)",
      "votes": 1,
      "replies": [
        {
          "id": 1163696,
          "postDate": "2021-01-21T21:29:26.750Z",
          "content": "<p>Yeah <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> , figuring everything at a higher level just looking at Tensorflow code can be hard 😄</p>",
          "rawMarkdown": "Yeah @barnwellguy , figuring everything at a higher level just looking at Tensorflow code can be hard 😄",
          "votes": 1
        },
        {
          "id": 1163719,
          "postDate": "2021-01-21T22:01:30.583Z",
          "content": "<p>Yeah <a href=\"https://www.kaggle.com/dimitreoliveira\" target=\"_blank\">@dimitreoliveira</a> I strongly agree!  🔥</p>\n<p>Now that we have good image captioning tools to give a short introduction sentence for a picture.</p>\n<p>Why don't we have a code captioning tool to give big ideas of each chunk of code? <br>\n\"These ten lines are loading data\", <br>\n\"These twenty lines are training a NN\", <br>\n\"These thirty lines don't even possibly run.\"</p>\n<p>That would save tremendous amount of anxiety learning an unfamiliar piece of code.</p>",
          "rawMarkdown": "Yeah @dimitreoliveira I strongly agree!  🔥\n\nNow that we have good image captioning tools to give a short introduction sentence for a picture.\n\nWhy don't we have a code captioning tool to give big ideas of each chunk of code? \n\"These ten lines are loading data\", \n\"These twenty lines are training a NN\", \n\"These thirty lines don't even possibly run.\"\n\nThat would save tremendous amount of anxiety learning an unfamiliar piece of code.",
          "votes": 1
        },
        {
          "id": 1163796,
          "postDate": "2021-01-22T00:05:48.853Z",
          "content": "<p>I agree <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> , I usually lose myself going through PyTorch code.</p>\n<p>When I share public code, I try to use functions whenever I can, I also give them intuitive names and if needed a text docummentation, usually help even myself when I go through the code sometime later.</p>",
          "rawMarkdown": "I agree @barnwellguy , I usually lose myself going through PyTorch code.\n\nWhen I share public code, I try to use functions whenever I can, I also give them intuitive names and if needed a text docummentation, usually help even myself when I go through the code sometime later.",
          "votes": 2
        },
        {
          "id": 1168380,
          "postDate": "2021-01-24T22:54:18.727Z",
          "content": "<p>Hi <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> and <a href=\"https://www.kaggle.com/dimitreoliveira\" target=\"_blank\">@dimitreoliveira</a> </p>\n<p>There is a nice github repo which shows the codes with the explanations by side. It's not a tool but very useful. <a href=\"https://github.com/lab-ml/nn\" target=\"_blank\">https://github.com/lab-ml/nn</a></p>",
          "rawMarkdown": "Hi @barnwellguy and @dimitreoliveira \n\nThere is a nice github repo which shows the codes with the explanations by side. It's not a tool but very useful. [https://github.com/lab-ml/nn](https://github.com/lab-ml/nn)",
          "votes": 1
        },
        {
          "id": 1168466,
          "postDate": "2021-01-25T00:44:01.490Z",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/snnclsr\" target=\"_blank\">@snnclsr</a> , that is a very useful repo, I can only imagine how hard was to build that.</p>",
          "rawMarkdown": "Thanks @snnclsr , that is a very useful repo, I can only imagine how hard was to build that."
        }
      ]
    },
    {
      "id": 1163237,
      "postDate": "2021-01-21T15:50:56.253Z",
      "content": "<p>Thanks for sharing, I was looking out for a notebook for beginners to get started in this competition.</p>",
      "rawMarkdown": "Thanks for sharing, I was looking out for a notebook for beginners to get started in this competition.",
      "votes": 1,
      "replies": [
        {
          "id": 1163697,
          "postDate": "2021-01-21T21:30:15.467Z",
          "content": "<p>Nice <a href=\"https://www.kaggle.com/sajidhussain3\" target=\"_blank\">@sajidhussain3</a> , note that this is just a weak baseline, the idea is to get you familiar with the basics of audio classification, and how to use Tensorflow for this task.</p>",
          "rawMarkdown": "Nice @sajidhussain3 , note that this is just a weak baseline, the idea is to get you familiar with the basics of audio classification, and how to use Tensorflow for this task.",
          "votes": 1
        }
      ]
    },
    {
      "id": 2581845,
      "postDate": "2024-01-01T06:30:11.327Z",
      "content": "<p>valuable information</p>",
      "rawMarkdown": "valuable information"
    },
    {
      "id": 1163238,
      "postDate": "2021-01-21T15:50:56.253Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 1162878,
      "postDate": "2021-01-21T11:43:45.377Z",
      "rawMarkdown": "",
      "votes": -1,
      "isDeleted": true
    },
    {
      "id": 1177173,
      "postDate": "2021-01-30T05:44:53.850Z",
      "content": "<p>Thanks for sharing. :)</p>",
      "rawMarkdown": "Thanks for sharing. :)",
      "votes": 1
    },
    {
      "id": 1172683,
      "postDate": "2021-01-27T13:53:13.967Z",
      "content": "<p>Thanks for sharing :D</p>",
      "rawMarkdown": "Thanks for sharing :D",
      "votes": 1
    },
    {
      "id": 1171333,
      "postDate": "2021-01-26T19:22:27.633Z",
      "content": "<p>Thanks for sharing!</p>",
      "rawMarkdown": "Thanks for sharing!",
      "votes": 1
    },
    {
      "id": 1162837,
      "postDate": "2021-01-21T11:23:03.647Z",
      "content": "<p>Great work, Thank you!!🙌</p>",
      "rawMarkdown": "Great work, Thank you!!🙌",
      "votes": 1
    },
    {
      "id": 2984092,
      "postDate": "2024-09-09T11:22:26.243Z",
      "content": "<p>thanks to you. I really appreciate</p>",
      "rawMarkdown": "thanks to you. I really appreciate"
    }
  ],
  "comments": [
    {
      "id": 1199859,
      "author_name": "Miguel Angel Velazquez Romero",
      "author_url": "",
      "post_date": "2021-02-14T06:43:30.950000",
      "content": "<p>Good work, Congrats! :) </p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1168308,
      "author_name": "ANZ",
      "author_url": "",
      "post_date": "2021-01-24T21:18:43.257000",
      "content": "<p>Thank you for sharing the great Discussion and Notebook!<br>\nTheses are helpful for me!</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1163681,
      "author_name": "Buffalo Spdwy",
      "author_url": "",
      "post_date": "2021-01-21T21:01:59.660000",
      "content": "<p>That is a very nice chart made specifically for this competition :)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1163696,
          "author_name": "DimitreOliveira",
          "author_url": "",
          "post_date": "2021-01-21T21:29:26.750000",
          "content": "<p>Yeah <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> , figuring everything at a higher level just looking at Tensorflow code can be hard 😄</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1163719,
          "author_name": "Buffalo Spdwy",
          "author_url": "",
          "post_date": "2021-01-21T22:01:30.583000",
          "content": "<p>Yeah <a href=\"https://www.kaggle.com/dimitreoliveira\" target=\"_blank\">@dimitreoliveira</a> I strongly agree!  🔥</p>\n<p>Now that we have good image captioning tools to give a short introduction sentence for a picture.</p>\n<p>Why don't we have a code captioning tool to give big ideas of each chunk of code? <br>\n\"These ten lines are loading data\", <br>\n\"These twenty lines are training a NN\", <br>\n\"These thirty lines don't even possibly run.\"</p>\n<p>That would save tremendous amount of anxiety learning an unfamiliar piece of code.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1163796,
          "author_name": "DimitreOliveira",
          "author_url": "",
          "post_date": "2021-01-22T00:05:48.853000",
          "content": "<p>I agree <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> , I usually lose myself going through PyTorch code.</p>\n<p>When I share public code, I try to use functions whenever I can, I also give them intuitive names and if needed a text docummentation, usually help even myself when I go through the code sometime later.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1168380,
          "author_name": "Sinan Calisir",
          "author_url": "",
          "post_date": "2021-01-24T22:54:18.727000",
          "content": "<p>Hi <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> and <a href=\"https://www.kaggle.com/dimitreoliveira\" target=\"_blank\">@dimitreoliveira</a> </p>\n<p>There is a nice github repo which shows the codes with the explanations by side. It's not a tool but very useful. <a href=\"https://github.com/lab-ml/nn\" target=\"_blank\">https://github.com/lab-ml/nn</a></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1168466,
          "author_name": "DimitreOliveira",
          "author_url": "",
          "post_date": "2021-01-25T00:44:01.490000",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/snnclsr\" target=\"_blank\">@snnclsr</a> , that is a very useful repo, I can only imagine how hard was to build that.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1163237,
      "author_name": "Sajid Hussain",
      "author_url": "",
      "post_date": "2021-01-21T15:50:56.253000",
      "content": "<p>Thanks for sharing, I was looking out for a notebook for beginners to get started in this competition.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1163697,
          "author_name": "DimitreOliveira",
          "author_url": "",
          "post_date": "2021-01-21T21:30:15.467000",
          "content": "<p>Nice <a href=\"https://www.kaggle.com/sajidhussain3\" target=\"_blank\">@sajidhussain3</a> , note that this is just a weak baseline, the idea is to get you familiar with the basics of audio classification, and how to use Tensorflow for this task.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2581845,
      "author_name": "Sumit Kumar Singh",
      "author_url": "",
      "post_date": "2024-01-01T06:30:11.327000",
      "content": "<p>valuable information</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1163238,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-01-21T15:50:56.253000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1162878,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-01-21T11:43:45.377000",
      "content": "",
      "votes": -1,
      "replies": []
    },
    {
      "id": 1177173,
      "author_name": "Aman Goyal",
      "author_url": "",
      "post_date": "2021-01-30T05:44:53.850000",
      "content": "<p>Thanks for sharing. :)</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1172683,
      "author_name": "Michael Jackson",
      "author_url": "",
      "post_date": "2021-01-27T13:53:13.967000",
      "content": "<p>Thanks for sharing :D</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1171333,
      "author_name": "rtldr5",
      "author_url": "",
      "post_date": "2021-01-26T19:22:27.633000",
      "content": "<p>Thanks for sharing!</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 1162837,
      "author_name": "Ankush kuwar",
      "author_url": "",
      "post_date": "2021-01-21T11:23:03.647000",
      "content": "<p>Great work, Thank you!!🙌</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2984092,
      "author_name": "Arielle Sezine",
      "author_url": "",
      "post_date": "2024-09-09T11:22:26.243000",
      "content": "<p>thanks to you. I really appreciate</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1162825": "Hi everyone, I find that this competition could be a good opportunity to finally try to apply machine learning to audio data, there is already a lot of available public notebooks with very good scores, but even being familiar with deep learning and Tensorflow I was having a hard time to understand everything that was going on (sometimes Tensorflow does that). So I wrote a notebook that has the basics for audio classification with Tensorflow, putting everything together in a more organized way, and added documentation to some of the methods, you can find it here [Rainforest - Audio classification Tensorflow starter](https://www.kaggle.com/dimitreoliveira/rainforest-audio-classification-tensorflow-starter/notebook)\n\nI also made a workflow diagram to make things visual.\n```\n1. Load TFRecords\n2. Decode audio waveform\n3. Crop audio waveform\n4. Convert the waveform into spectrogram\n4. Resize spectrogram\n5. Turn grayscale spectrogram into RGB image\n6. Feed to the model\n```\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1182060%2F473dfd70dd2d9e278dd5076310583766%2FRainforest%20diagram.jpg?generation=1611227361853675&alt=media)\n\n---\n\n#### A few ideas for improvements\n- Add data augmentation\n- Try different encoders (people seems to get good results with ResNet variants)\n- Different losses\n- Convert spectrogram to Mel-spectrogram\n- Add more layers at the top of the encoder\n- K-Fold\n- [Better crop](https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/200922)\n- Some of the things discussed [here](https://www.kaggle.com/c/rfcx-species-audio-detection/discussion/208830)",
    "1199859": "Good work, Congrats! :) ",
    "1168308": "Thank you for sharing the great Discussion and Notebook!\nTheses are helpful for me!",
    "1163681": "That is a very nice chart made specifically for this competition :)",
    "1163237": "Thanks for sharing, I was looking out for a notebook for beginners to get started in this competition.",
    "2581845": "valuable information",
    "1163238": "",
    "1162878": "",
    "1177173": "Thanks for sharing. :)",
    "1172683": "Thanks for sharing :D",
    "1171333": "Thanks for sharing!",
    "1162837": "Great work, Thank you!!🙌",
    "2984092": "thanks to you. I really appreciate"
  }
}