(sample_n_fn, sample_shape, name=None)
Reshapes vector of samples.
Reshapes vector of samples.
Reshapes vector of samples .
def _call_sampler(sample_n_fn, sample_shape, name=None):
  """Reshapes vector of samples."""
  with tf.name_scope(name, "call_sampler", values=[sample_shape]):
    sample_shape = tf.convert_to_tensor(
        sample_shape, dtype=tf.int32, name="sample_shape")
    # Ensure sample_shape is a vector (vs just a scalar).
    pad = tf.cast(tf.equal(tf.rank(sample_shape), 0), tf.int32)
    sample_shape = tf.reshape(
        sample_shape,
        tf.pad(tf.shape(sample_shape),
               paddings=[[pad, 0]],
               constant_values=1))
    samples = sample_n_fn(tf.reduce_prod(sample_shape))
    batch_event_shape = tf.shape(samples)[1:]
    final_shape = tf.concat([sample_shape, batch_event_shape], 0)
    return tf.reshape(samples, final_shape)
def _call_sampler ( sample_n_fn , sample_shape , name = None ) : with tf . name_scope ( name , "call_sampler" , values = [ sample_shape ] ) : sample_shape = tf . convert_to_tensor ( sample_shape , dtype = tf . int32 , name = "sample_shape" ) # Ensure sample_shape is a vector (vs just a scalar). pad = tf . cast ( tf . equal ( tf . rank ( sample_shape ) , 0 ) , tf . int32 ) sample_shape = tf . reshape ( sample_shape , tf . pad ( tf . shape ( sample_shape ) , paddings = [ [ pad , 0 ] ] , constant_values = 1 ) ) samples = sample_n_fn ( tf . reduce_prod ( sample_shape ) ) batch_event_shape = tf . shape ( samples ) [ 1 : ] final_shape = tf . concat ( [ sample_shape , batch_event_shape ] , 0 ) return tf . reshape ( samples , final_shape )