class_docstr: Implementation of `SSD head <https://arxiv.org/abs/1512.02325>`_
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (Sequence[int]): Number of channels in the input feature
          map.
      stacked_convs (int): Number of conv layers in cls and reg tower.
          Defaults to 0.
      feat_channels (int): Number of hidden channels when stacked_convs
          > 0. Defaults to 256.
      use_depthwise (bool): Whether to use DepthwiseSeparableConv.
          Defaults to False.
      conv_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config conv layer. Defaults to None.
      norm_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config norm layer. Defaults to None.
      act_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config activation layer. Defaults to None.
      anchor_generator (:obj:`ConfigDict` or dict): Config dict for anchor
          generator.
      bbox_coder (:obj:`ConfigDict` or dict): Config of bounding box coder.
      reg_decoded_bbox (bool): If true, the regression loss would be
          applied directly on decoded bounding boxes, converting both
          the predicted boxes and regression targets to absolute
          coordinates format. Defaults to False. It should be `True` when
          using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head.
      train_cfg (:obj:`ConfigDict` or dict, Optional): Training config of
          anchor head.
      test_cfg (:obj:`ConfigDict` or dict, Optional): Testing config of
          anchor head.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], Optional): Initialization config dict.
class_docstr_tok: ["Implementation","of","`","SSD","head","<","https",":","\/\/arxiv.org\/abs\/1512.02325",">","`","_","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","Sequence","[","int","]",")",":","Number","of","channels","in","the","input","feature","map",".","stacked_convs","(","int",")",":","Number","of","conv","layers","in","cls","and","reg","tower",".","Defaults","to","0.","feat_channels","(","int",")",":","Number","of","hidden","channels","when","stacked_convs",">","0",".","Defaults","to","256.","use_depthwise","(","bool",")",":","Whether","to","use","DepthwiseSeparableConv",".","Defaults","to","False",".","conv_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","conv","layer",".","Defaults","to","None",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","norm","layer",".","Defaults","to","None",".","act_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","activation","layer",".","Defaults","to","None",".","anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","anchor","generator",".","bbox_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","bounding","box","coder",".","reg_decoded_bbox","(","bool",")",":","If","true",",","the","regression","loss","would","be","applied","directly","on","decoded","bounding","boxes",",","converting","both","the","predicted","boxes","and","regression","targets","to","absolute","coordinates","format",".","Defaults","to","False",".","It","should","be","`","True","`","when","using","`","IoULoss","`",",","`","GIoULoss","`",",","or","`","DIoULoss","`","in","the","bbox","head",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Training","config","of","anchor","head",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Testing","config","of","anchor","head",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","Optional",")",":","Initialization","config","dict","."]
code: def __init__(
      self,
      num_classes: int = 80,
      in_channels: Sequence[int] = (512, 1024, 512, 256, 256, 256),
      stacked_convs: int = 0,
      feat_channels: int = 256,
      use_depthwise: bool = False,
      conv_cfg: Optional[ConfigType] = None,
      norm_cfg: Optional[ConfigType] = None,
      act_cfg: Optional[ConfigType] = None,
      anchor_generator: ConfigType = dict(
          type="SSDAnchorGenerator",
          scale_major=False,
          input_size=300,
          strides=[8, 16, 32, 64, 100, 300],
          ratios=([2], [2, 3], [2, 3], [2, 3], [2], [2]),
          basesize_ratio_range=(0.1, 0.9),
      ),
      bbox_coder: ConfigType = dict(
          type="DeltaXYWHBBoxCoder",
          clip_border=True,
          target_means=[0.0, 0.0, 0.0, 0.0],
          target_stds=[1.0, 1.0, 1.0, 1.0],
      ),
      reg_decoded_bbox: bool = False,
      train_cfg: Optional[ConfigType] = None,
      test_cfg: Optional[ConfigType] = None,
      init_cfg: MultiConfig = dict(
          type="Xavier", layer="Conv2d", distribution="uniform", bias=0
      ),
  ) -> None:
      super(AnchorHead, self).__init__(init_cfg=init_cfg)
      self.num_classes = num_classes
      self.in_channels = in_channels
      self.stacked_convs = stacked_convs
      self.feat_channels = feat_channels
      self.use_depthwise = use_depthwise
      self.conv_cfg = conv_cfg
      self.norm_cfg = norm_cfg
      self.act_cfg = act_cfg
  
      self.cls_out_channels = num_classes + 1  # add background class
      self.prior_generator = TASK_UTILS.build(anchor_generator)
  
      # Usually the numbers of anchors for each level are the same
      # except SSD detectors. So it is an int in the most dense
      # heads but a list of int in SSDHead
      self.num_base_priors = self.prior_generator.num_base_priors
  
      self._init_layers()
  
      self.bbox_coder = TASK_UTILS.build(bbox_coder)
      self.reg_decoded_bbox = reg_decoded_bbox
      self.use_sigmoid_cls = False
      self.cls_focal_loss = False
      self.train_cfg = train_cfg
      self.test_cfg = test_cfg
      if self.train_cfg:
          self.assigner = TASK_UTILS.build(self.train_cfg["assigner"])
          if self.train_cfg.get("sampler", None) is not None:
              self.sampler = TASK_UTILS.build(
                  self.train_cfg["sampler"],
                  default_args=dict(context=self),
              )
          else:
              self.sampler = PseudoSampler(context=self)
  
file_path: mmdetection/mmdet/models/dense_heads/ssd_head.py
imports: from typing import Dict, List, Optional, Sequence, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptInstanceList
  from ..losses import smooth_l1_loss
  from ..task_modules.samplers import PseudoSampler
  from ..utils import multi_apply
  from .anchor_head import AnchorHead
label_desc: Use image node_id 1 to create a new SSDHead object from inherited base classes: AnchorHead with example: obj = SSDHead(num_classes, in_channels, stacked_convs, feat_channels, use_depthwise, conv_cfg, norm_cfg, act_cfg, anchor_generator, bbox_coder, reg_decoded_bbox, train_cfg, test_cfg, init_cfg)