tensorflow / tensorflow/probability
joint_distribution._DefaultJointBijector is broken in nightly
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
The following code will work with tfp 0.10.0 but breaks in the nightly because of the DefaultJointBijector having multiple bugs. What won't show up in this example but is also suspect is it seems to move along batch dimension rather than event dimension in the _evaluate_bijector function in joint_distribution.py
import numpy as np
import tensorflow_probability as tfp
import tensorflow as tf
tfd=tfp.distributions
weights=np.random.multivariate_normal(np.arange(1,3),np.diag([4.0,6.0]),3)
design_matrix=np.random.normal(4,2,(3,200,2))
tseries = np.einsum('ij,ikj->ik',weights,design_matrix)
Root = tfd.JointDistributionCoroutine.Root
def joint_model():
yield Root(tfd.Exponential(1.0))
yield Root(tfd.Exponential(1.0))
model=tfp.sts.Sum([tfp.sts.LinearRegression(design_matrix=design_matrix.astype(np.float32),weights_prior=tfd.Blockwise(tfd.JointDistributionCoroutine(joint_model)))],observed_time_series=tseries.astype(np.float32))
variational_posterior = tfp.sts.build_factored_surrogate_posterior(model)
optimizer = tf.optimizers.Adam(learning_rate=0.1)
loss_curve=tfp.vi.fit_surrogate_posterior(target_log_prob_fn=model.joint_log_prob(observed_time_series=tseries.astype(np.float32)),
surrogate_posterior=variational_posterior,optimizer=optimizer,num_steps=500)
AttributeError: 'tuple' object has no attribute 'dtype'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied example against the nightly version and inspect _DefaultJointBijector and _evaluate_bijector in joint_distribution.py. Trace the tuple dtype failure and verify whether _evaluate_bijector is moving along the batch dimension instead of the event dimension; done means the example no longer raises the reported AttributeError and the dimension behavior is corrected.
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
- 35/100