(num_classes=1001, pretrained='imagenet')
return model
r"""NASNetALarge model architecture from the
    `"NASNet" <https://arxiv.org/abs/1707.07012>`_ paper.
r"""NASNetALarge model architecture from the
    `"NASNet" <https://arxiv.org/abs/1707.07012>`_ paper.
r NASNetALarge model architecture from the NASNet <https : // arxiv . org / abs / 1707 . 07012 > _ paper .
def nasnetalarge(num_classes=1001, pretrained='imagenet'):
    r"""NASNetALarge model architecture from the
    `"NASNet" <https://arxiv.org/abs/1707.07012>`_ paper.
    """
    if pretrained:
        settings = pretrained_settings['nasnetalarge'][pretrained]
        assert num_classes == settings['num_classes'], \
            "num_classes should be {}, but is {}".format(settings['num_classes'], num_classes)

        # both 'imagenet'&'imagenet+background' are loaded from same parameters
        model = NASNetALarge(num_classes=1001)
        model.load_state_dict(model_zoo.load_url(settings['url']))

        if pretrained == 'imagenet':
            new_last_linear = nn.Linear(model.last_linear.in_features, 1000)
            new_last_linear.weight.data = model.last_linear.weight.data[1:]
            new_last_linear.bias.data = model.last_linear.bias.data[1:]
            model.last_linear = new_last_linear

        model.input_space = settings['input_space']
        model.input_size = settings['input_size']
        model.input_range = settings['input_range']

        model.mean = settings['mean']
        model.std = settings['std']
    else:
        model = NASNetALarge(num_classes=num_classes)
    return model
def nasnetalarge ( num_classes = 1001 , pretrained = 'imagenet' ) : if pretrained : settings = pretrained_settings [ 'nasnetalarge' ] [ pretrained ] assert num_classes == settings [ 'num_classes' ] , "num_classes should be {}, but is {}" . format ( settings [ 'num_classes' ] , num_classes ) # both 'imagenet'&'imagenet+background' are loaded from same parameters model = NASNetALarge ( num_classes = 1001 ) model . load_state_dict ( model_zoo . load_url ( settings [ 'url' ] ) ) if pretrained == 'imagenet' : new_last_linear = nn . Linear ( model . last_linear . in_features , 1000 ) new_last_linear . weight . data = model . last_linear . weight . data [ 1 : ] new_last_linear . bias . data = model . last_linear . bias . data [ 1 : ] model . last_linear = new_last_linear model . input_space = settings [ 'input_space' ] model . input_size = settings [ 'input_size' ] model . input_range = settings [ 'input_range' ] model . mean = settings [ 'mean' ] model . std = settings [ 'std' ] else : model = NASNetALarge ( num_classes = num_classes ) return model