对数损失/二元交叉熵损失
C o s t ( h θ ( x ) , y ) = { − l o g ( h θ ( x ) ) if y=1 − l o g ( 1 − h θ ( x ) ) if y=0 Cost(h_{θ}(x),y)= \begin{cases} -log(h_{θ}(x))& \text{if y=1}\\ -log(1-h_{θ}(x))& \text{if y=0} \end{cases} Cost(hθ(x),y)={−log(hθ(x))−log(1−hθ(x))if y=1if y=0
h
θ
(
x
)
h_{θ}(x)
hθ(x)为y=1时候的概率p.
对于y=1的情况.
h
θ
(
x
)
h_{θ}(x)
hθ(x)越大
−
l
o
g
(
h
θ
(
x
)
)
-log(h_{θ}(x))
−log(hθ(x))越小,Cost值越小.
对于y=0的情况.
h
θ
(
x
)
h_{θ}(x)
hθ(x)越小
−
l
o
g
(
1
−
h
θ
(
x
)
)
-log(1-h_{θ}(x))
−log(1−hθ(x))越小,Cost值越小.