nlpmodels/utils/elt/transformer_batch.py
def subsequent_mask(size: int) -> torch.Tensor:
        """
        Mask out subsequent positions. Used for target mask.

        Args:
            size (int): max_seq_length of each target sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length) size with masked values to ignore previous value.

        """
        # create lower right triangle of 1s in numpy 3D tensor
        subsequent_mask = np.triu(np.ones((1, size, size)), k=1).astype('uint8')
        # return as torch tensor
        return torch.from_numpy(subsequent_mask) == 0

        Mask out subsequent positions. Used for target mask.

        Args:
            size (int): max_seq_length of each target sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length) size with masked values to ignore previous value.

        
Mask out subsequent positions. Used for target mask.
Mask out subsequent positions . Used for target mask .
def subsequent_mask(size: int) -> torch.Tensor:
        subsequent_mask = np.triu(np.ones((1, size, size)), k=1).astype('uint8')
        return torch.from_numpy(subsequent_mask) == 0
def subsequent_mask ( size : int ) -> torch . Tensor : subsequent_mask = np . triu ( np . ones ( ( 1 , size , size ) ) , k = 1 ) . astype ( 'uint8' ) return torch . from_numpy ( subsequent_mask ) == 0
Mask out subsequent positions.
Mask out subsequent positions .
"""
        Mask out subsequent positions. Used for target mask.

        Args:
            size (int): max_seq_length of each target sequence.

        Returns:
            output matrix of size (batch_size,max_seq_length,max_seq_length) size with masked values to ignore previous value.

        """ # create lower right triangle of 1s in numpy 3D tensor # return as torch tensor
output matrix of size (batch_size,max_seq_length,max_seq_length) size with masked values to ignore previous value.
output matrix of size ( batch_size max_seq_length max_seq_length ) size with masked values to ignore previous value .
size
int
max_seq_length of each target sequence.
max_seq_length of each target sequence .