8000 Use multi_dot for Hessian and gradient product · scikit-learn/scikit-learn@3b60347 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b60347

Browse files
committed
Use multi_dot for Hessian and gradient product
np.linalg.multi_dot quickly chooses the best order for the multiplication of three matrices. See: https://github.com/numpy/numpy/blob/860c8b82939d1535351f7b651c284a55efe21b10/numpy/linalg/linalg.py#L2742 Changes to be committed:
1 parent 94abe05 commit 3b60347

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sklearn/linear_model/_logistic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _logistic_grad_hess(w, X, y, alpha, sample_weight=None):
233233

234234
def Hs(s):
235235
ret = np.empty_like(s)
236-
ret[:n_features] = X.T.dot(dX.dot(s[:n_features]))
236+
ret[:n_features] = np.linalg.multi_dot(X.T, dX, s[:n_features])
237237
ret[:n_features] += alpha * s[:n_features]
238238

239239
# For the fit intercept case.

0 commit comments

Comments
 (0)
0