神经网络中的正则化


Adding regularization will often help To prevent overfitting problem (high variance problem ).

1. Logistic regression

回忆一下训练时的优化目标函数

minw,bJ(w,b),    wRnx,bR(1-1) (1-1) min w , b J ( w , b ) ,         w ∈ R n x , b ∈ R

其中
J(w,b)=1mi=1mL(y^(i),y(i))(1-2) (1-2) J ( w , b ) = 1 m ∑ i = 1 m L ( y ^ ( i ) , y ( i ) )

L2  regularization L 2     r e g u l a r i z a t i o n (most commonly used):
J(w,b)=1mi=1mL(y^(i),y(i))+λ2mw22(1-3) (1-3) J ( w , b ) = 1 m ∑ i = 1 m L ( y ^ ( i ) , y ( i ) ) + λ 2 m ‖ w ‖ 2 2

其中
w22=j=1nxw2j=wTw(1-4) (1-4) ‖ w ‖ 2 2 = ∑ j = 1 n x w j 2 = w T w

Why do we regularize just the parameter w? Because w Is usually a high dimensional parameter vector while b is A scalar. Almost all The parameters are in w rather than b.
L1  regularization L 1     r e g u l a r i z a t i o n
J(w,b)=1mi=1mL(y^(i),y(i))+λm|w|1(1-5) (1-5) J ( w , b ) = 1 m ∑ i = 1 m L ( y ^ ( i ) , y ( i ) ) + λ m | w | 1

其中
|w|1=jnx|wj|(1-6) (1-6) | w | 1 = ∑ j n x | w j |

w will end up being sparse. In other words the w vector will have a lot of zeros in it. This can help with compressing the model a little.

2. Neural network “Frobenius norm”

J(w[1],b[1],,w[L],b[L])=1mi=1mL(y^(i),y(i))+λ2ml=1Lw22(2-1) (2-1) J ( w [ 1 ] , b [ 1 ] , ⋯ , w [ L ] , b [ L ] ) = 1 m ∑ i = 1 m L ( y ^ ( i ) , y ( i ) ) + λ 2 m ∑ l = 1 L ‖ w ‖ 2 2

其中
w[l]2F=in[l1]jn[l](wij)2(2-2) (2-2) ‖ w [ l ] ‖ F 2 = ∑ i n [ l − 1 ] ∑ j n [ l ] ( w i j ) 2

L2 L 2 regulation is also called Weight decay:
dw[l]wl:=(from backprop)+λmw[l]=w[l]αdw[l]=(1αλm)w[l]α(from backprop)(2-3) (2-3) d w [ l ] = ( f r o m   b a c k p r o p ) + λ m w [ l ] w l : = w [ l ] − α d w [ l ] = ( 1 − α λ m ) w [ l ] − α ( f r o m   b a c k p r o p )

能够防止权重 w w 过大,从而避免过拟合

3. inverted dropout

对于不同的训练样本都可以随机消除一部分结点
反向随机失活(前向和后向都需要dropout):

(3-1)d3=np.random.rand(a3.shape[0],a3.shape[1])<keep.proba3=np.multiply(a3,d3)   #a3d3,element wise multiplicationa3/=keep.prob   #in order to not reduce the expected value of a3  inverted dropoutz[4]=w[4]a[3]+b[4]z[4]/=keep.prob

this inverted dropout technique by dividing by the keep.prob, it ensures that the expected value of a3 remains the same. This makes test time easier because you have less of a scaling problem.
测试时不需要使用drop out

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值