Output Layer
This module contains the output layer implemented in the toolbox. This layer computes the final model output by aggregating the individual outputs of each fuzzy rule.
- class neuro_fuzzy_toolbox.layers.output_layer.OutputLayer(*args: Any, **kwargs: Any)[source]
Bases:
ModuleOutput layer for an Adaptive Neuro-Fuzzy Inference System (ANFIS).
Aggregates the weighted rule outputs by summing across all rules and applies an output activation function to produce the final model prediction. The activation is determined by the specified output type:
'default': No activation (identity). Suitable for regression.'sigmoid': Sigmoid activation..'softmax': Softmax activation (applied only whenreturn_probs=Trueinforward()). Suitable for classification.
- __init__(output_type)[source]
Initializes a new OutputLayer instance.
- Parameters:
output_type (str) – Output activation type. Must be one of
'default','sigmoid', or'softmax'.
- forward(rules_outputs, return_probs=False)[source]
Forward pass of the output layer.
Sums the weighted rule outputs across all rules and applies the configured output activation.
- Parameters:
rules_outputs (torch.Tensor) – Weighted rule outputs of shape
(outputs, batch_size, rules).return_probs (bool) – If
Trueand the output type is'softmax', applies a softmax activation to return class probabilities. Ignored for all other output types. Defaults toFalse.
- Returns:
Model output of shape
(batch_size, outputs), or(batch_size,)for single-output models.- Return type:
torch.Tensor