tensorflow / tensorflow/probability

Issue when calling log_prob attribute in a logistic mixture distribution instance

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

Hey,

I have the following issue when using this particular instance of mixture same family distribution. Here is a snipper of my code:

`mean, scale, logits = self.decode(z)

  discretized_logistic_dist = tfd.QuantizedDistribution(
    distribution=tfd.TransformedDistribution(
        distribution=tfd.Logistic(loc=mean, scale=scale),
        bijector=tfb.Shift(shift=-0.5)),
    low=0.,
    high=2**16 - 1.)

  logistic_dist = tfd.Logistic(loc=mean, scale=scale)


  mixture_dist = tfd.MixtureSameFamily(
  mixture_distribution=tfd.Categorical(logits=logits),
  components_distribution=logistic_dist)

  ll = -tf.reduce_sum(mixture_dist.log_prob(x), axis=[1,2,3])`

I am basically using a VAE to learn the parameters of a logistic mixture family. The issue if the following:

when calling mixture_dist.log_prob(x) on my input data, in this case cifar10, for some odd reason the input is being reshaped into (x.shape, 1) basically performing tf.expand_dims on x at least assuming that is the case. Thus, an error of invalid dimensions is thrown at me

Dimensions must be equal, but are 32 and 256 for '{{node MixtureSameFamily_1/log_prob/Logistic_1/log_prob/sub}} = Sub[T=DT_FLOAT](MixtureSameFamily_1/log_prob/pad_sample_dims/Reshape, split_1)' with input shapes: [256,32,32,3,1], [256,32,32,15].

I have tried several hacks using tf.squeeze and converting the log_prob instance into a function prior to applying x in i, but to no result.

Could you please assist with the issue.

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

The report provides no repository file or test. Start by reproducing the shown TensorFlow Probability MixtureSameFamily.log_prob call with CIFAR10-shaped input and inspect the reported pad_sample_dims/Reshape operation. Done means the dimensionality behavior is isolated and covered by an appropriate regression test or clarified usage guidance.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.