Memberships
Differentiable membership functions for fuzzy TSK models.
This module defines learnable membership function classes for highFIS.
All membership functions inherit from MembershipFunction, which itself
inherits from torch.nn.Module.
Membership functions
Gaussian-based
- GaussianMF — standard Gaussian with mean and sigma.
- CompositeGaussianMF — Gaussian with a positive lower bound
to avoid zero membership.
- GaussianPIMF — Gaussian with a positive infimum, useful for
softmin-stable models.
Exponential
- CompositeExponentialMF — CEMF with lower bound 1/k, used
by AYATSK.
Piecewise polynomial
- TriangularMF — triangular membership with left/center/right.
- TrapezoidalMF — trapezoidal membership with four vertices.
- PiMF — pi-shaped membership with smooth S/Z transitions.
- SShapedMF / ZShapedMF — smooth S/Z membership curves.
- LinSShapedMF / LinZShapedMF — linear S/Z membership curves.
Sigmoidal
- SigmoidalMF — standard sigmoid.
- DiffSigmoidalMF — difference of two sigmoids.
- ProdSigmoidalMF — product of two sigmoids.
Notes
- Membership parameters are trainable and differentiable.
- This module is intended for use with TSK models in
highfis.models.
BellMF
Bases: MembershipFunction
Generalized bell membership: 1 / (1 + |((x-c)/a)|^(2b)).
Initialize bell MF with width a, slope b, and center.
Source code in highfis/memberships.py
a
property
Return positive width via softplus reparameterization.
b
property
Return positive slope via softplus reparameterization.
forward
CompositeExponentialMF
Bases: MembershipFunction
Composite exponential membership function used in AYATSK.
Initialize composite exponential membership function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
Center of the membership function \(c\). |
0.0
|
sigma
|
float
|
Width \(\sigma > 0\). Softplus-reparameterized to remain positive during training. |
1.0
|
k
|
float
|
Lower-bound control parameter \(k > 1\). The membership
lower bound equals |
10.0
|
eps
|
float | None
|
Numeric stability constant. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If sigma is not positive or k is not > 1. |
Source code in highfis/memberships.py
sigma
property
Return positive sigma using softplus reparameterization.
forward
Compute CompositeExponentialMF membership values for input tensor.
Source code in highfis/memberships.py
CompositeGaussianMF
Bases: MembershipFunction
Composite Gaussian membership with a nonzero lower bound.
Initialize composite Gaussian membership function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
Center of the Gaussian \(c\). |
0.0
|
sigma
|
float
|
Width \(\sigma > 0\). Softplus-reparameterized to remain positive during training. |
1.0
|
eps
|
float | None
|
Numeric stability constant and lower bound of the
membership value. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If sigma is not positive. |
Source code in highfis/memberships.py
sigma
property
Return positive sigma using softplus reparameterization.
forward
Compute Composite Gaussian membership values for input tensor.
GaussianMF
Bases: MembershipFunction
Gaussian membership: exp(-((x-c)^2)/(2*sigma^2)).
Initialize Gaussian membership function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
Center of the Gaussian \(c\). |
0.0
|
sigma
|
float
|
Width \(\sigma > 0\). Softplus-reparameterized to remain positive during training. |
1.0
|
eps
|
float | None
|
Numeric stability constant. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If sigma is not positive. |
Source code in highfis/memberships.py
sigma
property
Return positive sigma using softplus reparameterization.
forward
Compute Gaussian membership values for input tensor.
GaussianPIMF
Bases: MembershipFunction
Gaussian membership with a positive infimum (PIMF).
Defined as exp(-K * (1 - exp(-(x - m)^2 / (2 * sigma^2)))).
The infimum of this function is exp(-K) > 0, which prevents
numeric underflow when used with softmin-based T-norms on
high-dimensional data.
Reference: Ma et al., "An adaptive double-parameter softmin based Takagi-Sugeno-Kang fuzzy system for high-dimensional data", Fuzzy Sets and Systems 521 (2025), Eq. (41).
Initialize Gaussian PIMF with center, spread, and infimum control K.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
Center of the Gaussian. |
0.0
|
sigma
|
float
|
Spread (standard deviation); must be positive. |
1.0
|
K
|
float
|
Positive infimum control parameter in (0, 745]. The membership infimum is exp(-K). |
1.0
|
eps
|
float | None
|
Numerical stability constant. |
None
|
Source code in highfis/memberships.py
sigma
property
Return the positive standard deviation via softplus reparameterization.
forward
Compute Gaussian PIMF membership values for input tensor.
Source code in highfis/memberships.py
LinSShapedMF
Bases: MembershipFunction
Linear S-shaped membership from 0 to 1 between a and b.
Initialize with ramp start (a) and end (b); requires a < b.
Source code in highfis/memberships.py
b
property
Return right shoulder, guaranteed > a via softplus offset.
forward
Compute linear S-shaped membership values for input tensor.
LinZShapedMF
Bases: MembershipFunction
Linear Z-shaped membership from 1 to 0 between a and b.
Initialize with ramp start (a) and end (b); requires a < b.
Source code in highfis/memberships.py
b
property
Return right foot, guaranteed > a via softplus offset.
forward
Compute linear Z-shaped membership values for input tensor.
MembershipFunction
Bases: nn.Module
Base class for differentiable membership functions in PyTorch.
Initialize base membership function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eps
|
float | None
|
Numeric stability constant. |
None
|
Source code in highfis/memberships.py
PiMF
Bases: MembershipFunction
Pi-shaped membership with smooth S/Z transitions and flat top.
Initialize with four boundary points; requires a < b <= c < d.
Source code in highfis/memberships.py
forward
Compute Pi-shaped membership values for input tensor.
Source code in highfis/memberships.py
points
Return (a, b, c, d) with ordering guaranteed by softplus offsets.
Source code in highfis/memberships.py
ProdSigmoidalMF
Bases: MembershipFunction
Product of two sigmoids: s1(x) * s2(x).
Initialize with slope and center parameters for each sigmoid.
Source code in highfis/memberships.py
forward
Compute s1(x) * s2(x) membership values for input tensor.
Source code in highfis/memberships.py
SShapedMF
Bases: MembershipFunction
Smooth S-shaped membership from 0 to 1 between a and b.
Initialize with transition start (a) and end (b); requires a < b.
Source code in highfis/memberships.py
b
property
Return right shoulder, guaranteed > a via softplus offset.
forward
Compute smooth S-shaped membership values for input tensor.
SigmoidalMF
Bases: MembershipFunction
Sigmoidal membership: 1 / (1 + exp(-a*(x-c))).
Initialize sigmoidal MF with slope a and center.
Source code in highfis/memberships.py
TrapezoidalMF
Bases: MembershipFunction
Trapezoidal membership function defined by a, b, c, d.
Initialize trapezoidal MF with vertices a, b, c, d.
Source code in highfis/memberships.py
forward
Compute trapezoidal membership values for input tensor.
Source code in highfis/memberships.py
TriangularMF
Bases: MembershipFunction
Triangular membership function defined by left, center, right.
Initialize triangular MF with left, center, right vertices.
Source code in highfis/memberships.py
forward
Compute triangular membership values for input tensor.
Source code in highfis/memberships.py
ZShapedMF
Bases: MembershipFunction
Smooth Z-shaped membership from 1 to 0 between a and b.
Initialize with transition start (a) and end (b); requires a < b.
Source code in highfis/memberships.py
b
property
Return right foot, guaranteed > a via softplus offset.
forward
Compute smooth Z-shaped membership values for input tensor.