o
    ôjˆ  ã                   @   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__© úk/var/www/html/academy/tools/voices/clone/sv-venv/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-1Kg‰A`åÐBL@gNbX9ÄS@)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_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   Z
pretrained)ÚweightsT)rP   ÚprogressrP   rQ   Ú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   rE   T)rQ   Ú
check_hashr4   )r   Úverifyr   ÚlenrM   r   Úload_state_dictÚget_state_dict)rP   rQ   rR   Úmodelr4   r4   r5   r   P   s   
r   )Ú	functoolsr   Útypingr   r   r7   Útorch.nnr&   Ztransforms._presetsr   Úutilsr   Ú_apir	   r
   r   Ú_metar   Ú_utilsr   r   Ú__all__ÚModuler   r   rN   Úboolr   r4   r4   r4   r5   Ú<module>   s    &.