question: Logging metrics with compute()
context: Trying to understand compute() for logging. Could someone please tell if the self.log(train_acc..., on_epoch=True) is same as def training_epoch_end() which uses compute - code below
  def __init__():
      # ...
      self.train_acc = pl.metrics.Accuracy()
      self.valid_acc = pl.metrics.Accuracy()
  
  def training_step(self, batch, batch_idx):
      # ...
      self.train_acc(pred, target)
      self.log("train_acc", self.train_acc, on_step=False, on_epoch=True)
      self.log('train_loss', loss, on_step=True, on_epoch=False)
  
      return loss
  
  def training_epoch_end(self, training_step_outputs):
      self.log('train_acc_epoch', self.train_acc.compute())
      
  
  def validation_step(self, batch, batch_idx):
      # ...
      self.valid_acc(pred, target)
      self.log('val_loss', loss, prog_bar=True)
      self.log('val_acc', self.valid_acc, on_step=False, on_epoch=True, prog_bar=True)
  
      return loss
  
  
  def validation_epoch_end(self, validation_step_outputs):
      self.log('valid_acc_epoch', self.valid_acc.compute())
answer: Yes, its the same. Here is the relevant code:
  
    
      
        pytorch-lightning/pytorch_lightning/core/step_result.py
      
      
          Lines 325 to 330
        in
        4a8422c
      
    
    
      
  
          
            
             if options['logger'] and options['on_epoch']: 
          
  
          
            
                 if isinstance(self[k], Metric): 
          
  
          
            
                     result[dl_key] = self[k].compute().detach() 
          
  
          
            
                     self[k].reset() 
          
  
          
            
                 else: 
          
  
          
            
                     result[dl_key] = self[k] 
          
      
    
  
  
  Setting on_epoch=True will essentially call metric.compute at the end of the epoch.