statistics.py 文件源码

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

项目:FLASH 作者: yuyuz 项目源码 文件源码
def _get_best_trial(filename, cut=None):
    try:
        fh = open(filename, "r")
        trials = cPickle.load(fh)
        fh.close()

        current_best = numpy.Inf
        best_idx = 0
        if cut is None:
            cut = len(trials['trials'])
        print filename, "#Trials", len(trials['trials'])
        for i, trial in enumerate(trials['trials'][:cut]):
            result = trial['result']
            if result < current_best:
                best_idx = i
                current_best = result
        if current_best == numpy.Inf:
            raise Exception("%s does not contain any results" % filename)
        return current_best, best_idx
    except Exception as e:
        print "Problem with ", filename, e
        sys.stdout.flush()
        return None, None

# TODO: Don't know whether this is longer needed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号