{
  "id": 352438,
  "title": "Notebook threw exception",
  "url": "/competitions/hubmap-organ-segmentation/discussion/352438",
  "author_name": "",
  "post_date": "2022-09-14T11:29:30.373365500Z",
  "votes": 10,
  "comment_count": 15,
  "views": 0,
  "content": "<p>I went through the earlier posted discussions too and there's no clue at all to the probelm i'm facing.<br>\nI'm able to  run the notebook on test set with augmenting the test set( for testing), tried on lower resolution images too. I have patche sof 512 and so i tried even 100*100 images. Even though 16 batch size runs fine, i tired 8 and 4.<br>\nYet I've no clue.</p>\n<p>Anybody can help out?</p>",
  "messages": [
    {
      "id": "1938816",
      "postDate": "09/14/2022 11:29:30",
      "content": "<p>I went through the earlier posted discussions too and there's no clue at all to the probelm i'm facing.<br>\nI'm able to  run the notebook on test set with augmenting the test set( for testing), tried on lower resolution images too. I have patche sof 512 and so i tried even 100*100 images. Even though 16 batch size runs fine, i tired 8 and 4.<br>\nYet I've no clue.</p>\n<p>Anybody can help out?</p>",
      "rawMarkdown": "I went through the earlier posted discussions too and there's no clue at all to the probelm i'm facing.\nI'm able to  run the notebook on test set with augmenting the test set( for testing), tried on lower resolution images too. I have patche sof 512 and so i tried even 100*100 images. Even though 16 batch size runs fine, i tired 8 and 4.\nYet I've no clue.\n\nAnybody can help out?",
      "votes": null
    },
    {
      "id": "1939019",
      "postDate": "09/14/2022 13:41:22",
      "content": "<p>As you know, notebook threw exception error occurs when your model is unable to deal with data it encounters.<br>\nAnd, since you're speaking you patch the test images, here is the scenario I've come up with. Does your model discard less important patch (maybe less than threshold)? Then, your model could try to divide a small size image by a patch. Let's say image size = 256 and patch size=512. So 1 patch will be there. But the patch does not meet the threshold, and the model discards the patch or the whole image. That means your model returns nothing so your model halts there unless you prevent such case with  <code>rle = ''</code> setting . Or similarly your model makes an inference on a small image and there's nothing so it returns nothing, causing the same error. Maybe the same error occurs while combining multiple inference on one object when one of them returns null. I'll let you know if other bad scenarios come into my mind. Hopefully your case will be handled soon.<br>\nBy the way  make sure you have the model run through the whole validation set in order to see if the corresponding submission.csv for the validation set would print accordingly.</p>",
      "rawMarkdown": "As you know, notebook threw exception error occurs when your model is unable to deal with data it encounters.\nAnd, since you're speaking you patch the test images, here is the scenario I've come up with. Does your model discard less important patch (maybe less than threshold)? Then, your model could try to divide a small size image by a patch. Let's say image size = 256 and patch size=512. So 1 patch will be there. But the patch does not meet the threshold, and the model discards the patch or the whole image. That means your model returns nothing so your model halts there unless you prevent such case with  ```rle = '' ``` setting . Or similarly your model makes an inference on a small image and there's nothing so it returns nothing, causing the same error. Maybe the same error occurs while combining multiple inference on one object when one of them returns null. I'll let you know if other bad scenarios come into my mind. Hopefully your case will be handled soon.\nBy the way  make sure you have the model run through the whole validation set in order to see if the corresponding submission.csv for the validation set would print accordingly.",
      "votes": null
    },
    {
      "id": "1939046",
      "postDate": "09/14/2022 13:52:07",
      "content": "<p>Hello, I have some suggestions that may help you: </p>\n<ol>\n<li>Although you increase the amount of data, the noise will also increase, so you may consider removing the useless patches. </li>\n<li>Try to balance the proportion of positive and negative samples. It is possible that your patch contains a large number of blank RLE, which will bring great noise to the training.</li>\n</ol>\n<p>I have improved my performance by using these two methods, and I hope they can help you as well</p>",
      "rawMarkdown": "Hello, I have some suggestions that may help you: \n1. Although you increase the amount of data, the noise will also increase, so you may consider removing the useless patches. \n2. Try to balance the proportion of positive and negative samples. It is possible that your patch contains a large number of blank RLE, which will bring great noise to the training.\n\nI have improved my performance by using these two methods, and I hope they can help you as well",
      "votes": null
    },
    {
      "id": "1939052",
      "postDate": "09/14/2022 13:55:21",
      "content": "<p>I'm using tensorflow's extract patches so it pads the images , tried it after getting the error first time </p>\n<p>My code runs properly and has worked till now pretty fine<br>\nbut it broke down when i submitted to kaggle</p>",
      "rawMarkdown": "I'm using tensorflow's extract patches so it pads the images , tried it after getting the error first time \n\nMy code runs properly and has worked till now pretty fine\nbut it broke down when i submitted to kaggle",
      "votes": null
    },
    {
      "id": "1939075",
      "postDate": "09/14/2022 14:10:37",
      "content": "<p>I don't know much about tensorflow's extract patches method so I can't answer clearly about it but notebook threw exception occurs due to <a href=\"https://www.kaggle.com/code-competition-debugging#:~:text=Notebook%20Threw%20Exception%3A%20While%20rerunning%20your%20code%2C%20your%20notebook%20hit%20an%20unhandled%20error.%20Note%20that%20the%20hidden%20dataset%20can%20be%20larger/smaller/different%20than%20the%20public%20dataset.\" target=\"_blank\">this reason</a> for sure. So there must be something wrong with handling data. Maybe combining augmentation process could go wrong like (none object + predictions) etc. If I were you, I would first have the model run through validation sets and see if it prints out submission.csv for validation set accordingly. </p>\n<p>ps highlightlink doesn't work so I copy and past it here: <code>Notebook Threw Exception: While rerunning your code, your notebook hit an unhandled error. Note that the hidden dataset can be larger/smaller/different than the public dataset.</code></p>",
      "rawMarkdown": "I don't know much about tensorflow's extract patches method so I can't answer clearly about it but notebook threw exception occurs due to [this reason](https://www.kaggle.com/code-competition-debugging#:~:text=Notebook%20Threw%20Exception%3A%20While%20rerunning%20your%20code%2C%20your%20notebook%20hit%20an%20unhandled%20error.%20Note%20that%20the%20hidden%20dataset%20can%20be%20larger/smaller/different%20than%20the%20public%20dataset.) for sure. So there must be something wrong with handling data. Maybe combining augmentation process could go wrong like (none object + predictions) etc. If I were you, I would first have the model run through validation sets and see if it prints out submission.csv for validation set accordingly. \n\nps highlightlink doesn't work so I copy and past it here: ```Notebook Threw Exception: While rerunning your code, your notebook hit an unhandled error. Note that the hidden dataset can be larger/smaller/different than the public dataset.```",
      "votes": null
    },
    {
      "id": "1939082",
      "postDate": "09/14/2022 14:17:32",
      "content": "<p>i've tried making submission.csv on validation , it works fine</p>",
      "rawMarkdown": "i've tried making submission.csv on validation , it works fine",
      "votes": null
    },
    {
      "id": "1939089",
      "postDate": "09/14/2022 14:20:27",
      "content": "<p>I want to make sure your model returns <code>rle=''</code> when it predicts nothing. If you didn't check, could you put a zero tensor as the result of the prediction (maybe right after combining all predicted patches)?</p>",
      "rawMarkdown": "I want to make sure your model returns ```rle=''``` when it predicts nothing. If you didn't check, could you put a zero tensor as the result of the prediction (maybe right after combining all predicted patches)?",
      "votes": null
    },
    {
      "id": "1939114",
      "postDate": "09/14/2022 14:34:21",
      "content": "<p>Yes, i ran the notebook to confirm to you, but it does return <code>''</code> so there ain't problem either</p>",
      "rawMarkdown": "Yes, i ran the notebook to confirm to you, but it does return `''` so there ain't problem either",
      "votes": null
    },
    {
      "id": "1939121",
      "postDate": "09/14/2022 14:38:25",
      "content": "<p>Well… I think that's all I can come up with now. Sorry man. I'll let you know if there's anything comes into my mind.</p>",
      "rawMarkdown": "Well... I think that's all I can come up with now. Sorry man. I'll let you know if there's anything comes into my mind.",
      "votes": null
    },
    {
      "id": "1939176",
      "postDate": "09/14/2022 15:06:22",
      "content": "<p>thanks buddy, i hope something turns up</p>",
      "rawMarkdown": "thanks buddy, i hope something turns up",
      "votes": null
    },
    {
      "id": "1939493",
      "postDate": "09/14/2022 18:20:15",
      "content": "<p>It worked out, it really was error in the RLE function, just needed to return ''. Thanks a lot buddy</p>",
      "rawMarkdown": "It worked out, it really was error in the RLE function, just needed to return ''. Thanks a lot buddy",
      "votes": null
    },
    {
      "id": "1939637",
      "postDate": "09/14/2022 22:37:43",
      "content": "<p>Glad to hear that you managed the issue!  You're welcome.</p>",
      "rawMarkdown": "Glad to hear that you managed the issue!  You're welcome.",
      "votes": null
    },
    {
      "id": "1940141",
      "postDate": "09/15/2022 07:46:13",
      "content": "<p>I had some problem with submitting and got Notebook threw exception even if it worked during validation, and I used below fix dealing with it:<br>\nIt also saves GPU quota while submitting :)</p>\n<pre><code>import os\nif os.getenv('KAGGLE_IS_COMPETITION_RERUN'):\n\nYour code......\n\nelse:\n    import pandas as pd\n    finalsub = pd.read_csv('../input/hubmap-organ-segmentation/sample_submission.csv')\n    finalsub.to_csv('submission.csv', index=False)\n</code></pre>",
      "rawMarkdown": "I had some problem with submitting and got Notebook threw exception even if it worked during validation, and I used below fix dealing with it:\nIt also saves GPU quota while submitting :)\n\n```\nimport os\nif os.getenv('KAGGLE_IS_COMPETITION_RERUN'):\n\nYour code......\n\nelse:\n    import pandas as pd\n    finalsub = pd.read_csv('../input/hubmap-organ-segmentation/sample_submission.csv')\n    finalsub.to_csv('submission.csv', index=False)\n```",
      "votes": null
    },
    {
      "id": "1940172",
      "postDate": "09/15/2022 07:59:05",
      "content": "<p>Thanks for responding <a href=\"https://www.kaggle.com/kirderf\" target=\"_blank\">@kirderf</a> <br>\nI.did solve the problem and it is exactly what you pointed out<br>\nBut the code that you posted, what exactly it is doing?</p>",
      "rawMarkdown": "Thanks for responding @kirderf \nI.did solve the problem and it is exactly what you pointed out\nBut the code that you posted, what exactly it is doing?",
      "votes": null
    },
    {
      "id": "1940190",
      "postDate": "09/15/2022 08:10:07",
      "content": "<p>It's a new Env code that checks if the code is running in submit/local mode or in the private test-time mode.<br>\nBefore one could also use a code that checked the number of test time rows or files in the test ds/folder but the above works the same and is generic.</p>",
      "rawMarkdown": "It's a new Env code that checks if the code is running in submit/local mode or in the private test-time mode.\nBefore one could also use a code that checked the number of test time rows or files in the test ds/folder but the above works the same and is generic.",
      "votes": null
    },
    {
      "id": "1940201",
      "postDate": "09/15/2022 08:15:40",
      "content": "<p>Oh, makes sense</p>",
      "rawMarkdown": "Oh, makes sense",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1939019,
      "author_name": "cheulkay",
      "author_url": "",
      "post_date": "09/14/2022 13:41:22",
      "content": "<p>As you know, notebook threw exception error occurs when your model is unable to deal with data it encounters.<br>\nAnd, since you're speaking you patch the test images, here is the scenario I've come up with. Does your model discard less important patch (maybe less than threshold)? Then, your model could try to divide a small size image by a patch. Let's say image size = 256 and patch size=512. So 1 patch will be there. But the patch does not meet the threshold, and the model discards the patch or the whole image. That means your model returns nothing so your model halts there unless you prevent such case with  <code>rle = ''</code> setting . Or similarly your model makes an inference on a small image and there's nothing so it returns nothing, causing the same error. Maybe the same error occurs while combining multiple inference on one object when one of them returns null. I'll let you know if other bad scenarios come into my mind. Hopefully your case will be handled soon.<br>\nBy the way  make sure you have the model run through the whole validation set in order to see if the corresponding submission.csv for the validation set would print accordingly.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1939052,
          "author_name": "bhavesjain",
          "author_url": "",
          "post_date": "09/14/2022 13:55:21",
          "content": "<p>I'm using tensorflow's extract patches so it pads the images , tried it after getting the error first time </p>\n<p>My code runs properly and has worked till now pretty fine<br>\nbut it broke down when i submitted to kaggle</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1939075,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/14/2022 14:10:37",
          "content": "<p>I don't know much about tensorflow's extract patches method so I can't answer clearly about it but notebook threw exception occurs due to <a href=\"https://www.kaggle.com/code-competition-debugging#:~:text=Notebook%20Threw%20Exception%3A%20While%20rerunning%20your%20code%2C%20your%20notebook%20hit%20an%20unhandled%20error.%20Note%20that%20the%20hidden%20dataset%20can%20be%20larger/smaller/different%20than%20the%20public%20dataset.\" target=\"_blank\">this reason</a> for sure. So there must be something wrong with handling data. Maybe combining augmentation process could go wrong like (none object + predictions) etc. If I were you, I would first have the model run through validation sets and see if it prints out submission.csv for validation set accordingly. </p>\n<p>ps highlightlink doesn't work so I copy and past it here: <code>Notebook Threw Exception: While rerunning your code, your notebook hit an unhandled error. Note that the hidden dataset can be larger/smaller/different than the public dataset.</code></p>",
          "votes": null,
          "replies": [
            {
              "id": 1939082,
              "author_name": "bhavesjain",
              "author_url": "",
              "post_date": "09/14/2022 14:17:32",
              "content": "<p>i've tried making submission.csv on validation , it works fine</p>",
              "votes": null,
              "replies": []
            }
          ]
        },
        {
          "id": 1939089,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/14/2022 14:20:27",
          "content": "<p>I want to make sure your model returns <code>rle=''</code> when it predicts nothing. If you didn't check, could you put a zero tensor as the result of the prediction (maybe right after combining all predicted patches)?</p>",
          "votes": null,
          "replies": [
            {
              "id": 1939114,
              "author_name": "bhavesjain",
              "author_url": "",
              "post_date": "09/14/2022 14:34:21",
              "content": "<p>Yes, i ran the notebook to confirm to you, but it does return <code>''</code> so there ain't problem either</p>",
              "votes": null,
              "replies": []
            }
          ]
        },
        {
          "id": 1939121,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/14/2022 14:38:25",
          "content": "<p>Well… I think that's all I can come up with now. Sorry man. I'll let you know if there's anything comes into my mind.</p>",
          "votes": null,
          "replies": [
            {
              "id": 1939176,
              "author_name": "bhavesjain",
              "author_url": "",
              "post_date": "09/14/2022 15:06:22",
              "content": "<p>thanks buddy, i hope something turns up</p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 1939493,
              "author_name": "bhavesjain",
              "author_url": "",
              "post_date": "09/14/2022 18:20:15",
              "content": "<p>It worked out, it really was error in the RLE function, just needed to return ''. Thanks a lot buddy</p>",
              "votes": null,
              "replies": []
            }
          ]
        },
        {
          "id": 1939637,
          "author_name": "cheulkay",
          "author_url": "",
          "post_date": "09/14/2022 22:37:43",
          "content": "<p>Glad to hear that you managed the issue!  You're welcome.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1939046,
      "author_name": "zhangasa",
      "author_url": "",
      "post_date": "09/14/2022 13:52:07",
      "content": "<p>Hello, I have some suggestions that may help you: </p>\n<ol>\n<li>Although you increase the amount of data, the noise will also increase, so you may consider removing the useless patches. </li>\n<li>Try to balance the proportion of positive and negative samples. It is possible that your patch contains a large number of blank RLE, which will bring great noise to the training.</li>\n</ol>\n<p>I have improved my performance by using these two methods, and I hope they can help you as well</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1940141,
      "author_name": "kirderf",
      "author_url": "",
      "post_date": "09/15/2022 07:46:13",
      "content": "<p>I had some problem with submitting and got Notebook threw exception even if it worked during validation, and I used below fix dealing with it:<br>\nIt also saves GPU quota while submitting :)</p>\n<pre><code>import os\nif os.getenv('KAGGLE_IS_COMPETITION_RERUN'):\n\nYour code......\n\nelse:\n    import pandas as pd\n    finalsub = pd.read_csv('../input/hubmap-organ-segmentation/sample_submission.csv')\n    finalsub.to_csv('submission.csv', index=False)\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 1940172,
          "author_name": "bhavesjain",
          "author_url": "",
          "post_date": "09/15/2022 07:59:05",
          "content": "<p>Thanks for responding <a href=\"https://www.kaggle.com/kirderf\" target=\"_blank\">@kirderf</a> <br>\nI.did solve the problem and it is exactly what you pointed out<br>\nBut the code that you posted, what exactly it is doing?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1940190,
          "author_name": "kirderf",
          "author_url": "",
          "post_date": "09/15/2022 08:10:07",
          "content": "<p>It's a new Env code that checks if the code is running in submit/local mode or in the private test-time mode.<br>\nBefore one could also use a code that checked the number of test time rows or files in the test ds/folder but the above works the same and is generic.</p>",
          "votes": null,
          "replies": [
            {
              "id": 1940201,
              "author_name": "bhavesjain",
              "author_url": "",
              "post_date": "09/15/2022 08:15:40",
              "content": "<p>Oh, makes sense</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1938816": "I went through the earlier posted discussions too and there's no clue at all to the probelm i'm facing.\nI'm able to  run the notebook on test set with augmenting the test set( for testing), tried on lower resolution images too. I have patche sof 512 and so i tried even 100*100 images. Even though 16 batch size runs fine, i tired 8 and 4.\nYet I've no clue.\n\nAnybody can help out?",
    "1939019": "As you know, notebook threw exception error occurs when your model is unable to deal with data it encounters.\nAnd, since you're speaking you patch the test images, here is the scenario I've come up with. Does your model discard less important patch (maybe less than threshold)? Then, your model could try to divide a small size image by a patch. Let's say image size = 256 and patch size=512. So 1 patch will be there. But the patch does not meet the threshold, and the model discards the patch or the whole image. That means your model returns nothing so your model halts there unless you prevent such case with  ```rle = '' ``` setting . Or similarly your model makes an inference on a small image and there's nothing so it returns nothing, causing the same error. Maybe the same error occurs while combining multiple inference on one object when one of them returns null. I'll let you know if other bad scenarios come into my mind. Hopefully your case will be handled soon.\nBy the way  make sure you have the model run through the whole validation set in order to see if the corresponding submission.csv for the validation set would print accordingly.",
    "1939046": "Hello, I have some suggestions that may help you: \n1. Although you increase the amount of data, the noise will also increase, so you may consider removing the useless patches. \n2. Try to balance the proportion of positive and negative samples. It is possible that your patch contains a large number of blank RLE, which will bring great noise to the training.\n\nI have improved my performance by using these two methods, and I hope they can help you as well",
    "1939052": "I'm using tensorflow's extract patches so it pads the images , tried it after getting the error first time \n\nMy code runs properly and has worked till now pretty fine\nbut it broke down when i submitted to kaggle",
    "1939075": "I don't know much about tensorflow's extract patches method so I can't answer clearly about it but notebook threw exception occurs due to [this reason](https://www.kaggle.com/code-competition-debugging#:~:text=Notebook%20Threw%20Exception%3A%20While%20rerunning%20your%20code%2C%20your%20notebook%20hit%20an%20unhandled%20error.%20Note%20that%20the%20hidden%20dataset%20can%20be%20larger/smaller/different%20than%20the%20public%20dataset.) for sure. So there must be something wrong with handling data. Maybe combining augmentation process could go wrong like (none object + predictions) etc. If I were you, I would first have the model run through validation sets and see if it prints out submission.csv for validation set accordingly. \n\nps highlightlink doesn't work so I copy and past it here: ```Notebook Threw Exception: While rerunning your code, your notebook hit an unhandled error. Note that the hidden dataset can be larger/smaller/different than the public dataset.```",
    "1939082": "i've tried making submission.csv on validation , it works fine",
    "1939089": "I want to make sure your model returns ```rle=''``` when it predicts nothing. If you didn't check, could you put a zero tensor as the result of the prediction (maybe right after combining all predicted patches)?",
    "1939114": "Yes, i ran the notebook to confirm to you, but it does return `''` so there ain't problem either",
    "1939121": "Well... I think that's all I can come up with now. Sorry man. I'll let you know if there's anything comes into my mind.",
    "1939176": "thanks buddy, i hope something turns up",
    "1939493": "It worked out, it really was error in the RLE function, just needed to return ''. Thanks a lot buddy",
    "1939637": "Glad to hear that you managed the issue!  You're welcome.",
    "1940141": "I had some problem with submitting and got Notebook threw exception even if it worked during validation, and I used below fix dealing with it:\nIt also saves GPU quota while submitting :)\n\n```\nimport os\nif os.getenv('KAGGLE_IS_COMPETITION_RERUN'):\n\nYour code......\n\nelse:\n    import pandas as pd\n    finalsub = pd.read_csv('../input/hubmap-organ-segmentation/sample_submission.csv')\n    finalsub.to_csv('submission.csv', index=False)\n```",
    "1940172": "Thanks for responding @kirderf \nI.did solve the problem and it is exactly what you pointed out\nBut the code that you posted, what exactly it is doing?",
    "1940190": "It's a new Env code that checks if the code is running in submit/local mode or in the private test-time mode.\nBefore one could also use a code that checked the number of test time rows or files in the test ds/folder but the above works the same and is generic.",
    "1940201": "Oh, makes sense"
  },
  "source": "meta"
}