@@ -86,7 +86,7 @@ public double feedForward(double[] inputVals) {
8686 output .calcOutput ();
8787
8888 // Return output
89- return output .getOutput ();
89+ return output .output ();
9090 }
9191
9292 public double train (double [] inputs , double answer ) {
@@ -101,11 +101,11 @@ public double train(double[] inputs, double answer) {
101101 // BACKPROPOGATION
102102 // This is easier b/c we just have one output
103103 // Apply Delta to connections between hidden and output
104- ArrayList connections = output .getConnections ();
104+ ArrayList < Connection > connections = output .getConnections ();
105105 for (int i = 0 ; i < connections .size (); i ++) {
106- Connection c = ( Connection ) connections .get (i );
107- Neuron neuron = c .getFrom ();
108- double loutput = neuron .getOutput ();
106+ Connection c = connections .get (i );
107+ Neuron neuron = c .from ();
108+ double loutput = neuron .output ();
109109 double deltaWeight = loutput *deltaOutput ;
110110 c .adjustWeight (LEARNING_CONSTANT *deltaWeight );
111111 }
@@ -116,24 +116,24 @@ public double train(double[] inputs, double answer) {
116116 double sum = 0 ;
117117 // Sum output delta * hidden layer connections (just one output)
118118 for (int j = 0 ; j < connections .size (); j ++) {
119- Connection c = ( Connection ) connections .get (j );
119+ Connection c = connections .get (j );
120120 // Is this a connection from hidden layer to next layer (output)?
121- if (c .getFrom () == hidden1 ) {
122- sum += c .getWeight ()*deltaOutput ;
121+ if (c .from () == hidden1 ) {
122+ sum += c .weight ()*deltaOutput ;
123123 }
124124 }
125125 // Then adjust the weights coming in based:
126126 // Above sum * derivative of sigmoid output function for hidden neurons
127127 for (int j = 0 ; j < connections .size (); j ++) {
128- Connection c = ( Connection ) connections .get (j );
128+ Connection c = connections .get (j );
129129 // Is this a connection from previous layer (input) to hidden layer?
130- if (c .getTo () == hidden1 ) {
131- double loutput = hidden1 .getOutput ();
130+ if (c .to () == hidden1 ) {
131+ double loutput = hidden1 .output ();
132132 double deltaHidden = loutput * (1 - loutput ); // Derivative of sigmoid(x)
133133 deltaHidden *= sum ; // Would sum for all outputs if more than one output
134- Neuron neuron = c .getFrom ();
135- double deltaWeight = neuron .getOutput ()* deltaHidden ;
136- c .adjustWeight (LEARNING_CONSTANT * deltaWeight );
134+ Neuron neuron = c .from ();
135+ double deltaWeight = neuron .output () * deltaHidden ;
136+ c .adjustWeight (LEARNING_CONSTANT * deltaWeight );
137137 }
138138 }
139139 }
0 commit comments