(x, x_mask)
return alpha
Return uniform weights over non-masked input.
Return uniform weights over non-masked input.
Return uniform weights over non - masked input .
def uniform_weights(x, x_mask):
    """Return uniform weights over non-masked input."""
    alpha = Variable(torch.ones(x.size(0), x.size(1)))
    if x.data.is_cuda:
        alpha = alpha.cuda()
    alpha = alpha * x_mask.eq(0).float()
    alpha = alpha / alpha.sum(1, keepdim=True).expand(alpha.size())
    return alpha
def uniform_weights ( x , x_mask ) : alpha = Variable ( torch . ones ( x . size ( 0 ) , x . size ( 1 ) ) ) if x . data . is_cuda : alpha = alpha . cuda ( ) alpha = alpha * x_mask . eq ( 0 ) . float ( ) alpha = alpha / alpha . sum ( 1 , keepdim = True ) . expand ( alpha . size ( ) ) return alpha