Exemplo n.º 1
0
    pool_size = lemon_cfg['parameters'].getint('pool_size')
    python_prefix = lemon_cfg['parameters']['python_prefix'].rstrip("/")

    try:
        metrics_list = lemon_cfg['parameters']['metrics'].split(" ")
        lemon_results = {k: dict() for k in metrics_list}
        lemon_results = _generate_and_predict(lemon_results, flags.model,
                                              flags.mutate_num,
                                              flags.mutate_op, flags.test_size,
                                              flags.exp, flags.backends)
        with open("{}/{}_lemon_results.pkl".format(experiment_dir, flags.exp),
                  "wb+") as f:
            pickle.dump(lemon_results, file=f)
        utils.MetricsUtils.generate_result_by_metrics(metrics_list,
                                                      lemon_results,
                                                      metrics_result_dir,
                                                      flags.exp)

    except Exception as e:
        mutate_logger.exception(sys.exc_info())

    from keras import backend as K
    K.clear_session()

    endtime = datetime.datetime.now()
    time_delta = endtime - starttime
    h, m, s = utils.ToolUtils.get_HH_mm_ss(time_delta)
    mutate_logger.info(
        "INFO:Mutation process is done: Time used: {} hour,{} min,{} sec".
        format(h, m, s))
Exemplo n.º 2
0
        if not os.path.exists(nan_dir):
            os.makedirs(nan_dir)
        if not os.path.exists(inner_output_dir):
            os.makedirs(inner_output_dir)
        if not os.path.exists(metrics_result_dir):
            os.makedirs(metrics_result_dir)

        try:
            """Mutate and get output of different backends"""
            main_log.info("INFO:Lemon mutation starting!")
            main_log.info("INFO:Lemon for exp: {}".format(exp_identifier))
            origin_model_name = "{}_origin.h5".format(exp_identifier)
            origin_model_file = os.path.join(flags.origin_model_dir,
                                             origin_model_name)
            mutate_lemon = "{}/lemon/bin/python -u -m run.mutate_lemon --mutate_op {} --model {} --output_dir {}" \
                            " --backends {} --mutate_num {} --mutate_ratio {} --exp {} --test_size {} --redis_db {} --config_name {}"\
                            .format(flags.python_prefix,flags.mutate_ops,origin_model_file,flags.output_dir,flags.backend,
                                    flags.mutate_num,flags.mutate_ratio,exp_identifier,flags.test_size,flags.redis_db,config_name)
            os.system(mutate_lemon)

        except Exception:
            main_log.error(
                "Error: Lemon for exp:{} Failed!".format(exp_identifier))
            main_log.exception(sys.exc_info())

    end_time = datetime.datetime.now()
    time_delta = end_time - start_time
    h, m, s = utils.ToolUtils.get_HH_mm_ss(time_delta)
    main_log.info(
        "INFO:Lemon is done: Time used: {} hour,{} min,{} sec".format(h, m, s))