class_docstr: Region Proposal Network
  
  Args:
      anchor_generator (dict): configure of anchor generation
      rpn_target_assign (dict): configure of rpn targets assignment
      train_proposal (dict): configure of proposals generation
          at the stage of training
      test_proposal (dict): configure of proposals generation
          at the stage of prediction
      in_channel (int): channel of input feature maps which can be
          derived by from_config
class_docstr_tok: ["Region","Proposal","Network","Args",":","anchor_generator","(","dict",")",":","configure","of","anchor","generation","rpn_target_assign","(","dict",")",":","configure","of","rpn","targets","assignment","train_proposal","(","dict",")",":","configure","of","proposals","generation","at","the","stage","of","training","test_proposal","(","dict",")",":","configure","of","proposals","generation","at","the","stage","of","prediction","in_channel","(","int",")",":","channel","of","input","feature","maps","which","can","be","derived","by","from_config"]
code: def __init__(
      self,
      anchor_generator=_get_class_default_kwargs(AnchorGenerator),
      rpn_target_assign=_get_class_default_kwargs(RPNTargetAssign),
      train_proposal=_get_class_default_kwargs(
          ProposalGenerator, 12000, 2000
      ),
      test_proposal=_get_class_default_kwargs(ProposalGenerator),
      in_channel=1024,
      export_onnx=False,
      loss_rpn_bbox=None,
  ):
      super(RPNHead, self).__init__()
      self.anchor_generator = anchor_generator
      self.rpn_target_assign = rpn_target_assign
      self.train_proposal = train_proposal
      self.test_proposal = test_proposal
      self.export_onnx = export_onnx
      if isinstance(anchor_generator, dict):
          self.anchor_generator = AnchorGenerator(**anchor_generator)
      if isinstance(rpn_target_assign, dict):
          self.rpn_target_assign = RPNTargetAssign(**rpn_target_assign)
      if isinstance(train_proposal, dict):
          self.train_proposal = ProposalGenerator(**train_proposal)
      if isinstance(test_proposal, dict):
          self.test_proposal = ProposalGenerator(**test_proposal)
      self.loss_rpn_bbox = loss_rpn_bbox
  
      num_anchors = self.anchor_generator.num_anchors
      self.rpn_feat = RPNFeat(in_channel, in_channel)
      # rpn head is shared with each level
      # rpn roi classification scores
      self.rpn_rois_score = nn.Conv2D(
          in_channels=in_channel,
          out_channels=num_anchors,
          kernel_size=1,
          padding=0,
          weight_attr=paddle.ParamAttr(
              initializer=Normal(mean=0.0, std=0.01)
          ),
      )
      self.rpn_rois_score.skip_quant = True
  
      # rpn roi bbox regression deltas
      self.rpn_rois_delta = nn.Conv2D(
          in_channels=in_channel,
          out_channels=4 * num_anchors,
          kernel_size=1,
          padding=0,
          weight_attr=paddle.ParamAttr(
              initializer=Normal(mean=0.0, std=0.01)
          ),
      )
      self.rpn_rois_delta.skip_quant = True
  
file_path: PaddleDetection/ppdet/modeling/proposal_generator/rpn_head.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal
  from ppdet.core.workspace import register
  from .anchor_generator import AnchorGenerator
  from .target_layer import RPNTargetAssign
  from .proposal_generator import ProposalGenerator
  from ..cls_utils import _get_class_default_kwargs
label_desc: Use image node_id 1 to create a new RPNHead object from inherited base classes: nn with example: obj = RPNHead(anchor_generator, rpn_target_assign, train_proposal, test_proposal, in_channel, export_onnx, loss_rpn_bbox)