Skip to content

logging interval seems not working when i check results in Tensorboard #11461

@QW-Is-Here

Description

@QW-Is-Here

Discussed in #11460

Originally posted by MrWangg1992 January 13, 2022
Hi ,
i set all the settings with log interval == 'epoch' as the code shown below, but when i check the results output in tensorboard, it seems like still logging in steps, may i kindly ask how to figure it out?
image
image

lr_monitor = LearningRateMonitor(logging_interval='epoch')



    def configure_optimizers(self):
      
            optimizer_init = getattr(torch.optim, self.opt)
            optimizer = optimizer_init(self.parameters(), lr=self.basic_lr)


            scheduler_init = getattr(torch.optim.lr_scheduler, self.scheduler)
            lr_scheduler = scheduler_init(optimizer=optimizer)

        lr_scheduler_config = {
            # REQUIRED: The scheduler instance
            "scheduler": lr_scheduler,
            # The unit of the scheduler's step size, could also be 'step'.
            # 'epoch' updates the scheduler on epoch end whereas 'step'
            # updates it after a optimizer update.
            "interval": "epoch",
            # How many epochs/steps should pass between calls to
            # `scheduler.step()`. 1 corresponds to updating the learning
            # rate after every epoch/step.
            "frequency": 1,
            # Metric to monitor for schedulers like `ReduceLROnPlateau`
            "monitor": "val_loss",
            # If set to `True`, will enforce that the value specified 'monitor'
            # is available when the scheduler is updated, thus stopping
            # training if not found. If set to `False`, it will only produce a warning
            "strict": True,
            # If using the `LearningRateMonitor` callback to monitor the
            # learning rate progress, this keyword can be used to specify
            # a custom logged name
            "name": 'LearningRateMonitor',
        }

        return {"optimizer": optimizer, "lr_scheduler": lr_scheduler_config}


    def validation_step(self, val_batch, batch_idx):
        self.head.train()
        x, y, _, _ = val_batch
        fpn_outs = self.backbone(x)
        loss, _, _, _, _, _ = self.head(fpn_outs, y, x)
        self.log('loss/val', loss,  prog_bar=True, on_step=False, on_epoch=True)

    def training_epoch_end(self, outputs):
        avg_loss = torch.stack([x['loss'] for x in outputs]).mean()
        self.log('train-loss/epoch', avg_loss, prog_bar=True, on_step=False, on_epoch=True)


    def validation_epoch_end(self, outputs):
        avg_loss = torch.stack([x['loss'] for x in outputs]).mean()
        self.log('valid-loss/epoch', avg_loss, prog_bar=True, on_step=False, on_epoch=True)
```</div>

cc @rohitgr7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions