# ahmadrezafarvardin/resnet18-cifar10 architecture

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

## Overview

This repository trains a CIFAR-10 image classifier and supports checkpoint resume, standalone evaluation with per-class accuracy, and plotting saved training history. The main workflow is CLI → Trainer: load augmented data, run training and test evaluation through the CIFAR-adapted ResNet-18, then save model state and metrics. Standalone evaluation loads the best model and reports class-level results. Relationships reflect the sampled Python entry points; the README describes an interactive notebook, but its implementation was not sampled.

Main entry points: [`train.py`](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py) (Trainer), [`evaluate.py`](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/evaluate.py) (Evaluation CLI), [`main.py`](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/main.py) (Training CLI), [`model.py`](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py) (ResNet-18)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training workflow"]
  node_main["Training CLI<br/>[main.py]"]
  node_trainer["Trainer<br/>[train.py]"]
  node_epoch_train["Epoch training<br/>[train.py]"]
  node_epoch_eval["Epoch validation<br/>[train.py]"]
  node_data["CIFAR loaders<br/>[data.py]"]
end

subgraph group_network["Model architecture"]
  node_model_factory["ResNet factory<br/>[model.py]"]
  node_resnet["ResNet-18<br/>[model.py]"]
  node_block["Residual blocks<br/>[model.py]"]
end

subgraph group_evaluation["Evaluation and plots"]
  node_evaluate_cli["Evaluation CLI<br/>[evaluate.py]"]
  node_full_eval["Class analysis<br/>[evaluate.py]"]
  node_plots["Result plots<br/>[utils.py]"]
end

subgraph group_state["Configuration and state"]
  node_config["Hyperparameters<br/>[config.py]"]
  node_utils["Training utilities<br/>[utils.py]"]
  node_checkpoint[("Checkpoint files")]
  node_history[("Training history")]
end

node_user(("CLI user"))
node_cifar[("CIFAR-10")]

node_user -->|"runs"| node_main
node_main -->|"reads settings"| node_config
node_main -->|"starts training"| node_trainer
node_main -->|"plots history"| node_plots
node_trainer -->|"reads settings"| node_config
node_trainer -->|"seeds and checkpoints"| node_utils
node_trainer -->|"gets loaders"| node_data
node_data -->|"loads"| node_cifar
node_trainer -->|"creates model"| node_model_factory
node_model_factory -->|"constructs"| node_resnet
node_resnet -->|"builds stages"| node_block
node_trainer -->|"runs each epoch"| node_epoch_train
node_trainer -->|"validates each epoch"| node_epoch_eval
node_epoch_train -->|"forwards batches"| node_resnet
node_epoch_eval -->|"forwards batches"| node_resnet
node_trainer -->|"saves and resumes"| node_checkpoint
node_utils -->|"reads and writes"| node_checkpoint
node_trainer -->|"writes metrics"| node_history
node_main -->|"loads history"| node_history
node_user -->|"runs"| node_evaluate_cli
node_evaluate_cli -->|"reads settings"| node_config
node_evaluate_cli -->|"creates model"| node_model_factory
node_evaluate_cli -->|"loads best weights"| node_checkpoint
node_evaluate_cli -->|"gets test loader"| node_data
node_evaluate_cli -->|"runs analysis"| node_full_eval
node_full_eval -->|"predicts batches"| node_resnet
node_evaluate_cli -->|"plots class accuracy"| node_plots

click node_main "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/main.py"
click node_trainer "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py"
click node_epoch_train "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py"
click node_epoch_eval "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py"
click node_data "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/data.py"
click node_model_factory "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py"
click node_resnet "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py"
click node_block "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py"
click node_config "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/config.py"
click node_utils "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/utils.py"
click node_checkpoint "https://github.com/ahmadrezafarvardin/resnet18-cifar10/tree/main/checkpoints"
click node_history "https://github.com/ahmadrezafarvardin/resnet18-cifar10/tree/main/results"
click node_evaluate_cli "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/evaluate.py"
click node_full_eval "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/evaluate.py"
click node_plots "https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/utils.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_main,node_trainer,node_epoch_train,node_epoch_eval,node_data,node_user toneBlue
class node_model_factory,node_resnet,node_block,node_cifar toneAmber
class node_evaluate_cli,node_full_eval,node_plots toneMint
class node_config,node_utils,node_checkpoint,node_history toneRose
```

## Components

### Training workflow

- [Training CLI](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/main.py): `main.py`
- [Trainer](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py): `train.py`
- [Epoch training](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py): `train.py`
- [Epoch validation](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/train.py): `train.py`
- [CIFAR loaders](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/data.py): `data.py`

### Model architecture

- [ResNet factory](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py): `model.py`
- [ResNet-18](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py): `model.py`
- [Residual blocks](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/model.py): `model.py`

### Evaluation and plots

- [Evaluation CLI](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/evaluate.py): `evaluate.py`
- [Class analysis](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/evaluate.py): `evaluate.py`
- [Result plots](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/utils.py): `utils.py`

### Configuration and state

- [Hyperparameters](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/config.py): `config.py`
- [Training utilities](https://github.com/ahmadrezafarvardin/resnet18-cifar10/blob/main/utils.py): `utils.py`
- [Checkpoint files](https://github.com/ahmadrezafarvardin/resnet18-cifar10/tree/main/checkpoints): `checkpoints`
- [Training history](https://github.com/ahmadrezafarvardin/resnet18-cifar10/tree/main/results): `results`

### Other components

- **CLI user**
- **CIFAR-10**

## Connections

- CLI user → Training CLI: runs
- Training CLI → Hyperparameters: reads settings
- Training CLI → Trainer: starts training
- Training CLI → Result plots: plots history
- Trainer → Hyperparameters: reads settings
- Trainer → Training utilities: seeds and checkpoints
- Trainer → CIFAR loaders: gets loaders
- CIFAR loaders → CIFAR-10: loads
- Trainer → ResNet factory: creates model
- ResNet factory → ResNet-18: constructs
- ResNet-18 → Residual blocks: builds stages
- Trainer → Epoch training: runs each epoch
- Trainer → Epoch validation: validates each epoch
- Epoch training → ResNet-18: forwards batches
- Epoch validation → ResNet-18: forwards batches
- Trainer → Checkpoint files: saves and resumes
- Training utilities → Checkpoint files: reads and writes
- Trainer → Training history: writes metrics
- Training CLI → Training history: loads history
- CLI user → Evaluation CLI: runs
- Evaluation CLI → Hyperparameters: reads settings
- Evaluation CLI → ResNet factory: creates model
- Evaluation CLI → Checkpoint files: loads best weights
- Evaluation CLI → CIFAR loaders: gets test loader
- Evaluation CLI → Class analysis: runs analysis
- Class analysis → ResNet-18: predicts batches
- Evaluation CLI → Result plots: plots class accuracy
