private void applyL1Reg ( final double eta_t , Vec x ) { //apply l1 regularization if ( lambda1 > 0 ) { l1U += eta_t * lambda1 ; //line 6: in Tsuruoka et al paper, figure 2 for ( int k = 0 ; k < ws . length ; k ++ ) { final Vec w_k = ws [ k ] ; final double [ ] l1Q_k = l1Q [ k ] ; for ( IndexValue iv : x ) { final int i = iv . getIndex ( ) ; //see "APPLYPENALTY(i)" on line 15: from Figure 2 in Tsuruoka et al paper final double z = w_k . get ( i ) ; double newW_i = 0 ; if ( z > 0 ) newW_i = Math . max ( 0 , z - ( l1U + l1Q_k [ i ] ) ) ; else if ( z < 0 ) newW_i = Math . min ( 0 , z + ( l1U - l1Q_k [ i ] ) ) ; l1Q_k [ i ] += ( newW_i - z ) ; w_k . set ( i , newW_i ) ; } } } }
Applies L1 regularization to the model