{
  "id": 209858,
  "title": "Struggling Beginner Question",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/209858",
  "author_name": "",
  "post_date": "2021-01-08T19:58:41.845485400Z",
  "votes": null,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hi All,</p>\n<p>I am having a hard time getting my submissions to have a decent score. I essentially forked the code from <a href=\"https://www.kaggle.com/wuliaokaola/getting-started-tpus-new-tfrecords\" target=\"_blank\">another notebook</a> and submitted my score, but while the original notebook scored &gt;0.80, mine scored 0.8, but after making a submission it goes down significantly…</p>\n<p>I thought maybe this just a bad fluke and re-trained it using 5-fold CV and averaged their predictions in my inference notebook, and still got very awful results. <strong>Would anyone be able to quickly glance at my notebook and give me a pointer in to what is going wrong here?</strong> I really appreciate any help.</p>\n<p>My prediction notebook:<br>\n<a href=\"https://www.kaggle.com/funky15/tpus-with-5-fold\" target=\"_blank\">https://www.kaggle.com/funky15/tpus-with-5-fold</a></p>\n<p>My inference notebook:<br>\n<a href=\"https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1\" target=\"_blank\">https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1</a></p>",
  "messages": [
    {
      "id": "1145007",
      "postDate": "01/08/2021 19:58:41",
      "content": "<p>Hi All,</p>\n<p>I am having a hard time getting my submissions to have a decent score. I essentially forked the code from <a href=\"https://www.kaggle.com/wuliaokaola/getting-started-tpus-new-tfrecords\" target=\"_blank\">another notebook</a> and submitted my score, but while the original notebook scored &gt;0.80, mine scored 0.8, but after making a submission it goes down significantly…</p>\n<p>I thought maybe this just a bad fluke and re-trained it using 5-fold CV and averaged their predictions in my inference notebook, and still got very awful results. <strong>Would anyone be able to quickly glance at my notebook and give me a pointer in to what is going wrong here?</strong> I really appreciate any help.</p>\n<p>My prediction notebook:<br>\n<a href=\"https://www.kaggle.com/funky15/tpus-with-5-fold\" target=\"_blank\">https://www.kaggle.com/funky15/tpus-with-5-fold</a></p>\n<p>My inference notebook:<br>\n<a href=\"https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1\" target=\"_blank\">https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1</a></p>",
      "rawMarkdown": "Hi All,\n\nI am having a hard time getting my submissions to have a decent score. I essentially forked the code from [another notebook](https://www.kaggle.com/wuliaokaola/getting-started-tpus-new-tfrecords) and submitted my score, but while the original notebook scored >0.80, mine scored <0.60. No idea why. My validation accuracy is always >0.8, but after making a submission it goes down significantly...\n\nI thought maybe this just a bad fluke and re-trained it using 5-fold CV and averaged their predictions in my inference notebook, and still got very awful results. **Would anyone be able to quickly glance at my notebook and give me a pointer in to what is going wrong here?** I really appreciate any help.\n\nMy prediction notebook:\n[https://www.kaggle.com/funky15/tpus-with-5-fold](https://www.kaggle.com/funky15/tpus-with-5-fold)\n\nMy inference notebook:\n[https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1](https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1)",
      "votes": null
    },
    {
      "id": "1145023",
      "postDate": "01/08/2021 20:14:16",
      "content": "<p>It could be because you are normalizing pixel values in training but not during inference.</p>\n<p>In your TPU inference notebook add code that normalizes pixels.</p>\n<pre><code>for i in glob.glob(image_dir+\"/*.jpg\"):\n        image = Image.open(i)\n        image = image.resize((IMAGE_SIZE, IMAGE_SIZE))\n        image = np.expand_dims(image, axis = 0)\n        image = image/255 #ADD THIS LINE\n        preds.append(np.argmax(model_obj.predict(image))+1)\n        img_ids.append(i.replace(image_dir+\"/\", \"\"))\n</code></pre>\n<p>Let me know if this works!</p>",
      "rawMarkdown": "It could be because you are normalizing pixel values in training but not during inference.\n\nIn your TPU inference notebook add code that normalizes pixels.\n\n```\nfor i in glob.glob(image_dir+\"/*.jpg\"):\n        image = Image.open(i)\n        image = image.resize((IMAGE_SIZE, IMAGE_SIZE))\n        image = np.expand_dims(image, axis = 0)\n        image = image/255 #ADD THIS LINE\n        preds.append(np.argmax(model_obj.predict(image))+1)\n        img_ids.append(i.replace(image_dir+\"/\", \"\"))\n```\n\nLet me know if this works!",
      "votes": null
    },
    {
      "id": "1145038",
      "postDate": "01/08/2021 20:28:38",
      "content": "<p><a href=\"https://www.kaggle.com/brendanartley\" target=\"_blank\">@brendanartley</a> Thank you so much! That looks like it is a problem.</p>",
      "rawMarkdown": "brendanartley Thank you so much! That looks like it is a problem.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1145023,
      "author_name": "brendanartley",
      "author_url": "",
      "post_date": "01/08/2021 20:14:16",
      "content": "<p>It could be because you are normalizing pixel values in training but not during inference.</p>\n<p>In your TPU inference notebook add code that normalizes pixels.</p>\n<pre><code>for i in glob.glob(image_dir+\"/*.jpg\"):\n        image = Image.open(i)\n        image = image.resize((IMAGE_SIZE, IMAGE_SIZE))\n        image = np.expand_dims(image, axis = 0)\n        image = image/255 #ADD THIS LINE\n        preds.append(np.argmax(model_obj.predict(image))+1)\n        img_ids.append(i.replace(image_dir+\"/\", \"\"))\n</code></pre>\n<p>Let me know if this works!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1145038,
      "author_name": "funky15",
      "author_url": "",
      "post_date": "01/08/2021 20:28:38",
      "content": "<p><a href=\"https://www.kaggle.com/brendanartley\" target=\"_blank\">@brendanartley</a> Thank you so much! That looks like it is a problem.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1145007": "Hi All,\n\nI am having a hard time getting my submissions to have a decent score. I essentially forked the code from [another notebook](https://www.kaggle.com/wuliaokaola/getting-started-tpus-new-tfrecords) and submitted my score, but while the original notebook scored >0.80, mine scored <0.60. No idea why. My validation accuracy is always >0.8, but after making a submission it goes down significantly...\n\nI thought maybe this just a bad fluke and re-trained it using 5-fold CV and averaged their predictions in my inference notebook, and still got very awful results. **Would anyone be able to quickly glance at my notebook and give me a pointer in to what is going wrong here?** I really appreciate any help.\n\nMy prediction notebook:\n[https://www.kaggle.com/funky15/tpus-with-5-fold](https://www.kaggle.com/funky15/tpus-with-5-fold)\n\nMy inference notebook:\n[https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1](https://www.kaggle.com/funky15/5-fold-tpu-inference-plus1)",
    "1145023": "It could be because you are normalizing pixel values in training but not during inference.\n\nIn your TPU inference notebook add code that normalizes pixels.\n\n```\nfor i in glob.glob(image_dir+\"/*.jpg\"):\n        image = Image.open(i)\n        image = image.resize((IMAGE_SIZE, IMAGE_SIZE))\n        image = np.expand_dims(image, axis = 0)\n        image = image/255 #ADD THIS LINE\n        preds.append(np.argmax(model_obj.predict(image))+1)\n        img_ids.append(i.replace(image_dir+\"/\", \"\"))\n```\n\nLet me know if this works!",
    "1145038": "brendanartley Thank you so much! That looks like it is a problem."
  },
  "source": "meta"
}