Beispiel #1
0
    def __init__(self, game_params, arch_params, solver_params, trained_model, sn_dir):

        params=[None, None]

        if trained_model[0]:
            params[0] = common.load_params(trained_model[0])

        if trained_model[1]:
            params[1] = common.load_params(trained_model[1])

        self.lr_func = []
        self.lr_func.append(create_learning_rate_func(solver_params['controler_0']))
        self.lr_func.append(create_learning_rate_func(solver_params['controler_1']))

        self.x_host_0 = tt.fvector('x_host_0')
        self.v_host_0 = tt.fvector('v_host_0')
        self.x_target_0 = tt.fvector('x_target_0')
        self.v_target_0 = tt.fvector('v_target_0')
        self.x_mines_0 = tt.fmatrix('x_mines_0')
        self.mines_map = tt.fmatrix('mines_map')
        self.time_steps = tt.fvector('time_steps')
        self.force = tt.fmatrix('force')
        self.n_steps_0 = tt.iscalar('n_steps_0')
        self.n_steps_1 = tt.iscalar('n_steps_1')
        self.lr = tt.fscalar('lr')
        self.goal_1 = tt.fvector('goal_1')
        self.trnsprnt = tt.fscalar('trnsprnt')
        self.rand_goals = tt.fmatrix('rand_goals')
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params
        self.sn_dir = sn_dir

        self.model = CONTROLLER(self.x_host_0,
                                self.v_host_0,
                                self.x_target_0,
                                self.v_target_0,
                                self.x_mines_0,
                                self.mines_map,
                                self.time_steps,
                                self.force,
                                self.n_steps_0,
                                self.n_steps_1,
                                self.lr,
                                self.goal_1,
                                self.trnsprnt,
                                self.rand_goals,
                                self.game_params,
                                self.arch_params,
                                self.solver_params,
                                params)
def get_exp_params(data_dir):
    param_file = "%s/%s" % (data_dir, FILES['params_file'])
    if os.path.isfile(param_file):
        params = com.load_params(param_file)
    else:
        params = {}        
    return params
Beispiel #3
0
    def __init__(self, game_params, arch_params, solver_params, trained_model,
                 sn_dir):

        params = None

        if trained_model:
            params = common.load_params(trained_model)

        self.lr_func = create_learning_rate_func(solver_params)
        self.v_h_0 = tt.fvector('v_h_0')
        self.x_h_0 = tt.fvector('x_h_0')
        self.v_t_0 = tt.fmatrix('v_t_0')
        self.x_t_0 = tt.fmatrix('x_t_0')
        self.a_t_0 = tt.fmatrix('a_t_0')
        self.is_aggressive = tt.fmatrix('is_aggressive')
        self.lr_ = tt.fscalar('lr')
        self.n_steps_ = tt.iscalar('n_steps')
        self.sn_dir = sn_dir
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params

        self.model = CONTROLLER(self.v_h_0, self.x_h_0, self.v_t_0, self.x_t_0,
                                self.a_t_0, self.is_aggressive, self.lr_,
                                self.n_steps_, self.game_params,
                                self.arch_params, self.solver_params, params)
Beispiel #4
0
    def __init__(self, game_params, arch_params, solver_params, trained_model,
                 sn_dir):

        params = [None, None]

        if trained_model[0]:
            params[0] = common.load_params(trained_model[0])

        if trained_model[1]:
            params[1] = common.load_params(trained_model[1])

        self.lr_func = []
        self.lr_func.append(
            create_learning_rate_func(solver_params['controler_0']))
        self.lr_func.append(
            create_learning_rate_func(solver_params['controler_1']))

        self.x_host_0 = tt.fvector('x_host_0')
        self.v_host_0 = tt.fvector('v_host_0')
        self.x_target_0 = tt.fvector('x_target_0')
        self.v_target_0 = tt.fvector('v_target_0')
        self.x_mines_0 = tt.fmatrix('x_mines_0')
        self.mines_map = tt.fmatrix('mines_map')
        self.time_steps = tt.fvector('time_steps')
        self.force = tt.fmatrix('force')
        self.n_steps_0 = tt.iscalar('n_steps_0')
        self.n_steps_1 = tt.iscalar('n_steps_1')
        self.lr = tt.fscalar('lr')
        self.goal_1 = tt.fvector('goal_1')
        self.trnsprnt = tt.fscalar('trnsprnt')
        self.rand_goals = tt.fmatrix('rand_goals')
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params
        self.sn_dir = sn_dir

        self.model = CONTROLLER(self.x_host_0, self.v_host_0, self.x_target_0,
                                self.v_target_0, self.x_mines_0,
                                self.mines_map, self.time_steps, self.force,
                                self.n_steps_0, self.n_steps_1, self.lr,
                                self.goal_1, self.trnsprnt, self.rand_goals,
                                self.game_params, self.arch_params,
                                self.solver_params, params)
Beispiel #5
0
def load_experiment(sched_file, scheduler, duration, param_file, out_dir):
    if not os.path.isfile(sched_file):
        raise IOError("Cannot find schedule file: %s" % sched_file)

    dir_name, fname = os.path.split(sched_file)
    exp_name = os.path.split(dir_name)[1] + "/" + fname

    params = {}
    kernel = copts = ""

    param_file = param_file or \
      "%s/%s" % (dir_name, conf.DEFAULTS['params_file'])

    if os.path.isfile(param_file):
        params = com.load_params(param_file)
        scheduler = scheduler or params[conf.PARAMS['sched']]
        duration  = duration  or params[conf.PARAMS['dur']]

        # Experiments can specify required kernel name
        if conf.PARAMS['kernel'] in params:
            kernel = params[conf.PARAMS['kernel']]
        # Or required config options
        if conf.PARAMS['copts'] in params:
            copts = params[conf.PARAMS['copts']]

    duration = duration or conf.DEFAULTS['duration']

    if not scheduler:
        raise IOError("Parameter scheduler not specified in %s" % (param_file))

    # Parse schedule file's intentions
    schedule = load_schedule(sched_file)
    work_dir = "%s/tmp" % dir_name

    fix_paths(schedule, os.path.split(sched_file)[0], sched_file)

    verify_environment(kernel, copts)

    run_exp(exp_name, schedule, scheduler, kernel, duration, work_dir, out_dir)

    # Save parameters used to run experiment in out_dir
    out_params = dict(params.items() +
                      [(conf.PARAMS['sched'],  scheduler),
                       (conf.PARAMS['tasks'],  len(schedule['spin'])),
                       (conf.PARAMS['dur'],    duration)])

    # Feather-trace clock frequency saved for accurate overhead parsing
    ft_freq = com.ft_freq()
    if ft_freq:
        out_params[conf.PARAMS['cycles']] = ft_freq

    with open("%s/%s" % (out_dir, conf.DEFAULTS['params_file']), 'w') as f:
        f.write(str(out_params))
Beispiel #6
0
def make_exp_params(cmd_scheduler, cmd_duration, sched_dir):
    '''Return ExpParam with configured values of all hardcoded params.'''
    kernel = copts = ""

    # Load parameter file
    param_file = "%s/%s" % (sched_dir, FILES['params_file'])
    if os.path.isfile(param_file):
        fparams = com.load_params(param_file)
    else:
        fparams = {}

    scheduler = cmd_scheduler or fparams[PARAMS['sched']]
    duration  = cmd_duration  or fparams[PARAMS['dur']] or\
                DEFAULTS['duration']

    # Experiments can specify required kernel name
    if PARAMS['kernel'] in fparams:
        kernel = fparams[PARAMS['kernel']]

    # Or required config options
    if PARAMS['copts'] in fparams:
        copts = fparams[PARAMS['copts']]

    # Or required tracers
    requested = []
    if PARAMS['trace'] in fparams:
        requested = fparams[PARAMS['trace']]
    tracers = trace.get_tracer_types(requested)

    # Or scripts to run before and after experiments
    def get_script(name):
        return fparams[name] if name in fparams else None

    pre_script = get_script('pre')
    post_script = get_script('post')

    # But only these two are mandatory
    if not scheduler:
        raise IOError("No scheduler found in param file!")
    if not duration:
        raise IOError("No duration found in param file!")

    return ExpParams(scheduler=scheduler,
                     kernel=kernel,
                     duration=duration,
                     config_options=copts,
                     tracers=tracers,
                     file_params=fparams,
                     pre_script=pre_script,
                     post_script=post_script)
def load_experiment(sched_file, cmd_scheduler, cmd_duration,
                    param_file, out_dir, ignore, jabber):
    '''Load and parse data from files and run result.'''
    if not os.path.isfile(sched_file):
        raise IOError("Cannot find schedule file: %s" % sched_file)

    dir_name, fname = os.path.split(sched_file)
    exp_name = os.path.split(dir_name)[1] + "/" + fname
    work_dir = "%s/tmp" % dir_name

    # Load parameter file
    param_file = param_file or \
      "%s/%s" % (dir_name, conf.DEFAULTS['params_file'])
    if os.path.isfile(param_file):
        file_params = com.load_params(param_file)
    else:
        file_params = {}

    # Create input needed by Experiment
    exp_params = get_exp_params(cmd_scheduler, cmd_duration, file_params)
    procs, execs = load_schedule(exp_name, sched_file, exp_params.duration)

    exp = Experiment(exp_name, exp_params.scheduler, work_dir, out_dir,
                     procs, execs, exp_params.tracers)

    if not ignore:
        verify_environment(exp_params)

    run_parameter(dir_name, work_dir, file_params, 'pre')

    exp.run_exp()

    run_parameter(dir_name, out_dir, file_params, 'post')

    if jabber:
        jabber.send("Completed '%s'" % exp_name)

    # Save parameters used to run experiment in out_dir
    out_params = dict(file_params.items() +
                      [(conf.PARAMS['sched'],  exp_params.scheduler),
                       (conf.PARAMS['tasks'],  len(execs)),
                       (conf.PARAMS['dur'],    exp_params.duration)])

    # Feather-trace clock frequency saved for accurate overhead parsing
    ft_freq = com.ft_freq()
    if ft_freq:
        out_params[conf.PARAMS['cycles']] = ft_freq

    with open("%s/%s" % (out_dir, conf.DEFAULTS['params_file']), 'w') as f:
        f.write(str(out_params))
Beispiel #8
0
    def __init__(self, game_params, arch_params, solver_params, trained_model, sn_dir):

        params=None

        if trained_model:
            params = common.load_params(trained_model)

        self.lr_func = create_learning_rate_func(solver_params)

        self.x_h_0 = tt.fvector('x_h_0')
        self.v_h_0 = tt.fvector('v_h_0')
        self.t_h_0 = tt.fvector('t_h_0')
        self.x_t_0 = tt.fmatrix('x_t_0')
        self.v_t_0 = tt.fmatrix('v_t_0')
        self.a_t_0 = tt.fmatrix('a_t_0')
        self.t_t_0 = tt.fvector('t_t_0')
        self.time_steps = tt.fvector('t_0')
        self.exist = tt.bvector('exist')
        self.is_leader = tt.fvector('is_leader')
        self.x_goal = tt.fvector('x_goal')
        self.turn_vec_h = tt.fvector('turn_vec_h')
        self.turn_vec_t = tt.fvector('turn_vec_t')
        self.n_steps = tt.iscalar('n_steps')
        self.lr = tt.fscalar('lr')
        self.sn_dir = sn_dir
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params

        self.model = CONTROLLER(self.x_h_0,
                                self.v_h_0,
                                self.t_h_0,
                                self.x_t_0,
                                self.v_t_0,
                                self.a_t_0,
                                self.t_t_0,
                                self.time_steps,
                                self.exist,
                                self.is_leader,
                                self.x_goal,
                                self.turn_vec_h,
                                self.turn_vec_t,
                                self.n_steps,
                                self.lr,
                                self.game_params,
                                self.arch_params,
                                self.solver_params,
                                params)
def get_exp_params(data_dir, cm_builder):
    param_file = "%s/%s" % (data_dir, conf.DEFAULTS['params_file'])
    if os.path.isfile(param_file):
        params = load_params(param_file)

        # Store parameters in cm_builder, which will track which parameters change
        # across experiments
        for key, value in params.iteritems():
            cm_builder.try_add(key, value)
    else:
         params = {}

    # Cycles must be present for feather-trace measurement parsing
    if conf.PARAMS['cycles'] not in params:
        params[conf.PARAMS['cycles']] = conf.DEFAULTS['cycles']

    return params
Beispiel #10
0
def get_exp_params(data_dir, cm_builder):
    param_file = "%s/%s" % (data_dir, FILES['params_file'])
    if os.path.isfile(param_file):
        params = com.load_params(param_file)

        # Store parameters in cm_builder, which will track which parameters change
        # across experiments
        for key, value in params.iteritems():
            cm_builder.try_add(key, value)
    else:
        params = {}

    # Cycles must be present for feather-trace measurement parsing
    if PARAMS['cycles'] not in params:
        params[PARAMS['cycles']] = DEFAULTS['cycles']

    return params
Beispiel #11
0
def make_exp_params(cmd_scheduler, cmd_duration, sched_dir):
    '''Return ExpParam with configured values of all hardcoded params.'''
    kernel = copts = ""

    # Load parameter file
    param_file = "%s/%s" % (sched_dir, FILES['params_file'])
    if os.path.isfile(param_file):
        fparams = com.load_params(param_file)
    else:
        fparams = {}

    scheduler = cmd_scheduler or fparams[PARAMS['sched']]
    duration  = cmd_duration  or fparams[PARAMS['dur']] or\
                DEFAULTS['duration']

    # Experiments can specify required kernel name
    if PARAMS['kernel'] in fparams:
        kernel = fparams[PARAMS['kernel']]

    # Or required config options
    if PARAMS['copts'] in fparams:
        copts = fparams[PARAMS['copts']]

    # Or required tracers
    requested = []
    if PARAMS['trace'] in fparams:
        requested = fparams[PARAMS['trace']]
    tracers = trace.get_tracer_types(requested)

    # Or scripts to run before and after experiments
    def get_script(name):
        return fparams[name] if name in fparams else None
    pre_script  = get_script('pre')
    post_script = get_script('post')

    # But only these two are mandatory
    if not scheduler:
        raise IOError("No scheduler found in param file!")
    if not duration:
        raise IOError("No duration found in param file!")

    return ExpParams(scheduler=scheduler, kernel=kernel, duration=duration,
                     config_options=copts, tracers=tracers, file_params=fparams,
                     pre_script=pre_script, post_script=post_script)
Beispiel #12
0
    def __init__(self, game_params, arch_params, solver_params, trained_model, sn_dir):

        params=None

        if trained_model:
            params = common.load_params(trained_model)

        self.lr_func = create_learning_rate_func(solver_params)
        self.v_h_0 = tt.fvector('v_h_0')
        self.x_h_0 = tt.fvector('x_h_0')
        self.v_t_0 = tt.fmatrix('v_t_0')
        self.x_t_0 = tt.fmatrix('x_t_0')
        self.a_t_0 = tt.fmatrix('a_t_0')
        self.is_aggressive = tt.fmatrix('is_aggressive')
        self.lr_ = tt.fscalar('lr')
        self.n_steps_ = tt.iscalar('n_steps')
        self.sn_dir = sn_dir
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params

        self.model = CONTROLLER(self.v_h_0, self.x_h_0, self.v_t_0, self.x_t_0, self.a_t_0, self.is_aggressive, self.lr_, self.n_steps_, self.game_params, self.arch_params, self.solver_params, params)
Beispiel #13
0
    def __init__(self, game_params, arch_params, solver_params, trained_model,
                 sn_dir):

        params = None

        if trained_model:
            params = common.load_params(trained_model)

        self.lr_func = create_learning_rate_func(solver_params)

        self.x_h_0 = tt.fvector('x_h_0')
        self.v_h_0 = tt.fvector('v_h_0')
        self.t_h_0 = tt.fvector('t_h_0')
        self.x_t_0 = tt.fmatrix('x_t_0')
        self.v_t_0 = tt.fmatrix('v_t_0')
        self.a_t_0 = tt.fmatrix('a_t_0')
        self.t_t_0 = tt.fvector('t_t_0')
        self.time_steps = tt.fvector('t_0')
        self.exist = tt.bvector('exist')
        self.is_leader = tt.fvector('is_leader')
        self.x_goal = tt.fvector('x_goal')
        self.turn_vec_h = tt.fvector('turn_vec_h')
        self.turn_vec_t = tt.fvector('turn_vec_t')
        self.n_steps = tt.iscalar('n_steps')
        self.lr = tt.fscalar('lr')
        self.sn_dir = sn_dir
        self.game_params = game_params
        self.arch_params = arch_params
        self.solver_params = solver_params

        self.model = CONTROLLER(self.x_h_0, self.v_h_0, self.t_h_0, self.x_t_0,
                                self.v_t_0, self.a_t_0, self.t_t_0,
                                self.time_steps, self.exist, self.is_leader,
                                self.x_goal, self.turn_vec_h, self.turn_vec_t,
                                self.n_steps, self.lr, self.game_params,
                                self.arch_params, self.solver_params, params)