コード例 #1
0
 def _log_prob(self, counts):
     counts = self._maybe_assert_valid_sample(counts)
     concentration = tf.convert_to_tensor(self.concentration)
     ordered_prob = (tf.math.lbeta(concentration + counts) -
                     tf.math.lbeta(concentration))
     return ordered_prob + tfp_math.log_combinations(
         self.total_count, counts)
コード例 #2
0
 def _log_prob(self, counts):
     with tf.control_dependencies(self._maybe_assert_valid_sample(counts)):
         log_p = (tf.math.log(self._probs) if self._logits is None else
                  tf.math.log_softmax(self._logits))
         k = tf.convert_to_tensor(self.total_count)
         return (tf.reduce_sum(counts * log_p, axis=-1) +  # log_unnorm_prob
                 tfp_math.log_combinations(k, counts))  # -log_normalization
コード例 #3
0
 def _log_prob(self, counts):
     log_p = (tf.math.log(self._probs) if self._logits is None else
              tf.math.log_softmax(self._logits))
     log_unnorm_prob = tf.reduce_sum(tf.math.multiply_no_nan(log_p, counts),
                                     axis=-1)
     neg_log_normalizer = tfp_math.log_combinations(self.total_count,
                                                    counts)
     return log_unnorm_prob + neg_log_normalizer
コード例 #4
0
 def _log_prob(self, counts):
   log_p = (
       tf.math.log(self._probs)
       if self._logits is None else tf.math.log_softmax(self._logits))
   return (
       tf.reduce_sum(counts * log_p, axis=-1) +        # log_unnorm_prob
       tfp_math.log_combinations(
           self.total_count, counts))  # -log_normalization