Beispiel #1
0
 def aggregate_stats(self, stats: MetricStats) -> np.ndarray:
     """
     Aggregate sufficient statistics from multiple examples into a single example
     :param stats: stats for every example
     :return: aggregated stats
     """
     if self.config.name in {'bleu', 'chrf'}:
         return np.sum(stats.get_data(), axis=0)
     else:
         return np.mean(stats.get_data(), axis=0)
Beispiel #2
0
 def aggregate_stats(self, stats: MetricStats) -> np.ndarray:
     """
     Aggregate sufficient statistics from multiple examples into a single example
     :param stats: stats for every example
     :return: aggregated stats
     """
     data = stats.get_data()
     if data.size == 0:
         return np.array(0.0)
     else:
         return np.sum(data, axis=0)