# berndprach/1lipschitzlayerscompared architecture

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

- Interactive diagram: https://gitdiagram.com/berndprach/1lipschitzlayerscompared
- Repository: https://github.com/berndprach/1lipschitzlayerscompared

## Overview

This repository compares 1-Lipschitz neural-network layers through configured training runs, hyperparameter search, and measurements of accuracy, speed, memory, and Lipschitz bounds. The principal workflow is to define or generate settings, load datasets and construct a model, train and record metrics, then select hyperparameters and train final models. It also exposes reusable layers and pretrained models. Training internals are only partly sampled, so links not established by the excerpts or README are omitted; documented capabilities with unsampled implementations are represented at their known paths.

Main entry points: [`trainer/train_module.py`](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/trainer/train_module.py) (Training loop), [`train.py`](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/train.py) (Training command), [`make_tree.py`](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/make_tree.py) (Run settings), [`eval_best_lr_wd.py`](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/eval_best_lr_wd.py) (Best hyperparameters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Experiment setup"]
  node_make_tree["Run settings<br/>[make_tree.py]"]
  node_parser["Settings parser<br/>[setting_parser.py]"]
  node_epoch_budget["Epoch estimator"]
end

subgraph group_runtime["Model and training"]
  node_train_entry["Training command<br/>[train.py]"]
  node_trainer["Training loop<br/>[train_module.py]"]
  node_datasets["Datasets and loaders"]
  node_metrics["Training metrics"]
end

subgraph group_analysis["Evaluation and results"]
  node_statistics["Run statistics"]
  node_run_results["Run artifacts<br/>[read_results.py]"]
  node_best_lr["Best hyperparameters<br/>[eval_best_lr_wd.py]"]
  node_robust_eval["Robust accuracy<br/>[robust_accuracy.py]"]
  node_lip_eval["Lipschitz analysis"]
  node_batch_eval["Batch timing<br/>[batch_times.py]"]
  node_memory_eval["Memory measurement<br/>[memory_usage.py]"]
end

subgraph group_library["Reusable models"]
  node_models["Classifier models"]
  node_lipnn["LipConvNet<br/>[lip_conv_net.py]"]
  node_layers["1-Lipschitz layers"]
  node_hub["Pretrained models<br/>[hubconf.py]"]
end

node_user(("Researcher"))
node_torchhub(("Torch Hub"))

node_user -->|"generates settings"| node_make_tree
node_user -->|"estimates epochs"| node_epoch_budget
node_user -->|"starts runs"| node_train_entry
node_make_tree -->|"writes configuration"| node_parser
node_train_entry -->|"loads settings"| node_parser
node_train_entry -->|"starts training"| node_trainer
node_trainer -->|"gets loaders"| node_datasets
node_trainer -->|"trains model"| node_models
node_trainer -->|"evaluates batches"| node_metrics
node_trainer -->|"records metrics"| node_statistics
node_models -->|"uses layers"| node_layers
node_lipnn -->|"uses layers"| node_layers
node_trainer -->|"bounds Lipschitz"| node_lip_eval
node_run_results -->|"reads run data"| node_statistics
node_best_lr -->|"selects run metrics"| node_run_results
node_best_lr -->|"supplies hyperparameters"| node_make_tree
node_user -->|"evaluates robustness"| node_robust_eval
node_user -->|"measures speed"| node_batch_eval
node_user -->|"measures memory"| node_memory_eval
node_torchhub -->|"loads models"| node_hub
node_hub -->|"constructs models"| node_lipnn

click node_make_tree "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/make_tree.py"
click node_parser "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/parsers/setting_parser.py"
click node_epoch_budget "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/epoch_budget_estimator.py"
click node_train_entry "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/train.py"
click node_trainer "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/trainer/train_module.py"
click node_datasets "https://github.com/berndprach/1lipschitzlayerscompared/tree/main/datasets"
click node_models "https://github.com/berndprach/1lipschitzlayerscompared/tree/main/models"
click node_lipnn "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/lipnn/lip_conv_net.py"
click node_layers "https://github.com/berndprach/1lipschitzlayerscompared/tree/main/models/layers/lipschitz"
click node_metrics "https://github.com/berndprach/1lipschitzlayerscompared/tree/main/trainer/metrics"
click node_statistics "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/statistics/statistics_handler.py"
click node_run_results "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/results/read_results.py"
click node_best_lr "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/eval_best_lr_wd.py"
click node_robust_eval "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/robust_accuracy.py"
click node_lip_eval "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/lipschitz_constant.py"
click node_batch_eval "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/batch_times.py"
click node_memory_eval "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/memory_usage.py"
click node_hub "https://github.com/berndprach/1lipschitzlayerscompared/blob/main/hubconf.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_make_tree,node_parser,node_epoch_budget toneBlue
class node_train_entry,node_trainer,node_datasets,node_metrics toneAmber
class node_statistics,node_run_results,node_best_lr,node_robust_eval,node_lip_eval,node_batch_eval,node_memory_eval toneMint
class node_models,node_lipnn,node_layers,node_hub toneRose
class node_user,node_torchhub toneIndigo
```

## Components

### Experiment setup

- [Run settings](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/make_tree.py): `make_tree.py`
- [Settings parser](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/parsers/setting_parser.py): `utils/parsers/setting_parser.py`
- [Epoch estimator](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/epoch_budget_estimator.py): `epoch_budget_estimator.py`

### Model and training

- [Training command](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/train.py): `train.py`
- [Training loop](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/trainer/train_module.py): `trainer/train_module.py`
- [Datasets and loaders](https://github.com/berndprach/1lipschitzlayerscompared/tree/main/datasets): `datasets`
- [Training metrics](https://github.com/berndprach/1lipschitzlayerscompared/tree/main/trainer/metrics): `trainer/metrics`

### Evaluation and results

- [Run statistics](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/statistics/statistics_handler.py): `utils/statistics/statistics_handler.py`
- [Run artifacts](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/utils/results/read_results.py): `utils/results/read_results.py`
- [Best hyperparameters](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/eval_best_lr_wd.py): `eval_best_lr_wd.py`
- [Robust accuracy](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/robust_accuracy.py): `evaluator/robust_accuracy.py`
- [Lipschitz analysis](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/lipschitz_constant.py): `evaluator/lipschitz_constant.py`
- [Batch timing](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/batch_times.py): `evaluator/batch_times.py`
- [Memory measurement](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/evaluator/memory_usage.py): `evaluator/memory_usage.py`

### Reusable models

- [Classifier models](https://github.com/berndprach/1lipschitzlayerscompared/tree/main/models): `models`
- [LipConvNet](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/lipnn/lip_conv_net.py): `lipnn/lip_conv_net.py`
- [1-Lipschitz layers](https://github.com/berndprach/1lipschitzlayerscompared/tree/main/models/layers/lipschitz): `models/layers/lipschitz`
- [Pretrained models](https://github.com/berndprach/1lipschitzlayerscompared/blob/main/hubconf.py): `hubconf.py`

### Other components

- **Researcher**
- **Torch Hub**

## Connections

- Researcher → Run settings: generates settings
- Researcher → Epoch estimator: estimates epochs
- Researcher → Training command: starts runs
- Run settings → Settings parser: writes configuration
- Training command → Settings parser: loads settings
- Training command → Training loop: starts training
- Training loop → Datasets and loaders: gets loaders
- Training loop → Classifier models: trains model
- Training loop → Training metrics: evaluates batches
- Training loop → Run statistics: records metrics
- Classifier models → 1-Lipschitz layers: uses layers
- LipConvNet → 1-Lipschitz layers: uses layers
- Training loop → Lipschitz analysis: bounds Lipschitz
- Run artifacts → Run statistics: reads run data
- Best hyperparameters → Run artifacts: selects run metrics
- Best hyperparameters → Run settings: supplies hyperparameters
- Researcher → Robust accuracy: evaluates robustness
- Researcher → Batch timing: measures speed
- Researcher → Memory measurement: measures memory
- Torch Hub → Pretrained models: loads models
- Pretrained models → LipConvNet: constructs models
