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
activationas its coupling when predicting the output layer, which is whyfc1’s bias lands on the input→hidden matrix (the hidden node’s value isfc1.weight @ x + fc1.bias, and the activation acts on the whole of it one connection below), whilefc2’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_layerkeyword arguments for the bottom (observed) layer.layer_kwargs (dict | None) – Extra
add_layerkeyword arguments for the hidden and input layers.network_kwargs (dict | None) – Constructor arguments for the
DeepNetworkitself, such asfeedforward_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
predictreproduces the feed-forward block.- Return type: