Buggy code:
public class Trainer { final int length_I ; final int length_H ; final int length_O ; final double learn_factor ; double [ ] errors_H ; double [ ] errors_O ; double [ ] [ ] deltas_I_O ; double [ ] [ ] deltas_H_I ; double [ ] [ ] deltas_H_O ; double [ ] deltas_H_BIAS ; double [ ] deltas_O_BIAS ; Ann ann ; Ann ann_last ; double general_error ; public Trainer ( Ann ann , double learn_factor ) { } private void WeightsGen ( ) { } public void Training ( int training_iterations ) { WeightsGen ( ) ; DataGen datagen = new DataGen ( length_I , Const . SETS , Const . MIN , Const . BINARY ) ; if ( Const . DEBUG ) datagen . PrintDataSet ( ) ; double [ ] [ ] dataset = datagen . GetDataset ( ) ; double last_general_error = Integer . MAX_VALUE ; general_error = 0 ; for ( int i = 0 ; i < training_iterations ; i ++ ) { datagen . Generate ( length_I , SETS , MIN , BINARY ) ; dataset = datagen . GetDataset ( ) ; if ( Const . DEBUG ) System . out . println ( ( ( ( "____________________________ITERATION___" + ( i + 1 ) ) + "<seq2seq4repair_space>of<seq2seq4repair_space>" ) + training_iterations ) ) ; if ( Const . DEBUG ) PrintWeights ( ) ; if ( ( ( Const . ETYPE ) == ( EvalType . EARLY_STOP ) ) && ( ( i % ( Const . RANGE ) ) == 0 ) ) { ann_last = ann ; general_error //= Const . RANGE ; if ( ( general_error ) > last_general_error ) { System . out . println ( "VICTORYYYYYYYY" ) ; System . out . println ( ( "FINISHED<seq2seq4repair_space>IN<seq2seq4repair_space>ITERATION:__<seq2seq4repair_space>" + ( i - 1 ) ) ) ; ann = ann_last ; for ( int j = 0 , max = dataset . length ; j < max ; j ++ ) { FeedForward ( dataset , j ) ; } break ; } else if ( i != 0 ) { last_general_error = general_error ; general_error = 0 ; } } deltas_I_O = new double [ length_I ] [ length_O ] ; deltas_H_I = new double [ length_H ] [ length_I ] ; deltas_H_O = new double [ length_H ] [ length_O ] ; deltas_H_BIAS = new double [ length_H ] ; deltas_O_BIAS = new double [ length_O ] ; double error = 0 ; for ( int j = 0 , max = dataset . length ; j < max ; j ++ ) { FeedForward ( dataset , j ) ; BackPropagation ( ) ; DeltaWeights ( ) ; double current_error = 0 ; if ( Const . DEBUG ) { for ( int k = 0 ; k < 8 ; k ++ ) System . out . println ( ( ( ( "__________________________________________________________INPUTS<seq2seq4repair_space>" + k ) + "_____" ) + ( ann . neurons_I [ k ] ) ) ) ; System . out . println ( "\n" ) ; } for ( int k = 0 ; k < ( length_O ) ; k ++ ) { current_error = ( ExpectedValue ( k ) ) - ( ann . neurons_O [ k ] ) ; error += Math . pow ( current_error , 2 ) ; if ( Const . DEBUG ) { System . out . println ( ( "________________________________________________________EXPECTED_____" + ( ExpectedValue ( k ) ) ) ) ; System . out . println ( ( "__________________________________________________________NEURON_____" + ( ann . neurons_O [ k ] ) ) ) ; System . out . println ( "" ) ; } } } error //= dataset . length ; <START_BUG> general_error += Math . pow ( error , 2 ) ; <END_BUG> if ( Const . DEBUG ) System . out . println ( ( ( "________________________________________________________GLOBAL_ERROR___" + error ) + "\n\n" ) ) ; if ( ( ( Const . ETYPE ) == ( EvalType . FITNESS ) ) && ( error < ( Const . FITNESS ) ) ) { System . out . println ( "VICTORYYYYYYYY" ) ; System . out . println ( ( "FINISHED<seq2seq4repair_space>IN<seq2seq4repair_space>ITERATION:__<seq2seq4repair_space>" + i ) ) ; for ( int j = 0 , max = dataset . length ; j < max ; j ++ ) { FeedForward ( dataset , j ) ; } break ; } WeightsCorrection ( ) ; } if ( ( Const . ETYPE ) == ( EvalType . EARLY_STOP ) ) { for ( int j = 0 , max = dataset . length ; j < max ; j ++ ) { FeedForward ( dataset , j ) ; } } System . out . println ( "END" ) ; } public void FeedForward ( double [ ] [ ] dataset , int dataset_iteration ) { } private void BackPropagation ( ) { } private void DeltaWeights ( ) { } private void WeightsCorrection ( ) { } private double ExpectedValue ( int output ) { } private int ExpectedValue_XOR ( int output ) { } private double ExpectedValue_PacMan ( int output ) { } public Ann GetAnn ( ) { } public double GetError ( ) { } public void PrintNeuronsValues ( int dataset_iteration ) { } public void PrintWeights ( ) { } public void PrintDeltas ( ) { } public static double Sigmoid ( double x ) { } public static double HyperbolicTan ( double x ) { } public static double ArcHyperbolicTan ( double x ) { } }

Fix:
general_error += error ;