def sample_models(self, nsamples):
b = self.b_search
samples = []
choice_hists = []
for _ in xrange(nsamples):
bk = copy.deepcopy(b)
bk.initialize(self.in_d, Scope())
hist = []
while( not bk.is_specified() ):
name, vals = bk.get_choices()
#print(name, vals)
assert len(vals) > 1
choice_i = np.random.randint(0, len(vals))
bk.choose(choice_i)
hist.append(choice_i)
# keep the sampled model once specified.
samples.append(bk)
choice_hists.append(hist)
return (samples, choice_hists)
评论列表
文章目录