# vietnh1009/very-deep-cnn-pytorch architecture

> Architecture diagram of the GitHub repository vietnh1009/very-deep-cnn-pytorch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vietnh1009/very-deep-cnn-pytorch
- Repository: https://github.com/vietnh1009/very-deep-cnn-pytorch

## Overview

##### Project type and purpose
- This is a research‐oriented machine-learning training pipeline implemented in PyTorch.
- It implements the “Very Deep Convolutional Networks for Text Classification” (VDCNN) model, orchestrates data loading, model construction, training loops, logging, and visualization for multiple text‐classification datasets.

##### File structure
- Top level:
- train.py – entry point / CLI for training
- src/ – core Python modules
– dataset.py: Dataset loading and batching
– utils.py: shared utilities (e.g., text preprocessing, tokenization)
– very_deep_cnn.py: definition of the VDCNN model architectures (depth 9, 17, 29, 49)
- input/ – raw datasets (CSV & metadata)
- output/ – per‐experiment log directories (loss/accuracy metrics, confusion matrices in logs.txt)
- tensorboard/ – TensorBoard event files per run
- visualization/ – pre‐rendered accuracy/loss plots
- README.md & LICENSE

- Patterns & configuration:
- CLI pattern (train.py parses arguments: dataset name, depth, optimizer, input/output paths)
- Modular separation: dataset loader, model definition, training loop, logging
- Standard PyTorch training architecture

##### README for additional insights
- Describes supported datasets, hyperparameter settings (SGD/Adam, learning rates)
- Usage examples for training on standard & custom datasets
- Directory conventions for logs and TensorBoard

a. Data Layer
- Input storage (input/* CSVs)
- Dataset Loader (src/dataset.py) – reads CSV → token sequences → batches

b. Model Layer
- VDCNN model definitions (src/very_deep_cnn.py)
- Configurable depth parameter (9, 17, 29, 49)

c. Training Controller
- train.py – CLI
- Builds DataLoader + Model + Optimizer + Scheduler
- Training Loop: forward → loss → backward → update

d. Logging & Monitoring
- File logging (output/<dataset>_depth_<n>/logs.txt)
- TensorBoard writer (tensorboard/vdcnn_<depth>_<dataset>/events.*)

e. Visualization
- Static plots in visualization/ (PNG output of training/test curves)

f. External/Infrastructure
- GPU accelerator (NVIDIA Titan X / Quadro)
- Python environment with PyTorch

##### Relationships and data flows
- Training Loop drives compute on GPU → produces metrics
- Metrics branch to (a) File Logger and (b) TensorBoard Writer
- After training, Visualization scripts read logs/TensorBoard events → generate PNGs

##### Architectural patterns & design principles
- Separation of concerns: data loading vs. model definition vs. training orchestration
- Pluggable model depth and optimizer via CLI arguments
- Logging abstraction: unified interfaces for text files and TensorBoard
- Reproducibility: directory structure isolates each experiment

##### Don’t overthink—maximize clarity
- Break out each logical component
- How CLI arguments configure the pipeline
- Clearly distinguish experiment artifacts from core modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    inputStorage(["Input CSVs"]):::data
    datasetLoader["Dataset Loader\n(src/dataset.py)"]:::data
    utils["Utils\n(src/utils.py)"]:::data
    cli["CLI Entrypoint / Trainer\n(train.py)"]:::compute
    model["VDCNN Model Definitions\n(src/very_deep_cnn.py)"]:::compute
    gpu["GPU Accelerator"]:::external
    fileLogger["File Logger\n(output/*/logs.txt)"]:::logging
    tensorEvents["TensorBoard Events\n(tensorboard/.../events.*)"]:::logging
    visualizer["Static Plots\n(visualization/)"]:::viz
    docs["README.md & LICENSE"]:::external

    inputStorage --> datasetLoader
    utils --> datasetLoader
    datasetLoader --> cli
    cli --> model
    cli --> gpu
    model --> gpu
    cli -->|"metrics (loss/accuracy)"| fileLogger
    cli -->|"metrics (loss/accuracy)"| tensorEvents
    fileLogger --> visualizer
    tensorEvents --> visualizer

    click inputStorage "https://github.com/vietnh1009/very-deep-cnn-pytorch/tree/master/input/"
    click datasetLoader "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/src/dataset.py"
    click utils "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/src/utils.py"
    click cli "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/train.py"
    click model "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/src/very_deep_cnn.py"
    click fileLogger "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/output/ag_news_depth_17/logs.txt"
    click tensorEvents "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/tensorboard/vdcnn_<depth>_<dataset>/events.out.tfevents.*"
    click visualizer "https://github.com/vietnh1009/very-deep-cnn-pytorch/tree/master/visualization/"
    click docs "https://github.com/vietnh1009/very-deep-cnn-pytorch/blob/master/README.md"

    classDef data fill:#cce5ff,stroke:#6699cc,stroke-width:1px
    classDef compute fill:#d4edda,stroke:#4cae4c,stroke-width:1px
    classDef logging fill:#ffe5b4,stroke:#ff9933,stroke-width:1px
    classDef viz fill:#e6ccff,stroke:#9966cc,stroke-width:1px
    classDef external fill:#f0f0f0,stroke:#cccccc,stroke-width:1px
```
