tensorflow / tensorflow/probability

tfp.distributions.RelaxedBernoulli produces samples on the boundary with inf log_prob

Open
#1,738 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

When using relaxed_bernouli to sample on boundary, it outputs inf or NaN log_prob.

import tensorflow as tf
import tensorflow_probability as tfp
tf.random.set_seed(2)
dist = tfp.distributions.RelaxedBernoulli(temperature = tf.constant(0.005), logits = tf.constant(-5.0))
sample = dist.sample()
print('Sample: {}'.format(sample))  # should be non-zero value
print('Log prob: {}'.format(dist.log_prob(sample).numpy()))  # should be non-inf value


dist = tfp.distributions.RelaxedBernoulli(temperature = tf.constant(0.0), logits = tf.constant(-5.0))
sample = dist.sample()
print('Sample: {}'.format(sample))  # should be non-nan value
print('Log prob: {}'.format(dist.log_prob(sample).numpy()))  # should be non-nan value

Outputs:

Sample: 0.0
Log prob: inf
Sample: nan
Log prob: nan

Expected Outputs:

Sample: normal value but not not 0.0
Log prob: normal value not not inf
Sample: something not nan
Log prob: something not nan

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 supplied RelaxedBernoulli reproduction with temperatures 0.005 and 0.0, then inspect the RelaxedBernoulli sampling and log_prob implementation. Determine how boundary or non-finite samples arise and verify that both examples produce finite, non-NaN samples and log probabilities.

Written by the indexing model from the issue text.

Assessment

Tech stack
tensorflow
Domain
machine-learning
Issue type
Bug
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.