File size: 8,229 Bytes
95c13dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# Installation and Usage Guide
## π Quick Start Installation
### Prerequisites
Before installing, ensure you have the following:
- **Operating System**: Windows 10/11 (Linux support coming soon)
- **GPU**: NVIDIA GPU with CUDA Compute Capability 6.0+
- **Memory**: 8GB+ GPU memory, 16GB+ system RAM
- **Storage**: 2GB free space for project and dataset
### Required Software
1. **Visual Studio 2022** (Community Edition or higher)
- Download from: https://visualstudio.microsoft.com/vs/
- Install with "Desktop development with C++" workload
2. **CUDA Toolkit 13.0+**
- Download from: https://developer.nvidia.com/cuda-toolkit
- Install with default settings
- Verify installation: `nvcc --version`
3. **CMake 3.20+**
- Download from: https://cmake.org/download/
- Add to system PATH during installation
- Verify installation: `cmake --version`
4. **Git** (for cloning the repository)
- Download from: https://git-scm.com/
- Install with default settings
## π¦ Installation Steps
### Step 1: Clone the Repository
```bash
git clone https://github.com/franciscoangulo/fashion-mnist-optical-evolution.git
cd fashion-mnist-optical-evolution
```
### Step 2: Download Fashion-MNIST Dataset
Create the dataset directory and download the Fashion-MNIST files:
```bash
mkdir zalando_datasets
cd zalando_datasets
```
Download the following files from https://github.com/zalandoresearch/fashion-mnist:
- `train-images-idx3-ubyte` (Training images)
- `train-labels-idx1-ubyte` (Training labels)
- `t10k-images-idx3-ubyte` (Test images)
- `t10k-labels-idx1-ubyte` (Test labels)
### Step 3: Configure Build Environment
Open **Developer Command Prompt for VS 2022** and navigate to the project directory:
```bash
cd fashion-mnist-optical-evolution
```
Set CUDA environment variables:
```bash
set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0"
set "CUDACXX=%CUDA_PATH%\bin\nvcc.exe"
```
### Step 4: Build the Project
Configure the build with CMake:
```bash
cmake -B build -DCMAKE_BUILD_TYPE=Release
```
Build the project:
```bash
cmake --build build --config Release
```
### Step 5: Verify Installation
Check that the executable was created:
```bash
dir build\Release\fashion_mnist_trainer.exe
```
## πββοΈ Running the Training
### Quick Test (10 epochs)
```bash
build\Release\fashion_mnist_trainer.exe --data_dir zalando_datasets --epochs 10 --batch 256 --lr 5e-4 --fungi 128
```
### Full Training (100 epochs for best results)
Use the optimized training script:
```bash
run_training.bat
```
Or run manually:
```bash
build\Release\fashion_mnist_trainer.exe --data_dir zalando_datasets --epochs 100 --batch 256 --lr 5e-4 --fungi 128
```
## π§ Configuration Options
### Command Line Arguments
| Parameter | Description | Default | Range |
|-----------|-------------|---------|-------|
| `--data_dir` | Path to Fashion-MNIST data | `zalando_datasets` | - |
| `--epochs` | Number of training epochs | `100` | 1-1000 |
| `--batch` | Batch size | `256` | 32-512 |
| `--lr` | Learning rate | `5e-4` | 1e-5 to 1e-2 |
| `--fungi` | Fungi population size | `128` | 32-256 |
| `--wd` | Weight decay | `0` | 0-1e-3 |
| `--seed` | Random seed | `42` | Any integer |
### Performance Tuning
**For Maximum Accuracy (85.86%)**:
```bash
--epochs 100 --batch 256 --lr 5e-4 --fungi 128
```
**For Fast Experimentation**:
```bash
--epochs 10 --batch 512 --lr 1e-3 --fungi 64
```
**For Memory-Constrained GPUs**:
```bash
--epochs 50 --batch 128 --lr 5e-4 --fungi 64
```
## π Expected Output
### Successful Training Session
```
==========================================
Fashion-MNIST Optic Evolution Trainer
==========================================
Multi-Scale Optical Processing
Target: 90%+ Accuracy OPTIMIZED
==========================================
Configuration:
- Architecture: INTELLIGENT ENHANCED FFT (optimized 6-scale mirror = 2058 features)
- Network: 2058 β 1800 β 10 (ReLU activation - BALANCED CAPACITY)
- Epochs: 100
- Batch Size: 256
- Learning Rate: 5e-4
- Fungi Population: 128
========== TRAINING STARTED ==========
[Epoch 1] Train Loss: 1.234, Test Accuracy: 78.45%
[Epoch 10] Train Loss: 0.567, Test Accuracy: 82.14%
[Epoch 30] Train Loss: 0.398, Test Accuracy: 84.23%
[Epoch 60] Train Loss: 0.298, Test Accuracy: 85.86%
Dead Neurons: 87.6% | Saturated: 6.3% | Active: 6.1%
========== TRAINING COMPLETED SUCCESSFULLY ==========
Target: 90%+ accuracy (INTELLIGENT ENHANCED FFT: optimized solution)
```
### Performance Metrics
The training will display:
- **Epoch Progress**: Loss and accuracy per epoch
- **Neural Health**: Dead/saturated/active neuron percentages
- **Bottleneck Detection**: Real-time performance analysis
- **Final Accuracy**: Best test accuracy achieved
## π Troubleshooting
### Common Issues and Solutions
**1. CUDA Not Found**
```
Error: CUDA compiler not found
```
**Solution**: Verify CUDA installation and environment variables:
```bash
nvcc --version
set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0
```
**2. GPU Memory Error**
```
Error: Out of memory
```
**Solution**: Reduce batch size:
```bash
--batch 128
```
**3. Dataset Not Found**
```
Error: Cannot load Fashion-MNIST data
```
**Solution**: Verify dataset files in `zalando_datasets/`:
- `train-images-idx3-ubyte`
- `train-labels-idx1-ubyte`
- `t10k-images-idx3-ubyte`
- `t10k-labels-idx1-ubyte`
**4. Build Errors**
```
Error: Cannot find CUDA compiler
```
**Solution**: Use Developer Command Prompt for VS 2022 and set CUDA path:
```bash
set "CUDACXX=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\nvcc.exe"
```
**5. Low Performance**
```
Accuracy stuck at ~75%
```
**Solution**: Ensure you're using the optimized parameters:
```bash
--lr 5e-4 --fungi 128 --epochs 100
```
### Debug Mode
Enable detailed debugging information:
```bash
build\Release\fashion_mnist_trainer.exe --data_dir zalando_datasets --epochs 10 --batch 256 --lr 5e-4 --fungi 128 --verbose
```
### Log Files
Training logs are automatically saved to:
- `training_log.txt` - Epoch-by-epoch progress
- `error_log.txt` - Error messages and debugging info
## π¬ Advanced Usage
### Custom Fungi Evolution
Modify fungi parameters in `src/fungi_Parameters.hpp`:
```cpp
struct EvoParams {
float food = 0.05f; // Reward scale
float decay = 0.98f; // Energy decay
float death_th = -0.5f; // Death threshold
float cost = 5e-4f; // Metabolic cost
};
```
### Architecture Modifications
Adjust network size in `src/optical_model.hpp`:
```cpp
constexpr int HIDDEN_SIZE = 1800; // Hidden layer neurons
constexpr int MULTISCALE_SIZE = 2058; // Feature dimensions
```
### Performance Profiling
Use NVIDIA Nsight for detailed GPU profiling:
```bash
nsys profile build\Release\fashion_mnist_trainer.exe --data_dir zalando_datasets --epochs 5
```
## π Benchmarking
### Reproducible Results
For exact reproduction of 85.86% accuracy:
```bash
build\Release\fashion_mnist_trainer.exe --data_dir zalando_datasets --epochs 100 --batch 256 --lr 5e-4 --fungi 128 --seed 42
```
### Performance Validation
Expected performance on RTX 3080:
- Training Time: ~2 hours for 100 epochs
- GPU Memory Usage: ~6GB
- CPU Usage: ~30%
- Final Accuracy: 85.86% Β± 0.3%
## π Next Steps
After successful installation:
1. **Run Quick Test**: Verify 10-epoch training works
2. **Full Training**: Run 100 epochs for best results
3. **Experiment**: Try different hyperparameters
4. **Contribute**: Submit improvements via GitHub
5. **Research**: Explore optical computing applications
## π Support
For installation issues:
- **GitHub Issues**: https://github.com/franciscoangulo/fashion-mnist-optical-evolution/issues
- **Documentation**: See `README.md` and `PAPER.md`
- **Community**: Join optical computing discussions
---
*Ready to explore the future of optical neural networks!* π¬β¨ |