class_docstr: Head block for YOLOv3 network
  
  Args:
      norm_decay (float): weight decay for normalization layer weights
      num_classes (int): number of output classes
      ignore_thresh (float): threshold to ignore confidence loss
      label_smooth (bool): whether to use label smoothing
      anchors (list): anchors
      anchor_masks (list): anchor masks
      nms (object): an instance of `MultiClassNMS`
class_docstr_tok: ["Head","block","for","YOLOv3","network","Args",":","norm_decay","(","float",")",":","weight","decay","for","normalization","layer","weights","num_classes","(","int",")",":","number","of","output","classes","ignore_thresh","(","float",")",":","threshold","to","ignore","confidence","loss","label_smooth","(","bool",")",":","whether","to","use","label","smoothing","anchors","(","list",")",":","anchors","anchor_masks","(","list",")",":","anchor","masks","nms","(","object",")",":","an","instance","of","`","MultiClassNMS","`"]
docstr: Get YOLOv3 head output
  
  Args:
      input (list): List of Variables, output of backbone stages
      is_train (bool): whether in train or test mode
  
  Returns:
      outputs (list): Variables of each output layer
docstr_tok: ["Get","YOLOv3","head","output","Args",":","input","(","list",")",":","List","of","Variables",",","output","of","backbone","stages","is_train","(","bool",")",":","whether","in","train","or","test","mode","Returns",":","outputs","(","list",")",":","Variables","of","each","output","layer"]
code: def _get_outputs(self, input, is_train=True):
      """
      Get YOLOv3 head output
  
      Args:
          input (list): List of Variables, output of backbone stages
          is_train (bool): whether in train or test mode
  
      Returns:
          outputs (list): Variables of each output layer
      """
  
      outputs = []
  
      # get last out_layer_num blocks in reverse order
      out_layer_num = len(self.anchor_masks)
      if isinstance(input, OrderedDict):
          blocks = list(input.values())[-1 : -out_layer_num - 1 : -1]
      else:
          blocks = input[-1 : -out_layer_num - 1 : -1]
      route = None
      for i, block in enumerate(blocks):
          if i > 0:  # perform concat in first 2 detection_block
              block = fluid.layers.concat(input=[route, block], axis=1)
          route, tip = self._detection_block(
              block,
              channel=512 // (2**i),
              is_test=(not is_train),
              name=self.prefix_name + "yolo_block.{}".format(i),
          )
  
          # out channel number = mask_num * (5 + class_num)
          num_filters = len(self.anchor_masks[i]) * (
              self.num_classes + 5
          )
          block_out = fluid.layers.conv2d(
              input=tip,
              num_filters=num_filters,
              filter_size=1,
              stride=1,
              padding=0,
              act=None,
              param_attr=ParamAttr(
                  name=self.prefix_name
                  + "yolo_output.{}.conv.weights".format(i)
              ),
              bias_attr=ParamAttr(
                  regularizer=L2Decay(0.0),
                  name=self.prefix_name
                  + "yolo_output.{}.conv.bias".format(i),
              ),
          )
          outputs.append(block_out)
  
          if i < len(blocks) - 1:
              # do not perform upsample in the last detection_block
              route = self._conv_bn(
                  input=route,
                  ch_out=256 // (2**i),
                  filter_size=1,
                  stride=1,
                  padding=0,
                  is_test=(not is_train),
                  name=self.prefix_name
                  + "yolo_transition.{}".format(i),
              )
              # upsample
              route = self._upsample(route)
  
      return outputs, blocks
  
file_path: PaddleHub/modules/image/object_detection/yolov3_darknet53_venus/yolo_head.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from collections import OrderedDict
  from paddle import fluid
  from paddle.fluid.param_attr import ParamAttr
  from paddle.fluid.regularizer import L2Decay
label_desc: Use image node_id 6 for calling the YOLOv3Head obj's underlying member method code with example usage: obj._get_outputs(input, is_train) and returns: outputs,  blocks