TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #24954 23
Building a Deep learning framework in C++ (from scratch) - training MNIST as a milestone

i am building a deep learning framework called "Forge" completely from scratch in C++, its nowhere near complete yet, training MNIST Classifier shows a functional core on CPU (i'll add a CUDA backend too). My end goal is to train a modern transformer on Forge.

YT video of MNIST training :- www.youtube.com/watch?v=CalrXYYmpfc

this video shows:

\-> training an MLP on MNIST
\-> loss decreasing over epochs
\-> predictions vs ground truth

this stable training proves that the following components are working correctly:-

\--> Tensor system (it uses Eigen as math backend, but i'll handcraft the math backend/kernels for CUDA later) and CPU memory allocator.
\--> autodiff engine (computation graph is being built and traversed correctly)
\-->primitives -- linear layer, relu activation (Forge has sigmoid, softmax, gelu, tanh and leakyrelu too), CrossEntropy loss function (it fuses log softmax and CE. Forge has MSE and BinaryCrossEntropy too, the BCE fuses sigmoid and BCE) and SGD optimizer (i am planning to add momentum in SGD, Adam and AdamW)

[the Forge repo on GitHub is currently private as its WAP\]
My GitHub: github.com/muchlakshay

https://redd.it/1silamh
@r_cpp
YouTube I built a Deep Learning Framework in C++ - training MNIST on it. i am building a deep learning framework called "Forge" completely from scratch in C++, its nowhere near complete yet, this video just shows a functional core on CPU (i'll add a CUDA backend too) by training an MNIST classifier. My end goal is to train a modern…
More from @r_cpp
  1. Oct 6, 2026Why do people on Windows mostly choose Visual Studio? https://redd.it/1weku08 @r_cpp
  2. Oct 6, 2026Jonas Persson: Making every byte count https://youtu.be/GbwrztrY4kc https://redd.it/1wf1l3…
  3. Oct 6, 2026It annoys me that coroutines are described as "functions that can be suspended" Any functi…
  4. Oct 6, 2026==2896379== logger no timeout configured, using default 1000 ms ==2896379== ==2896379== HE…
  5. Oct 6, 2026No, -Wall -Werror Does Not Guarantee Detection of Conditionally Uninitialized Local Variab…
  6. Oct 6, 2026C++20 modules support: 228 projects already available to be consumed Hello everyone. I che…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →