Skip to content

Commit

Permalink
Merge pull request #586 from autonomio/callbacks_submodule
Browse files Browse the repository at this point in the history
Make callbacks to a submodule
  • Loading branch information
mikkokotila committed Apr 16, 2022
2 parents 8073e34 + be2e23f commit 859c50d
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 93 deletions.
2 changes: 1 addition & 1 deletion docs/Energy_Draw.md
Expand Up @@ -9,7 +9,7 @@ A callback for recording GPU power draw (watts) on epoch begin and end. The call

Before `model.fit()` in the input model:

`power_draw = PowerDrawCallback()`
`power_draw = PowerDraw()`

Then use `power_draw` as you would callbacks in general:

Expand Down
11 changes: 6 additions & 5 deletions docs/Monitoring.md
Expand Up @@ -7,29 +7,30 @@ There are several options for monitoring the experiment.
Scan(disable_progress_bar=True)

# enable live training plot
from talos import live
from talos.callbacks import TrainingPlot

out = model.fit(X,
Y,
epochs=20,
callbacks=[live()])
callbacks=[TrainingPlot()])

# turn on parameter printing
Scan(print_params=True)
```

**Progress Bar :** A round-by-round updating progress bar that shows the remaining rounds, together with a time estimate to completion. Progress bar is on by default.

**Live Monitoring :** Live monitoring provides an epoch-by-epoch updating line graph that is enabled through the `live()` custom callback.
**Live Monitoring :** Live monitoring provides an epoch-by-epoch updating line graph that is enabled through the `TrainingPlot()` custom callback.

**Round Hyperparameters :** Displays the hyperparameters for each permutation. Does not work together with live monitoring.

### Local Monitoring

Epoch-by-epoch training data is available during the experiment using the `ExperimentLogCallback`:
Epoch-by-epoch training data is available during the experiment using the `ExperimentLog`:

```python
model.fit(...
callbacks=[talos.utils.ExperimentLogCallback('experiment_name', params)])
callbacks=[talos.callbacks.ExperimentLog('experiment_name', params)])
```
Here `params` is the params dictionary in the `Scan()` input model. Both
`experiment_name` and `experiment_id` should match with the current experiment,
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
@@ -1,6 +1,6 @@
![logo](_media/talos_logo_bg.png)

## v1.2.4
## v1.2.5

> Hyperparameter Experiments with Tensorflow, PyTorch and Keras
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -16,7 +16,7 @@
<div id="app"></div>
<script>
window.$docsify = {
name: 'Talos 1.2.4',
name: 'Talos 1.2.5',
repo: 'https://github.com/autonomio/talos',
coverpage: true,
loadSidebar: true,
Expand Down
Expand Up @@ -2,21 +2,20 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src='https://raw.githubusercontent.com/autonomio/hyperio/master/logo.png' width=250px>"
]
],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook is a compliment to the *Hyperparameter Optimization on Keras* article. "
]
],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview\n",
"\n",
Expand All @@ -29,20 +28,19 @@
"3) Defining the Parameter Space Boundaries \n",
"\n",
"4) Running the Experiment"
]
],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. The Required Inputs and Data"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dropout, Dense\n",
Expand All @@ -52,33 +50,33 @@
"import sys\n",
"sys.path.insert(0, '/Users/mikko/Documents/GitHub/talos')\n",
"import talos"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# then we load the dataset\n",
"x, y = talos.templates.datasets.breast_cancer()\n",
"\n",
"# and normalize every feature to mean 0, std 1\n",
"x = talos.utils.rescale_meanzero(x)"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Creating the Keras Model"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# first we have to make sure to input data and params into the function\n",
"def breast_cancer_model(x_train, y_train, x_val, y_val, params):\n",
Expand All @@ -100,25 +98,25 @@
" history = model.fit(x_train, y_train, \n",
" validation_data=[x_val, y_val],\n",
" batch_size=params['batch_size'],\n",
" callbacks=[talos.utils.live()],\n",
" callbacks=[talos.callbacks.TrainingPlot()],\n",
" epochs=params['epochs'],\n",
" verbose=0)\n",
"\n",
" return history, model"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Defining the Parameter Space Boundary"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# then we can go ahead and set the parameter space\n",
"p = {'first_neuron':[9,10,11],\n",
Expand All @@ -131,22 +129,20 @@
" 'losses': ['binary_crossentropy'],\n",
" 'activation':['relu', 'elu'],\n",
" 'last_activation': ['sigmoid']}"
]
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Starting the Experiment"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# and run the experiment\n",
"t = talos.Scan(x=x,\n",
Expand All @@ -155,7 +151,11 @@
" params=p,\n",
" experiment_name='breast_cancer',\n",
" round_limit=10)"
]
],
"outputs": [],
"metadata": {
"collapsed": true
}
}
],
"metadata": {
Expand All @@ -179,4 +179,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}

0 comments on commit 859c50d

Please sign in to comment.