docstr: RPN - Region Proposal Network.
  
  Given an image (as feature map) and a fixed set of anchors, the RPN
  will learn weights to adjust those anchors so they better look like the
  ground truth objects, as well as scoring them by "objectness" (ie. how
  likely they are to be an object vs background).
  
  The final result will be a set of rectangular boxes ("proposals"),
  each associated with an objectness score.
  
  Note: this module can be used independently of Faster R-CNN.
docstr_tok: ["RPN","-","Region","Proposal","Network",".","Given","an","image","(","as","feature","map",")","and","a","fixed","set","of","anchors",",","the","RPN","will","learn","weights","to","adjust","those","anchors","so","they","better","look","like","the","ground","truth","objects",",","as","well","as","scoring","them","by","``","objectness","''","(","ie",".","how","likely","they","are","to","be","an","object","vs","background",")",".","The","final","result","will","be","a","set","of","rectangular","boxes","(","``","proposals","''",")",",","each","associated","with","an","objectness","score",".","Note",":","this","module","can","be","used","independently","of","Faster","R-CNN","."]
code: def __init__(
      self, num_anchors, config, debug=False, seed=None, name="rpn"
  ):
      """RPN - Region Proposal Network.
  
      Given an image (as feature map) and a fixed set of anchors, the RPN
      will learn weights to adjust those anchors so they better look like the
      ground truth objects, as well as scoring them by "objectness" (ie. how
      likely they are to be an object vs background).
  
      The final result will be a set of rectangular boxes ("proposals"),
      each associated with an objectness score.
  
      Note: this module can be used independently of Faster R-CNN.
      """
      super(RPN, self).__init__(name=name)
      self._num_anchors = num_anchors
      self._num_channels = config.num_channels
      self._kernel_shape = config.kernel_shape
  
      self._debug = debug
      self._seed = seed
  
      self._rpn_initializer = get_initializer(
          config.rpn_initializer, seed=seed
      )
      # According to Faster RCNN paper we need to initialize layers with
      # "from a zero-mean Gaussian distribution with standard deviation 0.01
      self._cls_initializer = get_initializer(
          config.cls_initializer, seed=seed
      )
      self._bbox_initializer = get_initializer(
          config.bbox_initializer, seed=seed
      )
      self._regularizer = tf.contrib.layers.l2_regularizer(
          scale=config.l2_regularization_scale
      )
  
      self._l1_sigma = config.l1_sigma
  
      # We could use normal relu without any problems.
      self._rpn_activation = get_activation_function(
          config.activation_function
      )
  
      self._config = config
  
file_path: luminoth/luminoth/models/fasterrcnn/rpn.py
imports: import sonnet
  import tensorflow
  from sonnet.python.modules.conv import Conv2D
  from .rpn_target import RPNTarget
  from .rpn_proposal import RPNProposal
  from luminoth.utils.losses import smooth_l1_loss
  from luminoth.utils.vars import get_initializer, layer_summaries, variable_summaries, get_activation_function
label_desc: Use image node_id 1 to create a new RPN object from inherited base classes: snt with example: obj = RPN(num_anchors, config, debug, seed, name)