pyhgf.model.transplant.from_linear#

pyhgf.model.transplant.from_linear(linear, leaf_kwargs=None, layer_kwargs=None, network_kwargs=None)[source]#

Build a two-layer network computing exactly linear(x).

The bottom (output) layer has out_features nodes, the top (input) layer in_features nodes, and the connecting matrix carries the Linear’s weight with the bias folded in as the last column (if the Linear has one).

Parameters:
  • linear (Linear) – The Equinox layer whose weights are transplanted.

  • leaf_kwargs (dict | None) – Extra add_layer keyword arguments for the bottom (observed) layer — e.g. the backprop-parity configuration.

  • layer_kwargs (dict | None) – Extra add_layer keyword arguments for the top (input) layer.

  • 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 Linear’s forward pass.

Return type:

DeepNetwork