class_docstr: RCNN: Region-based Convolutional Neural Network.
  
  Given region proposals (bounding boxes on an image) and a feature map of
  that image, RCNN adjusts the bounding boxes and classifies each region as
  either background or a specific object class.
  
  Steps:
      1. Region of Interest Pooling. Extract features from the feature map
         (based on the proposals) and convert into fixed size tensors
         (applying extrapolation).
      2. Two fully connected layers generate a smaller tensor for each
         region.
      3. A fully conected layer outputs the probability distribution over the
         classes (plus a background class), and another fully connected layer
         outputs the bounding box regressions (one 4-d regression for each of
         the possible classes).
  
  Using the class probability, filter regions classified as background. For
  the remaining regions, use the class probability together with the
  corresponding bounding box regression offsets to generate the final object
  bounding boxes, with classes and probabilities assigned.
class_docstr_tok: ["RCNN",":","Region-based","Convolutional","Neural","Network",".","Given","region","proposals","(","bounding","boxes","on","an","image",")","and","a","feature","map","of","that","image",",","RCNN","adjusts","the","bounding","boxes","and","classifies","each","region","as","either","background","or","a","specific","object","class",".","Steps",":","1",".","Region","of","Interest","Pooling",".","Extract","features","from","the","feature","map","(","based","on","the","proposals",")","and","convert","into","fixed","size","tensors","(","applying","extrapolation",")",".","2",".","Two","fully","connected","layers","generate","a","smaller","tensor","for","each","region",".","3",".","A","fully","conected","layer","outputs","the","probability","distribution","over","the","classes","(","plus","a","background","class",")",",","and","another","fully","connected","layer","outputs","the","bounding","box","regressions","(","one","4-d","regression","for","each","of","the","possible","classes",")",".","Using","the","class","probability",",","filter","regions","classified","as","background",".","For","the","remaining","regions",",","use","the","class","probability","together","with","the","corresponding","bounding","box","regression","offsets","to","generate","the","final","object","bounding","boxes",",","with","classes","and","probabilities","assigned","."]
code: def _instantiate_layers(self):
      # We define layers as an array since they are simple fully connected
      # ones and it should be easy to tune it from the network config.
      self._layers = [
          snt.Linear(
              layer_size,
              name="fc_{}".format(i),
              initializers={"w": self._rcnn_initializer},
              regularizers={"w": self.regularizer},
          )
          for i, layer_size in enumerate(self._layer_sizes)
      ]
      # We define the classifier layer having a num_classes + 1 background
      # since we want to be able to predict if the proposal is background as
      # well.
      self._classifier_layer = snt.Linear(
          self._num_classes + 1,
          name="fc_classifier",
          initializers={"w": self._cls_initializer},
          regularizers={"w": self.regularizer},
      )
  
      # The bounding box adjustment layer has 4 times the number of classes
      # We choose which to use depending on the output of the classifier
      # layer
      self._bbox_layer = snt.Linear(
          self._num_classes * 4,
          name="fc_bbox",
          initializers={"w": self._bbox_initializer},
          regularizers={"w": self.regularizer},
      )
  
      # ROIPoolingLayer is used to extract the feature from the feature map
      # using the proposals.
      self._roi_pool = ROIPoolingLayer(
          self._config.roi, debug=self._debug
      )
      # RCNNTarget is used to define a minibatch and the correct values for
      # each of the proposals.
      self._rcnn_target = RCNNTarget(
          self._num_classes,
          self._config.target,
          variances=self._variances,
          seed=self._seed,
      )
      # RCNNProposal generates the final bounding boxes and tries to remove
      # duplicates.
      self._rcnn_proposal = RCNNProposal(
          self._num_classes,
          self._config.proposals,
          variances=self._variances,
      )
  
file_path: luminoth/luminoth/models/fasterrcnn/rcnn.py
imports: import sonnet
  import tensorflow
  from luminoth.models.fasterrcnn.rcnn_proposal import RCNNProposal
  from luminoth.models.fasterrcnn.rcnn_target import RCNNTarget
  from luminoth.models.fasterrcnn.roi_pool import ROIPoolingLayer
  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 2 for calling the RCNN obj's underlying member method code with example usage: obj._instantiate_layers() without return types