r/C_Programming • u/Huge-Visual1472 • Jun 26 '26
Project Experimental neural network (multilayer perceptron) in C.
Name: Owaineur.
The goal was to create a compact neural network with a text interface that could learn and execute simple linear and nonlinear tasks. Not in Python, but in pure C using basic libraries. It only works with numbers in the range from -1 to 1. The first version has 5 inputs, 5 hidden neurons, and 5 output neurons. A total of about 50 weights and 10 biases. I tested it, and I can say that it can indeed learn and execute certain tasks, although it's certainly a long way from ChatGPT. I described it in more detail on GitHub. Generally, I've always had trouble creating neural networks, so the code is a bit clunky and hacky, but it works.
•
u/AutoModerator Jun 26 '26
Hi /u/Huge-Visual1472,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/TituxDev Jun 27 '26
Building a feedforward net in C from scratch is exactly how I started learning this too — same motivation, just want to see what's actually happening underneath without a framework hiding it.
On the small network question: they're often more capable than they look when the problem fits the architecture. I have an example where a single hidden layer with just 3 neurons learns all 16 two-input logic functions simultaneously, including XOR and XNOR — here if you're curious: https://github.com/TituxDev/NeuroTIC/blob/main/examples/logic_gates.c
That same from-scratch path eventually turned into a full library: https://github.com/TituxDev/NeuroTIC
1
u/Syedirfan4adi Jun 27 '26
hey man what exactly does it do? sorry i am new to this
2
u/Subject-Mobile-6250 Jun 27 '26
love this, if you have any spare time on your hands you can hand calculate backprop gradients for GD. maybe can add a few more layers like BN etc but looks great!
1
u/JEEZUS-CRIPES Jun 27 '26
Nice, thanks for sharing
1
u/swe__wannabe Jun 28 '26
Cool! Check mine out which has a drawing tool: https://www.reddit.com/r/C_Programming/comments/1r5mod0/feedforward_neural_network_in_pure_c99_no_libs_no/
1
u/Anode1_dev Aug 04 '26
This was my 1997 uni thesis. I implemented backprop from my thesis math in K&R C (later moved to C99),
and made many extensions including architecture search through GA (published a paper recently)
https://github.com/Anode1/SMBPANN
0
u/No_Highlight_3857 Jun 27 '26
What kind of tasks can a 50 neuron network possibly execute? I think you did not describe this properly.