Ejemplo n.º 1
0
def main():
    (options, args) = parse_args()

    if options.job:
        job_runner(load_job(options.job))
        exit(0)

    experiment_config = args[0]
    expt_dir  = os.path.dirname(os.path.realpath(experiment_config))
    log("Using experiment configuration: " + experiment_config)
    log("experiment dir: " + expt_dir)

    if not os.path.exists(expt_dir):
        log("Cannot find experiment directory '%s'. "
            "Aborting." % (expt_dir))
        sys.exit(-1)

    check_experiment_dirs(expt_dir)

    # Load up the chooser module.
    module  = importlib.import_module('chooser.' + options.chooser_module)
    chooser = module.init(expt_dir, options.chooser_args)

    if options.web_status:
        web_proc = start_web_view(options, experiment_config, chooser)

    # Load up the job execution driver.
    module = importlib.import_module('driver.' + options.driver)
    driver = module.init()

    # Loop until we run out of jobs.
    start = time.time()
    expt = load_experiment(experiment_config)
    expt_grid = ExperimentGrid(expt_dir,
                               expt.variable,
                               options.grid_size,
                               options.grid_seed)

    while attempt_dispatch(expt, expt_dir, expt_grid, chooser, options):
        # This is polling frequency. A higher frequency means that the algorithm
        # picks up results more quickly after they finish, but also significantly
        # increases overhead.
        time.sleep(0)
    print '%.3f' % (time.time() - start)
Ejemplo n.º 2
0
def main():
    (options, args) = parse_args()

    if options.job:
        job_runner(load_job(options.job))
        exit(0)

    experiment_config = args[0]
    # HPOlib mod:
    # We link experiment config, so using realpath will cause th whole output to be in
    # the experiment setup dir
    #
    # expt_dir  = os.path.dirname(os.path.realpath(experiment_config))
    expt_dir  = os.path.dirname(os.path.normpath(os.path.join(os.getcwd(), experiment_config)))

    log("Using experiment configuration: " + experiment_config)
    log("experiment dir: " + expt_dir)

    if not os.path.exists(expt_dir):
        log("Cannot find experiment directory '%s'. "
            "Aborting." % (expt_dir))
        sys.exit(-1)

    check_experiment_dirs(expt_dir)

    # Load up the chooser module.
    module  = importlib.import_module('chooser.' + options.chooser_module)
    chooser = module.init(expt_dir, options.chooser_args)

    if options.web_status:
        web_proc = start_web_view(options, experiment_config, chooser)

    # Load up the job execution driver.
    module = importlib.import_module('driver.' + options.driver)
    driver = module.init()

    # Loop until we run out of jobs.
    while attempt_dispatch(experiment_config, expt_dir, chooser, driver, options):
        # This is polling frequency. A higher frequency means that the algorithm
        # picks up results more quickly after they finish, but also significantly
        # increases overhead.
        time.sleep(options.polling_time)
Ejemplo n.º 3
0
def main():
    (options, args) = parse_args()

    if options.job:
        job_runner(load_job(options.job))
        exit(0)

    experiment_config = args[0]
    # HPOlib mod:
    # We link experiment config, so using realpath will cause th whole output to be in
    # the experiment setup dir
    #
    # expt_dir  = os.path.dirname(os.path.realpath(experiment_config))
    expt_dir = os.path.dirname(os.path.normpath(os.path.join(os.getcwd(), experiment_config)))
    log("Using experiment configuration: " + experiment_config)
    log("experiment dir: " + expt_dir)

    if not os.path.exists(expt_dir):
        log("Cannot find experiment directory '%s'. "
            "Aborting." % (expt_dir))
        sys.exit(-1)

    check_experiment_dirs(expt_dir)

    # Load up the chooser module.
    module  = importlib.import_module('chooser.' + options.chooser_module)
    chooser = module.init(expt_dir, options.chooser_args)

    if options.web_status:
        web_proc = start_web_view(options, experiment_config, chooser)

    # Load up the job execution driver.
    module = importlib.import_module('driver.' + options.driver)
    driver = module.init()

    # Loop until we run out of jobs.
    while attempt_dispatch(experiment_config, expt_dir, chooser, driver, options):
        # This is polling frequency. A higher frequency means that the algorithm
        # picks up results more quickly after they finish, but also significantly
        # increases overhead.
        time.sleep(options.polling_time)
Ejemplo n.º 4
0
def main():
    # Life universe and everything ...
    np.random.seed(42)
    random.seed(42)
    config.strikes = 0

    (options, args) = parse_args()

    if options.job:
        job_runner(load_job(options.job))
        exit(0)

    experiment_config = args[0]
    expt_dir = os.path.dirname(os.path.realpath(experiment_config))
    log("Using experiment configuration: " + experiment_config)
    log("experiment dir: " + expt_dir)

    if not os.path.exists(expt_dir):
        log("Cannot find experiment directory '%s'. " "Aborting." % (expt_dir))
        sys.exit(-1)

    check_experiment_dirs(expt_dir)

    # Load up the chooser module.
    module = importlib.import_module('chooser.' + options.chooser_module)
    chooser = module.init(expt_dir, options.chooser_args)

    if options.web_status:
        web_proc = start_web_view(options, experiment_config, chooser)

    # Load up the job execution driver.
    module = importlib.import_module('driver.' + options.driver)
    driver = module.init()

    # Loop until we run out of jobs.
    while attempt_dispatch(experiment_config, expt_dir, chooser, driver,
                           options):
        # This is polling frequency. A higher frequency means that the algorithm
        # picks up results more quickly after they finish, but also significantly
        # increases overhead.
        time.sleep(options.polling_time)
Ejemplo n.º 5
0
def main():
    (options, args) = parse_args()

    project_dir = os.environ['EXPERI_PROJECT_PATH']
    sys.path.append(project_dir)
    #sys.path.append("/home/jie/keras_experiment/incremental_bo")
    #sys.path.append("/home/fujie/keras_experiment/incremental_bo")
    log("experiment_config is: " + args[0]);

    if options.job:

        job_runner(load_job(options.job))
        log("run times are: ");
        exit(0)



    experiment_config = args[0]
    expt_dir  = os.path.dirname(os.path.realpath(experiment_config))
    log("Using experiment configuration: " + experiment_config)
    log("experiment dir: " + expt_dir)

    if not os.path.exists(expt_dir):
        
        log("Cannot find experiment directory '%s'. "
            "Aborting." % (expt_dir))
        sys.exit(-1)

    check_experiment_dirs(expt_dir)



    # Generate the yaml file
    classIndexFile = os.path.join(expt_dir, 'classIndex.txt')
    if not os.path.exists(classIndexFile):
        with open(classIndexFile, 'w') as fout:
            classIndex=random.sample(xrange(0,99), 20)
            fout.write("\t".join(np.array(map(str, classIndex))))

    # Load up the chooser module.
    module  = importlib.import_module('chooser.' + options.chooser_module)
    chooser = module.init(expt_dir, options.chooser_args)

    log("module is: "+options.chooser_module);

    if options.web_status:
        web_proc = start_web_view(options, experiment_config, chooser)

    # Load up the job execution driver.
    module = importlib.import_module('driver.' + options.driver)
    driver = module.init()

    #mode for user to choose: generate and test

    mode = options.mode_operate
    #"generate"
    #mode = "yaml_to_hyper"
  #  mode = "get_hyper_from_output"




    if mode == "yaml_to_hyper":
        # experiment_dir = "/mnt/random/hyperopt_experiment_1"
        yamlsDirectoryPath = expt_dir + "/hyper_yamels"

        hyper_file = os.path.join(expt_dir, 'hyperyaml.yaml')
        hyperList = []

        number = listdir( yamlsDirectoryPath).__len__()
        print("there are total "+str(number)+" yamls in the hyper_yaml directory")
        count = 0

        with open(hyper_file, 'r') as fin:
            for line in fin:
                if '!hyperopt' in line:
                    hyperList.append( line.split()[0] + " " + line.split()[2] + " " + line.split()[3])

        checkstatus = True;
        while  checkstatus:
            checkstatus = attempt_yaml_to_hyper(experiment_config, expt_dir, driver, options, count, hyperList, yamlsDirectoryPath,number,mode)
            if Flag:
                count = count+1
                global Flag
                Flag = True

            time.sleep(options.polling_time*2)
            #time.sleep(2)

    elif mode == "get_hyper_from_output":
        # experiment_dir = "/mnt/random/hyperopt_experiment_1"
        yamlsDirectoryPath = expt_dir + "/output_pre"
        
        hyper_file = os.path.join(expt_dir, 'hyperyaml.yaml')
        hyperList = []
        
#        number = listdir( yamlsDirectoryPath).__len__()
        number = options.max_finished_jobs
        print("there are total "+str(number)+" yamls in the hyper_yaml directory")
        count = 0
        
        with open(hyper_file, 'r') as fin:
            for line in fin:
                if '!hyperopt' in line:
                    hyperList.append( line.split()[0] + " " + line.split()[2] + " " + line.split()[3])

        checkstatus = True;
        while  checkstatus:
            checkstatus = attempt_yaml_to_hyper(experiment_config, expt_dir, driver, options, count, hyperList, yamlsDirectoryPath,number,mode)
            if Flag:
                count = count+1
                global Flag
                Flag = True
    
            time.sleep(options.polling_time*2)
    # Loop until we run out of jobs.
    elif mode == "generate":

        while attempt_dispatch(experiment_config, expt_dir, chooser, driver, options):
            # This is polling frequency. A higher frequency means that the algorithm
            # picks up results more quickly after they finish, but also significantly
            # increases overhead.
            time.sleep(options.polling_time)

    else:
        exit(0)