(self, cardinality, depth, num_classes, base_width, expansion=4)
Constructor
        Args:
            cardinality: number of convolution groups.
            depth: number of layers.
            num_classes: number of classes
            base_width: base number of channels in each group.
            expansion: factor to adjust the channel dimensionality
Constructor
        Args:
            cardinality: number of convolution groups.
            depth: number of layers.
            num_classes: number of classes
            base_width: base number of channels in each group.
            expansion: factor to adjust the channel dimensionality
Constructor Args : cardinality : number of convolution groups . depth : number of layers . num_classes : number of classes base_width : base number of channels in each group . expansion : factor to adjust the channel dimensionality
def __init__(self, cardinality, depth, num_classes, base_width, expansion=4):
        """ Constructor
        Args:
            cardinality: number of convolution groups.
            depth: number of layers.
            num_classes: number of classes
            base_width: base number of channels in each group.
            expansion: factor to adjust the channel dimensionality
        """
        super(ResNeXt, self).__init__()
        self.cardinality = cardinality
        self.depth = depth
        self.block_depth = (self.depth - 2) // 9
        self.base_width = base_width
        self.expansion = expansion
        self.num_classes = num_classes
        self.output_size = 64
        self.stages = [
            64,
            64 * self.expansion,
            128 * self.expansion,
            256 * self.expansion,
        ]

        self.conv_1_3x3 = nn.Conv2d(3, 64, 3, 1, 1, bias=False)
        self.bn_1 = nn.BatchNorm2d(64)
        self.stage_1 = self.block("stage_1", self.stages[0], self.stages[1], 1)
        self.stage_2 = self.block("stage_2", self.stages[1], self.stages[2], 2)
        self.stage_3 = self.block("stage_3", self.stages[2], self.stages[3], 2)
        self.fc = nn.Linear(self.stages[3], num_classes)
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight.data)
            elif isinstance(m, nn.BatchNorm2d):
                m.weight.data.fill_(1)
                m.bias.data.zero_()
def __init__ ( self , cardinality , depth , num_classes , base_width , expansion = 4 ) : super ( ResNeXt , self ) . __init__ ( ) self . cardinality = cardinality self . depth = depth self . block_depth = ( self . depth - 2 ) // 9 self . base_width = base_width self . expansion = expansion self . num_classes = num_classes self . output_size = 64 self . stages = [ 64 , 64 * self . expansion , 128 * self . expansion , 256 * self . expansion , ] self . conv_1_3x3 = nn . Conv2d ( 3 , 64 , 3 , 1 , 1 , bias = False ) self . bn_1 = nn . BatchNorm2d ( 64 ) self . stage_1 = self . block ( "stage_1" , self . stages [ 0 ] , self . stages [ 1 ] , 1 ) self . stage_2 = self . block ( "stage_2" , self . stages [ 1 ] , self . stages [ 2 ] , 2 ) self . stage_3 = self . block ( "stage_3" , self . stages [ 2 ] , self . stages [ 3 ] , 2 ) self . fc = nn . Linear ( self . stages [ 3 ] , num_classes ) for m in self . modules ( ) : if isinstance ( m , nn . Conv2d ) : nn . init . kaiming_normal_ ( m . weight . data ) elif isinstance ( m , nn . BatchNorm2d ) : m . weight . data . fill_ ( 1 ) m . bias . data . zero_ ( )