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
评论列表
文章目录