docstr: Asserts a prediction_dict has the right shapes.
  
  This includes testing that:
      - objects, objects_labels and objects_labels_prob have the same
          shape in the first dimension. (i.e. the same number of
          objects).
      - objects has shape (_, 4). objects_labels and objects_labels_prob
          have shape (_,).
      - cls_score and cls_prob have shape (num_proposals,
          num_classes + 1).
      - bbox_offsets has shape (num_proposals, num_classes * 4).
  
  And, if training:
      - cls_target has shape (num_proposals,).
      - bbox_offsets_target has shape (num_proposals, 4).
docstr_tok: ["Asserts","a","prediction_dict","has","the","right","shapes",".","This","includes","testing","that",":","-","objects",",","objects_labels","and","objects_labels_prob","have","the","same","shape","in","the","first","dimension",".","(","i.e",".","the","same","number","of","objects",")",".","-","objects","has","shape","(","_",",","4",")",".","objects_labels","and","objects_labels_prob","have","shape","(","_",",",")",".","-","cls_score","and","cls_prob","have","shape","(","num_proposals",",","num_classes","+","1",")",".","-","bbox_offsets","has","shape","(","num_proposals",",","num_classes","*","4",")",".","And",",","if","training",":","-","cls_target","has","shape","(","num_proposals",",",")",".","-","bbox_offsets_target","has","shape","(","num_proposals",",","4",")","."]
code: def _check_returning_shapes(self, prediction_dict, training=False):
      """Asserts a prediction_dict has the right shapes.
  
      This includes testing that:
          - objects, objects_labels and objects_labels_prob have the same
              shape in the first dimension. (i.e. the same number of
              objects).
          - objects has shape (_, 4). objects_labels and objects_labels_prob
              have shape (_,).
          - cls_score and cls_prob have shape (num_proposals,
              num_classes + 1).
          - bbox_offsets has shape (num_proposals, num_classes * 4).
  
      And, if training:
          - cls_target has shape (num_proposals,).
          - bbox_offsets_target has shape (num_proposals, 4).
      """
  
      objects_shape = prediction_dict["objects"].shape
      objects_labels_shape = prediction_dict["labels"].shape
      objects_labels_prob_shape = prediction_dict["probs"].shape
  
      cls_score_shape = prediction_dict["rcnn"]["cls_score"].shape
      cls_prob_shape = prediction_dict["rcnn"]["cls_prob"].shape
  
      bbox_offsets_shape = prediction_dict["rcnn"]["bbox_offsets"].shape
  
      # We choose cls_score as the 'standard' num_proposals which we will
      # compare to the other shapes that should include num_proposals. We
      # could have chosen a different one.
      num_proposals = cls_score_shape[0]
  
      self.assertEqual(objects_shape[0], objects_labels_shape[0])
      self.assertEqual(objects_shape[0], objects_labels_prob_shape[0])
  
      self.assertEqual(objects_shape[1], 4)
      self.assertEqual(len(objects_labels_shape), 1)
      self.assertEqual(len(objects_labels_prob_shape), 1)
  
      self.assertEqual(cls_score_shape, cls_prob_shape)
      self.assertEqual(
          cls_prob_shape, (num_proposals, self._num_classes + 1)
      )
  
      self.assertEqual(
          bbox_offsets_shape, (num_proposals, self._num_classes * 4)
      )
  
      if training:
          cls_target_shape = prediction_dict["target"]["cls"].shape
          self.assertEqual(cls_target_shape, (num_proposals,))
  
          bbox_offsets_trgt_shape = prediction_dict["target"][
              "bbox_offsets"
          ].shape
          self.assertEqual(bbox_offsets_trgt_shape, (num_proposals, 4))
  
file_path: luminoth/luminoth/models/fasterrcnn/rcnn_test.py
imports: import numpy
  import tensorflow
  from easydict import EasyDict
  from luminoth.models.fasterrcnn.rcnn import RCNN
label_desc: Use image node_id 3 for calling the RCNNTest obj's underlying member method code with example usage: obj._check_returning_shapes(prediction_dict, training) without return types