Skip to content

Update README and prepare for MNIST#13

Merged
oulrich1 merged 4 commits intomasterfrom
claude/readme-mnist-prep-01PdRRTjuyZJdQmb46DSHo6r
Nov 17, 2025
Merged

Update README and prepare for MNIST#13
oulrich1 merged 4 commits intomasterfrom
claude/readme-mnist-prep-01PdRRTjuyZJdQmb46DSHo6r

Conversation

@oulrich1
Copy link
Copy Markdown
Owner

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 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.
@oulrich1 oulrich1 merged commit ff6c77e into master Nov 17, 2025
1 check passed
@oulrich1 oulrich1 deleted the claude/readme-mnist-prep-01PdRRTjuyZJdQmb46DSHo6r branch November 17, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants