Skip to content

Commit

Permalink
PREVENT 1D DISTRIBUTION (#633)
Browse files Browse the repository at this point in the history
* PREVENT 1D DISTRIBUTION

* PREVENT 1D DISTRIBUTION
  • Loading branch information
reubenharry authored Dec 27, 2023
1 parent 70b8ae6 commit 2c1d779
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blackjax/mcmc/mclmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from blackjax.base import SamplingAlgorithm
from blackjax.mcmc.integrators import IntegratorState, isokinetic_mclachlan
from blackjax.types import ArrayLike, PRNGKey
from blackjax.util import generate_unit_vector
from blackjax.util import generate_unit_vector, pytree_size

__all__ = ["MCLMCInfo", "init", "build_kernel", "mclmc"]

Expand All @@ -45,6 +45,10 @@ class MCLMCInfo(NamedTuple):


def init(position: ArrayLike, logdensity_fn, rng_key):
if pytree_size(position) < 2:
raise ValueError(
"The target distribution must have more than 1 dimension for MCLMC."
)
l, g = jax.value_and_grad(logdensity_fn)(position)

return IntegratorState(
Expand Down

0 comments on commit 2c1d779

Please sign in to comment.