Merged
Conversation
Implements complete MNIST dataset loading functionality: - IDX file format parser for MNIST binary files - Image normalization to [0, 1] range - One-hot encoding for labels - Batch and single sample accessors - ASCII visualization utility - Comprehensive test suite - Build system integration (CMake + Makefile) Files added: - mnist_loader.h: Core MNIST loading functionality - test_mnist_loader.cpp: Test suite demonstrating usage - MNIST_README.md: Complete documentation and usage guide This prepares the codebase for MNIST digit classification training.
Implements comprehensive MNIST training capabilities: Loss Functions (loss.h): - Cross-entropy loss for classification - Binary cross-entropy loss - MSE loss - Loss computation and accuracy evaluation utilities Network Enhancements (network.h): - trainBatch() - batch training with gradient accumulation - trainSingle() - single sample training - evaluateLoss() - loss evaluation on datasets - evaluateAccuracy() - classification accuracy measurement - LossType configuration support - Removed duplicate Sigmoid/SigGrad functions MNIST Training Script (train_mnist.cpp): - Complete training pipeline for MNIST digit classification - Architecture: 784→256→128→10 (ReLU + Sigmoid) - Adam optimizer with cross-entropy loss - Batch training with data shuffling - Progress monitoring and visualization - Model checkpointing and saving - Expected 85-92% test accuracy Test Suite (test_mnist_training.cpp): - Network creation and initialization tests - Batch training functionality tests - Accuracy computation validation - Mini MNIST training integration test Build System: - CMake targets for train_mnist and test_mnist_training - Makefile targets: make train_mnist, make run_mnist - Makefile targets: make test_mnist_training, make run_test_mnist_training This enables full MNIST digit classification training with modern techniques (batch training, adaptive optimization, proper loss functions).
- Replace SigGrad with SigmoidGrad in test files - Change int to double in main.cpp tests (normal_distribution requires floating point) - Fixes build errors in test_comprehensive.cpp and test_network.cpp All targets now compile successfully: - NeuralNet, train_mnist, test_mnist_training - All test executables build without errors
Improvements: - Add comprehensive documentation to LossType enum explaining when to use each loss - MSE: Best for regression and simple binary problems (XOR, AND, OR) - CROSS_ENTROPY: Best for multi-class classification (MNIST) - BINARY_CROSS_ENTROPY: Best for binary classification with probabilities Test updates: - XOR test now explicitly uses MSE loss (better for simple problems) - AND gate test now uses MSE loss - OR gate test now uses MSE loss - Linear regression test continues using MSE (appropriate for regression) This allows users to choose the appropriate loss function for their task: - network->setLossType(LossType::MSE); for regression/simple problems - network->setLossType(LossType::CROSS_ENTROPY); for classification (default) Note: MNIST training correctly uses CROSS_ENTROPY for digit classification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements complete MNIST dataset loading functionality:
Files added:
This prepares the codebase for MNIST digit classification training.