How limsr12/nn works
Project type and purpose
• This is a small neural‐network classification project with two implementations:
• A C implementation (train_model.c / test_model.c) that reads raw MNIST image data, trains an MLP, saves weights, and evaluates accuracy.
• A Python implementation (python/mnist_mlp.py, python/mnist_mlp_image.py) for experimentation and image‐based inference.
• The goal is to recognize handwritten digits (0–9) using a multi‐layer perceptron (MLP).
File structure
Top level
• README.md – project overview (in Korean)
• .gitignore
• python/ – Python scripts for training/inference
• src/ – C source code, raw data archive, metadata files
Inside src/
• mnist_raw.zip – zipped training/testing folders with per‐digit images
• train_model.c – C training program
• test_model.c – C testing program
• meta_h1.txt, meta_h2.txt, meta_h3.txt – learned weight files for 1/2/3 hidden‐layer configurations
README for additional insights
• Architecture: Input layer (784 nodes), 1–3 hidden layers, output layer (10 nodes)
• Activation: Sigmoid / Softmax; Loss: Cross‐entropy or MSE; Optimizer: gradient descent + backprop
• Hyperparams: 40 epochs, batch size=1, learning rate fixed, random weight init in [–0.5,+0.5]
Main components
a. Data Sources
• Raw MNIST images (training / testing folders)
b. C‐based Training Module
• train_model.c
• Reads raw data → forward/backprop → outputs weight files (meta_h*.txt)
c. Weight Repository
• Persistent storage of meta_h1.txt, meta_h2.txt, meta_h3.txt
d. C‐based Testing Module
• test_model.c
• Loads weight files + testing images → computes accuracy metrics
e. Python MLP Modules (parallel path)
• mnist_mlp.py – pure‐Python training/inference loop using NumPy
• mnist_mlp_image.py – loads user‐provided images for classification
f. CLI / User Interface
• Command‐line invocation of C programs or Python scripts
g. Configuration
• Hyperparameter settings hard‐coded in source or passed as args
Relationships and data flows
• Parallel path: Raw MNIST Data → Python Training Module → Python‐based weight objects (in memory or disk) → Python Inference Module
• That both C and Python share the same data source but produce/use distinct weight outputs
Architectural patterns and principles
• Pipeline pattern: Data ingestion → Processing (train/test) → Storage → Reporting
• Separation of concerns: training vs. inference, C vs. Python implementations
• Configurability: different hidden‐layer depths via separate metadata files
Relevant technologies & frameworks
• C standard library for file I/O, math routines
• Python 3 + NumPy (assumed) for matrix ops / visualization
• No external services; purely local compute & disk storage