本文整理汇总了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
示例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()