class_docstr: A class to store the evaluation metrics.
docstr: Accumulate the metrics calculated locally for this mini-batch.
  
  Args:
    predictions: A numpy matrix containing the outputs of the model.
      Dimensions are 'batch' x 'num_classes'.
    labels: A numpy matrix containing the ground truth labels.
      Dimensions are 'batch' x 'num_classes'.
    loss: A numpy array containing the loss for each sample.
  
  Returns:
    dictionary: A dictionary storing the metrics for the mini-batch.
  
  Raises:
    ValueError: An error occurred when the shape of predictions and actuals
      does not match.
docstr_tok: ["Accumulate","the","metrics","calculated","locally","for","this","mini-batch",".","Args",":","predictions",":","A","numpy","matrix","containing","the","outputs","of","the","model",".","Dimensions","are","'batch","'","x","'num_classes","'",".","labels",":","A","numpy","matrix","containing","the","ground","truth","labels",".","Dimensions","are","'batch","'","x","'num_classes","'",".","loss",":","A","numpy","array","containing","the","loss","for","each","sample",".","Returns",":","dictionary",":","A","dictionary","storing","the","metrics","for","the","mini-batch",".","Raises",":","ValueError",":","An","error","occurred","when","the","shape","of","predictions","and","actuals","does","not","match","."]
code: def accumulate(self, loss, predictions, labels):
      """Accumulate the metrics calculated locally for this mini-batch.
  
      Args:
        predictions: A numpy matrix containing the outputs of the model.
          Dimensions are 'batch' x 'num_classes'.
        labels: A numpy matrix containing the ground truth labels.
          Dimensions are 'batch' x 'num_classes'.
        loss: A numpy array containing the loss for each sample.
  
      Returns:
        dictionary: A dictionary storing the metrics for the mini-batch.
  
      Raises:
        ValueError: An error occurred when the shape of predictions and actuals
          does not match.
      """
      batch_size = labels.shape[0]
      mean_hit_at_one = calculate_hit_at_one(predictions, labels)
      mean_perr = calculate_precision_at_equal_recall_rate(
          predictions, labels
      )
      mean_loss = numpy.mean(loss)
  
      # Take the top 20 predictions.
      sparse_predictions, sparse_labels, num_positives = top_k_by_class(
          predictions, labels, self.top_k
      )
      self.map_calculator.accumulate(
          sparse_predictions, sparse_labels, num_positives
      )
      self.global_ap_calculator.accumulate(
          flatten(sparse_predictions),
          flatten(sparse_labels),
          sum(num_positives),
      )
  
      self.num_examples += batch_size
      self.sum_hit_at_one += mean_hit_at_one * batch_size
      self.sum_perr += mean_perr * batch_size
      self.sum_loss += mean_loss * batch_size
  
      return {
          "hit_at_one": mean_hit_at_one,
          "perr": mean_perr,
          "loss": mean_loss,
      }
  
file_path: PaddleHub/modules/video/classification/videotag_tsn_lstm/resource/metrics/youtube8m/eval_util.py
imports: import datetime
  import numpy
  from .None import mean_average_precision_calculator
  from .None import average_precision_calculator
label_desc: Use image node_id 2 for calling the EvaluationMetrics obj's underlying member method code with example usage: obj.accumulate(loss, predictions, labels) and returns: dict