Live()
Initializes a DVCLive logger.
class Live:
def __init__(
self,
dir: str = "dvclive",
resume: bool = False,
report: Literal["md", "notebook", "html", None] = None,
save_dvc_exp: bool = True,
dvcyaml: Optional[str] = "dvc.yaml",
cache_images: bool = False,
exp_name: Optional[str] = None,
exp_message: Optional[str] = None,
monitor_system: bool = False,
):
Usage
from dvclive import Live
with Live() as live:
...
Description
A Live()
instance is required in order to log machine learning parameters,
metrics and other metadata.
Live()
will remove all existing DVCLive related files under dir
unless
resume=True
.
You can use Live()
as a context manager. When exiting the context manager,
Live.end()
will be called.
Properties
-
step
- seeLive.next_step()
. -
summary
- seeLive.make_summary()
. -
dir
- location of the directory to store outputs. -
dvc_file
- path fordvc.yaml
file. -
metrics_file
-{Live.dir}/metrics.json
. -
params_file
-{Live.dir}/params.yaml
. -
plots_dir
-{Live.dir}/plots
. -
report_file
-{Live.dir}/report.{format}
. Theformat
can be HTML (.html
) or Markdown (.md
) depending on the value of thereport
parameter.
Parameters
-
dir
- where to save DVCLive's outputs. Defaults todvclive
. -
resume
- ifTrue
, DVCLive will try to read the previousstep
from themetrics_file
and start from that point. Defaults toFalse
. -
report
- any ofhtml
,notebook
,md
orNone
. SeeLive.make_report()
. Defaults toNone
. -
save_dvc_exp
- ifTrue
, DVCLive will create a new DVC experiment as part ofLive.end()
. Defaults toTrue
.If you are using DVCLive inside a DVC Pipeline and running with
dvc exp run
, the option will be ignored. -
dvcyaml
- where to writedvc.yaml
file, which adds DVC configuration for metrics, plots, and parameters as part ofLive.next_step()
andLive.end()
. IfNone
, nodvc.yaml
file is written. Defaults todvc.yaml
. SeeLive.make_dvcyaml()
.If a string like
subdir/dvc.yaml
, DVCLive will write the configuration to that path (file must be nameddvc.yaml
).If
False
, DVCLive will not write todvc.yaml
(useful if you are tracking DVCLive metrics, plots, and parameters independently and want to avoid duplication). -
cache_images
- ifTrue
, DVCLive will cache any images logged withLive.log_image()
as part ofLive.end()
. Defaults toFalse
.If running a DVC pipeline,
cache_images
will be ignored, and you should instead cache images as pipeline outputs. -
exp_name
- if notNone
, andsave_dvc_exp
isTrue
, the provided string will be passed todvc exp save --name
.If DVCLive is used inside
dvc exp run
, the option will be ignored, usedvc exp run --name
instead. -
exp_message
- if notNone
, andsave_dvc_exp
isTrue
, the provided string will be passed todvc exp save --message
.If DVCLive is used inside
dvc exp run
, the option will be ignored, usedvc exp run --message
instead. -
monitor_system
- ifTrue
, DVCLive will log system metrics, including GPU, CPU, RAM, and disk usage. Defaults toFalse
.