Class SoftmaxOp_KM11_LBFGS
Provides outgoing messages for Softmax(IList<Double>), given random arguments to the function.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Factors
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[FactorMethod(typeof(MMath), "Softmax", new Type[]{typeof(IList<double>)})]
[Quality(QualityBand.Preview)]
[Buffers(new string[]{"A"})]
public static class SoftmaxOp_KM11_LBFGS
Remarks
This implementation uses the bound in Knowles and Minka (2011), followed by optimization using LBFGS. This approach is linear in the dimension K.
Methods
A(IList<Gaussian>, Vector)
Update the buffer A.
Declaration
public static Vector A(IList<Gaussian> x, Vector a)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Gaussian> | x | Incoming message from |
| Vector | a | Buffer |
Returns
| Type | Description |
|---|---|
| Vector | New value of buffer |
Remarks
Exceptions
| Type | Condition |
|---|---|
| ImproperMessageException |
|
AInit(IList<Gaussian>)
Initialize the buffer A.
Declaration
public static Vector AInit(IList<Gaussian> x)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Gaussian> | x | Incoming message from |
Returns
| Type | Description |
|---|---|
| Vector | Initial value of buffer |
Remarks
AverageLogFactor<GaussianList>(GaussianList, Vector, Dirichlet, Dirichlet)
Evidence message for VMP.
Declaration
public static double AverageLogFactor<GaussianList>(GaussianList x, Vector a, Dirichlet softmax, Dirichlet to_softmax)
where GaussianList : IList<Gaussian>
Parameters
| Type | Name | Description |
|---|---|---|
| GaussianList | x | Incoming message from |
| Vector | a | Buffer |
| Dirichlet | softmax | Incoming message from |
| Dirichlet | to_softmax | Previous outgoing message to |
Returns
| Type | Description |
|---|---|
| Double | Zero. |
Type Parameters
| Name | Description |
|---|---|
| GaussianList | The type of the incoming message from |
Remarks
In Variational Message Passing, the evidence contribution of a deterministic factor is zero. Adding up these values across all factors and variables gives the log-evidence estimate for VMP.
GradientAndValueAtPoint(Double[], Double[], Vector, Vector, Vector, Vector)
Function to evaluate this factor's KL divergence contribution, and gradient (if grad is not null).
Declaration
public static double GradientAndValueAtPoint(double[] mu, double[] s2, Vector a, Vector x, Vector ns, Vector grad)
Parameters
| Type | Name | Description |
|---|---|---|
| Double[] | mu | Prior means |
| Double[] | s2 | Prior variances |
| Vector | a | Variational parameter vector a |
| Vector | x | x[1..K]: posterior mean, x[K+1..2K]: posterior log variance |
| Vector | ns | Dirichlet counts-1 |
| Vector | grad | Vector to store the gradient in |
Returns
| Type | Description |
|---|---|
| Double | KL divergence |
SoftmaxAverageLogarithm<GaussianList>(GaussianList, Vector, Dirichlet)
VMP message to softmax.
Declaration
public static Dirichlet SoftmaxAverageLogarithm<GaussianList>([SkipIfAllUniform] GaussianList x, Vector a, Dirichlet result)
where GaussianList : IList<Gaussian>
Parameters
| Type | Name | Description |
|---|---|---|
| GaussianList | x | Incoming message from |
| Vector | a | Buffer |
| Dirichlet | result | Modified to contain the outgoing message. |
Returns
| Type | Description |
|---|---|
| Dirichlet |
|
Type Parameters
| Name | Description |
|---|---|
| GaussianList | The type of the incoming message from |
Remarks
The outgoing message is a distribution matching the moments of softmax as the random arguments are varied. The formula is proj[sum_(x) p(x) factor(softmax,x)].
Exceptions
| Type | Condition |
|---|---|
| ImproperMessageException |
|
SoftmaxAverageLogarithmInit(IList<Gaussian>)
Declaration
public static Dirichlet SoftmaxAverageLogarithmInit(IList<Gaussian> x)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Gaussian> | x | Incoming message from |
Returns
| Type | Description |
|---|---|
| Dirichlet |
Remarks
XAverageLogarithm<GaussianList>(Dirichlet, IList<Gaussian>, Vector, GaussianList)
VMP message to x.
Declaration
public static GaussianList XAverageLogarithm<GaussianList>(Dirichlet softmax, [SkipIfAllUniform] IList<Gaussian> x, Vector a, GaussianList result)
where GaussianList : IList<Gaussian>
Parameters
| Type | Name | Description |
|---|---|---|
| Dirichlet | softmax | Incoming message from |
| IList<Gaussian> | x | Incoming message from |
| Vector | a | Buffer |
| GaussianList | result | Modified to contain the outgoing message. |
Returns
| Type | Description |
|---|---|
| GaussianList |
|
Type Parameters
| Name | Description |
|---|---|
| GaussianList | The type of the outgoing message. |
Remarks
The outgoing message is the factor viewed as a function of x with softmax integrated out. The formula is sum_softmax p(softmax) factor(softmax,x).
Exceptions
| Type | Condition |
|---|---|
| ImproperMessageException |
|
| ImproperMessageException |
|