-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jungtaekkim/0.1.4
0.1.4
- Loading branch information
Showing
75 changed files
with
539 additions
and
157 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 |
---|---|---|
|
@@ -129,6 +129,6 @@ dmypy.json | |
.pyre/ | ||
|
||
# Jungtaek | ||
*.swp | ||
.DS_Store | ||
__MACOSX/ | ||
*.swp |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ python: | |
- "3.6" | ||
- "3.7" | ||
- "3.8" | ||
- "3.9" | ||
install: | ||
- pip install . | ||
script: | ||
|
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
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,2 +1,2 @@ | ||
include LICENSE | ||
include requirements.txt | ||
include LICENSE |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ Benchmarks for Bayesian optimization. | |
The details of benchmark functions can be found in [these notes](http://jungtaek.github.io/notes/benchmarks_bo.pdf). | ||
|
||
## Installation | ||
We recommend it should be installed in `virtualenv`. | ||
We recommend installing it with `virtualenv`. | ||
You can choose one of three installation options. | ||
|
||
* Using PyPI repository (for user installation) | ||
|
@@ -51,7 +51,7 @@ The following `requirements` files include the package list, the purpose of whic | |
* `requirements-dev.txt`: It is for developing the `bayeso-benchmarks` package. | ||
|
||
## Author | ||
* [Jungtaek Kim](http://mlg.postech.ac.kr/~jtkim/) (POSTECH) | ||
* [Jungtaek Kim](http://jungtaek.github.io) (POSTECH) | ||
|
||
## Contact | ||
* Jungtaek Kim: [[email protected]](mailto:[email protected]) | ||
|
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
# last updated: November 5, 2020 | ||
# | ||
|
||
__version__ = '0.1.3' | ||
__version__ = '0.1.4' |
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,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
@@ -9,7 +9,7 @@ | |
|
||
|
||
class Function(object): | ||
def __init__(self, dimensionality, bounds, global_minimizers, global_minimum, function, dim_problem=None): | ||
def __init__(self, dimensionality, bounds, global_minimizers, global_minimum, function, dim_problem=None, seed=None): | ||
assert isinstance(dimensionality, int) or dimensionality is np.inf | ||
assert isinstance(bounds, np.ndarray) | ||
assert isinstance(global_minimizers, np.ndarray) | ||
|
@@ -27,6 +27,7 @@ def __init__(self, dimensionality, bounds, global_minimizers, global_minimum, fu | |
self._function = function | ||
|
||
self.dim_problem = dim_problem | ||
self.random_state = np.random.RandomState(seed) | ||
|
||
self.validate_properties() | ||
|
||
|
@@ -70,7 +71,7 @@ def function(self, bx): | |
|
||
return self._function(bx) | ||
|
||
def output(self, X): | ||
def _output(self, X): | ||
assert isinstance(X, np.ndarray) | ||
|
||
if len(X.shape) == 2: | ||
|
@@ -79,22 +80,20 @@ def output(self, X): | |
list_results = [self.function(X)] | ||
|
||
by = np.array(list_results) | ||
return by | ||
|
||
def output(self, X): | ||
by = self._output(X) | ||
Y = np.expand_dims(by, axis=1) | ||
|
||
assert len(Y.shape) == 2 | ||
assert Y.shape[1] == 1 | ||
return Y | ||
|
||
def output_constant_noise(self, X, scale_noise=0.01): | ||
assert isinstance(X, np.ndarray) | ||
assert isinstance(scale_noise, float) | ||
|
||
if len(X.shape) == 2: | ||
list_results = [self.function(bx) for bx in X] | ||
else: | ||
list_results = [self.function(X)] | ||
|
||
by = np.array(list_results) | ||
by = self._output(X) | ||
by += scale_noise | ||
|
||
Y = np.expand_dims(by, axis=1) | ||
|
@@ -104,16 +103,10 @@ def output_constant_noise(self, X, scale_noise=0.01): | |
return Y | ||
|
||
def output_gaussian_noise(self, X, scale_noise=0.01): | ||
assert isinstance(X, np.ndarray) | ||
assert isinstance(scale_noise, float) | ||
|
||
if len(X.shape) == 2: | ||
list_results = [self.function(bx) for bx in X] | ||
else: | ||
list_results = [self.function(X)] | ||
|
||
by = np.array(list_results) | ||
by += scale_noise * np.random.randn(by.shape[0]) | ||
by = self._output(X) | ||
by += scale_noise * self.random_state.randn(by.shape[0]) | ||
|
||
Y = np.expand_dims(by, axis=1) | ||
|
||
|
@@ -122,23 +115,20 @@ def output_gaussian_noise(self, X, scale_noise=0.01): | |
return Y | ||
|
||
def output_sparse_gaussian_noise(self, X, scale_noise=0.1, sparsity=0.01): | ||
assert isinstance(X, np.ndarray) | ||
assert isinstance(scale_noise, float) | ||
assert isinstance(sparsity, float) | ||
assert sparsity >= 0.0 and sparsity <= 1.0 | ||
assert sparsity < 0.5 | ||
|
||
by = self._output(X) | ||
|
||
if len(X.shape) == 2: | ||
num_X = X.shape[0] | ||
list_results = [self.function(bx) for bx in X] | ||
else: | ||
num_X = 1 | ||
list_results = [self.function(X)] | ||
|
||
by = np.array(list_results) | ||
|
||
noise = np.random.randn(num_X) | ||
mask = np.random.uniform(low=0.0, high=1.0, size=num_X) < sparsity | ||
noise = self.random_state.randn(num_X) | ||
mask = self.random_state.uniform(low=0.0, high=1.0, size=num_X) < sparsity | ||
noise *= mask.astype(np.float) | ||
by += scale_noise * noise | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/inf_dim_ackley.py → bayeso_benchmarks/inf_dim_ackley.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx, | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/inf_dim_cosines.py → bayeso_benchmarks/inf_dim_cosines.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
|
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,6 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
|
@@ -17,6 +22,7 @@ def fun_target(bx, dim_bx): | |
class Rosenbrock(Function): | ||
def __init__(self, dim_problem): | ||
assert isinstance(dim_problem, int) | ||
assert dim_problem > 1 | ||
|
||
dim_bx = np.inf | ||
bounds = np.array([ | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/inf_dim_sphere.py → bayeso_benchmarks/inf_dim_sphere.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/one_dim_constant.py → bayeso_benchmarks/one_dim_constant.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx, constant): | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/one_dim_gramacyandlee2012.py → ...o_benchmarks/one_dim_gramacyandlee2012.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx): | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/one_dim_linear.py → bayeso_benchmarks/one_dim_linear.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx, slope): | ||
|
4 changes: 2 additions & 2 deletions
4
benchmarks/one_dim_step.py → bayeso_benchmarks/one_dim_step.py
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,11 +1,11 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: February 8, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
||
from benchmarks.benchmark_base import Function | ||
from bayeso_benchmarks.benchmark_base import Function | ||
|
||
|
||
def fun_target(bx, dim_bx, steps, step_values): | ||
|
Oops, something went wrong.