{
  "id": 73590,
  "title": "How can I save model in kernel?",
  "url": "/competitions/quora-insincere-questions-classification/discussion/73590",
  "author_name": "",
  "post_date": "2018-12-04T08:18:53.808286Z",
  "votes": 6,
  "comment_count": 9,
  "views": 0,
  "content": "<p>When training models, I want to save the best model, but I find the input folder is read-only, so I don't know how to save model.</p>",
  "messages": [
    {
      "id": "432707",
      "postDate": "12/04/2018 08:18:53",
      "content": "<p>When training models, I want to save the best model, but I find the input folder is read-only, so I don't know how to save model.</p>",
      "rawMarkdown": "When training models, I want to save the best model, but I find the input folder is read-only, so I don't know how to save model.",
      "votes": null
    },
    {
      "id": "432714",
      "postDate": "12/04/2018 08:36:00",
      "content": "<p>I use ModelCheckpoint in Keras, here is an example: <a href=\"https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook\">https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook</a></p>",
      "rawMarkdown": "I use ModelCheckpoint in Keras, here is an example: https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook",
      "votes": null
    },
    {
      "id": "432739",
      "postDate": "12/04/2018 09:10:51",
      "content": "<p>Thanks for your help. I think that the kernel can't provide the function to save models. So we can only use some library functions, such as Keras. Do I have an exact understanding?</p>",
      "rawMarkdown": "Thanks for your help. I think that the kernel can't provide the function to save models. So we can only use some library functions, such as Keras. Do I have an exact understanding?",
      "votes": null
    },
    {
      "id": "432747",
      "postDate": "12/04/2018 09:19:20",
      "content": "<p>yes. There are many possible models, we can't expect Kaggle to support saving all of them.</p>",
      "rawMarkdown": "yes. There are many possible models, we can't expect Kaggle to support saving all of them.",
      "votes": null
    },
    {
      "id": "433042",
      "postDate": "12/04/2018 15:46:35",
      "content": "<p>I believe you can save anything you want to the root folder. Just like you save the submission file.\n<a href=\"https://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output\">https://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output</a></p>",
      "rawMarkdown": "I believe you can save anything you want to the root folder. Just like you save the submission file.\nhttps://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output",
      "votes": null
    },
    {
      "id": "434041",
      "postDate": "12/05/2018 20:22:30",
      "content": "<p>don't save it in input folder but the /kaggle/working directory. Then, if you want to store it in your computer:</p>\n\n<pre><code>from IPython.display import FileLink, FileLinks\nFileLinks('.') #lists all downloadable files on server\n</code></pre>",
      "rawMarkdown": "don't save it in input folder but the /kaggle/working directory. Then, if you want to store it in your computer:\n\n    from IPython.display import FileLink, FileLinks\n    FileLinks('.') #lists all downloadable files on server",
      "votes": null
    },
    {
      "id": "435047",
      "postDate": "12/07/2018 11:46:27",
      "content": "<p>Maybe I can just save in the default folder. Thanks.</p>",
      "rawMarkdown": "Maybe I can just save in the default folder. Thanks.",
      "votes": null
    },
    {
      "id": "470591",
      "postDate": "02/13/2019 08:21:44",
      "content": "<p>Hi I would like to know how I can download my model as I already saved it in /kaggle/working directory\n I need to download the model  which has a name \"model_catdog.pth\"</p>\n\n<p>Thanks</p>",
      "rawMarkdown": "Hi I would like to know how I can download my model as I already saved it in /kaggle/working directory\n I need to download the model  which has a name \"model_catdog.pth\"\n\nThanks",
      "votes": null
    },
    {
      "id": "508066",
      "postDate": "04/05/2019 15:10:44",
      "content": "<p>Thank you <a href=\"/grg121\">@grg121</a> for sharing this technique.</p>",
      "rawMarkdown": "Thank you @grg121 for sharing this technique.",
      "votes": null
    },
    {
      "id": "582897",
      "postDate": "07/23/2019 18:31:23",
      "content": "<p>if I am training my model with pretrained weight 'unet_weights.hdf5', then can I save the best model in  ModelCheckpoint('/kaggle/working/best_model1.hdf5', monitor='val_loss', save_best_only=True)\nwill it be saved in the outputs after i commit my kernel?</p>",
      "rawMarkdown": "if I am training my model with pretrained weight 'unet_weights.hdf5', then can I save the best model in  ModelCheckpoint('/kaggle/working/best_model1.hdf5', monitor='val_loss', save_best_only=True)\nwill it be saved in the outputs after i commit my kernel?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 432714,
      "author_name": "artgor",
      "author_url": "",
      "post_date": "12/04/2018 08:36:00",
      "content": "<p>I use ModelCheckpoint in Keras, here is an example: <a href=\"https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook\">https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 432739,
          "author_name": "jonneryr",
          "author_url": "",
          "post_date": "12/04/2018 09:10:51",
          "content": "<p>Thanks for your help. I think that the kernel can't provide the function to save models. So we can only use some library functions, such as Keras. Do I have an exact understanding?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 432747,
          "author_name": "artgor",
          "author_url": "",
          "post_date": "12/04/2018 09:19:20",
          "content": "<p>yes. There are many possible models, we can't expect Kaggle to support saving all of them.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 433042,
      "author_name": "joeytaj",
      "author_url": "",
      "post_date": "12/04/2018 15:46:35",
      "content": "<p>I believe you can save anything you want to the root folder. Just like you save the submission file.\n<a href=\"https://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output\">https://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 434041,
      "author_name": "grg121",
      "author_url": "",
      "post_date": "12/05/2018 20:22:30",
      "content": "<p>don't save it in input folder but the /kaggle/working directory. Then, if you want to store it in your computer:</p>\n\n<pre><code>from IPython.display import FileLink, FileLinks\nFileLinks('.') #lists all downloadable files on server\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 435047,
          "author_name": "jonneryr",
          "author_url": "",
          "post_date": "12/07/2018 11:46:27",
          "content": "<p>Maybe I can just save in the default folder. Thanks.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 470591,
          "author_name": "ihgumilar",
          "author_url": "",
          "post_date": "02/13/2019 08:21:44",
          "content": "<p>Hi I would like to know how I can download my model as I already saved it in /kaggle/working directory\n I need to download the model  which has a name \"model_catdog.pth\"</p>\n\n<p>Thanks</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 508066,
          "author_name": "anirban97",
          "author_url": "",
          "post_date": "04/05/2019 15:10:44",
          "content": "<p>Thank you <a href=\"/grg121\">@grg121</a> for sharing this technique.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 582897,
      "author_name": "prativadas",
      "author_url": "",
      "post_date": "07/23/2019 18:31:23",
      "content": "<p>if I am training my model with pretrained weight 'unet_weights.hdf5', then can I save the best model in  ModelCheckpoint('/kaggle/working/best_model1.hdf5', monitor='val_loss', save_best_only=True)\nwill it be saved in the outputs after i commit my kernel?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "432707": "When training models, I want to save the best model, but I find the input folder is read-only, so I don't know how to save model.",
    "432714": "I use ModelCheckpoint in Keras, here is an example: https://www.kaggle.com/artgor/eda-and-lstm-cnn/notebook",
    "432739": "Thanks for your help. I think that the kernel can't provide the function to save models. So we can only use some library functions, such as Keras. Do I have an exact understanding?",
    "432747": "yes. There are many possible models, we can't expect Kaggle to support saving all of them.",
    "433042": "I believe you can save anything you want to the root folder. Just like you save the submission file.\nhttps://www.kaggle.com/shujian/single-rnn-with-5-folds-snapshot-ensemble/output",
    "434041": "don't save it in input folder but the /kaggle/working directory. Then, if you want to store it in your computer:\n\n    from IPython.display import FileLink, FileLinks\n    FileLinks('.') #lists all downloadable files on server",
    "435047": "Maybe I can just save in the default folder. Thanks.",
    "470591": "Hi I would like to know how I can download my model as I already saved it in /kaggle/working directory\n I need to download the model  which has a name \"model_catdog.pth\"\n\nThanks",
    "508066": "Thank you @grg121 for sharing this technique.",
    "582897": "if I am training my model with pretrained weight 'unet_weights.hdf5', then can I save the best model in  ModelCheckpoint('/kaggle/working/best_model1.hdf5', monitor='val_loss', save_best_only=True)\nwill it be saved in the outputs after i commit my kernel?"
  },
  "source": "meta"
}