public static < K > void updateWeights ( double l2 , double learningRate , Map < K , Double > weights , Map < K , Double > newWeights ) { if ( l2 > 0.0 ) { for ( Map . Entry < K , Double > e : weights . entrySet ( ) ) { K column = e . getKey ( ) ; newWeights . put ( column , newWeights . get ( column ) + l2 * e . getValue ( ) * ( - learningRate ) ) ; } } }
Updates the weights by applying the L2 regularization .