-
|
I'm struggling with writing linearization for nodes; consider this simple model using RxInfer
@model function example2(y)
x1 ~ NormalMeanPrecision(0.4, 1)
x2 ~ NormalMeanPrecision(0.7, 10)
diff := x1 - x2
y := abs(diff)
end
@meta function abs_meta()
abs(diff) -> Linearization()
end
# Inference
result2 = infer(
model = example2(),
data=(y=0.5,),
iterations = 20,
meta = abs_meta()
)This causes the julia interpreter to briefly emit a warning, then loop forever. What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hey @meditans , thanks for trying out using RxInfer
@model function example2(y)
x1 ~ NormalMeanPrecision(0.4, 1)
x2 ~ NormalMeanPrecision(0.7, 10)
diff := x1 - x2
y ~ NormalMeanVariance(abs(diff), 1e-6)
end
@meta function abs_meta()
abs() -> Linearization() # NOTE I also made a change here!
end
# Inference
result2 = infer(
model = example2(),
data=(y=0.5,),
iterations = 1, # Your model does not contain loops and you do regular sum-product BP, so it will converge in 1 iteration
meta = abs_meta()
)This gives me an inference result. Hoping this solves your problem! |
Beta Was this translation helpful? Give feedback.
Hey @meditans , thanks for trying out
RxInfer! For me, when I run your code, it does not emit a warning and then loop forever, but an error in the inference procedure is being thrown. This is because theLinearizationonly works withNormalin and outputs see docs Since you are passing data, this assumption is invalidated. A way to fix it is by wrappingyin aNormalwith very small variance, like so: