RxInfer.jl
RxInfer.jl copied to clipboard
Initialization macro lacks features compared to model macro
There are differences between the @initialization macro and the @model macro, which might be confusing for users. An example:
@model function model()
x ~ NormalMeanPrecision(0.0, 1.0) # allowed
x ~ Normal(mean = 0.0, precision = 1.0) # allowed
end
@initialization begin
q(x) = Normal(mean = 0.0, precision = 1.0) # not allowed
q(x) = NormalMeanPrecision(0.0, 1.0) # allowed
end
Would be nice if we can streamline this.
The issue here is that the code that transforms Normal(mean = 0.0, precision = 1.0) to NormalMeanPrecision(0.0, 1.0) lives in GraphPPL.jl. But the @initialization macro is not part of GraphPPL, but RxInfer. The proper fix would be to move this code maybe to BayesBase.jl and let both GraphPPL and RxInfer reuse it.
Don't you think we can do a similar thing to GraphPPL where we can use the GraphPPLs default_parametrization and factor_alias in RxInfer as well to transform this code? I don't see why if RxInfer depends on GraphPPL why we wouldn't reuse this function. The actual transformation is something that happens in RxInfer anyway:
https://github.com/ReactiveBayes/RxInfer.jl/blob/e8b1215e68451baa7bfad55c541a61354eba916e/src/model/graphppl.jl#L240
Hm, I think you're right @wouterwln