U
    (d                     @   s   d dl mZ d dlmZmZ d dlZd dlmZ ddlm	Z	 ddl
mZ ddlmZmZ dd	lmZ dd
lmZmZ dddgZG dd dejZG dd deZedejfddddee eeedddZddlmZ edejjiZdS )    )partial)AnyOptionalN   )ImageClassification)_log_api_usage_once   )WeightsEnumWeights)_IMAGENET_CATEGORIES)handle_legacy_interface_ovewrite_named_paramAlexNetAlexNet_Weightsalexnetc                       s<   e Zd Zd
eedd fddZejejddd	Z  Z	S )r           ?N)num_classesdropoutreturnc                    s$  t    t|  ttjddddddtjddtjddd	tjdd
dddtjddtjddd	tjd
ddddtjddtjdddddtjddtjdddddtjddtjddd	| _t	d| _
ttj|dtddtjddtj|dtddtjddtd|| _d S )N   @         r   )kernel_sizestridepaddingT)Zinplace)r   r         )r   r   i  r      )   r    )pi $  i   )super__init__r   nnZ
SequentialZConv2dZReLUZ	MaxPool2dfeaturesZAdaptiveAvgPool2davgpoolZDropoutZLinear
classifier)selfr   r   	__class__ >/tmp/pip-unpacked-wheel-vx7f76es/torchvision/models/alexnet.pyr#      s6    












zAlexNet.__init__)xr   c                 C   s.   |  |}| |}t|d}| |}|S )Nr   )r%   r&   torchflattenr'   )r(   r-   r+   r+   r,   forward/   s
    


zAlexNet.forward)r   r   )
__name__
__module____qualname__intfloatr#   r.   ZTensorr0   __classcell__r+   r+   r)   r,   r      s   c                   @   s>   e Zd Zedeeddddedddd	d
idddZeZdS )r   z<https://download.pytorch.org/models/alexnet-owt-7be5be79.pth   )Z	crop_sizei(S)?   r8   zUhttps://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vggzImageNet-1KgA`BL@gNbX9S@)zacc@1zacc@5zz
                These weights reproduce closely the results of the paper using a simplified training recipe.
            )Z
num_paramsZmin_size
categoriesZrecipeZ_metricsZ_docs)urlZ
transformsmetaN)	r1   r2   r3   r
   r   r   r   IMAGENET1K_V1DEFAULTr+   r+   r+   r,   r   7   s    
Z
pretrained)weightsT)r>   progress)r>   r?   kwargsr   c                 K   sP   t | } | dk	r(t|dt| jd  tf |}| dk	rL|| j|d |S )a  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:
    Nr   r9   )r?   )r   verifyr   lenr;   r   Zload_state_dictZget_state_dict)r>   r?   r@   modelr+   r+   r,   r   N   s    

)
_ModelURLs)	functoolsr   typingr   r   r.   Ztorch.nnr$   Ztransforms._presetsr   utilsr   Z_apir	   r
   Z_metar   _utilsr   r   __all__Moduler   r   r<   boolr   rD   r:   Z
model_urlsr+   r+   r+   r,   <module>   s&   
&") 