深度学习与PyTorch笔记17

Logistic Regression

regression一般指连续的。
interpret network as f : x → p ( y ∣ x ; θ ) f:x\to p(y|x;\theta) f:xp(yx;θ)其中, y = 1 y=1 y=1 θ = [ w , b ] \theta=[w,b] θ=[w,b]
使用sigmoid函数
output ∈ [ 0 , 1 ] \in[0,1] [0,1]
which is exactly what logistic function comes in!

For regression:
Goal: p r e d = y pred=y pred=y
Approach:minimize d i s t ( p r e d , y ) dist(pred,y) dist(pred,y)最小距离,使用一范数或者二范数的平方。

For classification:
Goal:maximize benchmark,e.g.accuracy
p θ ( y ∣ x ) p_{\theta}(y|x) pθ(yx) θ \theta θ参数上的分布, p r ( y ∣ x ) ) p_{r}(y|x)) pr(yx))为真实的分布,希望两个数越近越好。
Approach1:minimize d i s t ( C , p r ( y ∣ x ) ) dist(C,p_{r}(y|x)) dist(C,pr(yx))
Approach2:minimize d i v e r g e n c e ( p θ ( y ∣ x ) , p r ( y ∣ x ) ) divergence(p_{\theta}(y|x),p_{r}(y|x)) divergence(pθ(yx),pr(yx))

Q1.why not maximize accuracy?

为什么classification中train的目标和最终test的目标不一样?也就是为什么不能直接maximize accuracy?
a c c . = ∑ I ( p r e d i = = y i ) l e n ( Y ) acc.=\frac{\sum I(pred_{i}==y_{i})}{len(Y)} acc.=len(Y)I(predi==yi)
直接的maximize accuracy会有两个问题:
issues 1.gradient=0 if accuracy unchanged but weights changed
结果是非0即1的,概率大于0.5为1,小于0.5为0,若一个本该划为1的情况,w在计算中为0.4,w可能会发生由0.4到0.45的改变而并没有改变最终结果,结果仍为0,分类错误。
issues 2.gradient not continuous since the number of correct is not continuous
也有可能会出现从0.499到0.501的改变,w只改变了0.002,但结果发生了很大的变化,变得不连续。

Q2.why call logistic regression?

1.logistic,use sigmoid
2.controversial!
MSE=>regression
Cross Entropy=>classifiication

Multi-class classification

f : x → p ( y ∣ x ) f:x\to p(y|x) f:xp(yx)
[ p ( y = 0 ∣ x ) , p ( y = 1 ∣ x ) , . . . , p ( y = 9 ∣ x ) ] [p(y=0|x),p(y=1|x),...,p(y=9|x)] [p(y=0x),p(y=1x),...,p(y=9x)]
p ( y ∣ x ) ∈ [ 0 , 1 ] p(y|x)\in[0,1] p(yx)[0,1]
∑ i = 0 9 p ( y = i ∣ x ) = 1 \sum^{9}_{i=0}p(y=i|x)=1 i=09p(y=ix)=1使用softmax

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值