예제 #1
0
 def setup_loss(self, train_config):
     criterion_config = train_config['criterion']
     org_term_config = criterion_config.get('org_term', dict())
     org_criterion_config = org_term_config.get('criterion', dict()) if isinstance(org_term_config, dict) else None
     self.org_criterion = None if org_criterion_config is None or len(org_criterion_config) == 0 \
         else get_single_loss(org_criterion_config)
     self.criterion = get_custom_loss(criterion_config)
     self.uses_teacher_output = False
     self.extract_org_loss = get_func2extract_org_output(criterion_config.get('func2extract_org_loss', None))
 def setup_loss(self, train_config):
     criterion_config = train_config['criterion']
     org_term_config = criterion_config.get('org_term', dict())
     org_criterion_config = org_term_config.get(
         'criterion', dict()) if isinstance(org_term_config, dict) else None
     self.org_criterion = None if org_criterion_config is None or len(org_criterion_config) == 0 \
         else get_single_loss(org_criterion_config)
     self.criterion = get_custom_loss(criterion_config)
     logger.info(self.criterion)
     self.uses_teacher_output = \
         self.org_criterion is not None and isinstance(self.org_criterion, tuple(ORG_LOSS_LIST))
     self.extract_org_loss = get_func2extract_org_output(
         criterion_config.get('func2extract_org_loss', None))