# mathangi18/lab-1 architecture

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

- Interactive diagram: https://gitdiagram.com/mathangi18/lab-1
- Repository: https://github.com/mathangi18/lab-1

## Overview

CM2003 is a NumPy-based image-classification lab: users prepare CIFAR-10 data, train and evaluate classifiers, and study the training/validation workflow. Its runtime includes kNN and linear/Softmax classifiers, a two-layer neural network, reusable layer operations, and optimization utilities. The README describes the learning workflow; source excerpts confirm selected module calls. Unsampled data and feature utilities are included, but their connections are not inferred beyond documented relationships.

Main entry points: [`cm2003/classifiers/linear_classifier.py`](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/linear_classifier.py) (Linear Classifier), [`cm2003/classifiers/fc_net.py`](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/fc_net.py) (Two-Layer Network), [`cm2003/solver.py`](https://github.com/mathangi18/lab-1/blob/main/cm2003/solver.py) (Training Solver), [`cm2003/layer_utils.py`](https://github.com/mathangi18/lab-1/blob/main/cm2003/layer_utils.py) (Layer Compositions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and Features"]
  node_data_utils["Dataset Utilities<br/>[data_utils.py]"]
  node_features["Image Features<br/>[features.py]"]
end

subgraph group_classifiers["Classifiers"]
  node_knn["kNN Classifier"]
  node_linear["Linear Classifier"]
  node_softmax["Softmax Loss<br/>[softmax.py]"]
  node_fcnet["Two-Layer Network<br/>[fc_net.py]"]
end

subgraph group_training["Training and Evaluation"]
  node_solver["Training Solver<br/>[solver.py]"]
  node_optim["Update Rules<br/>[optim.py]"]
end

subgraph group_network["Network Operations"]
  node_layers["Layer Operations<br/>[layers.py]"]
  node_layer_utils["Layer Compositions<br/>[layer_utils.py]"]
end

node_user(("Lab User"))
node_cifar[("CIFAR-10 Dataset")]

node_user -->|"loads data"| node_data_utils
node_cifar -->|"provides batches"| node_data_utils
node_user -->|"trains and predicts"| node_knn
node_user -->|"trains and predicts"| node_linear
node_user -->|"trains network"| node_fcnet
node_user -.->|"extracts features"| node_features
node_linear -->|"imports loss"| node_softmax
node_solver -->|"applies updates"| node_optim
node_fcnet -->|"uses compositions"| node_layer_utils
node_layer_utils -->|"calls primitives"| node_layers
node_user -->|"trains and evaluates"| node_solver

click node_data_utils "https://github.com/mathangi18/lab-1/blob/main/cm2003/data_utils.py"
click node_features "https://github.com/mathangi18/lab-1/blob/main/cm2003/features.py"
click node_knn "https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/k_nearest_neighbor.py"
click node_linear "https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/linear_classifier.py"
click node_softmax "https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/softmax.py"
click node_fcnet "https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/fc_net.py"
click node_solver "https://github.com/mathangi18/lab-1/blob/main/cm2003/solver.py"
click node_optim "https://github.com/mathangi18/lab-1/blob/main/cm2003/optim.py"
click node_layers "https://github.com/mathangi18/lab-1/blob/main/cm2003/layers.py"
click node_layer_utils "https://github.com/mathangi18/lab-1/blob/main/cm2003/layer_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_data_utils,node_features,node_user toneBlue
class node_knn,node_linear,node_softmax,node_fcnet,node_cifar toneAmber
class node_solver,node_optim toneMint
class node_layers,node_layer_utils toneRose
```

## Components

### Data and Features

- [Dataset Utilities](https://github.com/mathangi18/lab-1/blob/main/cm2003/data_utils.py): `cm2003/data_utils.py`
- [Image Features](https://github.com/mathangi18/lab-1/blob/main/cm2003/features.py): `cm2003/features.py`

### Classifiers

- [kNN Classifier](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/k_nearest_neighbor.py): `cm2003/classifiers/k_nearest_neighbor.py`
- [Linear Classifier](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/linear_classifier.py): `cm2003/classifiers/linear_classifier.py`
- [Softmax Loss](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/softmax.py): `cm2003/classifiers/softmax.py`
- [Two-Layer Network](https://github.com/mathangi18/lab-1/blob/main/cm2003/classifiers/fc_net.py): `cm2003/classifiers/fc_net.py`

### Training and Evaluation

- [Training Solver](https://github.com/mathangi18/lab-1/blob/main/cm2003/solver.py): `cm2003/solver.py`
- [Update Rules](https://github.com/mathangi18/lab-1/blob/main/cm2003/optim.py): `cm2003/optim.py`

### Network Operations

- [Layer Operations](https://github.com/mathangi18/lab-1/blob/main/cm2003/layers.py): `cm2003/layers.py`
- [Layer Compositions](https://github.com/mathangi18/lab-1/blob/main/cm2003/layer_utils.py): `cm2003/layer_utils.py`

### Other components

- **Lab User**
- **CIFAR-10 Dataset**

## Connections

- Lab User → Dataset Utilities: loads data (evidence: `README.md`)
- CIFAR-10 Dataset → Dataset Utilities: provides batches (evidence: `README.md`)
- Lab User → kNN Classifier: trains and predicts (evidence: `README.md`)
- Lab User → Linear Classifier: trains and predicts (evidence: `README.md`)
- Lab User → Two-Layer Network: trains network (evidence: `README.md`)
- Lab User → Image Features: extracts features
- Linear Classifier → Softmax Loss: imports loss (evidence: `cm2003/classifiers/linear_classifier.py`)
- Training Solver → Update Rules: applies updates (evidence: `cm2003/solver.py`)
- Two-Layer Network → Layer Compositions: uses compositions (evidence: `cm2003/classifiers/fc_net.py`)
- Layer Compositions → Layer Operations: calls primitives (evidence: `cm2003/layer_utils.py`)
- Lab User → Training Solver: trains and evaluates (evidence: `README.md`)
