6bf3f51cd0a312da842157665663c2dad9983248,tensorflow_ranking/python/losses_impl.py,ClickEMLoss,_compute_latent_prob,#ClickEMLoss#Any#Any#Any#,914

Before Change


      P(examination | click) and P(relevance | click).
    
    with tf.compat.v1.name_scope(name="compute_latent_prob"):
      exam_prob = tf.math.sigmoid(tf.cast(exam_logits, tf.float32))
      rel_prob = tf.math.sigmoid(tf.cast(rel_logits, tf.float32))
      is_clicked = tf.greater_equal(tf.cast(clicks, tf.float32), 1.0)

      prob_non_clicks = 1 - exam_prob * rel_prob + 1e-6
      exam_prob_given_non_clicks = exam_prob * (1 - rel_prob) / prob_non_clicks
      rel_prob_given_non_clicks = (1 - exam_prob) * rel_prob / prob_non_clicks

      exam_prob_given_non_clicks, rel_prob_given_non_clicks = [
          tf.stop_gradient(
              tf.compat.v1.where(is_clicked, tf.ones_like(prob), prob))
          for prob in [exam_prob_given_non_clicks, rel_prob_given_non_clicks]
      ]
      return exam_prob_given_non_clicks, rel_prob_given_non_clicks

  def compute_unreduced_loss(self, labels, logits):
    Computes the loss for each element.

After Change


      rel_prob_posterior = tf.compat.v1.where(
          is_clicked, tf.ones_like(rel_logits_posterior),
          tf.sigmoid(rel_logits_posterior))
      return tf.stop_gradient(exam_prob_posterior), tf.stop_gradient(
          rel_prob_posterior)

  def compute_unreduced_loss(self, labels, logits):
    Computes the loss for each element.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: tensorflow/ranking
Commit Name: 6bf3f51cd0a312da842157665663c2dad9983248
Time: 2021-01-29
Author: xuanhui@google.com
File Name: tensorflow_ranking/python/losses_impl.py
Class Name: ClickEMLoss
Method Name: _compute_latent_prob


Project Name: reinforceio/tensorforce
Commit Name: f2328f664ba2ad19868d6e0eaff08721d96c506b
Time: 2018-01-27
Author: aok25@cl.cam.ac.uk
File Name: tensorforce/models/pg_model.py
Class Name: PGModel
Method Name: tf_reward_estimation


Project Name: MorvanZhou/tutorials
Commit Name: f1632a7d8a1c95f8a1b37c9b08d948f1adc7af92
Time: 2017-04-11
Author: morvanzhou@gmail.com
File Name: Reinforcement_learning_TUT/experiments/Solve_BipedalWalker/A3C.py
Class Name: ACNet
Method Name: _build_net