(max_length)
return torch_mask.unsqueeze(0).unsqueeze(1)
Generates bias values (-Inf) to mask future timesteps during attention
Generates bias values (-Inf) to mask future timesteps during attention
Generates bias values ( - Inf ) to mask future timesteps during attention
def _gen_bias_mask(max_length):
    """
    Generates bias values (-Inf) to mask future timesteps during attention
    """
    np_mask = np.triu(np.full([max_length, max_length], -np.inf), 1)
    torch_mask = torch.from_numpy(np_mask).type(torch.FloatTensor)
    
    return torch_mask.unsqueeze(0).unsqueeze(1)
def _gen_bias_mask ( max_length ) : np_mask = np . triu ( np . full ( [ max_length , max_length ] , - np . inf ) , 1 ) torch_mask = torch . from_numpy ( np_mask ) . type ( torch . FloatTensor ) return torch_mask . unsqueeze ( 0 ) . unsqueeze ( 1 )