Example #1
0
def ss_entry_of_sexp(sexp):
    m = inlining_tree.sexp_to_map(sexp)
    accuracy = m.get("accuracy", None)
    if accuracy is not None:
        accuracy = float(accuracy)
    loss = float(m["loss"])
    return Entry(loss=loss, accuracy=accuracy)
def read_exec_time(filename):
    if not os.path.exists(filename):
        return None
    assert isinstance(filename, str)
    with open(filename, "r") as f:
        sexp = sexpdata.loads(f.read())
    m = sexp_to_map(sexp)
    return geometric_mean([parse_time(t) for t in m["raw_execution_time"]])
Example #3
0
 def parse_features(sexp):
     m = inlining_tree.sexp_to_map(sexp)
     int_features = parse_feature_list(m["int_features"], f=int)
     numeric_features = parse_feature_list(m["numeric_features"], f=float)
     bool_features = parse_feature_list(m["bool_features"], f=parse_bool)
     return Features(int_features=int_features,
                     bool_features=bool_features,
                     numeric_features=numeric_features)
def load_execution_time(execution_stats_file):
    with open(execution_stats_file) as f:
        execution_stats_sexp = sexpdata.load(f)
        m = inlining_tree.sexp_to_map(execution_stats_sexp)
        execution_time = inlining_tree.geometric_mean([
                inlining_tree.parse_time(inlining_tree.unpack_atom(x))
                for x in m["raw_execution_time"]
        ])
        return execution_time
Example #5
0
    def parse_features(sexp):
        m = inlining_tree.sexp_to_map(sexp)
        int_features = parse_feature_list(m["int_features"], f=int)
        numeric_features = parse_feature_list(m["numeric_features"], f=float)
        bool_features = parse_feature_list(m["bool_features"], f=parse_bool)
        metadata = m["metadata"]

        return Features(int_features=int_features,
                        bool_features=bool_features,
                        numeric_features=numeric_features,
                        exp_name=exp_name,
                        metadata=metadata)
Example #6
0
def snapshot_of_sexp(sexp):
    try:
        m = inlining_tree.sexp_to_map(sexp)
        option_of_sexp = inlining_tree.option_of_sexp
        epoch = int(m["epoch"])
        training = option_of_sexp(m["training"], f=ss_entry_of_sexp)
        validation = option_of_sexp(m["validation"], f=ss_entry_of_sexp)
        test = option_of_sexp(m["test"], f=ss_entry_of_sexp)
        return Snapshot(epoch=epoch, training=training, validation=validation, test=test)
    except KeyError:
        return None
    except ValueError:  # When parsing other sexps
        return None
Example #7
0
 def parse_reward(sexp):
     m = inlining_tree.sexp_to_map(sexp)
     inline = option_of_sexp(m["inline"], f=parse_dual_reward)
     no_inline = option_of_sexp(m["no_inline"], f=float)
     return Reward(inline=inline, no_inline=no_inline)
Example #8
0
 def parse_dual_reward(sexp):
     m = inlining_tree.sexp_to_map(sexp)
     return DualReward(long_term=float(m["long_term"]),
                       immediate=float(m["immediate"]))