File size: 1,943 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: vessl.log
version: EN
---

Use `vessl.log` in a training or testing loop to log a dictionary of metrics. Provide the step parameter for the loop unit – like the epoch value – and any metrics you want to log as a dictionary in the `row` parameter. 

You can also log images or audio types of objects. Provide a list of `vessl.Image` objects or `vessl.Audio` with data and captions as the `payload` parameter with any dictionary key. Note that only the first key will be logged.

| Parameter | Description                                                                       |
| --------- | --------------------------------------------------------------------------------- |
| `step`    | Unit size of the loop                                                             |
| `payload` | Dictionary of metrics or a list of `vessl.Image` objects or `vessl.Audio` objects |

### Logging metrics

```python
# Logging loss values for each epoch in PyTorch

import vessl

for epoch in range(epochs):
    ...
    vessl.log(step=epoch, payload={'loss': loss.item})
```

### Logging image objects

```python
# Logging images in PyTorch

import vessl

def test(model, test_loader, ...):
    ...
    test_images = []
    with torch.no_grad():
        for data, target in test_loader:
            ...
            output = model(data)
            ...
            test_images.append(
                vessl.Image(
                    data[0], 
                    caption=f'Pred: {output[0].item()} Truth: {target[0]}'
                )
            )
    ...
    vessl.log(payload={"test-images": test_images})
```

### Logging audio objects

```python
# Logging audio

import vessl
import soundfile as sf

audio_path = "sample.wav"
data, sample_rate = sf.read(audio_path)

# Log audio with data
vessl.log(
  payload={
    "test-audio": [
      vessl.Audio(data, sample_rate=sample_rate, caption="audio with data example")
    ]
  }
)
```