Skip to content

Commit

Permalink
Rename log -> log_metric
Browse files Browse the repository at this point in the history
  • Loading branch information
daavoo committed Oct 27, 2022
1 parent 8c73db4 commit db49ca6
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions content/docs/dvclive/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ See `Live.log_param()` / `Live.log_params()`.
<tab title="Scalars">

```python
live.log("acc", 0.9)
live.log_metric("acc", 0.9)
```

See `Live.log_metric()`.
Expand Down Expand Up @@ -106,7 +106,7 @@ for epoch in range(NUM_EPOCHS):
metrics = evaluate_model(...)

for metric_name, value in metrics.items():
live.log(metric_name, value)
live.log_metric(metric_name, value)

live.next_step()
```
Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/api-reference/live/get_step.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from dvclive import Live
live = Live()

while live.get_step() < 3:
live.log("metric", 0.9)
live.log_metric("metric", 0.9)
live.next_step()
```

Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/api-reference/live/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ metrics and other metadata.
## Methods

- `Live.get_step()`
- `Live.log()`
- `Live.log_metric()`
- `Live.log_image()`
- `Live.log_param()`
- `Live.log_params()`
Expand Down
14 changes: 7 additions & 7 deletions content/docs/dvclive/api-reference/live/log_metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ from dvclive import Live

live = Live()

live.log("train/loss", 0.4)
live.log("val/loss", 0.9)
live.log_metric("train/loss", 0.4)
live.log_metric("val/loss", 0.9)
```

## Description

On each `live.log(name, val)` call DVCLive will create a _metrics history_ file
in `{Live.plots_dir}/metrics/{name}.tsv`:
On each `live.log_metric(name, val)` call DVCLive will create a _metrics
history_ file in `{Live.plots_dir}/metrics/{name}.tsv`:

```dvc
$ tree
Expand Down Expand Up @@ -48,13 +48,13 @@ dvc plots diff dvclive/plots

</admon>

Each subsequent call to `live.log(name, val)` will add a new row to
Each subsequent call to `live.log_metric(name, val)` will add a new row to
`{Live.plots_dir}/metrics/{name}.tsv`:

```python
live.next_step()
live.log("train/loss", 0.2)
live.log("val/loss", 0.4)
live.log_metric("train/loss", 0.2)
live.log_metric("val/loss", 0.4)
```

```dvc
Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/api-reference/live/log_plot.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you perform `step` updates in your code, you can later use

```python
for epoch in range(NUM_EPOCHS):
live.log(metric_name, value)
live.log_metric(metric_name, value)
live.next_step()

live.set_step(None)
Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/api-reference/live/next_step.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from dvclive import Live
live = Live()

for step in range(3):
live.log("metric", 0.9)
live.log_metric("metric", 0.9)
live.next_step()
```

Expand Down
4 changes: 2 additions & 2 deletions content/docs/dvclive/api-reference/live/set_step.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ live = Live()

for step in [0, 10, 20]:
live.set_step(step)
live.log("metric_1", 0.9)
live.log("metric_2", 0.7)
live.log_metric("metric_1", 0.9)
live.log_metric("metric_2", 0.7)
```

## Description
Expand Down
6 changes: 3 additions & 3 deletions content/docs/dvclive/api-reference/ml-frameworks/pytorch.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ live = Live()

for epoch in range(args.start_epoch, args.epochs):
lr = adjust_learning_rate(optimizer, epoch, args)
live.log("learning_rate", lr)
live.log_metric("learning_rate", lr)

train_acc1 = train(
train_loader, model, criterion, optimizer, epoch, args)
live.log("train/accuracy", train_acc1)
live.log_metric("train/accuracy", train_acc1)

val_acc1 = validate(val_loader, model, criterion, args)
live.log("validation/accuracy", val_acc1)
live.log_metric("validation/accuracy", val_acc1)

is_best = val_acc1 > best_acc1
best_acc1 = max(val_acc1, best_acc1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ for epoch in range(epochs):
optimizer.apply_gradients(zip(grads, model.trainable_weights))
train_acc_metric.update_state(y_batch_train, logits)

live.log("train/accuracy", float(train_acc_metric.result())
live.log_metric("train/accuracy", float(train_acc_metric.result())
train_acc_metric.reset_states()

for x_batch_val, y_batch_val in val_dataset:
val_logits = model(x_batch_val, training=False)
val_acc_metric.update_state(y_batch_val, val_logits)
live.log("val/accuracy", float(val_acc_metric.result())
live.log_metric("val/accuracy", float(val_acc_metric.result())
val_acc_metric.reset_states()

live.next_step()
Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ for epoch in range(NUM_EPOCHS):
metrics = evaluate_model(...)

for metric_name, value in metrics.items():
live.log(metric_name, value)
live.log_metric(metric_name, value)

live.make_report()
live.next_step()
Expand Down
4 changes: 2 additions & 2 deletions content/docs/dvclive/outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ live = Live()
live.log_param("epochs", EPOCHS)

for i in range(EPOCHS):
live.log("metric", i + random.random())
live.log("nested/metric", i + random.random())
live.log_metric("metric", i + random.random())
live.log_metric("nested/metric", i + random.random())

img = Image.new("RGB", (50, 50), (i, i, i))
live.log_image("img.png", img)
Expand Down

0 comments on commit db49ca6

Please sign in to comment.