CSVLogger¶
- class lightning.fabric.loggers.CSVLogger(root_dir, name='lightning_logs', version=None, prefix='', flush_logs_every_n_steps=100)[source]¶
Bases:
Logger
Log to the local file system in CSV format.
Logs are saved to
os.path.join(root_dir, name, version)
.- Parameters:
root_dir¶ (
Union
[str
,Path
]) – The root directory in which all your experiments with different names and versions will be stored.name¶ (
Optional
[str
]) – Experiment name. Defaults to'lightning_logs'
. If name isNone
, logs (versions) will be stored to the save dir directly.version¶ (
Union
[int
,str
,None
]) – Experiment version. If version is not specified the logger inspects the save directory for existing versions, then automatically assigns the next available version. If the version is specified, and the directory already contains a metrics file for that version, it will be overwritten.prefix¶ (
str
) – A string to put at the beginning of metric keys.flush_logs_every_n_steps¶ (
int
) – How often to flush logs to disk (defaults to every 100 steps).
Example:
from lightning.fabric.loggers import CSVLogger logger = CSVLogger("path/to/logs/root", name="my_model") logger.log_metrics({"loss": 0.235, "acc": 0.75}) logger.finalize("success")
- log_metrics(metrics, step=None)[source]¶
Records metrics. This method logs metrics as soon as it received them.
- property experiment: _ExperimentWriter¶
Actual ExperimentWriter object. To use ExperimentWriter features anywhere in your code, do the following.
Example:
self.logger.experiment.some_experiment_writer_function()