nlpmodels/models/transformer.py
def _encode(self, src: torch.Tensor, src_mask: torch.Tensor) -> torch.Tensor:
        """
        Calculate all the layers in the encoder side of the model.
        Args:
            src (torch.Tensor):
                matrix of (batch_size, max_seq_length) size from source sequence.
            src_mask (torch.Tensor):
                matrix of (batch_size, max_seq_length) masking source so model doesn't see padding.

        Returns:
            encoder "memory" matrix of (batch_size, max_seq_length, dim_model) for decoder block.
        """
        embeddings = self._input_embeddings(src)
        pos_encoding = self._input_pe(embeddings)

        return self._encoder_block(pos_encoding, src_mask)

        Calculate all the layers in the encoder side of the model.
        Args:
            src (torch.Tensor):
                matrix of (batch_size, max_seq_length) size from source sequence.
            src_mask (torch.Tensor):
                matrix of (batch_size, max_seq_length) masking source so model doesn't see padding.

        Returns:
            encoder "memory" matrix of (batch_size, max_seq_length, dim_model) for decoder block.
        
Calculate all the layers in the encoder side of the model.
Calculate all the layers in the encoder side of the model .
def _encode(self, src: torch.Tensor, src_mask: torch.Tensor) -> torch.Tensor:
        embeddings = self._input_embeddings(src)
        pos_encoding = self._input_pe(embeddings)
        return self._encoder_block(pos_encoding, src_mask)
def _encode ( self , src : torch . Tensor , src_mask : torch . Tensor ) -> torch . Tensor : embeddings = self . _input_embeddings ( src ) pos_encoding = self . _input_pe ( embeddings ) return self . _encoder_block ( pos_encoding , src_mask )
Calculate all the layers in the encoder side of the model.
Calculate all the layers in the encoder side of the model .
"""
        Calculate all the layers in the encoder side of the model.
        Args:
            src (torch.Tensor):
                matrix of (batch_size, max_seq_length) size from source sequence.
            src_mask (torch.Tensor):
                matrix of (batch_size, max_seq_length) masking source so model doesn't see padding.

        Returns:
            encoder "memory" matrix of (batch_size, max_seq_length, dim_model) for decoder block.
        """
encoder "memory" matrix of (batch_size, max_seq_length, dim_model) for decoder block.
encoder " memory " matrix of ( batch_size max_seq_length dim_model ) for decoder block .
self
src
torch.Tensor
matrix of (batch_size, max_seq_length) size from source sequence.
matrix of ( batch_size max_seq_length ) size from source sequence .
src_mask
torch.Tensor
matrix of (batch_size, max_seq_length) masking source so model doesn't see padding.
matrix of ( batch_size max_seq_length ) masking source so model doesn ' t see padding .