How shujanislam/vehicleneuralnetwork works
Project Type & Purpose
• Type: Command-line, single-process C++ feedforward neural-network tool
• Purpose: Classify input sentences as “Car” or “Bike” using a tiny neural net
• Key Characteristics:
– No client/server layers
– Modular separation of data loading, model training, and inference
File Structure
• main.cpp
– Entry point; handles user I/O and orchestrates the pipeline
• headers/DataSet.hpp
– Loads and preprocesses training data; maps words to indices/weights
• headers/TrainModel.hpp
– Implements the feedforward + weight-update logic for training
• headers/DetectType.hpp
– Runs the trained network in inference mode to predict Car vs. Bike
Core Components & Responsibilities
• CLI Module (main.cpp)
– Reads user sentences
– Calls DataSet to build or refresh word-weight maps
– Triggers TrainModel (optional or on first run)
– Invokes DetectType for each new input
– Displays prediction to console
• DataSet Module
– Vocabulary management
– Example-sentence loading & vectorization
– Interface: getFeatureVector(sentence)
• TrainModel Module
– Network topology: input layer (words) → hidden layer (2 neurons × 2 categories) → output layer
– Weight matrices & bias vectors
– Forward pass + simple gradient updates
– Interface: train(featureMatrix, labels) → weightStore
• DetectType Module
– Uses stored weights for feedforward inference
– Returns category with highest activation
Relationships & Data Flow
• Sequence:
1. User enters sentence → main.cpp
2. main.cpp → DataSet: preprocess & vectorize
3. main.cpp → DetectType: feed vector through network
4. DetectType → output label back to main.cpp
• Training (one-time or on demand):
1. main.cpp → DataSet: load training examples
2. main.cpp → TrainModel: compute & store weights
3. TrainModel → persistent in-memory store (could be file in future)
Architectural Patterns & Design Principles
• Single responsibility per module (I/O vs. data vs. training vs. inference)
• Layered structure within the neural network (input → hidden → output)
• Minimal external dependencies—pure C++ STL