# zhangzm0128/dvt architecture

> Architecture diagram of the GitHub repository zhangzm0128/dvt, 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/zhangzm0128/dvt
- Repository: https://github.com/zhangzm0128/dvt

## Overview

##### Main Components
- Configurations: The “configs” directory (e.g., DVT_cifar10.json) holds settings that customize the training or test modes.
- Execution Layer: The main scripts (main.py, train.py, test.py) serve as entry points. They parse command-line arguments, load configurations, and invoke training or testing routines.
- Network/Model Architecture: The “network” directory contains key modules such as the Vision Transformer (vision_transformer.py), core neural network logic (network.py), loss functions (loss.py), and additional modules like SPT for specialized operations.
- Utilities: The “utils” folder includes helper modules for data augmentation (data_aug.py), data loading (dataloader.py), logging (logger.py), and miscellaneous utility functions.
- Logs: The “logs” directory serves as a repository for runtime logs and experiment outputs.
- External Dependencies: Built on PyTorch and inspired by dendritic learning and Vision Transformers.

##### Relationships and Interactions
- The configuration files (configs/) feed into the main scripts (main.py) which control whether the application runs in train or test mode.
- During training, main.py uses the utility modules (utils/) to prepare the data and logs progress, while the actual model operations (forward/backward passes) are managed by modules in the network directory.
- The network modules interact with each other: the vision_transformer.py module is central to defining the transformer-based architecture, while network.py and net_utils.py might combine various building blocks. The loss function in loss.py captures the model’s performance during training.
- The overall data and control flow moves from config parameters to data loading (via utils/dataloader.py and utils/data_aug.py), then to the network for feature extraction and prediction, and finally to logging/metrics (via utils/logger.py) which are stored in logs/.

##### Important Architectural Patterns
- Clear Separation of Concerns: Configurations, model definitions, and utility functions are maintained in distinct directories.
- Modular Design: The network builds on the idea of modular components (e.g., independent vision transformer, dendritic learning modules, and loss computation).
- Reusability and Extensibility: Utility modules and separate network components allow for easy modifications, testing, and extension of the model’s capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configurations Layer
    subgraph "Configurations"
        Config("Configurations"):::config
    end

    %% Execution Layer
    subgraph "Execution Layer"
        MainScript("Main Script (main.py)"):::execute
        TrainScript("Training Script (train.py)"):::execute
        TestScript("Testing Script (test.py)"):::execute
    end

    %% Utilities Layer
    subgraph "Utilities"
        DataAug("Data Augmentation"):::utility
        DataLoader("Data Loader"):::utility
        LoggerMod("Logging Module"):::utility
        UtilsMod("Utility Functions"):::utility
    end

    %% Model & Network Layer
    subgraph "Model & Network"
        VTMod("Vision Transformer Module"):::network
        NetworkCore("Network Core (network.py)"):::network
        LossFunc("Loss Function (loss.py)"):::network
        SPTMod("SPT Module"):::network
        NetUtils("Network Utils"):::network
    end

    %% Logging Output
    subgraph "Logging"
        LogsDir("Logs Directory"):::logs
    end

    %% External Dependencies
    subgraph "External Dependencies"
        ExternalDep("PyTorch & GPU"):::external
    end

    %% Connections between layers
    Config -->|"loads"| MainScript

    MainScript -->|"uses"| DataAug
    MainScript -->|"uses"| DataLoader

    TrainScript -->|"triggers"| VTMod
    TestScript -->|"triggers"| VTMod

    DataAug -->|"preps"| VTMod
    DataLoader -->|"preps"| VTMod

    VTMod -->|"incorporates"| NetworkCore
    VTMod -->|"incorporates"| SPTMod
    VTMod -->|"incorporates"| NetUtils
    NetworkCore -->|"computes"| LossFunc

    ExternalDep -->|"supports"| VTMod

    LossFunc -->|"logs"| LoggerMod
    UtilsMod -->|"assists"| LoggerMod

    LoggerMod -->|"writes"| LogsDir

    %% Click Events for component mappings
    click Config "https://github.com/zhangzm0128/dvt/blob/main/configs/DVT_cifar10.json"
    click MainScript "https://github.com/zhangzm0128/dvt/blob/main/main.py"
    click TrainScript "https://github.com/zhangzm0128/dvt/blob/main/train.py"
    click TestScript "https://github.com/zhangzm0128/dvt/blob/main/test.py"
    click VTMod "https://github.com/zhangzm0128/dvt/blob/main/network/vision_transformer.py"
    click NetworkCore "https://github.com/zhangzm0128/dvt/blob/main/network/network.py"
    click LossFunc "https://github.com/zhangzm0128/dvt/blob/main/network/loss.py"
    click SPTMod "https://github.com/zhangzm0128/dvt/blob/main/network/SPT.py"
    click NetUtils "https://github.com/zhangzm0128/dvt/blob/main/network/net_utils.py"
    click DataAug "https://github.com/zhangzm0128/dvt/blob/main/utils/data_aug.py"
    click DataLoader "https://github.com/zhangzm0128/dvt/blob/main/utils/dataloader.py"
    click LoggerMod "https://github.com/zhangzm0128/dvt/blob/main/utils/logger.py"
    click UtilsMod "https://github.com/zhangzm0128/dvt/blob/main/utils/utils.py"
    click LogsDir "https://github.com/zhangzm0128/dvt/blob/main/logs/README.md"

    %% Styles
    classDef config fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef execute fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef network fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef utility fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef logs fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#DA70D6,stroke:#000,stroke-width:2px;
```
