VariationalNode

class VariationalNode(*shape: int | None)[source]

Bases: PredictiveNode, ABC

Base class for predictive coding nodes modelling a variational distribution.

Parameters:

*shape (int | None) – base shape of the node’s state.

abstractmethod sample(value: Tensor, generator: Generator | None = None) Tensor[source]

Samples from the learned variational distribution.

Parameters:
  • value (Tensor) – location parameter of the variational distribution for sampling.

  • generator (Generator | None, optional) – pseudorandom number generator for sampling. Defaults to None.

Raises:

NotImplementedError – must be implemented by subclasses.

Returns:

samples from the variational distribution.

Return type:

Tensor