Skip to content
Discussion options

You must be logged in to vote

Hi @sheensu

I am not totally sure, but it looks like the error might come from a shape mismatch between what PyMC passes into the MNLE potential and what MNLE expects. PyMC seems to send a 1-D (8,) float64 array, while MNLE usuaaly expects a batched float32 tensor like (1, 8).

I had a similar issue before, and adding a small reshape helped:

def lp_f(x, track_gradients=True):
    with torch.set_grad_enabled(track_gradients):
        x = torch.tensor(x, dtype=torch.float32)
        if x.ndim == 1:
            x = x.unsqueeze(0)
        return potential_fn(x)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sheensu
Comment options

Answer selected by sheensu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants