def compute_loss(self, hidden_outputs, targets, loss_fn, updates): if loss_fn == 'memory': return models.memory_efficiency_cross_entropy_loss(hidden_outputs, self.decoder, targets, self.criterion, self.config) elif loss_fn == 'emb': return models.prior_knowledge_loss(hidden_outputs, self.decoder, targets, self.criterion, self.config, updates) else: return models.cross_entropy_loss(hidden_outputs, self.decoder, targets, self.criterion, self.config)
def compute_loss(self, hidden_outputs, targets, memory_efficiency): if memory_efficiency: return models.memory_efficiency_cross_entropy_loss( hidden_outputs, self.decoder, targets, self.criterion, self.config) else: return models.cross_entropy_loss(hidden_outputs, self.decoder, targets, self.criterion, self.config)
def compute_loss(self, hidden_outputs, hidden_outputs_dir, targets, targets_dir, memory_efficiency): if memory_efficiency: return models.memory_efficiency_cross_entropy_loss( hidden_outputs, self.decoder, targets, self.criterion, self.config) else: sgm_loss_speaker, num_total, num_correct = models.cross_entropy_loss( hidden_outputs, self.decoder, targets, self.criterion, self.config) #sgm_loss_direction = models.mmse_loss2(hidden_outputs_dir, self.decoder, targets_dir, self.loss_for_dir) sgm_loss_direction, num_total_dir, num_correct_dir = models.cross_entropy_loss_dir( hidden_outputs_dir, self.decoder, targets_dir, self.criterion_dir, self.config) print("sgm_loss_speaker:", sgm_loss_speaker) print("sgm_loss_direction:", sgm_loss_direction) sgm_loss = sgm_loss_speaker + sgm_loss_direction return sgm_loss, num_total, num_correct, num_total_dir, num_correct_dir