|TensorFlow 1 version||View source on GitHub|
shape samples from each of the given Gamma distribution(s).
Compat aliases for migration
See Migration guide for more details.
tf.random.gamma( shape, alpha, beta=None, dtype=tf.dtypes.float32, seed=None, name=None )
alpha is the shape parameter describing the distribution(s), and
the inverse scale parameter(s).
The samples are differentiable w.r.t. alpha and beta. The derivatives are computed using the approach described in (Figurnov et al., 2018).
samples = tf.random.gamma(, [0.5, 1.5]) # samples has shape [10, 2], where each slice [:, 0] and [:, 1] represents # the samples drawn from each distribution samples = tf.random.gamma([7, 5], [0.5, 1.5]) # samples has shape [7, 5, 2], where each slice [:, :, 0] and [:, :, 1] # represents the 7x5 samples drawn from each of the two distributions alpha = tf.constant([[1.],[3.],[5.]]) beta = tf.constant([[3., 4.]]) samples = tf.random.gamma(, alpha=alpha, beta=beta) # samples has shape [30, 3, 2], with 30 samples each of 3x2 distributions. loss = tf.reduce_mean(tf.square(samples)) dloss_dalpha, dloss_dbeta = tf.gradients(loss, [alpha, beta]) # unbiased stochastic derivatives of the l