U
    h                     @   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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 edejfddddee eeedddZdS )    )partial)AnyOptionalN   )ImageClassification)_log_api_usage_once   )register_modelWeightsWeightsEnum)_IMAGENET_CATEGORIES)_ovewrite_named_paramhandle_legacy_interface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__ L/var/www/html/venv/lib/python3.8/site-packages/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Tensorr1   __classcell__r,   r,   r*   r-   r      s   c                   @   sB   e Zd Zedeeddddedddd	d
idddddZeZdS )r   z<https://download.pytorch.org/models/alexnet-owt-7be5be79.pth   )Z	crop_sizei(S)?   r9   zUhttps://github.com/pytorch/vision/tree/main/references/classification#alexnet-and-vggzImageNet-1KgA`BL@gNbX9S@)zacc@1zacc@5g+?gX9"m@zz
                These weights reproduce closely the results of the paper using a simplified training recipe.
            )Z
num_paramsZmin_size
categoriesZrecipeZ_metricsZ_ops
_file_sizeZ_docs)urlZ
transformsmetaN)	r2   r3   r4   r
   r   r   r   IMAGENET1K_V1DEFAULTr,   r,   r,   r-   r   7   s$   
Z
pretrained)weightsT)r@   progress)r@   rA   kwargsr   c                 K   sR   t | } | dk	r(t|dt| jd  tf |}| dk	rN|| j|d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   r:   T)rA   Z
check_hash)r   verifyr   lenr=   r   Zload_state_dictZget_state_dict)r@   rA   rB   modelr,   r,   r-   r   P   s    

)	functoolsr   typingr   r   r/   Ztorch.nnr%   Ztransforms._presetsr   utilsr   Z_apir	   r
   r   _metar   Z_utilsr   r   __all__Moduler   r   r>   boolr   r,   r,   r,   r-   <module>   s   
&