-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC benchmark_utils/__init__.py (#38)
Co-authored-by: mathurinm <[email protected]>
- Loading branch information
1 parent
9c6c32f
commit cebcb6b
Showing
2 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
# `benchmark_utils` is a module in which you can define code to reuse in | ||
# the benchmark objective, datasets, and solvers. The folder should have the | ||
# name `benchmark_utils`, and code defined inside will be importable using | ||
# the usual import syntax | ||
# the usual import syntax. To import external packages in this file, use a | ||
# `safe_import_context` named "import_ctx", as follows: | ||
|
||
from benchopt.utils import safe_import_context | ||
|
||
with safe_import_context() as import_ctx: | ||
import numpy as np | ||
|
||
|
||
def gradient_ols(X, y, beta): | ||
return X.T @ (X @ beta - y) | ||
|
||
|
||
def value_ols(X, y, beta): | ||
return 0.5 * np.mean((y - X @ beta) ** 2) |
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