Пример #1
0
 def calculate_loss(self, ff_dict):
     ###
     # Compute the loss.
     ###
     real_targets = ff_dict['real_targets']
     cate_targets = ff_dict['cate_targets']
     out = ff_dict['out_params']
     loss_type = self.loss_type
     if loss_type == 'ce':
         loss = loss_func.ce_loss(out, cate_targets)
     elif loss_type == 'mol':
         quant_chann = self.quant_chann
         loss = loss_func.mol_loss(out, real_targets, quant_chann)
     else:
         raise ValueError('[{}] loss is not supported.'.format(loss_type))
     return {'loss': loss}
Пример #2
0
 def calculate_loss(self, ff_dict):
     ###
     # Compute the loss.
     ###
     real_targets = ff_dict['real_targets']
     cate_targets = ff_dict['cate_targets']
     out = ff_dict['out_params']
     loss_type = self.loss_type
     if loss_type == 'ce':
         loss = loss_func.ce_loss(out, cate_targets)
     elif loss_type == 'mol':
         quant_chann = self.quant_chann
         loss = loss_func.mol_loss(out, real_targets, quant_chann)
     elif loss_type == 'gauss':
         loss = loss_func.gauss_loss(out, real_targets)
         if DETAIL_LOG:
             mean, std = loss_func.mean_std_from_out_params(
                 out, use_log_scales=True)
             tf.summary.histogram('mean', mean)
             tf.summary.histogram('std', std)
             tf.summary.histogram('log_std', tf.log(std))
     else:
         raise ValueError('[{}] loss is not supported.'.format(loss_type))
     return {'loss': loss}