class_docstr: Assign object detection proposals to ground-truth targets. Produces proposal
  classification labels and bounding-box regression targets.
class_docstr_tok: ["Assign","object","detection","proposals","to","ground-truth","targets",".","Produces","proposal","classification","labels","and","bounding-box","regression","targets","."]
code: def forward(self, bottom, top):
      # Proposal ROIs (0, x1, y1, x2, y2) coming from RPN
      # (i.e., rpn.proposal_layer.ProposalLayer), or any other source
      all_rois = bottom[0]
      # GT boxes (x1, y1, x2, y2, label)
      gt_boxes = bottom[1]
  
      # Include ground-truth boxes in the set of candidate rois
      zeros = np.zeros((gt_boxes.shape[0], 1), dtype=gt_boxes.dtype)
      all_rois = np.vstack(
          (all_rois, np.hstack((zeros, gt_boxes[:, :-1])))
      )
  
      # Sanity check: single batch only
      assert np.all(
          all_rois[:, 0] == 0
      ), "Only single item batches are supported"
  
      rois_per_image = 128
      fg_rois_per_image = np.round(FG_FRAC * rois_per_image)
  
      # Sample rois with classification labels and bounding box regression
      # targets
      labels, rois, bbox_targets, bbox_inside_weights = _sample_rois(
          all_rois,
          gt_boxes,
          fg_rois_per_image,
          rois_per_image,
          self._num_classes,
          self.deterministic,
      )
  
      if DEBUG:
          print("num fg: {}".format((labels > 0).sum()))
          print("num bg: {}".format((labels == 0).sum()))
          self._count += 1
          self._fg_num += (labels > 0).sum()
          self._bg_num += (labels == 0).sum()
          print("num fg avg: {}".format(self._fg_num / self._count))
          print("num bg avg: {}".format(self._bg_num / self._count))
          print(
              "ratio: {:.3f}".format(
                  float(self._fg_num) / float(self._bg_num)
              )
          )
  
      # sampled rois
      # top[0].reshape(*rois.shape)
      # top[0][...] = rois
  
      # classification labels
      # top[1].reshape(*labels.shape)
      top[1] = labels
  
      # bbox_targets
      # top[2].reshape(*bbox_targets.shape)
      top[2] = bbox_targets
  
      # bbox_inside_weights
      # top[3].reshape(*bbox_inside_weights.shape)
      top[3] = bbox_inside_weights
  
file_path: neon/examples/faster-rcnn/tests/proposal_target_layer_ref.py
imports: from __future__ import division
  from __future__ import print_function
  from builtins import object
  import numpy
  import numpy.random
  from util import bbox_transform, calculate_bb_overlap
label_desc: Use image node_id 2 for calling the PyCaffeProposalTargetLayer obj's underlying member method code with example usage: obj.forward(bottom, top) without return types