pyhgf.model.transplant.from_feedforward#

pyhgf.model.transplant.from_feedforward(fc1, fc2, activation=<function gelu>, leaf_kwargs=None, layer_kwargs=None, network_kwargs=None)[source]#

Build a three-layer network computing exactly fc2(activation(fc1(x))).

The hidden layer holds the pre-activation values and applies activation as its coupling when predicting the output layer, which is why fc1’s bias lands on the input→hidden matrix (the hidden node’s value is fc1.weight @ x + fc1.bias, and the activation acts on the whole of it one connection below), while fc2’s bias lands on the hidden → output matrix, outside the activation.

Parameters:
  • fc1 (Linear) – The first Equinox layer (input → hidden, inside the activation).

  • fc2 (Linear) – The second Equinox layer (hidden → output).

  • activation (Callable) – The nonlinearity between them (default GELU, matching the Transformer feed-forward block).

  • leaf_kwargs (dict | None) – Extra add_layer keyword arguments for the bottom (observed) layer.

  • layer_kwargs (dict | None) – Extra add_layer keyword arguments for the hidden and input layers.

  • network_kwargs (dict | None) – Constructor arguments for the DeepNetwork itself, such as feedforward_uncertainty. These reach the network’s state when it is built and cannot be set afterwards, so they belong here rather than in the per-layer keyword sets.

Returns:

A network whose predict reproduces the feed-forward block.

Return type:

DeepNetwork