mirror of
https://github.com/c-sooyoung/bo-ptycho.git
synced 2026-09-17 19:29:07 +09:00
renamed bo to samplers
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import copy
|
||||
import numpy as np
|
||||
from samplers.base import Sampler
|
||||
|
||||
|
||||
class RandomSampler(Sampler):
|
||||
|
||||
def __init__(self, config):
|
||||
super().__init__(config)
|
||||
|
||||
|
||||
def ask(self, n = 1):
|
||||
next_configs = []
|
||||
|
||||
for _ in range(n):
|
||||
next_config = copy.deepcopy(self.config)
|
||||
for param in self.params:
|
||||
radius = self.config['bo']['params'][param]['radius']
|
||||
center = self.config['ptycho']['params'][param]
|
||||
modulation = radius * (np.random.rand() - 0.5) * 2
|
||||
next_value = center + modulation
|
||||
if self.param_types[param] == 'int':
|
||||
next_value = round(next_value)
|
||||
next_config['ptycho']['params'][param] = next_value
|
||||
next_configs.append(next_config)
|
||||
|
||||
return next_configs
|
||||
Reference in New Issue
Block a user