@@ -149,10 +149,13 @@ private boolean convert() {
149149 }
150150
151151
152+ public static final int DIRECT = 0 ;
153+ public static final int RECURRENT = 1 ;
154+ public static final int POSITIVE = 0 ;
155+ public static final int NEGATIVE = 1 ;
156+
152157 private void initInputNodesAndComputeWeightSums () {
153- double negDirSumDelta = 0.0 ;
154- double negRecSumDelta = 0.0 ;
155- double posRecSumDelta = 0.0 ;
158+ double [][] sumDelta = new double [2 ][2 ];
156159 double maxRecurrentSumDelta = 0.0 ;
157160
158161 for (Synapse s : modifiedSynapses ) {
@@ -171,35 +174,19 @@ private void initInputNodesAndComputeWeightSums() {
171174 neuron .provider .setModified ();
172175 }
173176
174- if (s .isNegative ()) {
175- if (!s .key .isRecurrent ) {
176- negDirSumDelta -= s .w ;
177- } else {
178- negRecSumDelta -= s .w ;
179- }
180- } else if (s .key .isRecurrent ) {
181- posRecSumDelta -= s .w ;
182- }
183-
184- if (s .nw <= 0.0 ) {
185- if (!s .key .isRecurrent ) {
186- negDirSumDelta += s .nw ;
187- } else {
188- negRecSumDelta += s .nw ;
189- }
190- } else if (s .key .isRecurrent ) {
191- posRecSumDelta += s .nw ;
192- }
177+ sumDelta [s .key .isRecurrent ? RECURRENT : DIRECT ][s .isNegative () ? NEGATIVE : POSITIVE ] -= s .w ;
178+ sumDelta [s .key .isRecurrent ? RECURRENT : DIRECT ][s .nw <= 0.0 ? NEGATIVE : POSITIVE ] += s .nw ;
193179
194180 s .w = s .nw ;
195181
196182 in .lock .releaseWriteLock ();
197183 }
198184
199185 neuron .maxRecurrentSum += maxRecurrentSumDelta ;
200- neuron .negDirSum += negDirSumDelta ;
201- neuron .negRecSum += negRecSumDelta ;
202- neuron .posRecSum += posRecSumDelta ;
186+ neuron .posDirSum += sumDelta [DIRECT ][POSITIVE ];
187+ neuron .negDirSum += sumDelta [DIRECT ][NEGATIVE ];
188+ neuron .negRecSum += sumDelta [RECURRENT ][NEGATIVE ];
189+ neuron .posRecSum += sumDelta [RECURRENT ][POSITIVE ];
203190 }
204191
205192
0 commit comments