ऐसा लगता है कि आपने अपने विशेष उदाहरण में मुद्दा तय कर लिया है, लेकिन मुझे लगता है कि यह अभी भी कम से कम वर्गों और अधिकतम संभावना लॉजिस्टिक प्रतिगमन के बीच के अंतर का अधिक सावधानीपूर्वक अध्ययन करने के लायक है।
चलो कुछ संकेतन मिलता है। Let LS(yi,y^i)=12(yi−y^i)2औरLL(yi,y^i)=yilogy^i+(1−yi)log(1−y^i)। हम अधिक से अधिक संभावना (या के रूप में मैं यहाँ कर रहा हूँ कम से कम नकारात्मक लॉग संभावना) कर रहे हैं, हमारे पास
β एल:=argminख∈पी एन Σ मैंβ^L:=argminb∈Rp−∑i=1nyilogg−1(xTib)+(1−yi)log(1−g−1(xTib))
के साथg हमारे लिंक समारोह किया जा रहा है।
वैकल्पिक रूप से हमारे पास
β एस : = argmin ख ∈ आर पी 1β^S:=argminb∈Rp12∑i=1n(yi−g−1(xTib))2
कम से कम वर्गों समाधान के रूप में। इस प्रकार β एसको कम करता हैएलएसऔर इसी के लिएएलएलβ^SLSLL ।
चलो fS और fL को न्यूनतम करने के लिए इसी उद्देश्य कार्यों हो LS और LL क्रमशः के रूप में के लिए किया जाता है β एसβ^S और β एल । अंत में, चलो ज = जी - 1 तो y मैं = ज ( एक्स टी मैं ख ) । ध्यान दें कि यदि हम विहित लिंक का उपयोग कर रहे हैं तो हमें
h ( z ) = 1 मिला हैβ^Lh=g−1y^i=h(xTib)h(z)=11+e−z⟹h′(z)=h(z)(1−h(z)).
∂fL∂bj=−∑i=1nh′(xTib)xij(yih(xTib)−1−yi1−h(xTib)).
h′=h⋅(1−h)∂fL∂bj=−∑i=1nxij(yi(1−y^i)−(1−yi)y^i)=−∑i=1nxij(yi−y^i)
∇fL(b)=−XT(Y−Y^).
आगे दूसरा डेरिवेटिव करते हैं। हेसियन
HL:=∂2fL∂bj∂bk=∑i=1nxijxiky^i(1−y^i).
HL=XTAXA=diag(Y^(1−Y^))HLY^YHLb
आइए इसकी तुलना कम से कम वर्गों से करें।
∂fS∂bj=−∑i=1n(yi−y^i)h′(xTib)xij.
∇fS(b)=−XTA(Y−Y^).
i y^i(1−y^i)∈(0,1)∇fL
हेसियन के लिए हम पहले लिख सकते हैं
∂fS∂bj=−∑i=1nxij(yi−y^i)y^i(1−y^i)=−∑i=1nxij(yiy^i−(1+yi)y^2i+y^3i).
HS:=∂2fS∂bj∂bk=−∑i=1nxijxikh′(xTib)(yi−2(1+yi)y^i+3y^2i).
Let B=diag(yi−2(1+yi)y^i+3y^2i). We now have
HS=−XTABX.
Unfortunately for us, the weights in B are not guaranteed to be non-negative: if yi=0 then yi−2(1+yi)y^i+3y^2i=y^i(3y^i−2) which is positive iff y^i>23. Similarly, if yi=1 then yi−2(1+yi)y^i+3y^2i=1−4y^i+3y^2i which is positive when y^i<13 (it's also positive for y^i>1 but that's not possible). This means that HS is not necessarily PSD, so not only are we squashing our gradients which will make learning harder, but we've also messed up the convexity of our problem.
All in all, it's no surprise that least squares logistic regression struggles sometimes, and in your example you've got enough fitted values close to 0 or 1 so that y^i(1−y^i) can be pretty small and thus the gradient is quite flattened.
Connecting this to neural networks, even though this is but a humble logistic regression I think with squared loss you're experiencing something like what Goodfellow, Bengio, and Courville are referring to in their Deep Learning book when they write the following:
One recurring theme throughout neural network design is that the gradient of the cost function must be large and predictable enough to serve as a good guide for the learning algorithm. Functions that saturate (become very flat) undermine this objective because they make the gradient become very small. In many cases this happens because the activation functions used to produce the output of the hidden units or the output units saturate. The negative log-likelihood helps to avoid this problem for many models. Many output units involve an exp function that can saturate when its argument is very negative. The log function in the negative log-likelihood cost function undoes the exp of some output units. We will discuss the interaction between the cost function and the choice of output unit in Sec. 6.2.2.
and, in 6.2.2,
Unfortunately, mean squared error and mean absolute error often lead to poor results when used with gradient-based optimization. Some output units that saturate produce very small gradients when combined with these cost functions. This is one reason that the cross-entropy cost function is more popular than mean squared error or mean absolute error, even when it is not necessary to estimate an entire distribution p(y|x).
(both excerpts are from chapter 6).