File size: 1,976 Bytes
76d9c4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: Keras
version: EN
---

VESSL provides integrations for Keras, an interface for the TensorFlow library. You can find a complete example using Keras in our [GitHub repository](https://github.com/savvihub/examples/blob/main/mnist/keras/main.py).

## ExperimentCallback

`ExperimentCallback` extends Keras' callback class. Add `ExperimentCallback` as a callback parameter in the `fit` function to automatically track Keras metrics at the end of each epoch. You can also log image objects using `ExperimentCallback`.

| Parameter         | Description                                                                                                                        |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `data_type`       | Use `image` to log image objects                                                                                                   |
| `validation_data` | Tuple of `(validation_data, validation_labels)`                                                                                    |
| `labels`          | <p>List of labels to get the caption from the inferred logits.</p><p>The argmax value will be used if labels are not provided.</p> |
| `num_images`      | Number of images to log in the validation data                                                                                     |

### Logging metrics

```python
# Logging loss and accuracy for each epoch in Keras
from vessl.integration.keras import ExperimentCallback

...
model.fit(..., callbacks=[ExperimentCallback()])
...
```

### Logging image objects

```python
# Logging images along with the loss and accuracy for each epoch in Keras
from vessl.keras import ExperimentCallback

...
model.fit(
    ...,
    callbacks=[ExperimentCallback(
        data_type='image',
        validation_data=(x_val, y_val),
        num_images=5,
    )]
)
...
```