(probs=None, logits=None, dtype=tf.int32,
                     sample_shape=(), seed=None)
return _call_sampler(_sample_n, sample_shape)
Samples from Bernoulli distribution.
Samples from Bernoulli distribution.
Samples from Bernoulli distribution .
def bernoulli_sample(probs=None, logits=None, dtype=tf.int32,
                     sample_shape=(), seed=None):
  """Samples from Bernoulli distribution."""
  if probs is None:
    probs = tf.sigmoid(logits, name="probs")
  else:
    probs = tf.convert_to_tensor(probs, name="probs")
  batch_shape_tensor = tf.shape(probs)
  def _sample_n(n):
    """Sample vector of Bernoullis."""
    new_shape = tf.concat([[n], batch_shape_tensor], 0)
    uniform = tf.random_uniform(
        new_shape, seed=seed, dtype=probs.dtype)
    return tf.cast(tf.less(uniform, probs), dtype)
  return _call_sampler(_sample_n, sample_shape)
def bernoulli_sample ( probs = None , logits = None , dtype = tf . int32 , sample_shape = ( ) , seed = None ) : if probs is None : probs = tf . sigmoid ( logits , name = "probs" ) else : probs = tf . convert_to_tensor ( probs , name = "probs" ) batch_shape_tensor = tf . shape ( probs ) def _sample_n ( n ) : """Sample vector of Bernoullis.""" new_shape = tf . concat ( [ [ n ] , batch_shape_tensor ] , 0 ) uniform = tf . random_uniform ( new_shape , seed = seed , dtype = probs . dtype ) return tf . cast ( tf . less ( uniform , probs ) , dtype ) return _call_sampler ( _sample_n , sample_shape )