Node¶
- class Node(*shape: int | None)[source]¶
-
Base class for predictive coding nodes.
- Parameters:
*shape (int | None) – base shape of the node’s state.
Important
A placeholder \(\text{0}^\text{th}\) dimension is automatically added to
shape.- property bshape: tuple[int, ...]¶
Shape of the node state, safe for tensor construction.
Note
Placeholder dimensions represented with unit length dimensions. Use
shape()for a version to use that preserves placeholders.
- abstractmethod forward(inputs: Tensor, **kwargs) Tensor[source]¶
Computes a forward pass on the node.
- Parameters:
inputs (Tensor) – input to the node.
- Returns:
value of the node.
- Return type:
- Raises:
NotImplementedError – must be implemented by subclasses.
Important
Subclasses implementing this method should perform the following operations: - Initialize the value of the node based on
inputsifself.trainingisTrue. - Return the value of the node.Most subclasses should inherit from
PredictiveNodeinstead, although special cases may inherit from this class instead (seeBiasNodefor an example of this).
- abstractmethod reset() None[source]¶
Resets transient node state.
- Raises:
NotImplementedError – must be implemented by subclasses.
- property shape: tuple[int | None, ...]¶
Shape of the node state.
Note
Placeholder dimensions represented with
Nonevalues. Usebshape()for a version to use when constructing broadcastable tensors.