~/projects/mlp-from-scratch-cpp/

MLP From Scratch (C++)

Oct 22, 2022 #deep-learning#cpp#from-scratch

A 2–4–1 MLP trained on XOR in C++ without external libraries, exposing forward propagation and weight updates.

Purpose

This project builds a multilayer perceptron (MLP) in C++ without a deep-learning library and trains it on XOR. The forward pass, sigmoid activation, error, and weight updates are explicit rather than hidden behind a framework. The same learning exercise also has a Python version.

Model and result

The network has two inputs, four hidden neurons, and one output; weights are initialized from a normal distribution. It trains on 80 XOR samples for 5,000 epochs. The README reports a 0.007 learning rate, loss of 0.000108905, and 97.674% accuracy. These describe that run, not general performance.

Why C++?

Avoiding external libraries exposes the mathematics, loops, and data flow. The aim is understanding how a small model learns, not providing a ready neural-network library. The README also avoids claiming advanced C++ efficiency.

← cd ..