{
  "id": 98393,
  "title": "Unable to save model using fastai library",
  "url": "/competitions/aptos2019-blindness-detection/discussion/98393",
  "author_name": "",
  "post_date": "2019-07-03T13:45:57.613803700Z",
  "votes": 1,
  "comment_count": 7,
  "views": 0,
  "content": "<p>Hi All,\n   I am using fastai library for this competition. I saved the model using</p>\n\n<p>learn.save('stage-1')</p>\n\n<p>If I try to click on adding datasets to save the model, I am unable to see where my model is. I want to save the model and then run inference in a separate kernel but I am unable to save the model. Could someone please let me know how I could save the model and use it for inference? I am unable to see model when I click on add datasets link.</p>\n\n<p>Thanks and Regards,\nK Krishna Chaitanya</p>",
  "messages": [
    {
      "id": "567416",
      "postDate": "07/03/2019 13:45:57",
      "content": "<p>Hi All,\n   I am using fastai library for this competition. I saved the model using</p>\n\n<p>learn.save('stage-1')</p>\n\n<p>If I try to click on adding datasets to save the model, I am unable to see where my model is. I want to save the model and then run inference in a separate kernel but I am unable to save the model. Could someone please let me know how I could save the model and use it for inference? I am unable to see model when I click on add datasets link.</p>\n\n<p>Thanks and Regards,\nK Krishna Chaitanya</p>",
      "rawMarkdown": "Hi All,\n   I am using fastai library for this competition. I saved the model using\n\nlearn.save('stage-1')\n\n  If I try to click on adding datasets to save the model, I am unable to see where my model is. I want to save the model and then run inference in a separate kernel but I am unable to save the model. Could someone please let me know how I could save the model and use it for inference? I am unable to see model when I click on add datasets link.\n\nThanks and Regards,\nK Krishna Chaitanya",
      "votes": null
    },
    {
      "id": "567431",
      "postDate": "07/03/2019 14:07:09",
      "content": "<p>Did you check under output?</p>",
      "rawMarkdown": "Did you check under output?",
      "votes": null
    },
    {
      "id": "567523",
      "postDate": "07/03/2019 16:24:51",
      "content": "<p>You will need to change learner model_dir to \"/kaggle/working\"</p>\n\n<p><code>\nlearn.model_dir = \"/kaggle/working\"\n</code>\n<code>\nlearn.save(\"stage-1\")\n</code></p>",
      "rawMarkdown": "You will need to change learner model_dir to \"/kaggle/working\"\n\n`\nlearn.model_dir = \"/kaggle/working\"\n`\n`\nlearn.save(\"stage-1\")\n`",
      "votes": null
    },
    {
      "id": "567877",
      "postDate": "07/04/2019 05:33:15",
      "content": "<p>You can also use <code>model_dir='.'</code> as a parameter in <code>cnn_learner</code> function. The <code>.</code> folder means you will get an output in the folder where sample_submission file has been put.</p>\n\n<p><code>learn.save('stage-1', return_path=True)</code> saves a model and returns the path to that model.</p>",
      "rawMarkdown": "You can also use `model_dir='.'` as a parameter in `cnn_learner` function. The `.` folder means you will get an output in the folder where sample_submission file has been put.\n\n`learn.save('stage-1', return_path=True)` saves a model and returns the path to that model.",
      "votes": null
    },
    {
      "id": "567913",
      "postDate": "07/04/2019 06:47:02",
      "content": "<p>You can find complete docs <a href=\"https://docs.fast.ai/basic_train.html#Learner.save\">here</a></p>",
      "rawMarkdown": "You can find complete docs [here](https://docs.fast.ai/basic_train.html#Learner.save)",
      "votes": null
    },
    {
      "id": "568104",
      "postDate": "07/04/2019 12:01:55",
      "content": "<p>Thanks for the help. I am able to save the model but I am unable to save it to datasets. When I clicked on commit, my kernel is running from more than 5 hours. I do not know how long it would take. Will I be able to save my model once the kernel gets executed?</p>",
      "rawMarkdown": "Thanks for the help. I am able to save the model but I am unable to save it to datasets. When I clicked on commit, my kernel is running from more than 5 hours. I do not know how long it would take. Will I be able to save my model once the kernel gets executed?",
      "votes": null
    },
    {
      "id": "568108",
      "postDate": "07/04/2019 12:08:50",
      "content": "<p>I don't think you can save model to datasets without committing. Although you can use FileLink to download file directly from interactive kernel. </p>\n\n<p>Try training a model for few epocs and see if you are able to save model after commit. </p>",
      "rawMarkdown": "I don't think you can save model to datasets without committing. Although you can use FileLink to download file directly from interactive kernel. \n\nTry training a model for few epocs and see if you are able to save model after commit.",
      "votes": null
    },
    {
      "id": "568133",
      "postDate": "07/04/2019 13:07:12",
      "content": "<p>Fastai models are built over pytorch, so you can simply call the model as <code>learner.model</code> and save it using <code>learner.model.save(&lt;name&gt;)</code></p>",
      "rawMarkdown": "Fastai models are built over pytorch, so you can simply call the model as `learner.model` and save it using `learner.model.save(",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 567431,
      "author_name": "konradb",
      "author_url": "",
      "post_date": "07/03/2019 14:07:09",
      "content": "<p>Did you check under output?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 567523,
      "author_name": "sidujjain",
      "author_url": "",
      "post_date": "07/03/2019 16:24:51",
      "content": "<p>You will need to change learner model_dir to \"/kaggle/working\"</p>\n\n<p><code>\nlearn.model_dir = \"/kaggle/working\"\n</code>\n<code>\nlearn.save(\"stage-1\")\n</code></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 567877,
      "author_name": "safonau",
      "author_url": "",
      "post_date": "07/04/2019 05:33:15",
      "content": "<p>You can also use <code>model_dir='.'</code> as a parameter in <code>cnn_learner</code> function. The <code>.</code> folder means you will get an output in the folder where sample_submission file has been put.</p>\n\n<p><code>learn.save('stage-1', return_path=True)</code> saves a model and returns the path to that model.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 567913,
      "author_name": "init27",
      "author_url": "",
      "post_date": "07/04/2019 06:47:02",
      "content": "<p>You can find complete docs <a href=\"https://docs.fast.ai/basic_train.html#Learner.save\">here</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 568104,
      "author_name": "kkrishnachaitanya",
      "author_url": "",
      "post_date": "07/04/2019 12:01:55",
      "content": "<p>Thanks for the help. I am able to save the model but I am unable to save it to datasets. When I clicked on commit, my kernel is running from more than 5 hours. I do not know how long it would take. Will I be able to save my model once the kernel gets executed?</p>",
      "votes": null,
      "replies": [
        {
          "id": 568108,
          "author_name": "sidujjain",
          "author_url": "",
          "post_date": "07/04/2019 12:08:50",
          "content": "<p>I don't think you can save model to datasets without committing. Although you can use FileLink to download file directly from interactive kernel. </p>\n\n<p>Try training a model for few epocs and see if you are able to save model after commit. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 568133,
      "author_name": "thanatoz",
      "author_url": "",
      "post_date": "07/04/2019 13:07:12",
      "content": "<p>Fastai models are built over pytorch, so you can simply call the model as <code>learner.model</code> and save it using <code>learner.model.save(&lt;name&gt;)</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "567416": "Hi All,\n   I am using fastai library for this competition. I saved the model using\n\nlearn.save('stage-1')\n\n  If I try to click on adding datasets to save the model, I am unable to see where my model is. I want to save the model and then run inference in a separate kernel but I am unable to save the model. Could someone please let me know how I could save the model and use it for inference? I am unable to see model when I click on add datasets link.\n\nThanks and Regards,\nK Krishna Chaitanya",
    "567431": "Did you check under output?",
    "567523": "You will need to change learner model_dir to \"/kaggle/working\"\n\n`\nlearn.model_dir = \"/kaggle/working\"\n`\n`\nlearn.save(\"stage-1\")\n`",
    "567877": "You can also use `model_dir='.'` as a parameter in `cnn_learner` function. The `.` folder means you will get an output in the folder where sample_submission file has been put.\n\n`learn.save('stage-1', return_path=True)` saves a model and returns the path to that model.",
    "567913": "You can find complete docs [here](https://docs.fast.ai/basic_train.html#Learner.save)",
    "568104": "Thanks for the help. I am able to save the model but I am unable to save it to datasets. When I clicked on commit, my kernel is running from more than 5 hours. I do not know how long it would take. Will I be able to save my model once the kernel gets executed?",
    "568108": "I don't think you can save model to datasets without committing. Although you can use FileLink to download file directly from interactive kernel. \n\nTry training a model for few epocs and see if you are able to save model after commit.",
    "568133": "Fastai models are built over pytorch, so you can simply call the model as `learner.model` and save it using `learner.model.save("
  },
  "source": "meta"
}