The following is the original C program you provided. After it we explain where the JS differs.
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
srand(31);
int best=0;
int memspace[3]={2,4,1};
int memspacel=0;
int nodel=0;
int nodenum=sizeof(memspace);
double node[nodenum];
for(int memspacelc=0;memspacelcbest){
best=node[6];
std::cout<
Mapping notes (what changed)
1) The original code used ad-hoc arrays memspace, weight, and a loop that combined random inputs and random weight tweaks (hillclimbing). The JS implementation replaces that with a proper layered neural network (class Network) supporting any number of layers and neurons per layer.
2) You asked for backpropagation. The C code does not implement backprop; it only mutates weights when a better scalar node[6] is found. The JS implements forward + backward (gradient descent with optional L2) and trains on a supervised mapping: (x,y) → pixel intensity.
3) Image support: the JS loads an image, rescales it to the configured width/height and uses pixel values as targets. The original used random input values.
4) Biases, activation choices, learning rate, batch size and L2 regularization are exposed as parameters in the UI.
5) The network weight initialization uses a seeded random generator similar in spirit to srand(31).
6) The original program returned weight[4] at the end — not meaningful for JS. The page instead lets you export weights as JSON.
Scroll inside the code area above to view the full original C program. Use the controls to configure layers, load an image and run training. The reconstruction canvas shows the network's predicted grayscale values after each training step.