@@ -637,16 +637,35 @@ int lvq_nn::recall_class( DATA PTR input,
637637INPUT_LAYER.input_data_from_vector (input,input_dim);
638638recall ();
639639
640- // find which output nodeis best for input vector ( has smallest distance)
640+ // find which output nodewins, i.e is has smallest distance to input vector
641641
642642int current_winner_pe=0 ;
643- int current_winner_pe_rewards=0 ;
644643
645- DATA current_win_output = OUTPUT_LAYER.PE (0 ).output ;// this should be the distance, see lvq_output_layer::recall.
644+ // find at least one output node with requested number of rewards.
645+
646+ if (min_rewards>0 )
647+ {
648+ bool found_rewarded =false ;
649+ for (int i=0 ;i<output_dimension () AND NOT found_rewarded;i++)
650+ {
651+ if (OUTPUT_LAYER.PE (i).misc >= min_rewards)// misc in output PEs is just a counter of rewards given to the PE
652+ {
653+ current_winner_pe = i;
654+ found_rewarded =true ;
655+ }
656+ }
657+ if (NOT found_rewarded)
658+ {
659+ error (NN_METHOD_ERR," No output node has requested number of rewards" );
660+ return (-1 );
661+ }
662+ }
663+
664+ DATA current_win_output = OUTPUT_LAYER.PE (current_winner_pe).output ;// this should be the distance, see lvq_output_layer::recall.
646665
647666for (int i=0 ;i<output_dimension ();i++)
648667{
649- OUTPUT_LAYER.PE (i).bias = LVQ_DEACTI_PE;
668+ OUTPUT_LAYER.PE (i).bias = LVQ_DEACTI_PE;// (is this really necessary?) deactivate all
650669
651670if (OUTPUT_LAYER.PE (i).misc >= min_rewards)// misc in output PEs is just a counter of rewards given to the PE
652671{
@@ -655,7 +674,6 @@ int lvq_nn::recall_class( DATA PTR input,
655674{
656675current_win_output = d;
657676current_winner_pe = i;
658- current_winner_pe_rewards = OUTPUT_LAYER.PE (i).misc ;
659677}
660678}
661679}
@@ -664,12 +682,6 @@ int lvq_nn::recall_class( DATA PTR input,
664682
665683returned_class =
666684(int )(current_winner_pe / m_number_of_output_nodes_per_class);
667-
668- if (current_winner_pe_rewards<min_rewards)
669- {
670- error (NN_METHOD_ERR," No winning output node had required number of rewards" );
671- returned_class = -1 ;
672- }
673685}
674686
675687return returned_class;