def sample_hparams():
hparams = {}
for k, sample_range in ranges.items():
if isinstance(sample_range, (LogRange, LinearRange)):
if isinstance(sample_range[0], int):
# LogRange not valid for ints
hparams[k] = random.randint(sample_range[0], sample_range[1])
elif isinstance(sample_range[0], float):
start, end = sample_range
if isinstance(sample_range, LogRange):
start, end = np.log10(start), np.log10(end)
choice = np.random.uniform(start, end)
if isinstance(sample_range, LogRange):
choice = np.exp(choice)
hparams[k] = choice
return hparams
评论列表
文章目录