My object-oriented NN
The Main file is in neuralNet package
-
Setting up the neuralNet
Datensatz training2 = new Datensatz("training2"):- via
addDatenpunktone can add a(new Datenpunkt(x, y, tester)which has two double values and a boolean label
- via
int[] nodesInHiddenLayer = { 3,5 }:- is setting 3 nodes in first hidden layer and 5 nodes in second (not counting input/output layer)
- two loops,
jfor epoch andifor going through the Datapoints
-
Sequence of Methods during each Datapoint processing
NeuralNet nn = new NeuralNet(nodesInHiddenLayer.length, nodesInHiddenLayer, training2):- The creating nn instance: Dataset
training2with point 1 is set for InputNeurons (x,y)
- The creating nn instance: Dataset
nn.allCompute(): Run Forward Propagation via recursive "Neuron" methodcompute()for neurons in output layernn.setLosses():this.lsfct = new LossFunction(NeuronLayer nl, Datenpunkt): instance will have first backpropagation errors for output neurons in a HashMap- The recursive
backCompute(LossFunction ls)"Neuron" method: starts with instances ofInputNeuronand will backpropagate the error component, saving it in a double for the relevant Neurons
nn.updateAllLayersWeights(): this will use the Neuron instance variableerrorto update the weights in itsHashMap<Neuron, Double> neurolistof Neurons (as keys) acting as Input to the nodenn.nextPoint(): iterator for the Dataset of instanceDatensatz(set within the nn instance) will point to the next elementDatenpunktas datapoint to continue the process in the next loop