pyhgf.model.transplant.from_embedding#

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

Build a two-layer network reproducing a table lookup from one-hot inputs.

A lookup is a matrix product with a one-hot vector: table[i] equals one_hot(i) @ table. The top (input) layer therefore has one node per table row, the bottom (output) layer one node per embedding dimension, and the connecting matrix is the table transposed into PyHGF’s (out, in) orientation. Feed it one-hot rows: net.predict(jax.nn.one_hot(ids, num_embeddings)).

Parameters:
  • embedding (Embedding) – The Equinox embedding whose table is transplanted.

  • 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 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 on one-hot inputs reproduces the lookup.

Return type:

DeepNetwork