2021-05-13 23:48:51 +00:00
|
|
|
---
|
|
|
|
title: Keras with Matplotlib - Jupyter Notebook
|
|
|
|
---
|
|
|
|
|
|
|
|
The [jupyter.ipynb](https://github.com/allegroai/clearml/blob/master/examples/frameworks/keras/jupyter.ipynb) example
|
2022-03-13 13:07:06 +00:00
|
|
|
demonstrates ClearML's automatic logging of code running in a Jupyter Notebook that uses Keras and Matplotlib.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|
The example does the following:
|
|
|
|
1. Trains a simple deep neural network on the Keras built-in [MNIST](https://keras.io/api/datasets/mnist/#load_data-function)
|
|
|
|
dataset.
|
2021-11-04 09:21:05 +00:00
|
|
|
1. Builds a sequential model using a categorical cross entropy loss objective function.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|
1. Specifies accuracy as the metric, and uses two callbacks: a TensorBoard callback and a model checkpoint callback.
|
|
|
|
|
2023-09-04 12:40:42 +00:00
|
|
|
1. During script execution, creates an experiment named `notebook example` in the `examples` project.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|
## Scalars
|
|
|
|
|
2022-05-22 07:27:30 +00:00
|
|
|
The loss and accuracy metric scalar plots appear in **SCALARS**, along with the resource utilization plots, which are titled **:monitor: machine**.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## Plots
|
|
|
|
|
|
|
|
The example calls Matplotlib methods to create several sample plots, and TensorBoard methods to plot histograms for layer density.
|
2022-05-22 07:27:30 +00:00
|
|
|
They appear in **PLOTS**.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|

|
|
|
|
|
2021-09-02 07:48:37 +00:00
|
|
|
## Debug Samples
|
2021-05-13 23:48:51 +00:00
|
|
|
|
2022-05-22 07:27:30 +00:00
|
|
|
The example calls Matplotlib methods to log debug sample images. They appear in **DEBUG SAMPLES**.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## Hyperparameters
|
|
|
|
|
2022-03-13 13:07:06 +00:00
|
|
|
ClearML automatically logs TensorFlow Definitions. A parameter dictionary is logged by connecting it to the Task, by
|
2023-09-11 10:33:30 +00:00
|
|
|
calling [`Task.connect()`](../../../references/sdk/task.md#connect).
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|
```python
|
|
|
|
task_params = {'num_scatter_samples': 60, 'sin_max_value': 20, 'sin_steps': 30}
|
|
|
|
task_params = task.connect(task_params)
|
|
|
|
```
|
|
|
|
Later in the Jupyter Notebook, more parameters are added to the dictionary.
|
|
|
|
|
|
|
|
```python
|
|
|
|
task_params['batch_size'] = 128
|
|
|
|
task_params['nb_classes'] = 10
|
|
|
|
task_params['nb_epoch'] = 6
|
|
|
|
task_params['hidden_dim'] = 512
|
|
|
|
```
|
|
|
|
|
2023-01-12 10:49:55 +00:00
|
|
|
Parameter dictionaries appear in **CONFIGURATION** **>** **HYPERPARAMETERS** **>** **General**.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
The TensorFlow Definitions appear in the **TF_DEFINE** subsection.
|
|
|
|
|
|
|
|

|
|
|
|
|
2021-09-02 07:48:37 +00:00
|
|
|
## Console
|
2021-05-13 23:48:51 +00:00
|
|
|
|
2022-05-22 07:27:30 +00:00
|
|
|
Text printed to the console for training appears in **CONSOLE**.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## Artifacts
|
|
|
|
|
2023-11-13 14:31:57 +00:00
|
|
|
Models created by the experiment appear in the experiment's **ARTIFACTS** tab. ClearML automatically logs and tracks models
|
|
|
|
created using Keras.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|
The experiment info panel shows model tracking, including the model name and design in **ARTIFACTS** **>** **Output Model**.
|
|
|
|
|
|
|
|

|
|
|
|
|
2023-11-13 14:31:57 +00:00
|
|
|
Clicking on the model name takes you to the [model's page](../../../webapp/webapp_model_viewing.md), where you can view
|
|
|
|
the model's details and access the model.
|
2021-05-13 23:48:51 +00:00
|
|
|
|
|
|
|

|