pytorch_lightning.loggers.mlflow module¶
MLflow¶
-
class
pytorch_lightning.loggers.mlflow.
MLFlowLogger
(experiment_name='default', tracking_uri=None, tags=None, save_dir='./mlruns')[source]¶ Bases:
pytorch_lightning.loggers.base.LightningLoggerBase
Log using MLflow. Install it with pip:
pip install mlflow
Example
>>> from pytorch_lightning import Trainer >>> from pytorch_lightning.loggers import MLFlowLogger >>> mlf_logger = MLFlowLogger( ... experiment_name="default", ... tracking_uri="file:./ml-runs" ... ) >>> trainer = Trainer(logger=mlf_logger)
Use the logger anywhere in you
LightningModule
as follows:>>> from pytorch_lightning import LightningModule >>> class LitModel(LightningModule): ... def training_step(self, batch, batch_idx): ... # example ... self.logger.experiment.whatever_ml_flow_supports(...) ... ... def any_lightning_module_function_or_hook(self): ... self.logger.experiment.whatever_ml_flow_supports(...)
- Parameters
tracking_uri¶ (
Optional
[str
]) – Address of local or remote tracking server. If not provided, defaults to file:<save_dir>.tags¶ (
Optional
[Dict
[str
,Any
]]) – A dictionary tags for the experiment.save_dir¶ (
Optional
[str
]) – A path to a local directory where the MLflow runs get saved. Defaults to ./mlflow if tracking_uri is not provided. Has no effect if tracking_uri is provided.
-
log_metrics
(metrics, step=None)[source]¶ Records metrics. This method logs metrics as as soon as it received them. If you want to aggregate metrics for one specific step, use the
agg_and_log_metrics()
method.
-
property
experiment
[source]¶ Actual MLflow object. To use MLflow features in your
LightningModule
do the following.Example:
self.logger.experiment.some_mlflow_function()
- Return type
MlflowClient