Skip to main content

Neuro-fuzzy systems with PyTorch.

Project description

Mistify

Mistify is a library built on PyTorch for building Neurofuzzy Systems. A neurofuzzy system is a trainable fuzzy system, typically consisting of a fuzzifier, rules layers, and a defuzzifier. Mistify provides a variety of modules to use at each layer of the pipeline

Installation

pip install mistify

Brief Overview

Mistify consists of subpackages for inference operations, fuzzification and defuzzification, and preprocessing and postprocessing. It incldes

  • mistify: The core functions used for fuzzification and inference.
  • mistify.fuzzify: Modules for building fuzzifiers and defuzzifiers. Has a variety of shapes or other fuzzification and defuzzification modules to use.
  • mistify.infer: Modules for performing inference operations such as Or Neurons, Intersections, Activations etc.
  • mistify.process: Modules for preprocessing or postprocessing on the data to input into the fuzzy system
  • mistify.systems: Modules for building systems more easily.
  • mistify.utils: Utilities used by other modules in Mistify.

Usage

Mistify's primary prupose is to build neurofuzzy systems or fuzzy neural networks using the the framework of PyTorch.

Here is a (non-working) example that uses alternating Or and And neurons.

class FuzzySystem(nn.Module):

    def __init__(
        self, in_features: int, h1: int, h2: int, out_features: int
    ):

        # Use for these builders for buliding a neuron
        # In this case, tehre is no wait fou
        AndNeruon = BuildAnd().no_wf().inter_on().prob_union()
        OrNeuron = BuildOr().no_wf().union_on().prob_inter()

        # 
        self.fuzzifier = mistify.fuzzify.SigmoidFuzzifier.from_linspace(
            n_terms, 'min_core', 'average'
        )
        self.flatten = FlattenCat()
        self.layer1 = OrNeuron(in_features * categories, h1)
        self.layer2 = AndNeruon(h1, h2)
        self.layer3 = OrNeuron(h2, out_features * out_categories)
        self.deflatten = DeflattenCat(out_categories)

        self.defuzzifier = mistify.fuzzify.IsoscelesFuzzyConverter.from_linspace(
            out_terms, 'min_core', 'average'
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:

        m = self.fuzzifier(x)
        m = self.flatten(m)
        m = self.layer1(m)
        m = self.layer2(m)
        m = self.layer3(m)
        # use to prepare for defuzzification
        m = self.deflatten(m)
        return self.defuzzifier.defuzzify(m)

Since it uses Torch, these fuzzy systems can easily be stacked.

Contributing

To contribute to the project

  1. Fork the project
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Citing this Software

If you use this software in your research, we request you cite it. We have provided a CITATION.cff file in the root of the repository. Here is an example of how you might use it in BibTeX:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mistify-0.0.1.tar.gz (50.3 kB view details)

Uploaded Source

Built Distribution

mistify-0.0.1-py3-none-any.whl (72.0 kB view details)

Uploaded Python 3

File details

Details for the file mistify-0.0.1.tar.gz.

File metadata

  • Download URL: mistify-0.0.1.tar.gz
  • Upload date:
  • Size: 50.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.12

File hashes

Hashes for mistify-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b8e636eecce4811f87717fac54ece4b665ca5a3a1ca4ce26f50d8ed874878d14
MD5 6b9a0dd564932415cf08563e4e1a92e0
BLAKE2b-256 314379a56885b457d7274e8aed910f14cd303da05f55f7f0a619351231cb3820

See more details on using hashes here.

File details

Details for the file mistify-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mistify-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 72.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.12

File hashes

Hashes for mistify-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f20c02aac7cad8202422d0e3fd2948c71cf2a41833648fdcc79eaba1c97ce97
MD5 675591e78ac3dfe5c88847d3b0ac3305
BLAKE2b-256 2606e85e9cc86818fdb7c78f1f01d5615db5c10aa59215491a7b15e9211bd3db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page