o
    Qe‡  ã                   @   s.   d dl Z d dlmZ g ZG dd„ dejƒZdS )é    Nc                       s*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )ÚLeNeta—  LeNet model from
    `"Gradient-based learning applied to document recognition" <https://ieeexplore.ieee.org/document/726791>`_.

    Args:
        num_classes (int, optional): Output dim of last fc layer. If num_classes <= 0, last fc layer 
                            will not be defined. Default: 10.

    Returns:
        :ref:`api_paddle_nn_Layer`. An instance of LeNet model.

    Examples:
        .. code-block:: python

            import paddle
            from paddle.vision.models import LeNet

            model = LeNet()

            x = paddle.rand([1, 1, 28, 28])
            out = model(x)

            print(out.shape)
            # [1, 10]
    é
   c                    sš   t t| ƒ ¡  || _t tjddddddt ¡ t dd¡tjddddddt ¡ t dd¡¡| _	|dkrKt t 
d	d
¡t 
d
d¡t 
d|¡¡| _d S d S )Né   é   é   )ZstrideÚpaddingé   é   é   r   i  éx   éT   )Úsuperr   Ú__init__Únum_classesÚnnZ
SequentialZConv2DZReLUZ	MaxPool2DÚfeaturesZLinearÚfc)Úselfr   ©Ú	__class__© úJD:\Projects\ConvertPro\env\Lib\site-packages\paddle/vision/models/lenet.pyr   /   s   ý

ÿÿzLeNet.__init__c                 C   s.   |   |¡}| jdkrt |d¡}|  |¡}|S )Nr   r   )r   r   ÚpaddleÚflattenr   )r   ZinputsÚxr   r   r   Úforward;   s
   


zLeNet.forward)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r      s    r   )r   Z	paddle.nnr   Ú__all__ZLayerr   r   r   r   r   Ú<module>   s   