You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| 🔄 **Development of [ExponentialFamilyProjection.jl]()**| 🧠 **Automated inference with [ExponentialFamilyProjection.jl](https://github.com/reactivebayes/ExponentialFamilyProjection.jl)**| 🚀 **Robustness & Memory-efficiency**|
170
+
| 🔄 **Development of [ExponentialFamilyProjection.jl]()**✅| 🧠 **Automated inference with [ExponentialFamilyProjection.jl](https://github.com/reactivebayes/ExponentialFamilyProjection.jl)**| 🚀 **Robustness & Memory-efficiency**|
171
171
172
172
For a more granular view of our progress and ongoing tasks, check out our [project board](https://github.com/orgs/reactivebayes/projects/2/views/4) or join our 4-weekly [public meetings](https://dynalist.io/d/F4aA-Z2c8X-M1iWTn9hY_ndN).
Copy file name to clipboardExpand all lines: docs/src/manuals/customization/custom-node.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Welcome to the `RxInfer` documentation on creating custom factor graph nodes. In `RxInfer`, factor nodes represent functional relationships between variables, also known as factors. Together, these factors define your probabilistic model. Quite often these factors represent distributions, denoting how a certain parameter affects another. However, other factors are also possible, such as ones specifying linear or non-linear relationships. `RxInfer` already supports a lot of factor nodes, however, depending on the problem that you are trying to solve, you may need to create a custom node that better fits the specific requirements of your model. This tutorial will guide you through the process of defining a custom node in `RxInfer`, step by step. By the end of this tutorial, you will be able to create your own custom node and integrate it into your model.
4
4
5
+
In addition, read another section on a different way of running inference with custom stochastic nodes without explicit rule specification [here](@ref inference-undefinedrules).
6
+
5
7
---
6
8
7
9
To create a custom node in `RxInfer`, 4 steps are required:
Copy file name to clipboardExpand all lines: docs/src/manuals/getting-started.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -305,4 +305,4 @@ result.posteriors[:θ]
305
305
306
306
## Where to go next?
307
307
308
-
There are a set of [examples](@ref examples-overview) available in `RxInfer` repository that demonstrate the more advanced features of the package for various problems. Alternatively, you can head to the [Model specification](@ref user-guide-model-specification) which provides more detailed information of how to use `RxInfer` to specify probabilistic models. [Inference execution](@ref user-guide-inference-execution) section provides a documentation about `RxInfer` API for running reactive Bayesian inference. Also read the [Comparison](@ref comparison) to compare `RxInfer` with other probabilistic programming libraries.
308
+
There are a set of [examples](@ref examples-overview) available in `RxInfer` repository that demonstrate the more advanced features of the package for various problems. Alternatively, you can head to the [Model specification](@ref user-guide-model-specification) which provides more detailed information of how to use `RxInfer` to specify probabilistic models. [Inference execution](@ref user-guide-inference-execution) section provides a documentation about `RxInfer` API for running reactive Bayesian inference. Also read the [Comparison](@ref comparison) to compare `RxInfer` with other probabilistic programming libraries. For advances use cases refer to the [Non-conjugate inference](@ref inference-nonconjugate) tutorial and inference [without defining the message update rules explicitly](@ref inference-undefinedrules).
Copy file name to clipboardExpand all lines: docs/src/manuals/inference/delta-node.md
+39-22Lines changed: 39 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,20 @@ RxInfer.jl offers a comprehensive set of stochastic nodes, primarily emphasizing
6
6
7
7
The delta node supports several approximation methods for probabilistic inference. The desired approximation method depends on the nodes connected to the delta node. We differentiate the following deterministic transformation scenarios:
8
8
9
-
1.**Gaussian Nodes**: For delta nodes linked to strictly multivariate or univariate Gaussian distributions, the recommended methods are Linearization or Unscented transforms.
10
-
2.**Exponential Family Nodes**: For the delta node connected to nodes from the exponential family, the CVI (Conjugate Variational Inference) is the method of choice.
11
-
3.**Stacking Delta Nodes**: For scenarios where delta nodes are stacked, either Linearization or Unscented transforms are suitable.
9
+
1.**Gaussian Nodes**: For delta nodes linked to strictly multivariate or univariate Gaussian distributions, the recommended methods are `Linearization` or `Unscented` transforms.
10
+
2.**Exponential Family Nodes**: For the delta node connected to nodes from the exponential family, the `CVIProjection` (Conjugate Variational Inference) is the method of choice.
11
+
3.**Stacking Delta Nodes**: For scenarios where delta nodes are stacked, either `Linearization`, `Unscented` or `CVIProjection` are suitable.
12
+
4.**Support for Inverse Functions**: For scenarious, where an inverse function is available
12
13
13
14
The table below summarizes the features of the delta node in RxInfer.jl, categorized by the approximation method:
@@ -29,12 +32,15 @@ For clarity, consider the following example:
29
32
using RxInfer
30
33
31
34
@model function delta_node_example(z)
32
-
x ~ Normal(mean=0.0, var=1.0)
35
+
x ~ Normal(mean = 0.0, var = 1.0)
33
36
y := tanh(x)
34
-
z ~ Normal(mean=y, var=1.0)
37
+
z ~ Normal(mean = y, var = 1.0)
35
38
end
36
39
```
37
40
41
+
!!! note
42
+
While not strictly required, it is advised to use `:=` to define a deterministic relationship within the `@model` macro.
43
+
38
44
To perform inference on this model, designate the approximation method for the delta node (here, the `tanh` function) using the `@meta` specification:
39
45
40
46
```@example delta_node_example
@@ -62,21 +68,25 @@ end
62
68
To execute the inference procedure:
63
69
64
70
```@example delta_node_example
65
-
infer(model = delta_node_example(), meta=delta_meta, data = (z = 1.0,))
71
+
result = infer(
72
+
model = delta_node_example(),
73
+
meta = delta_meta,
74
+
data = (z = 1.0,)
75
+
)
66
76
```
67
77
68
-
This methodology is consistent even when the delta node is associated with multiple nodes. For instance:
78
+
This methodology is consistent even when the delta node is associated with multiple inputs. For instance:
69
79
70
80
```@example delta_node_example
71
81
f(x, g) = x*tanh(g)
72
82
```
73
83
74
84
```@example delta_node_example
75
85
@model function delta_node_example(z)
76
-
x ~ Normal(mean=1.0, var=1.0)
77
-
g ~ Normal(mean=1.0, var=1.0)
86
+
x ~ Normal(mean = 1.0, var = 1.0)
87
+
g ~ Normal(mean = 1.0, var = 1.0)
78
88
y := f(x, g)
79
-
z ~ Normal(mean=y, var=0.1)
89
+
z ~ Normal(mean = y, var = 0.1)
80
90
end
81
91
```
82
92
@@ -112,11 +122,14 @@ end
112
122
113
123
When the delta node is associated with nodes from the exponential family (excluding Gaussians), the `Linearization` and `Unscented` methods are not applicable. In such cases, the CVI (Conjugate Variational Inference) is available. Here's a modified example:
114
124
125
+
!!! note
126
+
The `CVIProjection` method is available only if `ExponentialFamilyProjection` package is installed in the current environment.
127
+
115
128
```@example delta_node_example_cvi
116
-
using RxInfer
129
+
using RxInfer, ExponentialFamilyProjection
117
130
118
131
@model function delta_node_example1(z)
119
-
x ~ Gamma(shape=1.0, rate=1.0)
132
+
x ~ Gamma(shape = 1.0, rate = 1.0)
120
133
y := tanh(x)
121
134
z ~ Bernoulli(y)
122
135
end
@@ -125,12 +138,16 @@ end
125
138
The corresponding meta specification can be represented as:
Consult the `ProdCVI` docstrings for a detailed explanation of these parameters.
146
+
Consult the `CVIProjection` docstrings for a detailed explanation of its hyper-parameters. Additionally, read the [Non-conjugate Inference](@ref inference-nonconjugate) section.
147
+
148
+
!!! note
149
+
The `CVIProjection` method is an improved version of the now-deprecated `CVI` method. This new implementation features different hyperparameters, better accuracy, and improved stability.
150
+
151
+
## Fuse deterministic nodes with stochastic nodes
152
+
153
+
Read how to circumvent the need to define the meta structure and, instead, fuse the deterministic relation with a neighboring stochastic factor node in [this section](@ref inference-undefinedrules-fusedelta).
0 commit comments