IsotropicGaussianNode¶
- class IsotropicGaussianNode(*shape: int | None, variance: float | Tensor = 1.0)[source]¶
Bases:
AbstractGaussianNodeGaussian predictive coding node with scalar variance.
Assumes the covariance matrix is a scalar matrix.
\[\boldsymbol{\Sigma} = \sigma\mathbf{I}\]- Parameters:
- property covariance: Tensor¶
Covariance matrix of the Gaussian distribution.
\[\boldsymbol{\Sigma} = \sigma\mathbf{I}\]- 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 are averaged.
2D-Tensor: diagonal of the covariance matrix is averaged.
- energy(pred: Tensor) Tensor[source]¶
Variational free energy with respect to the prediction.
\[\begin{split}\begin{aligned} \mathcal{F} &= \frac{1}{2} \left((\mathbf{z} - \boldsymbol{\mu}) ((\mathbf{z} - \boldsymbol{\mu}) \sigma^{-1})^\intercal + N \log \sigma\right) \\ &= \frac{1}{2} \left(\frac{\lVert\mathbf{z} - \boldsymbol{\mu}\rVert_2^2}{\sigma} + N \log \sigma\right) \end{aligned}\end{split}\]
- error(pred: Tensor) Tensor[source]¶
Error between the prediction and node state.
\[\boldsymbol{\varepsilon} = \frac{\mathbf{z} - \boldsymbol{\mu}}{\sigma}\]