o
    V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 g dZG dd dejZG dd deZe edejfdddddee dededef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                       sB   e Zd Zddededdf fddZd	ejdejfd
dZ  Z	S )r           ?num_classesdropoutreturnNc                    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)inplace)r   r         )r   r   i  r      )   r"   )pi $  i   )super__init__r   nn
SequentialConv2dReLU	MaxPool2dfeaturesAdaptiveAvgPool2davgpoolDropoutLinear
classifier)selfr   r   	__class__ N/var/www/vscode/kcb/lib/python3.10/site-packages/torchvision/models/alexnet.pyr%      s6   













zAlexNet.__init__xc                 C   s.   |  |}| |}t|d}| |}|S )Nr   )r+   r-   torchflattenr0   )r1   r6   r4   r4   r5   forward/   s
   


zAlexNet.forward)r   r   )
__name__
__module____qualname__intfloatr%   r7   Tensorr9   __classcell__r4   r4   r2   r5   r      s    r   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   )	crop_sizei(S)?   rC   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.
            )
num_paramsmin_size
categoriesrecipe_metrics_ops
_file_size_docs)url
transformsmetaN)	r:   r;   r<   r
   r   r   r   IMAGENET1K_V1DEFAULTr4   r4   r4   r5   r   7   s&    
r   
pretrained)weightsT)rR   progressrR   rS   kwargsr   c                 K   sV   t | } | durt|dt| jd  tdi |}| dur)|| 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   rF   T)rS   
check_hashr4   )r   verifyr   lenrN   r   load_state_dictget_state_dict)rR   rS   rT   modelr4   r4   r5   r   P   s   
r   )	functoolsr   typingr   r   r7   torch.nnr&   transforms._presetsr   utilsr   _apir	   r
   r   _metar   _utilsr   r   __all__Moduler   r   rO   boolr   r4   r4   r4   r5   <module>   s    &.