Skip to content

Commit

Permalink
fix(dvclive): add timestamp param to log metrics (#5004)
Browse files Browse the repository at this point in the history
  • Loading branch information
shcheklein authored Nov 27, 2023
1 parent fe83e5b commit d772444
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions content/docs/dvclive/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ make Git ignore it. It will generate a `model.pt.dvc` metadata file, which can
be tracked in Git and becomes part of the experiment. With this metadata file,
you can [retrieve](/doc/start/data-management/data-versioning#retrieving) the
versioned artifact from the Git commit. You can also use
`Live.log_artifact("model.pt", type="model")` to add it to the [DVC Studio Model
Registry](/doc/studio/model-registry).
`Live.log_artifact("model.pt", type="model")` to add it to the
[DVC Studio Model Registry](/doc/studio/model-registry).

Using `Live.log_image()` to log multiple images may also grow too large to track
with Git, in which case you can use
Expand Down
26 changes: 17 additions & 9 deletions content/docs/dvclive/live/log_metric.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Live.log_metric()

```py
def log_metric(name: str, val: Union[int, float, str], plot: Optional[bool] = True):
def log_metric(
name: str,
val: Union[int, float, str],
timestamp: bool = False,
plot: Optional[bool] = True
):
```

## Usage
Expand Down Expand Up @@ -41,7 +46,7 @@ timestamp step loss
The metrics history can be visualized with `dvc plots`:

```
dvc plots diff dvclive/plots
$ dvc plots diff dvclive/plots
```

</admon>
Expand All @@ -51,8 +56,8 @@ Each subsequent call to `live.log_metric(name, val)` will add a new row to

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

```ts
Expand Down Expand Up @@ -81,19 +86,22 @@ when exiting the `with` block:

The metrics summary can be visualized with `dvc metrics`:

```
dvc metrics diff dvclive/metrics.json
```cli
$ dvc metrics diff dvclive/metrics.json
```

</admon>

## Parameters

- `name` - Name of the metric being logged.
- `name` - name of the metric being logged.

- `val` - the value to be logged.

- `val` - The value to be logged.
- `timestamp` - whether to automatically log timestamp in the _metrics history_
file.

- `plot` - Whether to add the metric value to the _metrics history_ file for
- `plot` - whether to add the metric value to the _metrics history_ file for
plotting. If `false`, the metric will only be saved to the metrics summary.

## Exceptions
Expand Down
6 changes: 3 additions & 3 deletions content/docs/dvclive/live/log_param.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Live.log_param()

```py
def log_param(name: str, val: ParamLike):
def log_param(name: str, val: ParamLike):
```

Also see `Live.log_params()`.
Expand Down Expand Up @@ -41,9 +41,9 @@ automatically, and you can skip logging them with DVCLive.

## Parameters

- `name` - Name of the parameter being logged.
- `name` - name of the parameter being logged.

- `val` - The value to be logged.
- `val` - the value to be logged.

## Exceptions

Expand Down
2 changes: 1 addition & 1 deletion content/docs/dvclive/live/log_params.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Live.log_params()

```py
def log_params(params: Dict[ParamLike]):
def log_params(params: Dict[ParamLike]):
```

Also see `Live.log_param()`.
Expand Down

0 comments on commit d772444

Please sign in to comment.