Defuzzifiers
Defuzzification strategies for normalized rule firing strengths.
This module defines defuzzifier classes used by TSK models to convert raw
antecedent firing strengths into normalized rule weights for consequent
aggregation. Each defuzzifier accepts an (N, R) tensor and returns a
normalized tensor of the same shape.
Built-in strategies
SoftmaxLogDefuzzifier—softmax(log(w)), numerically stable equivalent ofw / sum(w)(default for HTSK and DG variants).SumBasedDefuzzifier— classicw / sum(w)normalization (used by TSK, AYATSK, DombiTSK, AdaTSK).LogSumDefuzzifier— temperature-scaledsoftmax(log(w) / T)(used by LogTSK).InvLogDefuzzifier— inverse-log normalization for log-domain firing strengths.
Notes
- A custom defuzzifier may be supplied via the
defuzzifierconstructor parameter of any model. - Custom defuzzifiers must accept a 2-D firing-strength tensor and return a normalized tensor of the same shape.
InvLogDefuzzifier
Bases: nn.Module
Scale-invariant inverse-log defuzzifier for LogTSK.
This defuzzifier normalizes log-domain firing strengths using an inverse-log transformation and L1 normalization.
Initialize with numeric stability eps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eps
|
float | None
|
Small constant used to clamp |
None
|
Source code in highfis/defuzzifiers.py
forward
Compute L1-normalised inverse-log weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
Tensor
|
Tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
If w does not have exactly 2 dimensions. |
Source code in highfis/defuzzifiers.py
LogSumDefuzzifier
Bases: nn.Module
Normalize in log-space: softmax(log(w) / temperature).
The temperature parameter controls the sharpness of the distribution.
temperature=1 recovers :class:SoftmaxLogDefuzzifier.
Initialize with temperature and optional numeric stability floor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
temperature
|
float
|
Positive scaling factor |
1.0
|
eps
|
float | None
|
Small positive constant used to clamp weights before
taking the logarithm. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If temperature is not positive. |
Source code in highfis/defuzzifiers.py
forward
Normalize firing strengths via temperature-scaled softmax(log(w)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
Tensor
|
Firing-strength tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Normalized weight tensor of shape |
Tensor
|
along the rule dimension. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If w does not have exactly 2 dimensions. |
Source code in highfis/defuzzifiers.py
SoftmaxLogDefuzzifier
Bases: nn.Module
Normalize firing strengths via softmax(log(w)).
Equivalent to w / sum(w) but numerically more stable in high
dimensions thanks to the internal max-subtraction trick of
:func:torch.softmax.
Initialize with optional numeric stability floor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eps
|
float | None
|
Small positive constant used to clamp weights before
taking the logarithm. |
None
|
Source code in highfis/defuzzifiers.py
forward
Normalize firing strengths via softmax(log(w)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
Tensor
|
Firing-strength tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Normalized weight tensor of shape |
Tensor
|
along the rule dimension. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If w does not have exactly 2 dimensions. |
Source code in highfis/defuzzifiers.py
SumBasedDefuzzifier
Bases: nn.Module
Classic w / sum(w) normalization.
Initialize with optional numeric stability floor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eps
|
float | None
|
Small positive constant used to clamp weights before
division. |
None
|
Source code in highfis/defuzzifiers.py
forward
Normalize firing strengths via sum-based division.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w
|
Tensor
|
Firing-strength tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Normalized weight tensor of shape |
Tensor
|
along the rule dimension. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If w does not have exactly 2 dimensions. |