test_hyperparameters.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:ConfigSpace 作者: automl 项目源码 文件源码
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())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号