Go Back

Node Network

I made this program mainly as a way to demonstrate c++ knowledge. The program is a class-based implementation of a neural network with InputNodes, InternalNodes, OuputNodes, and NodeNetworks. InputNodes are simply a wrapper for a double. InternalNodes contain references to all of their inputs, as well as weights for each input. The internal node then uses the inputs, each input's weight, and a sigmoid function to calcuate its value. Output nodes are the same as internal nodes, except they also contain a string denoting which output they represent. Node networks contain layers of nodes, where each layer inputs from the layer before it. The first layer is made of input nodes and the last lay is made of output nodes. The node networks also contain functions to learn from input data. The network accepts a list of values to be passed to the first lay of input nodes, as well as what the output should be. For each internal or output node weight, the network calcuates what the final ouput would be for: 1) the weight as it is now 2) the weight if it was slightly increased and 3) the weight if it was slightly decreased. Whichever one of the 3 weights produces an output closest to the expected output will become the new vale for that weight. By slowly adjusting weights to fit the expected output, the network changes its state better predict the desired output from the given input. The code shows the trival example of adding two binary bits. The example network starts with 2 input nodes and 4 output nodes. After being given 100 datasets to train on, the network goes from producing random outputs to consistently producing the desired outputs.