---
title: LearningRateMonitor
description: >-
  Automatically monitor and logs learning rate for learning rate schedulers
  during training.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.callbacks.LearningRateMonitor
---
# LearningRateMonitor {#learningratemonitor}

### `class lightning.pytorch.callbacks.LearningRateMonitor(logging_interval=None, log_momentum=False, log_weight_decay=False)` {#lightning.pytorch.callbacks.LearningRateMonitor}

Bases: [`Callback`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.callbacks.Callback.md#lightning.pytorch.callbacks.Callback "lightning.pytorch.callbacks.callback.Callback")

Automatically monitor and logs learning rate for learning rate schedulers during training.

Parameters:

*   **logging\_interval** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'step'`, `'epoch'`\]\]) – set to `'epoch'` or `'step'` to log `lr` of all optimizers at the same interval, set to `None` to log at individual interval according to the `interval` key of each scheduler. Defaults to `None`.
    
*   **log\_momentum** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – option to also log the momentum values of the optimizer, if the optimizer has the `momentum` or `betas` attribute. Defaults to `False`.
    
*   **log\_weight\_decay** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – option to also log the weight decay values of the optimizer. Defaults to `False`.
    

Raises:

**MisconfigurationException** – If `logging_interval` is none of `"step"`, `"epoch"`, or `None`.

Example:

```python
>>> from lightning.pytorch import Trainer
>>> from lightning.pytorch.callbacks import LearningRateMonitor
>>> lr_monitor = LearningRateMonitor(logging_interval='step')
>>> trainer = Trainer(callbacks=[lr_monitor])
```

Logging names are automatically determined based on optimizer class name. In case of multiple optimizers of same type, they will be named `Adam`, `Adam-1` etc. If an optimizer has multiple parameter groups they will be named `Adam/pg1`, `Adam/pg2` etc. To control naming, pass in a `name` keyword in the construction of the learning rate schedulers. A `name` keyword can also be used for parameter groups in the construction of the optimizer.

Example:

```python
def configure_optimizer(self):
    optimizer = torch.optim.Adam(...)
    lr_scheduler = {
        'scheduler': torch.optim.lr_scheduler.LambdaLR(optimizer, ...)
        'name': 'my_logging_name'
    }
    return [optimizer], [lr_scheduler]
```

Example:

```python
def configure_optimizer(self):
    optimizer = torch.optim.SGD(
        [{
            'params': [p for p in self.parameters()],
            'name': 'my_parameter_group_name'
        }],
        lr=0.1
    )
    lr_scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer, ...)
    return [optimizer], [lr_scheduler]
```

#### `on_train_batch_start(trainer, *args, **kwargs)` {#lightning.pytorch.callbacks.LearningRateMonitor.on_train_batch_start}

Called when the train batch begins.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `on_train_epoch_start(trainer, *args, **kwargs)` {#lightning.pytorch.callbacks.LearningRateMonitor.on_train_epoch_start}

Called when the train epoch begins.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `on_train_start(trainer, *args, **kwargs)` {#lightning.pytorch.callbacks.LearningRateMonitor.on_train_start}

Called before training, determines unique names for all lr schedulers in the case of multiple of the same type or in the case of multiple parameter groups.

Raises:

**MisconfigurationException** – If `Trainer` has no `logger`.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
