soft.fuzzy.logic.inference.engines package

Submodules

soft.fuzzy.logic.inference.engines.mamdani module

Implements the various versions of the Mamdani inference engine.

class soft.fuzzy.logic.inference.engines.mamdani.MamdaniInference(specs: Engine, consequences: Tensor | GroupedFuzzySets, links, offset)

Bases: BaseInference, ABC

Implements an abstract process for Mamdani fuzzy inference.

abstract calc_intermediate_output(rule_activations: Tensor) NoReturn

Calculate the intermediate output.

Parameters:

rule_activations – Activations of fuzzy logic rules.

Returns:

NotImplementedError as this is an abstract method.

forward(antecedents_memberships: tuple | Membership) Tensor

Conduct the forward inference when given the antecedents’ membership values.

Parameters:

antecedents_memberships – The antecedents’ memberships.

Returns:

The inferred consequences.

infer_from_activated_rules(rule_activations: Tensor) Tensor

Given the activations of the fuzzy logic rules, calculate the output of the Mamdani FLC.

Parameters:

rule_activations – Activations of fuzzy logic rules.

Returns:

The defuzzified output of a Mamdani FLC.

class soft.fuzzy.logic.inference.engines.mamdani.MamdaniProductInference(specs: Engine, consequences: Tensor | GroupedFuzzySets, links, offset)

Bases: MamdaniInference

Implements the Mamdani product inference engine used in fuzzy logic control or neuro-fuzzy networks.

calc_intermediate_output(rule_activations: Tensor) Tensor

Calculate the intermediate output; may no longer be needed.

Parameters:

rule_activations – Activations of fuzzy logic rules.

Returns:

torch.Tensor

calc_rules_applicability(antecedents_memberships: Membership) Tensor

Calculates the fuzzy logic rules’ applicability using the product inference engine.

Parameters:

antecedents_memberships – The antecedents’ memberships.

Returns:

The applicability of the fuzzy logic rules.

soft.fuzzy.logic.inference.engines.tsk module

Implements the various versions of the TSK inference engine.

class soft.fuzzy.logic.inference.engines.tsk.TSKInference(specs: Engine, consequences: Tensor | GroupedFuzzySets, links, offset)

Bases: BaseInference, ABC

Implements an abstract process for zero-order TSK fuzzy inference.

calc_rules_applicability(antecedents_memberships: Membership) Tensor

Calculates the fuzzy logic rules’ applicability.

Parameters:

antecedents_memberships – The antecedents’ memberships.

Returns:

The applicability of the fuzzy logic rules.

forward(antecedents_memberships: Membership) Tensor

Conduct the forward inference when given the antecedents’ membership values.

Parameters:

antecedents_memberships – The antecedents’ memberships.

Returns:

The inferred consequences.

rule_activation(antecedents_memberships: Membership) Tensor

Calculates the rule activation.

Parameters:

antecedents_memberships – The antecedents’ memberships.

Returns:

The rule activation.

Module contents

Implements the engines required to facilitate fuzzy logic inference.