Why is there a difference in loss value logged using self.log ?
What is your question?
(New to Lightning) The progress bar shows loss for each step. Before logging other metrics using self.log, wanted to sanity test it to log the loss again with a different name.
Please check the last 2 lines of the code. I'm logging the same loss value under "train_loss" that is being returned so I expected to see the "loss" and "train_loss_step" values to be the same in the progress bar but they aren't. The values don't seem to be time-shifted.
Which value should I interpret as the loss of the current mini-batch and why is there a difference?
Code
class LitCNN(pl.LightningModule):
    def __init__(self):
        super(LitCNN, self).__init__()
        # Model preparation
        model = torchvision.models.resnet34(pretrained=True)
        # Freeze layers
        for params in model.parameters():
            params.requires_grad = False
        # Change the final fully-connected layer to match our number of classes
        model.fc = nn.Linear(in_features=512, out_features=5, bias=True)
        self.model = model
        
        self.metric_accuracy = pl.metrics.Accuracy()
        self.loss = nn.CrossEntropyLoss()

    def forward(self, x):
        # called with self(x)
        return self.model(x)#.argmax(1) # Return class ID

    def training_step(self, batch, batch_nb):
        # REQUIRED
        X, y = batch
        logits = self.model(X)
        loss = self.loss(logits, y)
        
        self.log('train_loss', loss, on_step=True, on_epoch=True, prog_bar=True)
        return {'loss': loss}

   


What have you tried?
I've experimented with the "reduce_fx" arg in self.log but it seems to get invoked only on epoch end.
What's your environment?

OS: Win 10
Packaging: Conda
Version: 1.1.0