# benjimayonez/invertible-scattering-transform architecture

> Architecture diagram of the GitHub repository benjimayonez/invertible-scattering-transform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benjimayonez/invertible-scattering-transform
- Repository: https://github.com/benjimayonez/invertible-scattering-transform

## Overview

##### Main Components
- Core Library (kymatio-main/kymatio): This is the heart of the project where modifications are made. Mark components such as:
– The core modules in “scattering1d”, “scattering2d”, and “scattering3d” (with a specific focus on scattering2d where the invertibleScattering2d function is added).
– Backend modules (e.g., jax_backend, numpy_backend, tensorflow_backend, torch_backend, and torch_skcuda_backend) that offer support for multiple computation frameworks.
– Frontend modules within each scattering dimension (providing simple entry points into the scattering functionality).

- Examples (kymatio-main/examples): This folder demonstrates how the new invertible scattering functionality is used:
– 2D examples (e.g., “plot_scattering_frequencies.py”, “long_mnist_classify_torch.py”, “cifar_torch.py”) to validate the functionality with visualization and classification.
– 1D and 3D examples providing context and additional use cases.

- Texture Reconstruction (texture_reconstruction): A separate module that uses the invertible scattering transform (specifically the 2D function) to perform texture reconstruction. It’s important to show how output from the scattering module flows into this component.

##### Interactions and Data Flow
- That the input flows into one of the frontend wrappers (e.g., the tensorflow_frontend, torch_frontend, etc.), which then route the data to the appropriate backend (e.g., numpy_backend, torch_backend, etc.). Indicate that the backend and frontend layers work together to compute both the standard and invertible scattering transforms.
– One path leads to the examples demonstrating classification and plotting.
– The other path flows into the texture reconstruction module where the scattering coefficients are used to recreate textures.
- A node for “Tests” which interacts with core libraries—validating backend consistency across frameworks (as seen in tests/general and tests/scattering{1d,2d,3d}) ensuring that selected transformations meet expected norms.

##### Architectural Patterns and Design Principles
- Modular design pattern: the clear separation between the core scattering implementation (splitting into backend and frontend layers) and the application examples.
- Extension pattern: the project builds upon the Kymatio library by adding additional functionality (invertibility) without overhauling the original API.
- External dependencies such as various deep learning/numerical libraries (PyTorch, TensorFlow, JAX, and NumPy) which are referenced through the backend modules.
- Continuous integration and deployment (CI/CD) aspects via configuration files (see the .github workflows and Jenkinsfile).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Input Data"]:::input

    subgraph "Compute Framework"
        F["Scattering Frontend"]:::frontend
        B["Backend Modules"]:::backend
    end

    subgraph "Core Library"
        C1["Scattering Core"]:::core
        S1["scattering1d"]:::module
        S2["scattering2d (Invertible)"]:::module
        S3["scattering3d"]:::module
    end

    subgraph "Application Examples"
        E["Classification Examples"]:::example
        T["Texture Reconstruction"]:::example
        V["Visualization (Coefficients Plot)"]:::output
    end

    Tests["Tests"]:::test
    CICD["CI/CD & Build Scripts"]:::cicd

    A --> F
    F --> B
    B --> C1

    C1 --> S1
    C1 --> S2
    C1 --> S3

    C1 --> E
    C1 --> T
    C1 --> V

    Tests --> C1
    CICD --> C1

    click S1 "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/kymatio/scattering1d"
    click S2 "https://github.com/benjimayonez/invertible-scattering-transform/blob/main/kymatio-main/kymatio/scattering2d/core/scattering2d.py"
    click S3 "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/kymatio/scattering3d"
    click B "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/kymatio/backend"
    click F "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/kymatio/scattering2d/frontend"
    click E "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/examples/2d"
    click T "https://github.com/benjimayonez/invertible-scattering-transform/blob/main/texture_reconstruction/ScatteringTextureReconstruct.py"
    click V "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/coefficients_plot"
    click Tests "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/tests"
    click CICD "https://github.com/benjimayonez/invertible-scattering-transform/tree/main/kymatio-main/.github/workflows"

    classDef input fill:#fceabb,stroke:#e88d67,stroke-width:2px;
    classDef frontend fill:#cfe2f3,stroke:#6fa8dc,stroke-width:2px;
    classDef backend fill:#d9ead3,stroke:#93c47d,stroke-width:2px;
    classDef core fill:#fad7a0,stroke:#f1c232,stroke-width:2px;
    classDef module fill:#f9cb9c,stroke:#e69138,stroke-width:2px;
    classDef example fill:#ead1dc,stroke:#dd7e6b,stroke-width:2px;
    classDef output fill:#d0e0e3,stroke:#6d9eeb,stroke-width:2px;
    classDef test fill:#c9daf8,stroke:#3c78d8,stroke-width:2px;
    classDef cicd fill:#f4cccc,stroke:#c00,stroke-width:2px;
```
