# liguge/pydsn architecture

> Architecture diagram of the GitHub repository liguge/pydsn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/liguge/pydsn
- Repository: https://github.com/liguge/pydsn

## Overview

This repository contains only a small PyTorch loss module, not the full pyDSN diagnosis system described in the README. The module computes entropy, cyclostationarity, kurtosis, and spectrogram-quality metrics; no callers or training pipeline are present. The documented workflow is signal-to-MDSTFT-to-transfer diagnosis, with balanced spectrum quality guiding model optimization, but those implementation relationships are documented rather than visible in source. Thus the graph separates the available loss implementation from the README-described system.

Main entry points: [`loss.py`](https://github.com/liguge/pydsn/blob/main/loss.py) (Spectrum quality loss)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_signals(("Bearing signals"))
node_mdstft["Modulated STFT"]
node_pydsn["Transfer network"]
node_diagnosis["Fault diagnosis"]
node_spectrum_quality["Spectrum quality loss<br/>[loss.py]"]
node_other_losses["Other loss metrics<br/>[loss.py]"]

node_signals -->|"transforms"| node_mdstft
node_mdstft -->|"provides spectra"| node_pydsn
node_pydsn -->|"predicts faults"| node_diagnosis
node_spectrum_quality -->|"guides optimization"| node_mdstft
node_spectrum_quality -->|"regularizes"| node_pydsn

click node_spectrum_quality "https://github.com/liguge/pydsn/blob/main/loss.py"
click node_other_losses "https://github.com/liguge/pydsn/blob/main/loss.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_signals,node_mdstft,node_pydsn,node_diagnosis toneIndigo
class node_spectrum_quality,node_other_losses toneTeal
```

## Components

### Other components

- **Bearing signals**
- **Modulated STFT**
- **Transfer network**
- **Fault diagnosis**
- [Spectrum quality loss](https://github.com/liguge/pydsn/blob/main/loss.py): `loss.py`
- [Other loss metrics](https://github.com/liguge/pydsn/blob/main/loss.py): `loss.py`

## Connections

- Bearing signals → Modulated STFT: transforms (evidence: `README.md`)
- Modulated STFT → Transfer network: provides spectra (evidence: `README.md`)
- Transfer network → Fault diagnosis: predicts faults (evidence: `README.md`)
- Spectrum quality loss → Modulated STFT: guides optimization (evidence: `README.md`)
- Spectrum quality loss → Transfer network: regularizes (evidence: `README.md`)
