def training_step(self, batch, batch_idx):
    loss = self.model.get_loss(batch)
    self._check_nan_loss(loss)
    self.log('train/loss', loss)
    mlflow.log_metric('train/loss', loss.item(), step=self.global_step)
    mlflow.log_metric('train/epoch', self.trainer.current_epoch, step=self.global_step)
    if self.image:
        if ((self.global_step in [0]) or (batch_idx == 0)):
            self.log_meta(self.model.result)
        if False:
            self.log_video('train/inputs', x)
        if False:
            self.log_layer_weights('weight', ['convs.conv1'])
        if False:
            self.log_layer_activations('train features', self.model.result['video'], self.cfg.LEARNER.VIS.ACTIVATIONS)
        if True:
            for layer_name in self.cfg.LEARNER.VIS.HISTOGRAM:
                self.logger.experiment.add_histogram('weights/{} kernel'.format(layer_name), utils.get_layer(self.model, layer_name).weight, self.global_step)
    self.logger.experiment.flush()
    return {'loss': loss}
def training_step(self, batch, batch_idx):
    loss = self.model.get_loss(batch)
    self._check_nan_loss(loss)
    self.log('train/loss', loss)
    mlflow.log_metric('train/loss', loss.item(), step=self.global_step)
    mlflow.log_metric('train/epoch', self.trainer.current_epoch, step=self.global_step)
    if self.image:
        if ((self.global_step in [0]) or (batch_idx == 0)):
            self.log_meta(self.model.result)
        if False:
            self.log_video('train/inputs', x)
        if False:
            self.log_layer_weights('weight', ['convs.conv1'])
        if False:
            self.log_layer_activations('train features', self.model.result['video'], self.cfg.LEARNER.VIS.ACTIVATIONS)
        if True:
            for layer_name in self.cfg.LEARNER.VIS.HISTOGRAM:
                self.logger.experiment.add_histogram('weights/{} kernel'.format(layer_name), utils.get_layer(self.model, layer_name).weight, self.global_step)
    self.logger.experiment.flush()
    return {'loss': loss}