mirror of
https://github.com/c-sooyoung/bo-ptycho.git
synced 2026-09-17 20:29:07 +09:00
renamed bo to samplers
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
from .base import BOEngine
|
|
||||||
from .random import RandomBOEngine
|
|
||||||
from .sobo import SingleObjectiveBOEngine
|
|
||||||
@@ -2,7 +2,7 @@ import os
|
|||||||
import traceback
|
import traceback
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
|
|
||||||
import bo
|
import samplers
|
||||||
import ptycho
|
import ptycho
|
||||||
|
|
||||||
def run_ptycho_worker(worker_id, gpu_token, job_config, metric, run_id, result_queue):
|
def run_ptycho_worker(worker_id, gpu_token, job_config, metric, run_id, result_queue):
|
||||||
@@ -71,7 +71,7 @@ def sobo_pipeline(config):
|
|||||||
|
|
||||||
|
|
||||||
############################ RANDOM SAMPLING ###############################
|
############################ RANDOM SAMPLING ###############################
|
||||||
randombo = bo.RandomBOEngine(config)
|
randombo = samplers.RandomSampler(config)
|
||||||
|
|
||||||
for j in range(RANDOM_ITERS):
|
for j in range(RANDOM_ITERS):
|
||||||
print(f"RANDOM sampling; iteration {j}")
|
print(f"RANDOM sampling; iteration {j}")
|
||||||
@@ -81,7 +81,7 @@ def sobo_pipeline(config):
|
|||||||
randombo.tell(job_config, y_value)
|
randombo.tell(job_config, y_value)
|
||||||
|
|
||||||
############################ SOBO SAMPLING ###############################
|
############################ SOBO SAMPLING ###############################
|
||||||
sobo = bo.SingleObjectiveBOEngine(config)
|
sobo = samplers.SOBOSampler(config)
|
||||||
sobo.train_x = randombo.train_x
|
sobo.train_x = randombo.train_x
|
||||||
sobo.train_y = randombo.train_y
|
sobo.train_y = randombo.train_y
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from .base import Sampler
|
||||||
|
from .random import RandomSampler
|
||||||
|
from .sobo import SOBOSampler
|
||||||
|
|
||||||
|
samplers = {
|
||||||
|
'sobo': SOBOSampler,
|
||||||
|
'random': RandomSampler,
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import os
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
class BOEngine(ABC):
|
class Sampler(ABC):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.params = [key for key, spec in config["bo"]["params"].items() if spec is not None]
|
self.params = [key for key, spec in config["bo"]["params"].items() if spec is not None]
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import copy
|
import copy
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from bo.base import BOEngine
|
from samplers.base import Sampler
|
||||||
|
|
||||||
|
|
||||||
class RandomBOEngine(BOEngine):
|
class RandomSampler(Sampler):
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
@@ -15,10 +15,10 @@ from botorch.sampling.normal import SobolQMCNormalSampler
|
|||||||
from botorch.utils.rounding import approximate_round
|
from botorch.utils.rounding import approximate_round
|
||||||
|
|
||||||
|
|
||||||
from bo.base import BOEngine
|
from samplers.base import Sampler
|
||||||
|
|
||||||
|
|
||||||
class SingleObjectiveBOEngine(BOEngine):
|
class SOBOSampler(Sampler):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
self.acquisition = config['bo']['acquisition']
|
self.acquisition = config['bo']['acquisition']
|
||||||
Reference in New Issue
Block a user