Skip to content

Protocols

Runtime-checkable structural typing protocols for the highFIS pipeline.

All protocols are decorated with @runtime_checkable so they can be used with isinstance at runtime.

Protocols:

  • MembershipFn — any callable (x: Tensor) -> Tensor that computes membership degrees. Satisfied by all classes in highfis.memberships.
  • TNorm — any callable (terms: Tensor) -> Tensor that aggregates antecedent activations. Satisfied by T-norm classes in highfis.t_norms.
  • Defuzzifier — any callable (w: Tensor) -> Tensor that normalizes rule firing strengths. Satisfied by all classes in highfis.defuzzifiers.
  • ConsequentFn — any callable (x: Tensor, norm_w: Tensor) -> Tensor that computes the model output. Satisfied by consequent layers in highfis.layers.

ConsequentFn

Bases: Protocol

Callable that computes consequent output from inputs and normalized strengths.

__call__

Compute consequent output from x and norm_w.

Source code in highfis/protocols.py
def __call__(self, x: Tensor, norm_w: Tensor) -> Tensor:
    """Compute consequent output from *x* and *norm_w*."""
    ...

Defuzzifier

Bases: Protocol

Callable that normalizes rule firing strengths.

__call__

Normalize firing strengths w.

Source code in highfis/protocols.py
def __call__(self, w: Tensor) -> Tensor:
    """Normalize firing strengths *w*."""
    ...

MembershipFn

Bases: Protocol

Callable that maps an input tensor to membership degrees.

__call__

Compute membership degrees for x.

Source code in highfis/protocols.py
def __call__(self, x: Tensor) -> Tensor:
    """Compute membership degrees for *x*."""
    ...

TNorm

Bases: Protocol

Callable that aggregates antecedent term activations per rule.

__call__

Aggregate terms into a single firing strength.

Source code in highfis/protocols.py
def __call__(self, terms: Tensor) -> Tensor:
    """Aggregate *terms* into a single firing strength."""
    ...