mirror of
https://github.com/clearml/clearml-docs
synced 2025-02-01 06:56:56 +00:00
79 lines
2.7 KiB
Markdown
79 lines
2.7 KiB
Markdown
|
---
|
||
|
title: Keras Tuner Integration
|
||
|
---
|
||
|
|
||
|
Integrate **ClearML** into code that uses [Keras Tuner](https://www.tensorflow.org/tutorials/keras/keras_tuner). By
|
||
|
specifying `ClearMLTunerLogger` (see [kerastuner.py](https://github.com/allegroai/clearml/blob/master/clearml/external/kerastuner.py))
|
||
|
as the Keras Tuner logger, **ClearML** automatically logs scalars and hyperparameter optimization.
|
||
|
|
||
|
## ClearMLTunerLogger
|
||
|
|
||
|
Take a look at [keras_tuner_cifar.py](https://github.com/allegroai/clearml/blob/master/examples/frameworks/kerastuner/keras_tuner_cifar.py)
|
||
|
example script, which demonstrates the integration of **ClearML** in a code that uses Keras Tuner.
|
||
|
|
||
|
The script does the following:
|
||
|
1. Creates a `Hyperband` object, which uses Keras Tuner's `Hyperband` tuner. It finds the best hyperparameters to train a
|
||
|
network on a CIFAR10 dataset.
|
||
|
1. When the `Hyperband` object is created, instantiates a `ClearMLTunerLogger` object and assigns it to the `Hyperband` logger.
|
||
|
The `ClearMLTunerLogger` class provides the required binding for **ClearML** automatic logging.
|
||
|
|
||
|
```python
|
||
|
tuner = kt.Hyperband(
|
||
|
build_model,
|
||
|
project_name='kt examples',
|
||
|
logger=ClearMLTunerLogger(),
|
||
|
objective='val_accuracy',
|
||
|
max_epochs=10,
|
||
|
hyperband_iterations=6)
|
||
|
```
|
||
|
|
||
|
When the script runs, it logs:
|
||
|
* Tabular summary of hyperparameters tested and their metrics by trial ID
|
||
|
* Scalar plot showing metrics for all runs
|
||
|
* Summary plot
|
||
|
* Output model with configuration and snapshot location.
|
||
|
|
||
|
## Scalars
|
||
|
|
||
|
**ClearML** logs the scalars from training each network. They appear in the project's page in the **ClearML web UI**, under
|
||
|
**RESULTS** **>** **SCALARS**.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_06.png)
|
||
|
|
||
|
## Summary of hyperparameter optimization
|
||
|
|
||
|
**ClearML** automatically logs the parameters of each experiment run in the hyperparameter search. They appear in tabular
|
||
|
form in **RESULTS** **>** **PLOTS**.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_07.png)
|
||
|
|
||
|
## Artifacts
|
||
|
|
||
|
**ClearML** automatically stores the output model. It appears in **ARTIFACTS** **>** **Output Model**.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_03.png)
|
||
|
|
||
|
Model details, such as snap locations, appear in the **MODELS** tab.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_04.png)
|
||
|
|
||
|
The model configuration is stored with the model.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_05.png)
|
||
|
|
||
|
## Configuration objects
|
||
|
|
||
|
### Hyperparameters
|
||
|
|
||
|
**ClearML** automatically logs the TensorFlow Definitions, which appear in **RESULTS** **>** **CONFIGURATION** **>** **HYPER PARAMETERS**.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_01.png)
|
||
|
|
||
|
### Configuration
|
||
|
|
||
|
The Task configuration appears in **RESULTS** **>** **CONFIGURATION** **>** **General**.
|
||
|
|
||
|
![image](../../../img/integration_keras_tuner_02.png)
|
||
|
|
||
|
|