tensorflow / tensorflow/probability

Feature request: 2-D weights option for log prob

Open
#1,562 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I am working on a VAE with a Gaussian decoder using tensorflow probability. I calculate the log likelihood using x_hat.log_prob(x) where x_hat is the output of the decoder (tfp.distributions.Distribution). However, in my application it is important to apply weights to the values from the log_prob summation using a weights tensor of floats whose shape matches x_true i.e weights.shape=(batch_size, features). So this weights tensor will apply a different weight to each feature of each sample.

Essentially I want to do what is being done in the MSE example below:

MSE = tf.reduce_sum(0.5 * weights * (x - recon_x)**2)

where x, recon_x and weights all have shape (batch_size, features).

I tried looking for a way to get the log_prob before the summation so that I can apply the weights and then sum but I couldn’t find something relevant in the documentation.

Is there another way to go about doing this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the TensorFlow Probability Distribution.log_prob documentation and the behavior of x_hat.log_prob(x) for batched feature inputs. Determine how per-feature log probabilities and a weights tensor shaped like x_true could be supported, then verify that weighted values can be summed per sample as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
tensorflow
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.