(self, cfg, in_channels)
Arguments:
            in_channels (int): number of channels of the input feature
            num_anchors (int): number of anchors to be predicted
Arguments:
            in_channels (int): number of channels of the input feature
            num_anchors (int): number of anchors to be predicted
Arguments : in_channels ( int ) : number of channels of the input feature num_anchors ( int ) : number of anchors to be predicted
def __init__(self, cfg, in_channels):
        """
        Arguments:
            in_channels (int): number of channels of the input feature
            num_anchors (int): number of anchors to be predicted
        """
        super(RetinaNetHead, self).__init__()
        # TODO: Implement the sigmoid version first.
        num_classes = cfg.MODEL.RETINANET.NUM_CLASSES - 1
        num_anchors = len(cfg.MODEL.RETINANET.ASPECT_RATIOS) \
                        * cfg.MODEL.RETINANET.SCALES_PER_OCTAVE

        cls_tower = []
        bbox_tower = []
        for i in range(cfg.MODEL.RETINANET.NUM_CONVS):
            cls_tower.append(
                nn.Conv2d(
                    in_channels,
                    in_channels,
                    kernel_size=3,
                    stride=1,
                    padding=1
                )
            )
            cls_tower.append(nn.ReLU())
            bbox_tower.append(
                nn.Conv2d(
                    in_channels,
                    in_channels,
                    kernel_size=3,
                    stride=1,
                    padding=1
                )
            )
            bbox_tower.append(nn.ReLU())

        self.add_module('cls_tower', nn.Sequential(*cls_tower))
        self.add_module('bbox_tower', nn.Sequential(*bbox_tower))
        self.cls_logits = nn.Conv2d(
            in_channels, num_anchors * num_classes, kernel_size=3, stride=1,
            padding=1
        )
        self.bbox_pred = nn.Conv2d(
            in_channels,  num_anchors * 4, kernel_size=3, stride=1,
            padding=1
        )

        # Initialization
        for modules in [self.cls_tower, self.bbox_tower, self.cls_logits,
                  self.bbox_pred]:
            for l in modules.modules():
                if isinstance(l, nn.Conv2d):
                    torch.nn.init.normal_(l.weight, std=0.01)
                    torch.nn.init.constant_(l.bias, 0)


        # retinanet_bias_init
        prior_prob = cfg.MODEL.RETINANET.PRIOR_PROB
        bias_value = -math.log((1 - prior_prob) / prior_prob)
        torch.nn.init.constant_(self.cls_logits.bias, bias_value)
def __init__ ( self , cfg , in_channels ) : super ( RetinaNetHead , self ) . __init__ ( ) # TODO: Implement the sigmoid version first. num_classes = cfg . MODEL . RETINANET . NUM_CLASSES - 1 num_anchors = len ( cfg . MODEL . RETINANET . ASPECT_RATIOS ) * cfg . MODEL . RETINANET . SCALES_PER_OCTAVE cls_tower = [ ] bbox_tower = [ ] for i in range ( cfg . MODEL . RETINANET . NUM_CONVS ) : cls_tower . append ( nn . Conv2d ( in_channels , in_channels , kernel_size = 3 , stride = 1 , padding = 1 ) ) cls_tower . append ( nn . ReLU ( ) ) bbox_tower . append ( nn . Conv2d ( in_channels , in_channels , kernel_size = 3 , stride = 1 , padding = 1 ) ) bbox_tower . append ( nn . ReLU ( ) ) self . add_module ( 'cls_tower' , nn . Sequential ( * cls_tower ) ) self . add_module ( 'bbox_tower' , nn . Sequential ( * bbox_tower ) ) self . cls_logits = nn . Conv2d ( in_channels , num_anchors * num_classes , kernel_size = 3 , stride = 1 , padding = 1 ) self . bbox_pred = nn . Conv2d ( in_channels , num_anchors * 4 , kernel_size = 3 , stride = 1 , padding = 1 ) # Initialization for modules in [ self . cls_tower , self . bbox_tower , self . cls_logits , self . bbox_pred ] : for l in modules . modules ( ) : if isinstance ( l , nn . Conv2d ) : torch . nn . init . normal_ ( l . weight , std = 0.01 ) torch . nn . init . constant_ ( l . bias , 0 ) # retinanet_bias_init prior_prob = cfg . MODEL . RETINANET . PRIOR_PROB bias_value = - math . log ( ( 1 - prior_prob ) / prior_prob ) torch . nn . init . constant_ ( self . cls_logits . bias , bias_value )