def dirichlet_likelihood(weights, alpha=None):
 if (type(weights) is Variable):
  n_topics = weights.data.shape[1]
 else:
  n_topics = weights.W.data.shape[1]
 if (alpha is None):
  alpha = (1.0 / n_topics)
 if (type(weights) is Variable):
  log_proportions = F.log_softmax(weights)
 else:
  log_proportions = F.log_softmax(weights.W)
 loss = ((alpha - 1.0) * log_proportions)
 return (- F.sum(loss))

def dirichlet_likelihood ( weights , alpha = None ) : if ( type ( weights ) is Variable ) : n_topics = weights . data . shape [ 1 ] else : n_topics = weights . W . data . shape [ 1 ] if ( alpha is None ) : alpha = ( 1.0 / n_topics ) if ( type ( weights ) is Variable ) : log_proportions = F . log_softmax ( weights ) else : log_proportions = F . log_softmax ( weights . W ) loss = ( ( alpha - 1.0 ) * log_proportions ) return ( - F . sum ( loss ) )
calculate the log likelihood of the observed topic proportions .