{
  "id": 321500,
  "title": "Notebook Threw Exception",
  "url": "/competitions/birdclef-2022/discussion/321500",
  "author_name": "",
  "post_date": "2022-04-27T05:24:07.639607800Z",
  "votes": 4,
  "comment_count": 1,
  "views": 0,
  "content": "<p><strong>UPDATE: SOLVED BELOW</strong></p>\n<p>Hello Everyone.<br>\nI need help. I cannot find where I have a mistake in my code. I keep getting 'Notebook Threw Exception' error every time I submit my notebook for predictions.<br>\nThe log seems to be fine. Its status is: <code>Successfully ran in 42.3s</code>. There are a bunch of lines when I load the model, no errors. The last few lines of the log are:</p>\n<pre><code>39.4s    31  [NbConvertApp] Converting notebook __notebook__.ipynb to notebook\n39.6s    32  [NbConvertApp] Writing 24073 bytes to __notebook__.ipynb\n41.6s    33  /opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py:2567: FutureWarning: --Exporter.preprocessors=[\"nbconvert.preprocessors.ExtractOutputPreprocessor\"] for containers is deprecated in traitlets 5.0. You can pass `--Exporter.preprocessors item` ... multiple times to add items to a list.\n41.6s    34    FutureWarning,\n41.6s    35  [NbConvertApp] Converting notebook __notebook__.ipynb to html\n42.2s    36  [NbConvertApp] Writing 322649 bytes to __results__.html\n</code></pre>\n<p>It seems like one of the reasons why the notebook throws exception is that the hidden test set is not being populated. Can this be  possible?<br>\nHere is some of my code that I use for inference. </p>\n<p><strong>Note that the code works perfectly fine with 1 and 10 test soundscapes (which are basically 1 given test soundscape but copied 10 times with random name.</strong></p>\n<pre><code>SAMPLING_RATE = 21952\nINDENT_SECONDS = 21952\nSIGNAL_LENGTH = 5  # seconds\n\nTEST_DIR = '../input/birdclef-2022/test_soundscapes/'\nTEST_FILES = sorted(os.listdir(TEST_DIR))\nwith open('../input/birdclef-2022/scored_birds.json') as sbfile:\n    SCORED_BIRDS = json.load(sbfile)\nBIRD_SPARSE_IDXS = [SPARSE_META[SPARSE_META['label'] == bird]['idx'].values[0] for bird in SCORED_BIRDS]\nBIRDS_IDXS = {bird: bird_idx for bird, bird_idx in zip(SCORED_BIRDS, BIRD_SPARSE_IDXS)}\nEND_TIMES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]\n\ndef preprocessAudio(path, normalization):\n\n    mel_specs = []\n\n    audio, rate = librosa.load(path, sr=SAMPLING_RATE, mono=True, res_type=\"kaiser_fast\")\n\n    step_5_sec = SIGNAL_LENGTH * INDENT_SECONDS - 1\n\n    for end_time, i in enumerate(range(0, len(audio), step_5_sec)):\n\n        split = audio[i:i + step_5_sec]\n\n        if end_time == 12:\n            break\n\n        mel_spec = librosa.feature.melspectrogram(\n            y=split, sr=SAMPLING_RATE, win_length=WIN_LENGTH, \n            n_fft=N_FFT, hop_length=HOP_LENGTH, n_mels=N_MELS, fmin=FMIN)\n\n        ...\n\n        mel_specs.append(mel_spec)\n\n    return mel_specs\n\ndef perFilePrediction():\n\n    prediction_dict = {'row_id': [], 'target': []}\n\n    for file in TEST_FILES:\n\n        file_path = TEST_DIR + file\n        file_id = file.split('.')[0]\n\n        mel_specs = preprocessAudio(file_path, normalization_function)\n        mel_specs = np.asarray(mel_specs)\n        mel_specs = np.squeeze(mel_specs, axis=1)\n\n        predictions = model(mel_specs, training=False).numpy()\n\n        for time_idx, end_time in enumerate(END_TIMES):\n\n            prediction = predictions[time_idx]\n\n            for bird, bird_idx in BIRDS_IDXS.items():\n\n                row_id = file_id + '_' + bird + '_' + str(end_time)\n\n                prediction_val = prediction[bird_idx]\n\n                prediction_dict['row_id'].append(row_id)\n                prediction_dict['target'].append(True if prediction_val &gt; prediction_threshold else False)\n\n    return prediction_dict\n\nprediction_dict = perFilePrediction()\nsubmission = pd.DataFrame(prediction_dict, columns=['row_id', 'target'])\nsubmission.to_csv(path_or_buf='submission.csv', index=False)\n</code></pre>\n<pre><code>submission.head(23)\n\nrow_id    target\n0    soundscape_453028782_akiapo_5   False\n1    soundscape_453028782_aniani_5   False\n2    soundscape_453028782_apapan_5   False\n3    soundscape_453028782_barpet_5   False\n4    soundscape_453028782_crehon_5   False\n5    soundscape_453028782_elepai_5   False\n6    soundscape_453028782_ercfra_5   False\n7    soundscape_453028782_hawama_5   False\n8    soundscape_453028782_hawcre_5   False\n9    soundscape_453028782_hawgoo_5   False\n10    soundscape_453028782_hawhaw_5   False\n11    soundscape_453028782_hawpet1_5  False\n12    soundscape_453028782_houfin_5   False\n13    soundscape_453028782_iiwi_5 False\n14    soundscape_453028782_jabwar_5   False\n15    soundscape_453028782_maupar_5   False\n16    soundscape_453028782_omao_5 False\n17    soundscape_453028782_puaioh_5   False\n18    soundscape_453028782_skylar_5   False\n19    soundscape_453028782_warwhe1_5  False\n20    soundscape_453028782_yefcan_5   False\n21    soundscape_453028782_akiapo_10  False\n22    soundscape_453028782_aniani_10  False\n\n# one soundscape\nlen(submission)\n\n252\n\n# ten soundscapes\nlen(submission)\n\n2520\n</code></pre>\n<p>Let me know if you have any ideas why the error appears!<br>\nThank you.</p>",
  "messages": [
    {
      "id": "1769248",
      "postDate": "04/27/2022 05:24:07",
      "content": "<p><strong>UPDATE: SOLVED BELOW</strong></p>\n<p>Hello Everyone.<br>\nI need help. I cannot find where I have a mistake in my code. I keep getting 'Notebook Threw Exception' error every time I submit my notebook for predictions.<br>\nThe log seems to be fine. Its status is: <code>Successfully ran in 42.3s</code>. There are a bunch of lines when I load the model, no errors. The last few lines of the log are:</p>\n<pre><code>39.4s    31  [NbConvertApp] Converting notebook __notebook__.ipynb to notebook\n39.6s    32  [NbConvertApp] Writing 24073 bytes to __notebook__.ipynb\n41.6s    33  /opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py:2567: FutureWarning: --Exporter.preprocessors=[\"nbconvert.preprocessors.ExtractOutputPreprocessor\"] for containers is deprecated in traitlets 5.0. You can pass `--Exporter.preprocessors item` ... multiple times to add items to a list.\n41.6s    34    FutureWarning,\n41.6s    35  [NbConvertApp] Converting notebook __notebook__.ipynb to html\n42.2s    36  [NbConvertApp] Writing 322649 bytes to __results__.html\n</code></pre>\n<p>It seems like one of the reasons why the notebook throws exception is that the hidden test set is not being populated. Can this be  possible?<br>\nHere is some of my code that I use for inference. </p>\n<p><strong>Note that the code works perfectly fine with 1 and 10 test soundscapes (which are basically 1 given test soundscape but copied 10 times with random name.</strong></p>\n<pre><code>SAMPLING_RATE = 21952\nINDENT_SECONDS = 21952\nSIGNAL_LENGTH = 5  # seconds\n\nTEST_DIR = '../input/birdclef-2022/test_soundscapes/'\nTEST_FILES = sorted(os.listdir(TEST_DIR))\nwith open('../input/birdclef-2022/scored_birds.json') as sbfile:\n    SCORED_BIRDS = json.load(sbfile)\nBIRD_SPARSE_IDXS = [SPARSE_META[SPARSE_META['label'] == bird]['idx'].values[0] for bird in SCORED_BIRDS]\nBIRDS_IDXS = {bird: bird_idx for bird, bird_idx in zip(SCORED_BIRDS, BIRD_SPARSE_IDXS)}\nEND_TIMES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]\n\ndef preprocessAudio(path, normalization):\n\n    mel_specs = []\n\n    audio, rate = librosa.load(path, sr=SAMPLING_RATE, mono=True, res_type=\"kaiser_fast\")\n\n    step_5_sec = SIGNAL_LENGTH * INDENT_SECONDS - 1\n\n    for end_time, i in enumerate(range(0, len(audio), step_5_sec)):\n\n        split = audio[i:i + step_5_sec]\n\n        if end_time == 12:\n            break\n\n        mel_spec = librosa.feature.melspectrogram(\n            y=split, sr=SAMPLING_RATE, win_length=WIN_LENGTH, \n            n_fft=N_FFT, hop_length=HOP_LENGTH, n_mels=N_MELS, fmin=FMIN)\n\n        ...\n\n        mel_specs.append(mel_spec)\n\n    return mel_specs\n\ndef perFilePrediction():\n\n    prediction_dict = {'row_id': [], 'target': []}\n\n    for file in TEST_FILES:\n\n        file_path = TEST_DIR + file\n        file_id = file.split('.')[0]\n\n        mel_specs = preprocessAudio(file_path, normalization_function)\n        mel_specs = np.asarray(mel_specs)\n        mel_specs = np.squeeze(mel_specs, axis=1)\n\n        predictions = model(mel_specs, training=False).numpy()\n\n        for time_idx, end_time in enumerate(END_TIMES):\n\n            prediction = predictions[time_idx]\n\n            for bird, bird_idx in BIRDS_IDXS.items():\n\n                row_id = file_id + '_' + bird + '_' + str(end_time)\n\n                prediction_val = prediction[bird_idx]\n\n                prediction_dict['row_id'].append(row_id)\n                prediction_dict['target'].append(True if prediction_val &gt; prediction_threshold else False)\n\n    return prediction_dict\n\nprediction_dict = perFilePrediction()\nsubmission = pd.DataFrame(prediction_dict, columns=['row_id', 'target'])\nsubmission.to_csv(path_or_buf='submission.csv', index=False)\n</code></pre>\n<pre><code>submission.head(23)\n\nrow_id    target\n0    soundscape_453028782_akiapo_5   False\n1    soundscape_453028782_aniani_5   False\n2    soundscape_453028782_apapan_5   False\n3    soundscape_453028782_barpet_5   False\n4    soundscape_453028782_crehon_5   False\n5    soundscape_453028782_elepai_5   False\n6    soundscape_453028782_ercfra_5   False\n7    soundscape_453028782_hawama_5   False\n8    soundscape_453028782_hawcre_5   False\n9    soundscape_453028782_hawgoo_5   False\n10    soundscape_453028782_hawhaw_5   False\n11    soundscape_453028782_hawpet1_5  False\n12    soundscape_453028782_houfin_5   False\n13    soundscape_453028782_iiwi_5 False\n14    soundscape_453028782_jabwar_5   False\n15    soundscape_453028782_maupar_5   False\n16    soundscape_453028782_omao_5 False\n17    soundscape_453028782_puaioh_5   False\n18    soundscape_453028782_skylar_5   False\n19    soundscape_453028782_warwhe1_5  False\n20    soundscape_453028782_yefcan_5   False\n21    soundscape_453028782_akiapo_10  False\n22    soundscape_453028782_aniani_10  False\n\n# one soundscape\nlen(submission)\n\n252\n\n# ten soundscapes\nlen(submission)\n\n2520\n</code></pre>\n<p>Let me know if you have any ideas why the error appears!<br>\nThank you.</p>",
      "rawMarkdown": "**UPDATE: SOLVED BELOW**\n\nHello Everyone.\nI need help. I cannot find where I have a mistake in my code. I keep getting 'Notebook Threw Exception' error every time I submit my notebook for predictions.\nThe log seems to be fine. Its status is: ``Successfully ran in 42.3s``. There are a bunch of lines when I load the model, no errors. The last few lines of the log are:\n```\n39.4s\t31\t[NbConvertApp] Converting notebook __notebook__.ipynb to notebook\n39.6s\t32\t[NbConvertApp] Writing 24073 bytes to __notebook__.ipynb\n41.6s\t33\t/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py:2567: FutureWarning: --Exporter.preprocessors=[\"nbconvert.preprocessors.ExtractOutputPreprocessor\"] for containers is deprecated in traitlets 5.0. You can pass `--Exporter.preprocessors item` ... multiple times to add items to a list.\n41.6s\t34\t  FutureWarning,\n41.6s\t35\t[NbConvertApp] Converting notebook __notebook__.ipynb to html\n42.2s\t36\t[NbConvertApp] Writing 322649 bytes to __results__.html\n```\nIt seems like one of the reasons why the notebook throws exception is that the hidden test set is not being populated. Can this be  possible?\nHere is some of my code that I use for inference. \n\n**Note that the code works perfectly fine with 1 and 10 test soundscapes (which are basically 1 given test soundscape but copied 10 times with random name.**\n\n```\nSAMPLING_RATE = 21952\nINDENT_SECONDS = 21952\nSIGNAL_LENGTH = 5  # seconds\n\nTEST_DIR = '../input/birdclef-2022/test_soundscapes/'\nTEST_FILES = sorted(os.listdir(TEST_DIR))\nwith open('../input/birdclef-2022/scored_birds.json') as sbfile:\n    SCORED_BIRDS = json.load(sbfile)\nBIRD_SPARSE_IDXS = [SPARSE_META[SPARSE_META['label'] == bird]['idx'].values[0] for bird in SCORED_BIRDS]\nBIRDS_IDXS = {bird: bird_idx for bird, bird_idx in zip(SCORED_BIRDS, BIRD_SPARSE_IDXS)}\nEND_TIMES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]\n\ndef preprocessAudio(path, normalization):\n\n    mel_specs = []\n    \n    audio, rate = librosa.load(path, sr=SAMPLING_RATE, mono=True, res_type=\"kaiser_fast\")\n    \n    step_5_sec = SIGNAL_LENGTH * INDENT_SECONDS - 1\n\n    for end_time, i in enumerate(range(0, len(audio), step_5_sec)):\n\n        split = audio[i:i + step_5_sec]\n        \n        if end_time == 12:\n            break\n\n        mel_spec = librosa.feature.melspectrogram(\n            y=split, sr=SAMPLING_RATE, win_length=WIN_LENGTH, \n            n_fft=N_FFT, hop_length=HOP_LENGTH, n_mels=N_MELS, fmin=FMIN)\n\n        ...\n\n        mel_specs.append(mel_spec)\n            \n    return mel_specs\n\ndef perFilePrediction():\n    \n    prediction_dict = {'row_id': [], 'target': []}\n\n    for file in TEST_FILES:\n\n        file_path = TEST_DIR + file\n        file_id = file.split('.')[0]\n\n        mel_specs = preprocessAudio(file_path, normalization_function)\n        mel_specs = np.asarray(mel_specs)\n        mel_specs = np.squeeze(mel_specs, axis=1)\n        \n        predictions = model(mel_specs, training=False).numpy()\n\n        for time_idx, end_time in enumerate(END_TIMES):\n            \n            prediction = predictions[time_idx]\n            \n            for bird, bird_idx in BIRDS_IDXS.items():\n                \n                row_id = file_id + '_' + bird + '_' + str(end_time)\n                \n                prediction_val = prediction[bird_idx]\n\n                prediction_dict['row_id'].append(row_id)\n                prediction_dict['target'].append(True if prediction_val > prediction_threshold else False)\n            \n    return prediction_dict\n\nprediction_dict = perFilePrediction()\nsubmission = pd.DataFrame(prediction_dict, columns=['row_id', 'target'])\nsubmission.to_csv(path_or_buf='submission.csv', index=False)\n```\n```\nsubmission.head(23)\n\nrow_id\ttarget\n0\tsoundscape_453028782_akiapo_5\tFalse\n1\tsoundscape_453028782_aniani_5\tFalse\n2\tsoundscape_453028782_apapan_5\tFalse\n3\tsoundscape_453028782_barpet_5\tFalse\n4\tsoundscape_453028782_crehon_5\tFalse\n5\tsoundscape_453028782_elepai_5\tFalse\n6\tsoundscape_453028782_ercfra_5\tFalse\n7\tsoundscape_453028782_hawama_5\tFalse\n8\tsoundscape_453028782_hawcre_5\tFalse\n9\tsoundscape_453028782_hawgoo_5\tFalse\n10\tsoundscape_453028782_hawhaw_5\tFalse\n11\tsoundscape_453028782_hawpet1_5\tFalse\n12\tsoundscape_453028782_houfin_5\tFalse\n13\tsoundscape_453028782_iiwi_5\tFalse\n14\tsoundscape_453028782_jabwar_5\tFalse\n15\tsoundscape_453028782_maupar_5\tFalse\n16\tsoundscape_453028782_omao_5\tFalse\n17\tsoundscape_453028782_puaioh_5\tFalse\n18\tsoundscape_453028782_skylar_5\tFalse\n19\tsoundscape_453028782_warwhe1_5\tFalse\n20\tsoundscape_453028782_yefcan_5\tFalse\n21\tsoundscape_453028782_akiapo_10\tFalse\n22\tsoundscape_453028782_aniani_10\tFalse\n\n# one soundscape\nlen(submission)\n\n252\n\n# ten soundscapes\nlen(submission)\n\n2520\n```\n\nLet me know if you have any ideas why the error appears!\nThank you.",
      "votes": null
    },
    {
      "id": "1770103",
      "postDate": "04/28/2022 01:27:16",
      "content": "<p>OK, I found the reason why the notebook threw an exception every time I tried to do predictions.</p>\n<p>The problem was with the <code>mel_spec</code> creation. Some of the soundscapes are less than 1 minute, so the shape of some the last created <code>mel_spec</code>'s will not be what you intended. To solve this, simply pad your audio with zeros so that it is 5 seconds long (at least that's what I did when I was preparing training dataset). If you have similar code to mine, you can use this piece code to pad audio split with zeros:</p>\n<pre><code>...\nsplit = audio[i:i + step_5_sec]\n\nif len(split) &lt; step_5_sec:\n\n    split_pad = np.zeros(step_5_sec)\n    split_pad[:len(split)] += split\n\n...\n</code></pre>",
      "rawMarkdown": "OK, I found the reason why the notebook threw an exception every time I tried to do predictions.\n\nThe problem was with the `mel_spec` creation. Some of the soundscapes are less than 1 minute, so the shape of some the last created `mel_spec`'s will not be what you intended. To solve this, simply pad your audio with zeros so that it is 5 seconds long (at least that's what I did when I was preparing training dataset). If you have similar code to mine, you can use this piece code to pad audio split with zeros:\n\n```\n...\nsplit = audio[i:i + step_5_sec]\n\nif len(split) < step_5_sec:\n\n    split_pad = np.zeros(step_5_sec)\n    split_pad[:len(split)] += split\n\n...\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1770103,
      "author_name": "antonzv",
      "author_url": "",
      "post_date": "04/28/2022 01:27:16",
      "content": "<p>OK, I found the reason why the notebook threw an exception every time I tried to do predictions.</p>\n<p>The problem was with the <code>mel_spec</code> creation. Some of the soundscapes are less than 1 minute, so the shape of some the last created <code>mel_spec</code>'s will not be what you intended. To solve this, simply pad your audio with zeros so that it is 5 seconds long (at least that's what I did when I was preparing training dataset). If you have similar code to mine, you can use this piece code to pad audio split with zeros:</p>\n<pre><code>...\nsplit = audio[i:i + step_5_sec]\n\nif len(split) &lt; step_5_sec:\n\n    split_pad = np.zeros(step_5_sec)\n    split_pad[:len(split)] += split\n\n...\n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1769248": "**UPDATE: SOLVED BELOW**\n\nHello Everyone.\nI need help. I cannot find where I have a mistake in my code. I keep getting 'Notebook Threw Exception' error every time I submit my notebook for predictions.\nThe log seems to be fine. Its status is: ``Successfully ran in 42.3s``. There are a bunch of lines when I load the model, no errors. The last few lines of the log are:\n```\n39.4s\t31\t[NbConvertApp] Converting notebook __notebook__.ipynb to notebook\n39.6s\t32\t[NbConvertApp] Writing 24073 bytes to __notebook__.ipynb\n41.6s\t33\t/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py:2567: FutureWarning: --Exporter.preprocessors=[\"nbconvert.preprocessors.ExtractOutputPreprocessor\"] for containers is deprecated in traitlets 5.0. You can pass `--Exporter.preprocessors item` ... multiple times to add items to a list.\n41.6s\t34\t  FutureWarning,\n41.6s\t35\t[NbConvertApp] Converting notebook __notebook__.ipynb to html\n42.2s\t36\t[NbConvertApp] Writing 322649 bytes to __results__.html\n```\nIt seems like one of the reasons why the notebook throws exception is that the hidden test set is not being populated. Can this be  possible?\nHere is some of my code that I use for inference. \n\n**Note that the code works perfectly fine with 1 and 10 test soundscapes (which are basically 1 given test soundscape but copied 10 times with random name.**\n\n```\nSAMPLING_RATE = 21952\nINDENT_SECONDS = 21952\nSIGNAL_LENGTH = 5  # seconds\n\nTEST_DIR = '../input/birdclef-2022/test_soundscapes/'\nTEST_FILES = sorted(os.listdir(TEST_DIR))\nwith open('../input/birdclef-2022/scored_birds.json') as sbfile:\n    SCORED_BIRDS = json.load(sbfile)\nBIRD_SPARSE_IDXS = [SPARSE_META[SPARSE_META['label'] == bird]['idx'].values[0] for bird in SCORED_BIRDS]\nBIRDS_IDXS = {bird: bird_idx for bird, bird_idx in zip(SCORED_BIRDS, BIRD_SPARSE_IDXS)}\nEND_TIMES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]\n\ndef preprocessAudio(path, normalization):\n\n    mel_specs = []\n    \n    audio, rate = librosa.load(path, sr=SAMPLING_RATE, mono=True, res_type=\"kaiser_fast\")\n    \n    step_5_sec = SIGNAL_LENGTH * INDENT_SECONDS - 1\n\n    for end_time, i in enumerate(range(0, len(audio), step_5_sec)):\n\n        split = audio[i:i + step_5_sec]\n        \n        if end_time == 12:\n            break\n\n        mel_spec = librosa.feature.melspectrogram(\n            y=split, sr=SAMPLING_RATE, win_length=WIN_LENGTH, \n            n_fft=N_FFT, hop_length=HOP_LENGTH, n_mels=N_MELS, fmin=FMIN)\n\n        ...\n\n        mel_specs.append(mel_spec)\n            \n    return mel_specs\n\ndef perFilePrediction():\n    \n    prediction_dict = {'row_id': [], 'target': []}\n\n    for file in TEST_FILES:\n\n        file_path = TEST_DIR + file\n        file_id = file.split('.')[0]\n\n        mel_specs = preprocessAudio(file_path, normalization_function)\n        mel_specs = np.asarray(mel_specs)\n        mel_specs = np.squeeze(mel_specs, axis=1)\n        \n        predictions = model(mel_specs, training=False).numpy()\n\n        for time_idx, end_time in enumerate(END_TIMES):\n            \n            prediction = predictions[time_idx]\n            \n            for bird, bird_idx in BIRDS_IDXS.items():\n                \n                row_id = file_id + '_' + bird + '_' + str(end_time)\n                \n                prediction_val = prediction[bird_idx]\n\n                prediction_dict['row_id'].append(row_id)\n                prediction_dict['target'].append(True if prediction_val > prediction_threshold else False)\n            \n    return prediction_dict\n\nprediction_dict = perFilePrediction()\nsubmission = pd.DataFrame(prediction_dict, columns=['row_id', 'target'])\nsubmission.to_csv(path_or_buf='submission.csv', index=False)\n```\n```\nsubmission.head(23)\n\nrow_id\ttarget\n0\tsoundscape_453028782_akiapo_5\tFalse\n1\tsoundscape_453028782_aniani_5\tFalse\n2\tsoundscape_453028782_apapan_5\tFalse\n3\tsoundscape_453028782_barpet_5\tFalse\n4\tsoundscape_453028782_crehon_5\tFalse\n5\tsoundscape_453028782_elepai_5\tFalse\n6\tsoundscape_453028782_ercfra_5\tFalse\n7\tsoundscape_453028782_hawama_5\tFalse\n8\tsoundscape_453028782_hawcre_5\tFalse\n9\tsoundscape_453028782_hawgoo_5\tFalse\n10\tsoundscape_453028782_hawhaw_5\tFalse\n11\tsoundscape_453028782_hawpet1_5\tFalse\n12\tsoundscape_453028782_houfin_5\tFalse\n13\tsoundscape_453028782_iiwi_5\tFalse\n14\tsoundscape_453028782_jabwar_5\tFalse\n15\tsoundscape_453028782_maupar_5\tFalse\n16\tsoundscape_453028782_omao_5\tFalse\n17\tsoundscape_453028782_puaioh_5\tFalse\n18\tsoundscape_453028782_skylar_5\tFalse\n19\tsoundscape_453028782_warwhe1_5\tFalse\n20\tsoundscape_453028782_yefcan_5\tFalse\n21\tsoundscape_453028782_akiapo_10\tFalse\n22\tsoundscape_453028782_aniani_10\tFalse\n\n# one soundscape\nlen(submission)\n\n252\n\n# ten soundscapes\nlen(submission)\n\n2520\n```\n\nLet me know if you have any ideas why the error appears!\nThank you.",
    "1770103": "OK, I found the reason why the notebook threw an exception every time I tried to do predictions.\n\nThe problem was with the `mel_spec` creation. Some of the soundscapes are less than 1 minute, so the shape of some the last created `mel_spec`'s will not be what you intended. To solve this, simply pad your audio with zeros so that it is 5 seconds long (at least that's what I did when I was preparing training dataset). If you have similar code to mine, you can use this piece code to pad audio split with zeros:\n\n```\n...\nsplit = audio[i:i + step_5_sec]\n\nif len(split) < step_5_sec:\n\n    split_pad = np.zeros(step_5_sec)\n    split_pad[:len(split)] += split\n\n...\n```"
  },
  "source": "meta"
}