Skip to content

Commit 2b8f879

Browse files
Flatten before transporting
1 parent 63d3117 commit 2b8f879

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

coupled_rejection_sampling/reflected_coupled_mh.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def step(key, x, y):
7171

7272

7373
def _transport_fn(x, y, x_prime):
74+
shape = x.shape
75+
flat_x = x.flatten()
76+
flat_y = y.flatten()
77+
flat_x_prime = x_prime.flatten()
78+
flat_out = _transport_flat_x(flat_x, flat_y, flat_x_prime)
79+
out = flat_out.reshape(shape)
80+
return out
81+
82+
83+
def _transport_flat_x(x, y, x_prime):
7484
r_curr = jnp.linalg.norm(y - x)
7585
e = jax.lax.select(r_curr < 1e-8, jnp.zeros_like(x), (y - x) / r_curr)
7686
x_diff = x_prime - x

0 commit comments

Comments
 (0)