'Binarizes input array
Arguments:
ary: tensor
out: reference to output
stochastic: stochastic or deterministic'

def binarize(self, ary, out, stochastic=True):

    if stochastic:
        out[:] = ((ary + 1) / 2.0)
        self.clip(out, 0, 1, out)
        prob = self.array(np.random.uniform(0, 1, size=ary.shape))
        self.less_equal(prob, out, out)
    else:
        self.greater_equal(ary, 0, out)
    out[:] = ((2 * out) - 1)
    return out
