nlpmodels/models/transformer.py
def forward(self, data: TransformerBatch) -> torch.Tensor:
        """
        Main call of transformer model. Pass through encoder-decoder architecture.

        Args:
            data(TransformerBatch):
                Class of batch data containing source, source_mask, target, target_mask.
        Returns:
            output matrix of probabilities of size (batch_size,max_seq_length,target_vocab_size).
        """

        encode = self._encode(data.src, data.src_mask)
        decode = self._decode(encode, data.src_mask, data.tgt, data.tgt_mask)

        y_hat = self._final_softmax(self._final_linear(decode))

        return y_hat

        Main call of transformer model. Pass through encoder-decoder architecture.

        Args:
            data(TransformerBatch):
                Class of batch data containing source, source_mask, target, target_mask.
        Returns:
            output matrix of probabilities of size (batch_size,max_seq_length,target_vocab_size).
        
Main call of transformer model. Pass through encoder-decoder architecture.
Main call of transformer model . Pass through encoder - decoder architecture .
def forward(self, data: TransformerBatch) -> torch.Tensor:
        encode = self._encode(data.src, data.src_mask)
        decode = self._decode(encode, data.src_mask, data.tgt, data.tgt_mask)
        y_hat = self._final_softmax(self._final_linear(decode))
        return y_hat
def forward ( self , data : TransformerBatch ) -> torch . Tensor : encode = self . _encode ( data . src , data . src_mask ) decode = self . _decode ( encode , data . src_mask , data . tgt , data . tgt_mask ) y_hat = self . _final_softmax ( self . _final_linear ( decode ) ) return y_hat
Main call of transformer model.
Main call of transformer model .
"""
        Main call of transformer model. Pass through encoder-decoder architecture.

        Args:
            data(TransformerBatch):
                Class of batch data containing source, source_mask, target, target_mask.
        Returns:
            output matrix of probabilities of size (batch_size,max_seq_length,target_vocab_size).
        """
output matrix of probabilities of size (batch_size,max_seq_length,target_vocab_size).
output matrix of probabilities of size ( batch_size max_seq_length target_vocab_size ) .
self
data
TransformerBatch
Class of batch data containing source, source_mask, target, target_mask.
Class of batch data containing source source_mask target target_mask .