class_docstr: Dirichlet distribution.
  
  The Dirichlet distribution is defined over the
  [`(k-1)`-simplex](https://en.wikipedia.org/wiki/Simplex) using a positive,
  length-`k` vector `concentration` (`k > 1`). The Dirichlet is identically the
  Beta distribution when `k = 2`.
  
  #### Mathematical Details
  
  The Dirichlet is a distribution over the open `(k-1)`-simplex, i.e.,
  
  ```none
  S^{k-1} = { (x_0, ..., x_{k-1}) in R^k : sum_j x_j = 1 and all_j x_j > 0 }.
  ```
  
  The probability density function (pdf) is,
  
  ```none
  pdf(x; alpha) = prod_j x_j**(alpha_j - 1) / Z
  Z = prod_j Gamma(alpha_j) / Gamma(sum_j alpha_j)
  ```
  
  where:
  
  * `x in S^{k-1}`, i.e., the `(k-1)`-simplex,
  * `concentration = alpha = [alpha_0, ..., alpha_{k-1}]`, `alpha_j > 0`,
  * `Z` is the normalization constant aka the [multivariate beta function](
    https://en.wikipedia.org/wiki/Beta_function#Multivariate_beta_function),
    and,
  * `Gamma` is the [gamma function](
    https://en.wikipedia.org/wiki/Gamma_function).
  
  The `concentration` represents mean total counts of class occurrence, i.e.,
  
  ```none
  concentration = alpha = mean * total_concentration
  ```
  
  where `mean` in `S^{k-1}` and `total_concentration` is a positive real number
  representing a mean total count.
  
  Distribution parameters are automatically broadcast in all functions; see
  examples for details.
  
  Warning: Some components of the samples can be zero due to finite precision.
  This happens more often when some of the concentrations are very small.
  Make sure to round the samples to `np.finfo(dtype).tiny` before computing the
  density.
  
  Samples of this distribution are reparameterized (pathwise differentiable).
  The derivatives are computed using the approach described in
  (Figurnov et al., 2018).
  
  #### Examples
  
  ```python
  import tensorflow_probability as tfp
  tfd = tfp.distributions
  
  # Create a single trivariate Dirichlet, with the 3rd class being three times
  # more frequent than the first. I.e., batch_shape=[], event_shape=[3].
  alpha = [1., 2, 3]
  dist = tfd.Dirichlet(alpha)
  
  dist.sample([4, 5])  # shape: [4, 5, 3]
  
  # x has one sample, one batch, three classes:
  x = [.2, .3, .5]   # shape: [3]
  dist.prob(x)       # shape: []
  
  # x has two samples from one batch:
  x = [[.1, .4, .5],
       [.2, .3, .5]]
  dist.prob(x)         # shape: [2]
  
  # alpha will be broadcast to shape [5, 7, 3] to match x.
  x = [[...]]   # shape: [5, 7, 3]
  dist.prob(x)  # shape: [5, 7]
  ```
  
  ```python
  # Create batch_shape=[2], event_shape=[3]:
  alpha = [[1., 2, 3],
           [4, 5, 6]]   # shape: [2, 3]
  dist = tfd.Dirichlet(alpha)
  
  dist.sample([4, 5])  # shape: [4, 5, 2, 3]
  
  x = [.2, .3, .5]
  # x will be broadcast as [[.2, .3, .5],
  #                         [.2, .3, .5]],
  # thus matching batch_shape [2, 3].
  dist.prob(x)         # shape: [2]
  ```
  
  Compute the gradients of samples w.r.t. the parameters:
  
  ```python
  alpha = tf.constant([1.0, 2.0, 3.0])
  dist = tfd.Dirichlet(alpha)
  samples = dist.sample(5)  # Shape [5, 3]
  loss = tf.reduce_mean(tf.square(samples))  # Arbitrary loss function
  # Unbiased stochastic gradients of the loss function
  grads = tf.gradients(loss, alpha)
  ```
  
  References:
    Implicit Reparameterization Gradients:
      [Figurnov et al., 2018]
      (http://papers.nips.cc/paper/7326-implicit-reparameterization-gradients)
      ([pdf]
      (http://papers.nips.cc/paper/7326-implicit-reparameterization-gradients.pdf))
class_docstr_tok: ["Dirichlet","distribution",".","The","Dirichlet","distribution","is","defined","over","the","[","`","(","k-1",")","`","-simplex","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Simplex",")","using","a","positive",",","length-","`","k","`","vector","`","concentration","`","(","`","k",">","1","`",")",".","The","Dirichlet","is","identically","the","Beta","distribution","when","`","k","=","2","`",".","#","#","#","#","Mathematical","Details","The","Dirichlet","is","a","distribution","over","the","open","`","(","k-1",")","`","-simplex",",","i.e.",",","``","`","none","S^","{","k-1","}","=","{","(","x_0",",","...",",","x_","{","k-1","}",")","in","R^k",":","sum_j","x_j","=","1","and","all_j","x_j",">","0","}",".","``","`","The","probability","density","function","(","pdf",")","is",",","``","`","none","pdf","(","x",";","alpha",")","=","prod_j","x_j","*","*","(","alpha_j","-","1",")","\/","Z","Z","=","prod_j","Gamma","(","alpha_j",")","\/","Gamma","(","sum_j","alpha_j",")","``","`","where",":","*","`","x","in","S^","{","k-1","}","`",",","i.e.",",","the","`","(","k-1",")","`","-simplex",",","*","`","concentration","=","alpha","=","[","alpha_0",",","...",",","alpha_","{","k-1","}","]","`",",","`","alpha_j",">","0","`",",","*","`","Z","`","is","the","normalization","constant","aka","the","[","multivariate","beta","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Beta_function","#","Multivariate_beta_function",")",",","and",",","*","`","Gamma","`","is","the","[","gamma","function","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Gamma_function",")",".","The","`","concentration","`","represents","mean","total","counts","of","class","occurrence",",","i.e.",",","``","`","none","concentration","=","alpha","=","mean","*","total_concentration","``","`","where","`","mean","`","in","`","S^","{","k-1","}","`","and","`","total_concentration","`","is","a","positive","real","number","representing","a","mean","total","count",".","Distribution","parameters","are","automatically","broadcast","in","all","functions",";","see","examples","for","details",".","Warning",":","Some","components","of","the","samples","can","be","zero","due","to","finite","precision",".","This","happens","more","often","when","some","of","the","concentrations","are","very","small",".","Make","sure","to","round","the","samples","to","`","np.finfo","(","dtype",")",".tiny","`","before","computing","the","density",".","Samples","of","this","distribution","are","reparameterized","(","pathwise","differentiable",")",".","The","derivatives","are","computed","using","the","approach","described","in","(","Figurnov","et","al.",",","2018",")",".","#","#","#","#","Examples","``","`","python","import","tensorflow_probability","as","tfp","tfd","=","tfp.distributions","#","Create","a","single","trivariate","Dirichlet",",","with","the","3rd","class","being","three","times","#","more","frequent","than","the","first",".","I.e.",",","batch_shape=","[","]",",","event_shape=","[","3","]",".","alpha","=","[","1.",",","2",",","3","]","dist","=","tfd.Dirichlet","(","alpha",")","dist.sample","(","[","4",",","5","]",")","#","shape",":","[","4",",","5",",","3","]","#","x","has","one","sample",",","one","batch",",","three","classes",":","x","=","[",".2",",",".3",",",".5","]","#","shape",":","[","3","]","dist.prob","(","x",")","#","shape",":","[","]","#","x","has","two","samples","from","one","batch",":","x","=","[","[",".1",",",".4",",",".5","]",",","[",".2",",",".3",",",".5","]","]","dist.prob","(","x",")","#","shape",":","[","2","]","#","alpha","will","be","broadcast","to","shape","[","5",",","7",",","3","]","to","match","x.","x","=","[","[","...","]","]","#","shape",":","[","5",",","7",",","3","]","dist.prob","(","x",")","#","shape",":","[","5",",","7","]","``","`","``","`","python","#","Create","batch_shape=","[","2","]",",","event_shape=","[","3","]",":","alpha","=","[","[","1.",",","2",",","3","]",",","[","4",",","5",",","6","]","]","#","shape",":","[","2",",","3","]","dist","=","tfd.Dirichlet","(","alpha",")","dist.sample","(","[","4",",","5","]",")","#","shape",":","[","4",",","5",",","2",",","3","]","x","=","[",".2",",",".3",",",".5","]","#","x","will","be","broadcast","as","[","[",".2",",",".3",",",".5","]",",","#","[",".2",",",".3",",",".5","]","]",",","#","thus","matching","batch_shape","[","2",",","3","]",".","dist.prob","(","x",")","#","shape",":","[","2","]","``","`","Compute","the","gradients","of","samples","w.r.t",".","the","parameters",":","``","`","python","alpha","=","tf.constant","(","[","1.0",",","2.0",",","3.0","]",")","dist","=","tfd.Dirichlet","(","alpha",")","samples","=","dist.sample","(","5",")","#","Shape","[","5",",","3","]","loss","=","tf.reduce_mean","(","tf.square","(","samples",")",")","#","Arbitrary","loss","function","#","Unbiased","stochastic","gradients","of","the","loss","function","grads","=","tf.gradients","(","loss",",","alpha",")","``","`","References",":","Implicit","Reparameterization","Gradients",":","[","Figurnov","et","al.",",","2018","]","(","http",":","\/\/papers.nips.cc\/paper\/7326-implicit-reparameterization-gradients",")","(","[","pdf","]","(","http",":","\/\/papers.nips.cc\/paper\/7326-implicit-reparameterization-gradients.pdf",")",")"]
code: def _mean(self):
      return (
          self.concentration
          / self.total_concentration[..., array_ops.newaxis]
      )
  
imports: import numpy
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import check_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import special_math_ops
  from tensorflow.python.ops.distributions import distribution
  from tensorflow.python.ops.distributions import kullback_leibler
  from tensorflow.python.ops.distributions import util
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 14 for calling the Dirichlet obj's underlying member method code with example usage: obj._mean() and returns: unknown