Skip to content

Commit

Permalink
Updating the "train a model" demo notebook, adding it to the document…
Browse files Browse the repository at this point in the history
…ation. (#117)
  • Loading branch information
drewoldag authored Nov 13, 2024
1 parent e666dbe commit 4d878a9
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 151 deletions.
2 changes: 1 addition & 1 deletion docs/notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Notebooks

.. toctree::

Introducing Jupyter Notebooks <notebooks/intro_notebook>
Training a simple model <notebooks/train_model>
66 changes: 0 additions & 66 deletions docs/notebooks/TrainingAModel.ipynb

This file was deleted.

84 changes: 0 additions & 84 deletions docs/notebooks/intro_notebook.ipynb

This file was deleted.

97 changes: 97 additions & 0 deletions docs/notebooks/train_model.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Intro to Training and Configurations\n",
"\n",
"First we import fibad and create a new fibad object, instantiated (implicitly), with the default configuration file."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import fibad\n",
"\n",
"fibad_instance = fibad.Fibad()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For this demo, we'll make a few adjustments to the default configuration settings that the `fibad` object was instantiated with. By accessing the `.config` attribute of the fibad instance, we can modify any configuration value. Here we change which built in model to use, the dataset, batch size, number of epochs for training."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fibad_instance.config[\"model\"][\"name\"] = \"ExampleCNN\"\n",
"fibad_instance.config[\"data_set\"][\"name\"] = \"CifarDataSet\"\n",
"fibad_instance.config[\"data_loader\"][\"batch_size\"] = 64\n",
"fibad_instance.config[\"train\"][\"epochs\"] = 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We call the `.train()` method to train the model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fibad_instance.train()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The output of the training will be stored in a time-stamped directory under the `./results/`. By default, a copy of the final configuration used in training is persisted as `runtime_config.toml`. To run fibad again with the same configuration, you can reference the runtime_config.toml file.\n",
"\n",
"If running in another notebook, instantiate a fibad object like so:\n",
"```\n",
"new_fibad_instance = fibad.Fibad(config_file='./results/<timestamped_directory>/runtime_config.toml')\n",
"```\n",
"\n",
"Or from the command line:\n",
"```\n",
">> fibad train --runtime-config ./results/<timestamped_directory>/runtime_config.toml\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "fibad",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 4d878a9

Please sign in to comment.