Ejemplo n.º 1
0
def restore_model(agents, path=None):

    if path:
        agents[0].restore(path)
        idex = path.split("/")[-1]
    else:
        idex = get_max_idx("./saved_model")
        path = os.path.join("./saved_model/", str(idex))
        agents[0].restore(path)

    logging.info("Agent model restored at {}".format(path))

    return int(idex)
Ejemplo n.º 2
0
def restore_model(agents, path=None):

    alg_tag = "current_models/CNN_DQN" if use_dqn(
    ) else "current_models/CNN_A2C"
    try:

        if path:
            agents[0].restore(path)
            idex = path.split("/")[-1]
        else:
            idex = get_max_idx(alg_tag + fmt_hyperparameters())
            path = os.path.join(alg_tag + fmt_hyperparameters(), str(idex))
            agents[0].restore(path)

        logging.info("Agent model restored at {}".format(path))

    except:
        print(sys.exc_info())
        logging.info("No saved Model!!")
        idex = 0

    return int(idex)
Ejemplo n.º 3
0
def main(unused_argv):

    # logging.info("Train on " + fmt_output_channels())

    env, info_state_size, num_actions, begin = init_env()
    cnn_parameters, hidden_layers_sizes, kwargs, ret, max_len = init_hyper_paras(
    )

    with tf.Session() as sess:

        # rival_path = "rivals/a2c_0"
        # rival_path = "../saved_model/CNN_A2C_2_2_4_4_8_8_16**_32_64_32"
        rival_path = "../saved_model/CNN_A2C" + fmt_hyperparameters()

        rival_model = os.path.join(rival_path, str(get_max_idx(rival_path)))
        agents = init_agents(sess, info_state_size, num_actions,
                             cnn_parameters, hidden_layers_sizes, rival_model,
                             **kwargs)

        train(agents, env, ret, max_len, begin)

        ret = evaluate(agents, env)

        stat(ret, begin)