(shape=[1], p=0.5, dtype='float32')
return tf.where(tf.less(dist, tf.fill(shape, p)),
                    tf.ones(shape, dtype=dtype),
                    tf.zeros(shape, dtype=dtype))
Generate a binomial distribution.

    Parameters
    ----------
    shape : list
        Shape of binomial distribution.
    p : float
        Probability level for dropping an element.

    Returns
    -------
    Tensor
        Binomial distribution.
Generate a binomial distribution.
Generate a binomial distribution .
def binomial(shape=[1], p=0.5, dtype='float32'):
    """Generate a binomial distribution.

    Parameters
    ----------
    shape : list
        Shape of binomial distribution.
    p : float
        Probability level for dropping an element.

    Returns
    -------
    Tensor
        Binomial distribution.
    """
    dist = tf.random_uniform(shape=shape, minval=0, maxval=1, dtype='float32')
    return tf.where(tf.less(dist, tf.fill(shape, p)),
                    tf.ones(shape, dtype=dtype),
                    tf.zeros(shape, dtype=dtype))
def binomial ( shape = [ 1 ] , p = 0.5 , dtype = 'float32' ) : dist = tf . random_uniform ( shape = shape , minval = 0 , maxval = 1 , dtype = 'float32' ) return tf . where ( tf . less ( dist , tf . fill ( shape , p ) ) , tf . ones ( shape , dtype = dtype ) , tf . zeros ( shape , dtype = dtype ) )