parameters: (self, num_classes=1000, width_mult=1.0, inverted_residual_setting=None, round_nearest=8)
docstring: MobileNet V2 main class
          Args:
              num_classes (int): Number of classes
              width_mult (float): Width multiplier - adjusts number of channels in each layer by this amount
              inverted_residual_setting: Network structure
              round_nearest (int): Round the number of channels in each layer to be a multiple of this number
              Set to 1 to turn off rounding
docstring_summary: MobileNet V2 main class
          Args:
              num_classes (int): Number of classes
              width_mult (float): Width multiplier - adjusts number of channels in each layer by this amount
              inverted_residual_setting: Network structure
              round_nearest (int): Round the number of channels in each layer to be a multiple of this number
              Set to 1 to turn off rounding
docstring_tokens: MobileNet V2 main class Args : num_classes ( int ) : Number of classes width_mult ( float ) : Width multiplier - adjusts number of channels in each layer by this amount inverted_residual_setting : Network structure round_nearest ( int ) : Round the number of channels in each layer to be a multiple of this number Set to 1 to turn off rounding
function: def __init__(self, num_classes=1000, width_mult=1.0, inverted_residual_setting=None, round_nearest=8):
          """
          MobileNet V2 main class
          Args:
              num_classes (int): Number of classes
              width_mult (float): Width multiplier - adjusts number of channels in each layer by this amount
              inverted_residual_setting: Network structure
              round_nearest (int): Round the number of channels in each layer to be a multiple of this number
              Set to 1 to turn off rounding
          """
          super(MobileNetV2, self).__init__()
          block = InvertedResidual
          input_channel = 32
  
          if inverted_residual_setting is None:
              inverted_residual_setting = [
                  # t, c, n, s
                  [2, 16, 4, 1],
                  [2, 24, 4, 2],
                  [2, 32, 2, 2],
                  [2, 64, 1, 2],
                  [2, 96, 1, 2],
              ]
  
          if len(inverted_residual_setting) == 0 or len(inverted_residual_setting[0]) != 4:
              raise ValueError("inverted_residual_setting should be non-empty "
                               "or a 4-element list, got {}".format(inverted_residual_setting))
  
          # building first layer
          input_channel = _make_divisible(input_channel * width_mult, round_nearest)
          self.layers = []
          # building inverted residual blocks
          for t, c, n, s in inverted_residual_setting:
              output_channel = _make_divisible(c * width_mult, round_nearest)
              for i in range(n):
                  stride = s if i == 0 else 1
                  self.layers.append(block(input_channel, output_channel, stride, expand_ratio=t))
                  input_channel = output_channel
                  
          # weight initialization
          for m in self.modules():
              if isinstance(m, nn.Conv2d):
                  nn.init.kaiming_normal_(m.weight, mode='fan_out')
                  if m.bias is not None:
                      nn.init.zeros_(m.bias)
              elif isinstance(m, nn.BatchNorm2d):
                  nn.init.ones_(m.weight)
                  nn.init.zeros_(m.bias)
              elif isinstance(m, nn.Linear):
                  nn.init.normal_(m.weight, 0, 0.01)
                  nn.init.zeros_(m.bias)
function_tokens: def __init__ ( self , num_classes = 1000 , width_mult = 1.0 , inverted_residual_setting = None , round_nearest = 8 ) : super ( MobileNetV2 , self ) . __init__ ( ) block = InvertedResidual input_channel = 32 if inverted_residual_setting is None : inverted_residual_setting = [ # t, c, n, s [ 2 , 16 , 4 , 1 ] , [ 2 , 24 , 4 , 2 ] , [ 2 , 32 , 2 , 2 ] , [ 2 , 64 , 1 , 2 ] , [ 2 , 96 , 1 , 2 ] , ] if len ( inverted_residual_setting ) == 0 or len ( inverted_residual_setting [ 0 ] ) != 4 : raise ValueError ( "inverted_residual_setting should be non-empty " "or a 4-element list, got {}" . format ( inverted_residual_setting ) ) # building first layer input_channel = _make_divisible ( input_channel * width_mult , round_nearest ) self . layers = [ ] # building inverted residual blocks for t , c , n , s in inverted_residual_setting : output_channel = _make_divisible ( c * width_mult , round_nearest ) for i in range ( n ) : stride = s if i == 0 else 1 self . layers . append ( block ( input_channel , output_channel , stride , expand_ratio = t ) ) input_channel = output_channel # weight initialization for m in self . modules ( ) : if isinstance ( m , nn . Conv2d ) : nn . init . kaiming_normal_ ( m . weight , mode = 'fan_out' ) if m . bias is not None : nn . init . zeros_ ( m . bias ) elif isinstance ( m , nn . BatchNorm2d ) : nn . init . ones_ ( m . weight ) nn . init . zeros_ ( m . bias ) elif isinstance ( m , nn . Linear ) : nn . init . normal_ ( m . weight , 0 , 0.01 ) nn . init . zeros_ ( m . bias )