tensorflow / tensorflow/probability

Inconsistent behavior with log_prob on transformed distributions

Open
#430 0 comments 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

The same input in a transformed log_prob will raise an exception, or provide the correct value, depending on the sequence of execution.

Talking with @brianwa84 the jacobian in the bijector might be expecting the wrong data type, if I understood correctly.

Below is the example that him and I talked about in person

dist =  distributions.Bernoulli(probs=.5, dtype=tf.int32)

_bijector = bijectors.Identity()
transformed_dist = distributions.TransformedDistribution(
            distribution=dist, bijector=bijectors.Invert(_bijector)
        )

To reproduce run the above code interactively, then run each line below in sequence.

log_prob(int) will raise an exception until

transformed_dist.log_prob(1)

log_prob(float) is executed

transformed_dist.log_prob(.5)

Then log_prob(int) will provide the correct value

transformed_dist.log_prob(1)

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 running the provided Bernoulli, Identity, Invert, and TransformedDistribution example interactively, then compare the three log_prob calls in sequence. Investigate the transformed-distribution or bijector Jacobian path for the dtype-dependent behavior; done means integer log_prob behaves consistently regardless of whether the float call ran first.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.