Customising the algorithm initialisation
By default, Infer.NET initialises all messages to a uniform distribution. It it sometimes necessary to override this behaviour, for example to break symmetries in the model or to initialise based on a custom preprocessing of the data. Infer.NET supports overriding the initialisation of the algorithm by specifying an initial marginal for a variable or variables.The syntax is:
|
when the algorithm is initialised, the initial marginal for x will be set to a Gaussian with zero mean and a variance of 10.
Often you will need to initialise a variable array. To do this, first build up a .NET array of the correct size. Then use the static Array method in the Distribution class to create the correct IDistribution type needed by InitialiseTo. For example,
Range r = new Range(10); |
Important note: Initialising a variable will often change the inference schedule used. This is because the inference scheduler will use manually initialised messages in favour of automatically initialised ones, and so the order of operations may change. The scheduler will also warn if the initialisation is unnecessary, for example, if the initial values supplied are never used.

