def test_sample_NormalFloatHyperparameter(self):
hp = NormalFloatHyperparameter("nfhp", 0, 1)
def actual_test():
rs = np.random.RandomState(1)
counts_per_bin = [0 for i in range(11)]
for i in range(100000):
value = hp.sample(rs)
index = min(max(int((round(value + 0.5)) + 5), 0), 9)
counts_per_bin[index] += 1
self.assertEqual([0, 4, 138, 2113, 13394, 34104, 34282, 13683,
2136, 146, 0], counts_per_bin)
return counts_per_bin
self.assertEqual(actual_test(), actual_test())
评论列表
文章目录