o
    %ݫi                     @   s.   d Z ddlZddlZG dd dejjjZdS )zThis lobes replicate the encoder first introduced in ESPNET v1

source: https://github.com/espnet/espnet/blob/master/espnet/nets/pytorch_backend/rnn/encoders.py

Authors
 * Titouan Parcollet 2020
    Nc                	       sB   e Zd ZdZejjdddgejj	j
dddddf	 fd	d
	Z  ZS )	ESPnetVGGah  This model is a combination of CNNs and RNNs following
        the ESPnet encoder. (VGG+RNN+MLP+tanh())

    Arguments
    ---------
    input_shape : tuple
        The shape of an example expected input.
    activation : torch class
        A class used for constructing the activation layers. For CNN and DNN.
    dropout : float
        Neuron dropout rate, applied to RNN only.
    cnn_channels : list of ints
        A list of the number of output channels for each CNN block.
    rnn_class : torch class
        The type of RNN to use (LiGRU, LSTM, GRU, RNN)
    rnn_layers : int
        The number of recurrent layers to include.
    rnn_neurons : int
        Number of neurons in each layer of the RNN.
    rnn_bidirectional : bool
        Whether this model will process just forward or both directions.
    rnn_re_init : bool
    projection_neurons : int
        The number of neurons in the last linear layer.

    Example
    -------
    >>> inputs = torch.rand([10, 40, 60])
    >>> model = ESPnetVGG(input_shape=inputs.shape)
    >>> outputs = model(inputs)
    >>> outputs.shape
    torch.Size([10, 10, 512])
    g333333?@         i   TFc              	      s\  t  j|d | jtjjjdd | jtjjj|d ddd | j| dd | jtjjj|d dd	d | j| d
d | jtjj	j
dddddd | jtjjj|d ddd | j| dd | jtjjj|d ddd | j| dd | jtjj	j
dddddd |dkr| j|d|||||	d | jtjjj|
dd | jtj dd d S )N)input_shapeVGG)
layer_namer   )   r	   conv_1_1)out_channelskernel_sizer   act_1_1conv_1_2act_1_2max)   r   )   r   )	pool_typer   	pool_axis	pooling_1r   conv_2_1act_2_1conv_2_2act_2_2	pooling_2RNN)r   hidden_size
num_layersdropoutbidirectionalre_initproj)	n_neuronsr   proj_act)super__init__appendsbnnet
containers
SequentialCNNConv2dpooling	Pooling2dlinearLineartorchnnTanh)selfr   
activationr   cnn_channels	rnn_class
rnn_layersrnn_neuronsrnn_bidirectionalrnn_re_initprojection_neurons	__class__ V/home/ubuntu/.local/lib/python3.10/site-packages/speechbrain/lobes/models/ESPnetVGG.pyr%   1   s|   		
zESPnetVGG.__init__)__name__
__module____qualname____doc__r1   r2   ReLUr'   r(   r   LSTMr%   __classcell__r?   r?   r=   r@   r      s    %r   )rD   r1   speechbrainr'   r(   r)   r*   r   r?   r?   r?   r@   <module>   s    