[docs]classAlexNet_Weights(WeightsEnum):IMAGENET1K_V1=Weights(url="https://download.pytorch.org/models/alexnet-owt-7be5be79.pth",transforms=partial(ImageClassification,crop_size=224),meta={"num_params":61100840,"min_size":(63,63),"categories":_IMAGENET_CATEGORIES,"recipe":"https://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vgg","_metrics":{"ImageNet-1K":{"acc@1":56.522,"acc@5":79.066,}},"_ops":0.714,"_file_size":233.087,"_docs":""" These weights reproduce closely the results of the paper using a simplified training recipe. """,},)DEFAULT=IMAGENET1K_V1
[docs]@register_model()@handle_legacy_interface(weights=("pretrained",AlexNet_Weights.IMAGENET1K_V1))defalexnet(*,weights:Optional[AlexNet_Weights]=None,progress:bool=True,**kwargs:Any)->AlexNet:"""AlexNet model architecture from `One weird trick for parallelizing convolutional neural networks <https://arxiv.org/abs/1404.5997>`__. .. note:: AlexNet was originally introduced in the `ImageNet Classification with Deep Convolutional Neural Networks <https://papers.nips.cc/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html>`__ paper. Our implementation is based instead on the "One weird trick" paper above. Args: weights (:class:`~torchvision.models.AlexNet_Weights`, optional): The pretrained weights to use. See :class:`~torchvision.models.AlexNet_Weights` below for more details, and possible values. By default, no pre-trained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr. Default is True. **kwargs: parameters passed to the ``torchvision.models.squeezenet.AlexNet`` base class. Please refer to the `source code <https://github.com/pytorch/vision/blob/main/torchvision/models/alexnet.py>`_ for more details about this class. .. autoclass:: torchvision.models.AlexNet_Weights :members: """weights=AlexNet_Weights.verify(weights)ifweightsisnotNone:_ovewrite_named_param(kwargs,"num_classes",len(weights.meta["categories"]))model=AlexNet(**kwargs)ifweightsisnotNone:model.load_state_dict(weights.get_state_dict(progress=progress,check_hash=True))returnmodel
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.