{"id":31534082,"url":"https://github.com/dorukkarinca/keras-buoy","last_synced_at":"2025-10-04T05:17:14.200Z","repository":{"id":62573962,"uuid":"254968803","full_name":"dorukkarinca/keras-buoy","owner":"dorukkarinca","description":"Keras wrapper that autosaves what ModelCheckpoint cannot.","archived":false,"fork":false,"pushed_at":"2022-07-04T20:13:00.000Z","size":43,"stargazers_count":24,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-28T14:47:32.063Z","etag":null,"topics":["autosave","checkpointing","colab","colab-automation","colab-notebook","colaboratory","data-science","keras","machine-learning"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dorukkarinca.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-11T22:49:43.000Z","updated_at":"2025-03-24T15:44:42.000Z","dependencies_parsed_at":"2022-11-03T18:44:34.166Z","dependency_job_id":null,"html_url":"https://github.com/dorukkarinca/keras-buoy","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dorukkarinca/keras-buoy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorukkarinca%2Fkeras-buoy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorukkarinca%2Fkeras-buoy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorukkarinca%2Fkeras-buoy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorukkarinca%2Fkeras-buoy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dorukkarinca","download_url":"https://codeload.github.com/dorukkarinca/keras-buoy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorukkarinca%2Fkeras-buoy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276921324,"owners_count":25728642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autosave","checkpointing","colab","colab-automation","colab-notebook","colaboratory","data-science","keras","machine-learning"],"created_at":"2025-10-04T05:17:11.638Z","updated_at":"2025-10-04T05:17:14.191Z","avatar_url":"https://github.com/dorukkarinca.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\nkeras-buoy\n==========\n\n.. image:: https://travis-ci.com/dorukkarinca/keras-buoy.svg?branch=master\n    :target: https://travis-ci.com/dorukkarinca/keras-buoy\n\nKeras wrapper that autosaves and auto-recovers not just the model weights but also the last epoch number and training history metrics.\n\nSee it in action in `this Colab notebook \u003chttps://colab.research.google.com/drive/1uubwP4DQJPpMDKN9GY1y1SZeds83gwYV?usp=sharing\u003e`_!\n\n::\n\n    pip install keras-buoy\n\n\nDescription\n===========\n\nWhen training is interrupted and you rerun the whole code, it recovers the model weights and the epoch counter to the last saved values. Then it resumes training as if nothing happened. At the end, the Keras History.history dictionaries are combined so that the training history looks like one single training run.\n\nExample\n=======\n\n::\n    \n    \u003e\u003e\u003e from tensorflow import keras\n    \u003e\u003e\u003e from keras_buoy.models import ResumableModel\n\n    \u003e\u003e\u003e model = keras.Sequential()\n    ...\n    \u003e\u003e\u003e resumable_model = ResumableModel(model, \n                                         save_every_epochs=4, \n                                         custom_objects=None, \n                                         to_path='/path/to/save/model_weights.h5')\n    \u003e\u003e\u003e history = resumable_model.fit(x=x_train, \n                                      y=y_train,\n                                      validation_split=0.1,\n                                      batch_size=256,\n                                      verbose=2,\n                                      epochs=15)\n    \n    Recovered model from kerascheckpoint.h5 at epoch 8.\n\n    Epoch 9/15\n    1125/1125 - 5s - loss: 0.4790 - top_k_categorical_accuracy: 0.9698 - val_loss: 1.1075 - val_top_k_categorical_accuracy: 0.9206\n    Epoch 10/15\n    1125/1125 - 5s - loss: 0.4758 - top_k_categorical_accuracy: 0.9701 - val_loss: 1.1119 - val_top_k_categorical_accuracy: 0.9214\n    Epoch 11/15\n    1125/1125 - 5s - loss: 0.4753 - top_k_categorical_accuracy: 0.9702 - val_loss: 1.1000 - val_top_k_categorical_accuracy: 0.9215\n    Epoch 12/15\n\nTry it out yourself in `this Colab notebook \u003chttps://colab.research.google.com/drive/1uubwP4DQJPpMDKN9GY1y1SZeds83gwYV?usp=sharing\u003e`_.\n\nDocs\n====\n\n++++++++++++++++++++++++++++++++++++++++\n:code:`keras_buoy.models.ResumableModel`\n++++++++++++++++++++++++++++++++++++++++\n\nCreates a resumable model.\n\n**Parameters:**\n\n+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Parameter name                    | Description                                                                                                                                                                     |\n+===================================+=================================================================================================================================================================================+\n| :code:`model (tf.keras.Model)`    | The instance of :code:`tf.keras.Model` which you want to make resumable.                                                                                                        |\n+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| :code:`save_every_epochs (int)`   | Specifies how often to save the model, history, and epoch counter.  In case of a crash, recovery will happen from the last saved epoch multiple.                                |\n+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| :code:`custom_objects (dict)`     | At recovery time, this is passed into :code:`tf.keras.models.load_model(...)` exactly as shown in Tensorflow docs so you can load your model with a custom loss for example.    |\n+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| :code:`to_path (str)`             | Specifies the path where the model weights will be saved. If it ends with :code:`.h5`, then it saves in the Keras H5 format instead of the default TensorFlow SavedModel format.|\n+-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n\nIf :code:`to_path` is :code:`mymodel.h5`, then there will be :code:`mymodel_epoch_num.pkl` and :code:`mymodel_history.pkl` in the same directory as :code:`mymodel.h5`, which hold backups for the epoch counter and the history dict, respectively.\n\n**Returns:**\n\nA ResumableModel instance. You can call :code:`.fit(...)` on it.\n\n|\n|\n|\n\n++++++++++++++++++++++++++++++++++++++++++++\n:code:`keras.buoy.models.ResumableModel.fit` \n++++++++++++++++++++++++++++++++++++++++++++\n\nFits a resumable model.\n\n**Parameters:**\n\nThe accepted parameters are the same as :code:`tf.Keras.model.fit(...)` except you cannot specify :code:`initial_epoch`.\n\n**Returns:**\n\n:code:`history (dict)`: The history dict of the Keras History object. Note that it does not return the :code:`Keras.History` object itself, just the dict.\n\nNote\n====\n\nThis project has been set up using PyScaffold 3.2.3. For details and usage\ninformation on PyScaffold see https://pyscaffold.org/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorukkarinca%2Fkeras-buoy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdorukkarinca%2Fkeras-buoy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorukkarinca%2Fkeras-buoy/lists"}