当前位置: 首页>>代码示例>>Python>>正文


Python Experiment.compute_informativeness方法代码示例

本文整理汇总了Python中experiment.Experiment.compute_informativeness方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.compute_informativeness方法的具体用法?Python Experiment.compute_informativeness怎么用?Python Experiment.compute_informativeness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在experiment.Experiment的用法示例。


在下文中一共展示了Experiment.compute_informativeness方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_experiment

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import compute_informativeness [as 别名]
def run_experiment(args):
    """ Parallelizable method for computing experiments.

    This method is used in parallel computation for running experiments in
    parallel. Due to the nature of pickling, it must be declared globally,
    because instance methods cannot be pickled.
    """
    # args is a tuple, so that we can map over an array of tuples.
    # see run_parallel_experiments()
    params, param_name, val = args

    params = params.copy()
    params[param_name] = val

    while True:
        try:
            start_time = time.clock()
            exp = Experiment(**params)
            exp.compute_informativeness()
            break
        except Exception:
            traceback.print_exc()

    elapsed_time = time.clock() - start_time
    print "Experiment with val %s added in %0.2f seconds" % \
            (str(val), elapsed_time)

    return val, exp
开发者ID:thenovices,项目名称:transitive-trust-models,代码行数:30,代码来源:experiment_sets.py

示例2: run_experiments

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import compute_informativeness [as 别名]
    def run_experiments(self, clear=False):
        if clear:
            self.experiments = defaultdict(list)

        if not hasattr(self, 'failed_experiments'):
            self.failed_experiments = []

        experiment_count = sum(len(x) for x in self.experiments.values())
        params = self.experiment_params.copy()

        for val in self.ind_param_values:
            for _ in xrange(self.num_experiments - len(self.experiments[val])):
                experiment_count += 1
                start_time = time.clock()

                params[self.ind_param_name] = val

                # Sometimes running experiments throws exceptions -- mainly
                # max flow for some as of now unknown reason.
                # We could possibly be concerned about slight biasing because
                # we're not getting an unbiased distribution over graphs, but
                # this seems to happen rarely enough that it isn't a problem.
                while True:
                    exp = Experiment(**params)
                    try:
                        exp.compute_informativeness()
                        self.experiments[val].append(exp)
                        break
                    except Exception:
                        self.failed_experiments.append(exp)
                        traceback.print_exc()

                elapsed_time = time.clock() - start_time
                print "Experiment %d added in %0.2f seconds" % \
                        (experiment_count, elapsed_time)

                # self.save_experiment(exp, experiment_count)

        self.aggregate_results()
        self.aggregate_runtimes()
开发者ID:thenovices,项目名称:transitive-trust-models,代码行数:42,代码来源:experiment_sets.py


注:本文中的experiment.Experiment.compute_informativeness方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。