tensorflow / tensorflow/probability

variational_posteriors.log_prob error for run_smc_ in SMC Demo file

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

Hello, I ran SMC Demo and when I ran "run_smc_()", the error below occured

"""
94
95 def _tempered_target_log_prob(*args):
--> 96 priorlogprob = tf.identity(prior_log_prob_fn(*args),
97 name='prior_log_prob')
98 loglike = tf.identity(likelihood_log_prob_fn(*args),

TypeError: in user code:

File "<ipython-input-61-86b08bf263c9>", line 3, in run_smc_  *
    (
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/experimental/mcmc/sample_sequential_monte_carlo.py", line 387, in sample_sequential_monte_carlo  **
    pkr = kernel.bootstrap_results(current_state)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/transformed_kernel.py", line 493, in bootstrap_results
    transformed_init_state))
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/hmc.py", line 561, in bootstrap_results
    kernel_results = self._impl.bootstrap_results(init_state)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/metropolis_hastings.py", line 273, in bootstrap_results
    pkr = self.inner_kernel.bootstrap_results(init_state)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/hmc.py", line 775, in bootstrap_results
    ] = mcmc_util.maybe_call_fn_and_grads(self.target_log_prob_fn, init_state)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/internal/util.py", line 297, in maybe_call_fn_and_grads
    result, grads = _value_and_gradients(fn, fn_arg_list, result, grads)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/internal/util.py", line 265, in _value_and_gradients
    return tfp_math_value_and_gradients(fn, fn_arg_list)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/math/gradient.py", line 117, in value_and_gradient
    **kwargs)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/math/gradient.py", line 380, in _value_and_grad_impl
    output_gradients)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/math/gradient.py", line 330, in _gradient_old
    y, aux = f()
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/math/gradient.py", line 378, in <lambda>
    y, dydx, aux = grad_fn(lambda: f(*args, **kwargs) if _has_args(f) else f(),
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/math/gradient.py", line 376, in <lambda>
    if _has_args(real_f) else real_f(), ())
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/mcmc/transformed_kernel.py", line 123, in transformed_log_prob_fn
    tlp = log_prob_fn(*fn(state_parts))
File "/usr/local/lib/python3.7/dist-packages/tensorflow_probability/python/experimental/mcmc/sample_sequential_monte_carlo.py", line 96, in _tempered_target_log_prob
    priorlogprob = tf.identity(prior_log_prob_fn(*args),

TypeError: log_prob() takes from 2 to 3 positional arguments but 5 were given

"""

Any ideas about the error and how to fix it?

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

Reproduce the failure in the linked SMC Demo notebook by running run_smc_(). Start with tensorflow_probability/python/experimental/mcmc/sample_sequential_monte_carlo.py at _tempered_target_log_prob and trace the prior_log_prob_fn call; done means the demo no longer raises the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, tensorflow
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.