{
  "id": 101996,
  "title": "Different LB scores from exactly identical kernel?",
  "url": "/competitions/aptos2019-blindness-detection/discussion/101996",
  "author_name": "",
  "post_date": "2019-07-30T10:17:44.112063500Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I have a kernel of LB score 0.710 (commit to competition few days ago)\nbut when I commit to competition today with this kernel, the score much lower, only got 0.647\nthen i recommit some other previous kernels to competition, it turned out that all LB score is declined.\ndose public test dataset changed? \nanyone has encountered this problem?</p>",
  "messages": [
    {
      "id": "588240",
      "postDate": "07/30/2019 10:17:44",
      "content": "<p>I have a kernel of LB score 0.710 (commit to competition few days ago)\nbut when I commit to competition today with this kernel, the score much lower, only got 0.647\nthen i recommit some other previous kernels to competition, it turned out that all LB score is declined.\ndose public test dataset changed? \nanyone has encountered this problem?</p>",
      "rawMarkdown": "I have a kernel of LB score 0.710 (commit to competition few days ago)\nbut when I commit to competition today with this kernel, the score much lower, only got 0.647\nthen i recommit some other previous kernels to competition, it turned out that all LB score is declined.\ndose public test dataset changed? \nanyone has encountered this problem?",
      "votes": null
    },
    {
      "id": "588242",
      "postDate": "07/30/2019 10:21:11",
      "content": "<p>In case you haven't set random seed for everything than it is supposed to differ.</p>",
      "rawMarkdown": "In case you haven't set random seed for everything than it is supposed to differ.",
      "votes": null
    },
    {
      "id": "588304",
      "postDate": "07/30/2019 12:00:58",
      "content": "<p>i use kernel pipeline to commit my predictions. that is :  training the model in one kernel, upload the model as dataset, and using another kernel to load that trained model and predict. \nso there should be no random seed problem, cos they load exactly the same model, and preprocessing is deterministic(just resize)\nbut they got quite different score. that puzzled me.</p>",
      "rawMarkdown": "i use kernel pipeline to commit my predictions. that is :  training the model in one kernel, upload the model as dataset, and using another kernel to load that trained model and predict. \nso there should be no random seed problem, cos they load exactly the same model, and preprocessing is deterministic(just resize)\nbut they got quite different score. that puzzled me.",
      "votes": null
    },
    {
      "id": "588578",
      "postDate": "07/30/2019 18:59:27",
      "content": "<p>as Val an said, you need to explicitly set the seed to get reproducible results. You can find more details in this nice blog: <a href=\"https://machinelearningmastery.com/randomness-in-machine-learning/\">https://machinelearningmastery.com/randomness-in-machine-learning/</a></p>\n\n<p>in PyTorch, I use the below snippet to set the seed (credits to multiple Kagglers who posted the same in other threads)</p>\n\n<p><code>\n    np.random.seed(seedValue) # cpu vars\n    torch.manual_seed(seedValue) # cpu  vars\n    random.seed(seedValue) # Python\n    os.environ['PYTHONHASHSEED'] = str(seedValue)\n    torch.cuda.manual_seed(seedValue)\n    torch.cuda.manual_seed_all(seedValue) # gpu vars\n    torch.backends.cudnn.deterministic = True  #needed\n    torch.backends.cudnn.benchmark = False\n</code>\nApparrently Keras with GPUs does not support deterministic results. Hard luck if you are using Keras with GPU. This is one of the reasons I moved from Keras to PyTorch.</p>",
      "rawMarkdown": "as Val an said, you need to explicitly set the seed to get reproducible results. You can find more details in this nice blog: https://machinelearningmastery.com/randomness-in-machine-learning/\n\nin PyTorch, I use the below snippet to set the seed (credits to multiple Kagglers who posted the same in other threads)\n\n```\n    np.random.seed(seedValue) # cpu vars\n    torch.manual_seed(seedValue) # cpu  vars\n    random.seed(seedValue) # Python\n    os.environ['PYTHONHASHSEED'] = str(seedValue)\n    torch.cuda.manual_seed(seedValue)\n    torch.cuda.manual_seed_all(seedValue) # gpu vars\n    torch.backends.cudnn.deterministic = True  #needed\n    torch.backends.cudnn.benchmark = False\n```\nApparrently Keras with GPUs does not support deterministic results. Hard luck if you are using Keras with GPU. This is one of the reasons I moved from Keras to PyTorch.",
      "votes": null
    },
    {
      "id": "588765",
      "postDate": "07/31/2019 02:26:31",
      "content": "<p>thank you, learned a lot. unfortunately, I use keras now,  I will try PyTorch if I have time.</p>",
      "rawMarkdown": "thank you, learned a lot. unfortunately, I use keras now,  I will try PyTorch if I have time.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 588242,
      "author_name": "valanm",
      "author_url": "",
      "post_date": "07/30/2019 10:21:11",
      "content": "<p>In case you haven't set random seed for everything than it is supposed to differ.</p>",
      "votes": null,
      "replies": [
        {
          "id": 588304,
          "author_name": "frank518",
          "author_url": "",
          "post_date": "07/30/2019 12:00:58",
          "content": "<p>i use kernel pipeline to commit my predictions. that is :  training the model in one kernel, upload the model as dataset, and using another kernel to load that trained model and predict. \nso there should be no random seed problem, cos they load exactly the same model, and preprocessing is deterministic(just resize)\nbut they got quite different score. that puzzled me.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 588578,
          "author_name": "ravivadapalli",
          "author_url": "",
          "post_date": "07/30/2019 18:59:27",
          "content": "<p>as Val an said, you need to explicitly set the seed to get reproducible results. You can find more details in this nice blog: <a href=\"https://machinelearningmastery.com/randomness-in-machine-learning/\">https://machinelearningmastery.com/randomness-in-machine-learning/</a></p>\n\n<p>in PyTorch, I use the below snippet to set the seed (credits to multiple Kagglers who posted the same in other threads)</p>\n\n<p><code>\n    np.random.seed(seedValue) # cpu vars\n    torch.manual_seed(seedValue) # cpu  vars\n    random.seed(seedValue) # Python\n    os.environ['PYTHONHASHSEED'] = str(seedValue)\n    torch.cuda.manual_seed(seedValue)\n    torch.cuda.manual_seed_all(seedValue) # gpu vars\n    torch.backends.cudnn.deterministic = True  #needed\n    torch.backends.cudnn.benchmark = False\n</code>\nApparrently Keras with GPUs does not support deterministic results. Hard luck if you are using Keras with GPU. This is one of the reasons I moved from Keras to PyTorch.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 588765,
          "author_name": "frank518",
          "author_url": "",
          "post_date": "07/31/2019 02:26:31",
          "content": "<p>thank you, learned a lot. unfortunately, I use keras now,  I will try PyTorch if I have time.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "588240": "I have a kernel of LB score 0.710 (commit to competition few days ago)\nbut when I commit to competition today with this kernel, the score much lower, only got 0.647\nthen i recommit some other previous kernels to competition, it turned out that all LB score is declined.\ndose public test dataset changed? \nanyone has encountered this problem?",
    "588242": "In case you haven't set random seed for everything than it is supposed to differ.",
    "588304": "i use kernel pipeline to commit my predictions. that is :  training the model in one kernel, upload the model as dataset, and using another kernel to load that trained model and predict. \nso there should be no random seed problem, cos they load exactly the same model, and preprocessing is deterministic(just resize)\nbut they got quite different score. that puzzled me.",
    "588578": "as Val an said, you need to explicitly set the seed to get reproducible results. You can find more details in this nice blog: https://machinelearningmastery.com/randomness-in-machine-learning/\n\nin PyTorch, I use the below snippet to set the seed (credits to multiple Kagglers who posted the same in other threads)\n\n```\n    np.random.seed(seedValue) # cpu vars\n    torch.manual_seed(seedValue) # cpu  vars\n    random.seed(seedValue) # Python\n    os.environ['PYTHONHASHSEED'] = str(seedValue)\n    torch.cuda.manual_seed(seedValue)\n    torch.cuda.manual_seed_all(seedValue) # gpu vars\n    torch.backends.cudnn.deterministic = True  #needed\n    torch.backends.cudnn.benchmark = False\n```\nApparrently Keras with GPUs does not support deterministic results. Hard luck if you are using Keras with GPU. This is one of the reasons I moved from Keras to PyTorch.",
    "588765": "thank you, learned a lot. unfortunately, I use keras now,  I will try PyTorch if I have time."
  },
  "source": "meta"
}