FixedNode

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

Bases: Node

Input node with a fixed value.

Parameters:

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

value

current value of the node.

Type:

Buffer

Hint

This is primarily useful when performing query by conditioning from an input, where the value is not updated on E-steps.

error(pred: Tensor) Tensor[source]

Error between the prediction and node state.

\[\boldsymbol{\varepsilon} = \mathbf{z} - \boldsymbol{\mu}\]
Parameters:

pred (Tensor) – predicted value \(\boldsymbol{\mu}\).

Returns:

elementwise error \(\boldsymbol{\varepsilon}\).

Return type:

Tensor

forward(inputs: Tensor, **kwargs) Tensor[source]

Computes a forward pass on the node.

When self.training is True, the prediction is assigned to the value and then value is returned. When self.training is False, the prediction is directly returned (i.e. this acts as the identity operation).

Parameters:

inputs (Tensor) – prediction of the value.

Returns:

value of the node.

Return type:

Tensor

init(value: Tensor) Buffer[source]

Initializes the node’s state to a new value.

Parameters:

value (Tensor) – value to initialize to.

Returns:

the reinitialized value.

Return type:

Buffer

Raises:

RuntimeError – shape of value is incompatible with the node.

reset() None[source]

Resets the node state.

This operation is typically executed after each new batch. With inference learning, this is done after M-step. With incremental inference learning, this is done after the final M-step.