# Run ANN my $results = $neural->run_ann($testing_image); # Zero the old differences foreach my $compare_result (keys %training_data) { if exists ($training_data{$compare_result}{diff}) { delete $training_data{$compare_result}{diff}; } } # For every result from the neural net (this will be one result per keypoint) foreach my $result (@$results) { # For every result in the training data (one per image) foreach my $compare_result (keys %training_data) { # Compare each value of the result... foreach my $bit (@$result) { # ...to each value of the known result foreach my $bit2 ($training_data{$compare_result}{output}) { my $diff = abs($bit - $bit2); $training_data{$compare_result}{diff} += $diff; } } } }