Examples#
The best way to learn is by doing! microgradpp comes with some really cool examples to get your hands dirty.
Building the Examples#
First, make sure you build with examples enabled:
cd build
cmake -DBUILD_EXAMPLES=ON .. && make
cd examplesMulti-Layer Perceptron (MLP)#
The mlp.cpp example trains a simple multi-layer perceptron. Run it like this:
./example_mlpThis runs training for 50 iterations and you'll see the loss decrease over time as the network learns. It's a great starting point for understanding how the training loop works.
The MLP example is the perfect first stop if you're new to neural networks. It's simple, fast, and you can see results immediately!
Computer Vision Example 🐕#
This one's a fan favorite! The images.cpp example trains a neural network to learn a German Shepherd puppy face using OpenCV integration.
./example_imagesWatch as the network progressively reconstructs the image from scratch — it's honestly mesmerizing.
You'll need OpenCV installed on your system to run the computer vision example. Make sure it's available before building!
Exploring on Your Own#
All examples live in the examples/ directory. Feel free to poke around, modify them, and use them as templates for your own projects.
examples/
├── mlp.cpp # Multi-layer perceptron training
├── images.cpp # Computer vision with OpenCV
└── ... # More examples coming soon!The examples are intentionally kept simple and well-commented. They're a great resource for understanding how all the pieces fit together.