{
  "id": 453660,
  "title": "Beginner question: can you use models you trained locally?",
  "url": "/competitions/stanford-ribonanza-rna-folding/discussion/453660",
  "author_name": "",
  "post_date": "2023-11-07T08:19:48.712255300Z",
  "votes": 6,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Hi guys, </p>\n<p>I haven<code>t been on kaggle for a while. I wanted to asked you if it</code>s possible (and allowed) to do inference for the competition with models you trained locally or somewhere else other than a kaggle notebook?</p>\n<p>If it`s possible, how can one do that? By uploading the model to a dataset and import at inference?</p>",
  "messages": [
    {
      "id": "2515766",
      "postDate": "11/07/2023 08:19:48",
      "content": "<p>Hi guys, </p>\n<p>I haven<code>t been on kaggle for a while. I wanted to asked you if it</code>s possible (and allowed) to do inference for the competition with models you trained locally or somewhere else other than a kaggle notebook?</p>\n<p>If it`s possible, how can one do that? By uploading the model to a dataset and import at inference?</p>",
      "rawMarkdown": "Hi guys, \n\nI haven`t been on kaggle for a while. I wanted to asked you if it`s possible (and allowed) to do inference for the competition with models you trained locally or somewhere else other than a kaggle notebook?\n\nIf it`s possible, how can one do that? By uploading the model to a dataset and import at inference?",
      "votes": null
    },
    {
      "id": "2515787",
      "postDate": "11/07/2023 08:39:07",
      "content": "<p>Yes. This is not a code competition, so you can train and predict locally, then just submit the results. </p>",
      "rawMarkdown": "Yes. This is not a code competition, so you can train and predict locally, then just submit the results.",
      "votes": null
    },
    {
      "id": "2515893",
      "postDate": "11/07/2023 10:24:14",
      "content": "<p>Yes your approach is correct <a href=\"https://www.kaggle.com/rosuluc\" target=\"_blank\">@rosuluc</a> <br>\nYou need to pickle and save your local models and upload this as a dataset and use it on Kaggle for inferencing. However ensure that the dependencies are in sync or else you will need to use extra .whl files for the associated mismatches with the Kaggle environment too. </p>",
      "rawMarkdown": "Yes your approach is correct @rosuluc \nYou need to pickle and save your local models and upload this as a dataset and use it on Kaggle for inferencing. However ensure that the dependencies are in sync or else you will need to use extra .whl files for the associated mismatches with the Kaggle environment too.",
      "votes": null
    },
    {
      "id": "2516314",
      "postDate": "11/07/2023 16:10:08",
      "content": "<p>Hey, there. Of course you can do it, just simply follow these step1.</p>\n<ol>\n<li>Save the model your train into a dictionary. <code>torch.save(model.state_dict(), 'model.pt')</code></li>\n<li>re-construct the model in you code. <code>model = XXXX</code></li>\n<li>Load the parameters into the model. <code>model.load_state_dict(torch.load('model.pt'))</code></li>\n</ol>",
      "rawMarkdown": "Hey, there. Of course you can do it, just simply follow these step1.\n1. Save the model your train into a dictionary. `torch.save(model.state_dict(), 'model.pt')`\n2. re-construct the model in you code. `model = XXXX`\n3. Load the parameters into the model. `model.load_state_dict(torch.load('model.pt'))`",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2515787,
      "author_name": "fnands",
      "author_url": "",
      "post_date": "11/07/2023 08:39:07",
      "content": "<p>Yes. This is not a code competition, so you can train and predict locally, then just submit the results. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2515893,
      "author_name": "ravi20076",
      "author_url": "",
      "post_date": "11/07/2023 10:24:14",
      "content": "<p>Yes your approach is correct <a href=\"https://www.kaggle.com/rosuluc\" target=\"_blank\">@rosuluc</a> <br>\nYou need to pickle and save your local models and upload this as a dataset and use it on Kaggle for inferencing. However ensure that the dependencies are in sync or else you will need to use extra .whl files for the associated mismatches with the Kaggle environment too. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 2516314,
      "author_name": "ruiqizhuangricky",
      "author_url": "",
      "post_date": "11/07/2023 16:10:08",
      "content": "<p>Hey, there. Of course you can do it, just simply follow these step1.</p>\n<ol>\n<li>Save the model your train into a dictionary. <code>torch.save(model.state_dict(), 'model.pt')</code></li>\n<li>re-construct the model in you code. <code>model = XXXX</code></li>\n<li>Load the parameters into the model. <code>model.load_state_dict(torch.load('model.pt'))</code></li>\n</ol>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2515766": "Hi guys, \n\nI haven`t been on kaggle for a while. I wanted to asked you if it`s possible (and allowed) to do inference for the competition with models you trained locally or somewhere else other than a kaggle notebook?\n\nIf it`s possible, how can one do that? By uploading the model to a dataset and import at inference?",
    "2515787": "Yes. This is not a code competition, so you can train and predict locally, then just submit the results.",
    "2515893": "Yes your approach is correct @rosuluc \nYou need to pickle and save your local models and upload this as a dataset and use it on Kaggle for inferencing. However ensure that the dependencies are in sync or else you will need to use extra .whl files for the associated mismatches with the Kaggle environment too.",
    "2516314": "Hey, there. Of course you can do it, just simply follow these step1.\n1. Save the model your train into a dictionary. `torch.save(model.state_dict(), 'model.pt')`\n2. re-construct the model in you code. `model = XXXX`\n3. Load the parameters into the model. `model.load_state_dict(torch.load('model.pt'))`"
  },
  "source": "meta"
}