-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tc/precomputed vars #19
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…stuff if not needed
1f5125f
to
02430d5
Compare
f1bb621
to
cc90e83
Compare
@fschlimb This merge is implicated for breakage affecting sklearn patches (#15). Specifically, the following script # d4py_log_loss.py
import numpy as np
import daal4py
def getFPType(X):
dt = getattr(X, 'dtype', None)
if dt == np.double:
return "double"
elif dt == np.single:
return "float"
else:
raise ValueError("Input array has unexpected dtype = {}".format(dt))
def make2d(X):
if np.isscalar(X):
X = np.asarray(X)[np.newaxis, np.newaxis]
elif isinstance(X, np.ndarray) and X.ndim == 1:
X = X.reshape((X.size, 1))
return X
def _resultsToCompute_string(value=True, gradient=True, hessian=False):
results_needed = []
if value:
results_needed.append('value')
if gradient:
results_needed.append('gradient')
if hessian:
results_needed.append('hessian')
return '|'.join(results_needed)
def _daal4py_logistic_loss_extra_args(
nClasses_unused, beta, X, y, l1=0.0, l2=0.0, fit_intercept=True,
value=True, gradient=True, hessian=False):
X = make2d(X)
nSamples, nFeatures = X.shape
y = make2d(y)
beta = make2d(beta)
n = X.shape[0]
results_to_compute = _resultsToCompute_string(value=value,
gradient=gradient, hessian=hessian)
objective_function_algorithm_instance = daal4py.optimization_solver_logistic_loss(
numberOfTerms = n,
fptype = getFPType(X),
method = 'defaultDense',
interceptFlag = fit_intercept,
penaltyL1 = l1 / n,
penaltyL2 = l2 / n,
resultsToCompute = results_to_compute
)
objective_function_algorithm_instance.setup(X, y, beta)
return (objective_function_algorithm_instance, X, y, n)
def _daal4py_loss_and_grad(beta, objF_instance, X, y, n):
beta_ = make2d(beta)
res = objF_instance.compute(X, y, beta_)
gr = res.gradientIdx
if gr is None:
print(X)
print(y)
print(beta_)
gr *= n
v = res.valueIdx
v *= n
return (v, gr)
if __name__ == '__main__':
X, Y1 = np.array([[-1, 0], [0, 1], [1, 1]], dtype=np.double), np.array([0, 1, 1], np.double)
X = X[-1:]
y = Y1[-1:]
beta = np.zeros(3, dtype=np.double)
objF, X2d, y2d, n = _daal4py_logistic_loss_extra_args(
1, beta, X, y, l1=0.0, l2=1.,
value=True, gradient=True, hessian=False)
_daal4py_loss_and_grad(beta, objF, X2d, y2d, n) runs fine in daal4py built from 2133108, but fails with an error in package built from 08f1301. Specifically, |
Vika-F
pushed a commit
to Vika-F/scikit-learn-intelex
that referenced
this pull request
Apr 4, 2024
Extension of benchmark parameters and output
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.