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

MethodError: no method matching length(::Variable) #161

Closed
quantumhub opened this issue Apr 22, 2021 · 2 comments
Closed

MethodError: no method matching length(::Variable) #161

quantumhub opened this issue Apr 22, 2021 · 2 comments
Assignees

Comments

@quantumhub
Copy link

Thanks for this great work which makes FG inference a lot easier!
In demo (ForneyLab.jl-master/demo/bayes_rule_2d.ipynb)
Slightly change of the calculation in factor graph makes it fail:

@rv y ~ GaussianMeanVariance(A*(x.^2) + b, Sigma_y) # Likelihood

The error message is:
MethodError: no method matching length(::Variable)

Could any one help? Thanks.

@albertpod
Copy link
Collaborator

albertpod commented Apr 22, 2021

Hi @quantumhub! Thanks for trying out ForneyLab.

Unfortunately, Variable type doesn't support broadcasting.
If you want to apply a quadratic function to a multivariate Gaussian random variable you can (1) use a Nonlinear node (see demo/variational_laplace_and_sampling.ipynb), (2) define your own node or Composite node and provide the required update rules for it (see demo/composite_nodes.ipynb).

It will be useful if you provide the entire snippet where you specify your model.

@quantumhub
Copy link
Author

Thank you for this answer! The nonlinear function in demo/variational_laplace_and_sampling.ipynb is very helpful for my application!

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

4 participants