(num_classes=1000, pretrained='imagenet')
return model
r"""Inception v3 model architecture from
    `"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
r"""Inception v3 model architecture from
    `"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
r Inception v3 model architecture from Rethinking the Inception Architecture for Computer Vision <http : // arxiv . org / abs / 1512 . 00567 > _ .
def inceptionv3(num_classes=1000, pretrained='imagenet'):
    r"""Inception v3 model architecture from
    `"Rethinking the Inception Architecture for Computer Vision" <http://arxiv.org/abs/1512.00567>`_.
    """
    model = models.inception_v3(pretrained=False)
    if pretrained is not None:
        settings = pretrained_settings['inceptionv3'][pretrained]
        model = load_pretrained(model, num_classes, settings)

    # Modify attributs
    model.last_linear = model.fc
    del model.fc

    def features(self, input):
        # 299 x 299 x 3
        x = self.Conv2d_1a_3x3(input) # 149 x 149 x 32
        x = self.Conv2d_2a_3x3(x) # 147 x 147 x 32
        x = self.Conv2d_2b_3x3(x) # 147 x 147 x 64
        x = F.max_pool2d(x, kernel_size=3, stride=2) # 73 x 73 x 64
        x = self.Conv2d_3b_1x1(x) # 73 x 73 x 80
        x = self.Conv2d_4a_3x3(x) # 71 x 71 x 192
        x = F.max_pool2d(x, kernel_size=3, stride=2) # 35 x 35 x 192
        x = self.Mixed_5b(x) # 35 x 35 x 256
        x = self.Mixed_5c(x) # 35 x 35 x 288
        x = self.Mixed_5d(x) # 35 x 35 x 288
        x = self.Mixed_6a(x) # 17 x 17 x 768
        x = self.Mixed_6b(x) # 17 x 17 x 768
        x = self.Mixed_6c(x) # 17 x 17 x 768
        x = self.Mixed_6d(x) # 17 x 17 x 768
        x = self.Mixed_6e(x) # 17 x 17 x 768
        if self.training and self.aux_logits:
            self._out_aux = self.AuxLogits(x) # 17 x 17 x 768
        x = self.Mixed_7a(x) # 8 x 8 x 1280
        x = self.Mixed_7b(x) # 8 x 8 x 2048
        x = self.Mixed_7c(x) # 8 x 8 x 2048
        return x

    def logits(self, features):
        x = F.avg_pool2d(features, kernel_size=8) # 1 x 1 x 2048
        x = F.dropout(x, training=self.training) # 1 x 1 x 2048
        x = x.view(x.size(0), -1) # 2048
        x = self.last_linear(x) # 1000 (num_classes)
        if self.training and self.aux_logits:
            aux = self._out_aux
            self._out_aux = None
            return x, aux
        return x

    def forward(self, input):
        x = self.features(input)
        x = self.logits(x)
        return x

    # Modify methods
    model.features = types.MethodType(features, model)
    model.logits = types.MethodType(logits, model)
    model.forward = types.MethodType(forward, model)
    return model
def inceptionv3 ( num_classes = 1000 , pretrained = 'imagenet' ) : model = models . inception_v3 ( pretrained = False ) if pretrained is not None : settings = pretrained_settings [ 'inceptionv3' ] [ pretrained ] model = load_pretrained ( model , num_classes , settings ) # Modify attributs model . last_linear = model . fc del model . fc def features ( self , input ) : # 299 x 299 x 3 x = self . Conv2d_1a_3x3 ( input ) # 149 x 149 x 32 x = self . Conv2d_2a_3x3 ( x ) # 147 x 147 x 32 x = self . Conv2d_2b_3x3 ( x ) # 147 x 147 x 64 x = F . max_pool2d ( x , kernel_size = 3 , stride = 2 ) # 73 x 73 x 64 x = self . Conv2d_3b_1x1 ( x ) # 73 x 73 x 80 x = self . Conv2d_4a_3x3 ( x ) # 71 x 71 x 192 x = F . max_pool2d ( x , kernel_size = 3 , stride = 2 ) # 35 x 35 x 192 x = self . Mixed_5b ( x ) # 35 x 35 x 256 x = self . Mixed_5c ( x ) # 35 x 35 x 288 x = self . Mixed_5d ( x ) # 35 x 35 x 288 x = self . Mixed_6a ( x ) # 17 x 17 x 768 x = self . Mixed_6b ( x ) # 17 x 17 x 768 x = self . Mixed_6c ( x ) # 17 x 17 x 768 x = self . Mixed_6d ( x ) # 17 x 17 x 768 x = self . Mixed_6e ( x ) # 17 x 17 x 768 if self . training and self . aux_logits : self . _out_aux = self . AuxLogits ( x ) # 17 x 17 x 768 x = self . Mixed_7a ( x ) # 8 x 8 x 1280 x = self . Mixed_7b ( x ) # 8 x 8 x 2048 x = self . Mixed_7c ( x ) # 8 x 8 x 2048 return x def logits ( self , features ) : x = F . avg_pool2d ( features , kernel_size = 8 ) # 1 x 1 x 2048 x = F . dropout ( x , training = self . training ) # 1 x 1 x 2048 x = x . view ( x . size ( 0 ) , - 1 ) # 2048 x = self . last_linear ( x ) # 1000 (num_classes) if self . training and self . aux_logits : aux = self . _out_aux self . _out_aux = None return x , aux return x def forward ( self , input ) : x = self . features ( input ) x = self . logits ( x ) return x # Modify methods model . features = types . MethodType ( features , model ) model . logits = types . MethodType ( logits , model ) model . forward = types . MethodType ( forward , model ) return model