FactorizedGaussianNode¶
- class FactorizedGaussianNode(*shape: int | None, variance: float | Tensor = 1.0)[source]¶
Bases:
AbstractGaussianNodeGaussian predictive coding node with diagonal variances.
Assumes the covariance matrix is a diagonal matrix.
\[\begin{split}\boldsymbol{\Sigma} = \begin{bmatrix} \sigma_1 & 0 & \cdots & 0 \\ 0 & \sigma_2 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & \sigma_N \end{bmatrix}\end{split}\]- Parameters:
- property covariance: Tensor¶
Covariance matrix of the Gaussian distribution.
\[\boldsymbol{\Sigma} = \operatorname{diag}(\sigma_1, \sigma_2, \ldots, \sigma_N)\]- Parameters:
value (float | Tensor) – new covariance for the distribution.
- Returns:
covariance of the distribution.
- Return type:
Note
Assigment of variances is performed as follows:
0D-Tensor (or float): single variance is used.
1D-Tensor: vector of variances is used.
2D-Tensor: diagonal of the covariance matrix is used.
- energy(pred: Tensor) Tensor[source]¶
Variational free energy with respect to the prediction.
\[\mathcal{F} = \frac{1}{2} \left( (\mathbf{z} - \boldsymbol{\mu}) ((\mathbf{z} - \boldsymbol{\mu}) \oslash \boldsymbol{\sigma})^\intercal + N \log \sigma\right)\]
- error(pred: Tensor) Tensor[source]¶
Error between the prediction and node state.
\[\boldsymbol{\varepsilon} = (\mathbf{z} - \boldsymbol{\mu}) \oslash \boldsymbol{\sigma}\]