为什么L1正则项会产生稀疏解

前端之家收集整理的这篇文章主要介绍了为什么L1正则项会产生稀疏解前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Consider the vector x=(1,ε)R2 where ε>0 is small. The l1 and l2 norms of x ,respectively,are given by

||x|@H_301_287@|1=1+ε,||x||22=1+ε2

Now say that,as part of some regularization procedure,we are going to reduce the magnitude of one of the elements of x by δε . If we change @H_869_502@x1 to 1δ ,the resulting norms are

||x(δ,0)||1=1δ+ε,||x(δ,0)||22=12δ+δ2+ε2

On the other hand,reducing @H_869_502@x2 by δ gives norms

||x(0,δ)||1=1δ+ε,||x(0,δ)||22=12εδ+δ2+ε2

The thing to notice here is that,for an l2 penalty,regularizing the larger term @H_869_502@x1 results in a much greater reduction in norm than doing so to the smaller term x20 . For the l1 penalty,however,the reduction is the same. Thus,when penalizing a model using the l2 @H_403_1320@l_2 norm,it is highly unlikely that anything will ever be set to zero,since the reduction in norm going from ε to 0 is almost nonexistent when ε is small. On the other hand,the reduction in l1 norm is always equal to δ ,regardless of the quantity being penalized.

Another way to think of it: it’s not so much that l1 penalties encourage sparsity,but that l2 penalties in some sense discourage sparsity by yielding diminishing returns as elements are moved closer to zero.

an lα penalty for any α1 will also induce sparsity,but you see those less often in practice (probably because they’re non-convex). If you really just want sparsity then an l0 penalty (proportional to the number of non-zero entries) is the way to go,it just so happens that it’s a bit of a nightmare to work with.

Yes - that’s correct. There are many norms that lead to sparsity (e.g.,as you mentioned,any Lp norm with p <= 1). In general,any norm with a sharp corner at zero induces sparsity. So,going back to the original question - the L1 norm induces sparsity by having a discontinuous gradient at zero (and any other penalty with this property will do so too)

Have a look on figure 3.11 (page 71) of The elements of statistical learning. It shows the position of a unconstrained β^ that minimizes the squared error function,the ellipses showing the levels of the square error function,and where are the β^ subject to constraints @H_404_1716@1(β^)<t and @H_404_1716@2(β^)<t .

This will allow you to understand very geometrically that subject to the 1 constraint,you get some null components. This is basically because the 1 ball {x:1(x)1} has “edges” on the axes.

More generally,this book is a good reference on this subject: both rigorous and well illustrated,great explanations.

I think your second paragraph is a key… at least for my intuition: an l1 “ball” is more like a diamond that’s spikey along the axes,which means that a hyperplane constrained to hit it is more likely to have a zero on the axes.

Yes,I use to imagine the optimization process as the movement of a point submitted to two forces : attraction towards the unconstrained β^ thanks to the squared error function,attraction towards 0 thaks to the 1 or 2 norm. Here,the “geometry” of this attraction force changes the behavior of the point. If you fix a small 1 or 2 ball in which it can freely move,it will slide on the border of the ball,in order to go near to β^ . The result is shown on the illustration in the aforementionned book.

With a sparse model,we think of a model where many of the weights are 0. Let us therefore reason about how L1-regularization is more likely to create 0-weights.

Consider a model consisting of the weights (w1,w2,,wm) .

With L1 regularization,you penalize the model by a loss function @H_93_2301@L1(w) = Σi|wi| .

With L2-regularization,you penalize the model by a loss function @H_301_2405@L2(w) = 12Σi@H_404_2489@w2i

If using gradient descent,you will iteratively make the weights change in the opposite direction of the gradient with a step size η . Let us look at the gradients:

dL1(w)dw=sign(w) ,where sign(w)=(w1|w1|,w1|w1|,,w1|wm|)

dL2(w)dw=w

If we plot the loss function and it’s derivative for a model consisting of just a single parameter,it looks like this for L1:

Notice that for L1 ,the gradient is either 1 or -1,except for when @H_713_3010@@H_539_3013@w@H_59_3019@1=0 . That means that L1-regularization will move any weight towards 0 with the same step size,regardless the weight’s value. In contrast,you can see that the L2 gradient is linearly decreasing towards 0 as the weight goes towards 0. Therefore,L2-regularization will also move any weight towards 0,but it will take smaller and smaller steps as a weight approaches 0.

Try to imagine that you start with a model with w1=5 and using η=12 . In the following picture,you can see how gradient descent using L1-regularization makes 10 of the updates w1:=w1ηdL1(w)dw=w10.51 ,until reaching a model with w1=0 :

In constrast,with L2-regularization where η=12 ,the gradient is @H_899_3404@ w1 ,causing every step to be only halfway towards 0. That is we make the update w1:=w1ηdL1(w)dw=w10.5w1 Therefore,the model never reaches a weight of 0,regardless of how many steps we take:

Note that L2-regularization can make a weight reach zero if the step size η is so high that it reaches zero or beyond in a single step. However,the loss function will also consist of a term measuring the error of the model with the respect to the given weights,and that term will also affect the gradient and hence the change in weights. However,what is shown in this example is just how the two types of regularization contribute to a change in weights.

原文链接:https://www.f2er.com/regex/360072.html

猜你在找的正则表达式相关文章