Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if 3d model #42

Open
haohaiziround opened this issue Jan 26, 2018 · 1 comment
Open

if 3d model #42

haohaiziround opened this issue Jan 26, 2018 · 1 comment
Assignees

Comments

@haohaiziround
Copy link
Collaborator

haohaiziround commented Jan 26, 2018

if 3d model has something wrong for computing grad_logp(logp,x[key]) in line 159 of dhmc alg.

Error as following:

RuntimeError: mul() received an invalid combination of arguments - got (NoneType), but expected one of:
 * (float other)
      didn't match because some of the arguments have invalid types: (!NoneType!)
 * (Variable other)
      didn't match because some of the arguments have invalid types: (!NoneType!)
@haohaiziround haohaiziround changed the title if 2d model if 3d model Jan 26, 2018
@haohaiziround
Copy link
Collaborator Author

haohaiziround commented Jan 26, 2018

The model is as following:

x1 ~ N(0, 1)
if x1 > 0:
    x2 ~ N(0, 1)
    observe(N(x2, 1) y)
else:
    x3 ~ N(0, 1)
    observe(N(x3, 1) y)

We have two ways to write the model.
One is

(let [x1 (sample (normal 0 1))
      x2 (sample (normal 0 1))
      x3 (sample (normal 0 1))
      y 1]
  (if (> x1 0)
    (observe (normal x2 1) y)
    (observe (normal x3 1) y))
  (vector x1 x2 x3))

and the other is

(let [x1 (sample (normal 0 1))
      y 10]
  (if (> x1 0)
    (let [x2 (sample (normal 0 1))]
      (observe (normal x2 2) y))
    (let [x3 (sample (normal 0 1))]
      (observe (normal x3 2) y)))
  x1)

The top one is running fine but the bottom one has some issue as mentioned earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants