Network Layers đź§©#

HONN#

class ghonn_models_pytorch.core.HONN(in_features, out_features, layer_size, polynomial_orders, *, activations='identity', output_type='linear', **kwargs)[source]#

Higher-Order Neural Network (HONN) model.

This class implements a neural network composed of multiple HONU (Higher-Order Neuron Unit) in a single layer. Each unit applies a polynomial transformation to the input features, enabling the model to capture higher-order interactions between input variables.

The model supports flexible configurations, including the number of units, polynomial orders for each unit, and different output transformation types.

__init__()[source]#

Initializes the HONN model with the specified parameters.

__repr__()[source]#

Returns a string representation of the HONN model.

forward()[source]#

Performs a forward pass through the HONN model.

_assign_polynomial_orders()#

Adjusts the polynomial orders list to match the number of layers.

_get_head()[source]#

Constructs and returns the output head function based on the specified output type.

Initialize the Higher-Order Neural Network model.

Parameters:
  • in_features (int) – Number of input features for the model.

  • out_features (int) – Number of output features for the model.

  • layer_size (int) – Number of HONU layers in the model.

  • polynomial_orders (list[int]) – List specifying the polynomial order for each layer. - If the list length is less than layer_size, it will be cycled to match the size. - If the list length is greater than layer_size, it will be truncated.

  • activations (list[str] | tuple[str], optional) – List of activation fnfor each layer. - If the list length is less than layer_size, it will be cycled to match the size.

  • output_type (str, optional) – Type of output transformation. Defaults to “linear”. - “sum”: Sum the outputs of all layers. - “linear”: Apply a linear transformation to the concatenated outputs. - “raw”: Return the raw outputs of all layers without any transformation.

  • **kwargs – Additional keyword arguments passed to each HONU layer.

in_features#

Number of input features for the model.

Type:

int

out_features#

Number of output features for the model.

Type:

int

layer_size#

Number of HONU in the model layer.

Type:

int

polynomial_orders#

List of polynomial orders for each layer.

Type:

list[int]

output_type#

Type of output transformation.

Type:

str

honu#

List of HONU neurons in the model.

Type:

nn.ModuleList

head#

Output head function or module for processing the model’s output.

Type:

callable

GHONN#

class ghonn_models_pytorch.core.GHONN(in_features, out_features, layer_size, predictor_orders, gate_orders, *, predictor_activations='identity', gate_activations='sigmoid', output_type='linear', **kwargs)[source]#

GHONN (Gated Higher Order Neural Network) model.

This class implements a neural network composed of multiple GHONUs (Gated Higher Order Neural Units) in a single layer. Each unit applies polynomial transformations to the input data and uses a gating mechanism to modulate the output.

The model supports flexible configurations, including the number of units, polynomial orders for both the predictor and gate, and the activation function for the gate and different output types.

Initialize the Gater Higher Order Neural Network model.

Parameters:
  • in_features (int) – Number of input features.

  • out_features (int) – Number of output features.

  • layer_size (int) – Number of layers in the model.

  • predictor_orders (list[int]) – List of predictor orders for each layer.

  • gate_orders (list[int]) – List of gate orders for each layer.

  • predictor_activations (list[str] | tuple[str], optional) – List or tuple of activation functions for the predictor. Defaults to (“identity”).

  • gate_activations (list[str] | tuple[str], optional) – List or tuple of activation functions for the gates. Defaults to (“sigmoid”).

  • output_type (str, optional) – Type of output layer. Defaults to “linear”.

  • **kwargs – Additional keyword arguments passed to the GHONU layers.

in_features#

Number of input features.

Type:

int

out_features#

Number of output features.

Type:

int

layer_size#

Number of layers in the model.

Type:

int

predictor_orders#

Normalized list of predictor orders for each layer.

Type:

list[int]

gate_orders#

Normalized list of gate orders for each layer.

Type:

list[int]

gate_activations#

Normalized list of activation functions for the gates.

Type:

list[str]

output_type#

Type of output layer.

Type:

str

ghonus#

List of GHONU layers.

Type:

nn.ModuleList

head#

Output head module.

Type:

nn.Module