{
  "id": 666181,
  "title": "Submission error ",
  "url": "/competitions/csiro-biomass/discussion/666181",
  "author_name": "",
  "post_date": "2026-01-05T18:04:29.308295200Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I have made my notebook public for any one to see and tell why it throws error when submitted : <a href=\"https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook\" target=\"_blank\">https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook</a></p>",
  "messages": [
    {
      "id": "3386706",
      "postDate": "01/05/2026 18:04:29",
      "content": "<p>I have made my notebook public for any one to see and tell why it throws error when submitted : <a href=\"https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook\" target=\"_blank\">https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook</a></p>",
      "rawMarkdown": "I have made my notebook public for any one to see and tell why it throws error when submitted : https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook",
      "votes": null
    },
    {
      "id": "3386809",
      "postDate": "01/05/2026 21:58:27",
      "content": "<p>Looking at it now - I revised the notebook so it predicts on the train folder.  Will let you know what I find after it runs.  I think it's going to end up predicting only one train image, but we will see ….</p>",
      "rawMarkdown": "Looking at it now - I revised the notebook so it predicts on the train folder.  Will let you know what I find after it runs.  I think it's going to end up predicting only one train image, but we will see ....",
      "votes": null
    },
    {
      "id": "3386837",
      "postDate": "01/05/2026 23:44:47",
      "content": "<p>It was a bit tricky to get your code to predict on the train images.  Doing this is a Kaggle basic's debug method when you get a submission error.   </p>\n<p>I think I got it right and as I guessed you are only predicting values for the first image.  The rest of the images in train all got nan for values.</p>\n<p>Change your code to predict on train images.  Than work to understand why only the initial image is predicted.  Once you are successfully predicting the 357 train images than you can convert back to predicting on test and make a submission.</p>\n<p>Good luck</p>",
      "rawMarkdown": "It was a bit tricky to get your code to predict on the train images.  Doing this is a Kaggle basic's debug method when you get a submission error.   \n\nI think I got it right and as I guessed you are only predicting values for the first image.  The rest of the images in train all got nan for values.\n\nChange your code to predict on train images.  Than work to understand why only the initial image is predicted.  Once you are successfully predicting the 357 train images than you can convert back to predicting on test and make a submission.\n\nGood luck",
      "votes": null
    },
    {
      "id": "3386841",
      "postDate": "01/05/2026 23:49:05",
      "content": "<p>Gemini Pro suggests this as your error</p>\n<p>The evaluation loop (Cell 31) collects predictions into a list called all_preds. The issue is in Cell 33, where all_preds[0] is selected. This only retrieves the predictions for the first batch (which, with the default batch size of 1, is just the first image's rows). The remaining rows in your submission DataFrame become NaN because the target list is too short.</p>",
      "rawMarkdown": "Gemini Pro suggests this as your error\n\nThe evaluation loop (Cell 31) collects predictions into a list called all_preds. The issue is in Cell 33, where all_preds[0] is selected. This only retrieves the predictions for the first batch (which, with the default batch size of 1, is just the first image's rows). The remaining rows in your submission DataFrame become NaN because the target list is too short.",
      "votes": null
    },
    {
      "id": "3386853",
      "postDate": "01/06/2026 00:07:49",
      "content": "<p>I replaced this line</p>\n<p><code>target = pd.DataFrame(all_preds[0].view(-1).tolist(), columns = ['target'])</code></p>\n<p>with this code and it predicts all the images in the train folder.</p>\n<pre><code># Concatenate all batch outputs into a single tensor first (handles any batch size)\nfull_predictions = torch.cat(all_preds)\n\n# The test set repeats images 5 times (for each target type), but the model predicts all 5 values at once.\n# We take every 5th output row (which corresponds to the 'Clover' input, matching your training data prep)\n# and flatten the [N, 5] tensor to [N*5] to align with the test dataframe rows.\n# Use .reshape(-1) instead of .view(-1) because slicing [::5] creates a non-contiguous tensor.\ntarget = pd.DataFrame(full_predictions[::5].reshape(-1).tolist(), columns = ['target'])\n</code></pre>",
      "rawMarkdown": "I replaced this line\n\n`target = pd.DataFrame(all_preds[0].view(-1).tolist(), columns = ['target'])`\n\nwith this code and it predicts all the images in the train folder.\n```python\n\n# Concatenate all batch outputs into a single tensor first (handles any batch size)\nfull_predictions = torch.cat(all_preds)\n\n# The test set repeats images 5 times (for each target type), but the model predicts all 5 values at once.\n# We take every 5th output row (which corresponds to the 'Clover' input, matching your training data prep)\n# and flatten the [N, 5] tensor to [N*5] to align with the test dataframe rows.\n# Use .reshape(-1) instead of .view(-1) because slicing [::5] creates a non-contiguous tensor.\ntarget = pd.DataFrame(full_predictions[::5].reshape(-1).tolist(), columns = ['target'])\n\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3386809,
      "author_name": "pcjimmmy",
      "author_url": "",
      "post_date": "01/05/2026 21:58:27",
      "content": "<p>Looking at it now - I revised the notebook so it predicts on the train folder.  Will let you know what I find after it runs.  I think it's going to end up predicting only one train image, but we will see ….</p>",
      "votes": null,
      "replies": [
        {
          "id": 3386837,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "01/05/2026 23:44:47",
          "content": "<p>It was a bit tricky to get your code to predict on the train images.  Doing this is a Kaggle basic's debug method when you get a submission error.   </p>\n<p>I think I got it right and as I guessed you are only predicting values for the first image.  The rest of the images in train all got nan for values.</p>\n<p>Change your code to predict on train images.  Than work to understand why only the initial image is predicted.  Once you are successfully predicting the 357 train images than you can convert back to predicting on test and make a submission.</p>\n<p>Good luck</p>",
          "votes": null,
          "replies": [
            {
              "id": 3386841,
              "author_name": "pcjimmmy",
              "author_url": "",
              "post_date": "01/05/2026 23:49:05",
              "content": "<p>Gemini Pro suggests this as your error</p>\n<p>The evaluation loop (Cell 31) collects predictions into a list called all_preds. The issue is in Cell 33, where all_preds[0] is selected. This only retrieves the predictions for the first batch (which, with the default batch size of 1, is just the first image's rows). The remaining rows in your submission DataFrame become NaN because the target list is too short.</p>",
              "votes": null,
              "replies": [
                {
                  "id": 3386853,
                  "author_name": "pcjimmmy",
                  "author_url": "",
                  "post_date": "01/06/2026 00:07:49",
                  "content": "<p>I replaced this line</p>\n<p><code>target = pd.DataFrame(all_preds[0].view(-1).tolist(), columns = ['target'])</code></p>\n<p>with this code and it predicts all the images in the train folder.</p>\n<pre><code># Concatenate all batch outputs into a single tensor first (handles any batch size)\nfull_predictions = torch.cat(all_preds)\n\n# The test set repeats images 5 times (for each target type), but the model predicts all 5 values at once.\n# We take every 5th output row (which corresponds to the 'Clover' input, matching your training data prep)\n# and flatten the [N, 5] tensor to [N*5] to align with the test dataframe rows.\n# Use .reshape(-1) instead of .view(-1) because slicing [::5] creates a non-contiguous tensor.\ntarget = pd.DataFrame(full_predictions[::5].reshape(-1).tolist(), columns = ['target'])\n</code></pre>",
                  "votes": null,
                  "replies": []
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3386706": "I have made my notebook public for any one to see and tell why it throws error when submitted : https://www.kaggle.com/code/mohammadwaleed123/csiro-notebook",
    "3386809": "Looking at it now - I revised the notebook so it predicts on the train folder.  Will let you know what I find after it runs.  I think it's going to end up predicting only one train image, but we will see ....",
    "3386837": "It was a bit tricky to get your code to predict on the train images.  Doing this is a Kaggle basic's debug method when you get a submission error.   \n\nI think I got it right and as I guessed you are only predicting values for the first image.  The rest of the images in train all got nan for values.\n\nChange your code to predict on train images.  Than work to understand why only the initial image is predicted.  Once you are successfully predicting the 357 train images than you can convert back to predicting on test and make a submission.\n\nGood luck",
    "3386841": "Gemini Pro suggests this as your error\n\nThe evaluation loop (Cell 31) collects predictions into a list called all_preds. The issue is in Cell 33, where all_preds[0] is selected. This only retrieves the predictions for the first batch (which, with the default batch size of 1, is just the first image's rows). The remaining rows in your submission DataFrame become NaN because the target list is too short.",
    "3386853": "I replaced this line\n\n`target = pd.DataFrame(all_preds[0].view(-1).tolist(), columns = ['target'])`\n\nwith this code and it predicts all the images in the train folder.\n```python\n\n# Concatenate all batch outputs into a single tensor first (handles any batch size)\nfull_predictions = torch.cat(all_preds)\n\n# The test set repeats images 5 times (for each target type), but the model predicts all 5 values at once.\n# We take every 5th output row (which corresponds to the 'Clover' input, matching your training data prep)\n# and flatten the [N, 5] tensor to [N*5] to align with the test dataframe rows.\n# Use .reshape(-1) instead of .view(-1) because slicing [::5] creates a non-contiguous tensor.\ntarget = pd.DataFrame(full_predictions[::5].reshape(-1).tolist(), columns = ['target'])\n\n```"
  },
  "source": "meta"
}