コード例 #1
0
ファイル: load_action.py プロジェクト: wyz2368/oldagent
def load_action(path, scope, game, training_flag):

    env = game.env
    env.set_training_flag(training_flag)

    param_path = os.getcwd() + '/network_parameters/param.json'
    param = jp.load_json_data(param_path)

    act = learn_multi_nets(env,
                           network=models.mlp(num_layers=param['num_layers'],
                                              num_hidden=param['num_hidden']),
                           total_timesteps=0,
                           load_path=path,
                           scope=scope + '/')
    return act
コード例 #2
0
ファイル: sample_strategy.py プロジェクト: wyz2368/oldagent
def rand_def_str_generator(env, game):
    # Generate random nn for attacker.
    num_layers = game.num_layers
    num_hidden = game.num_hidden

    env.set_training_flag(0)
    act_def = learn_multi_nets(env,
                               network=models.mlp(num_hidden=num_hidden,
                                                  num_layers=num_layers - 3),
                               total_timesteps=0)

    print("Saving defender's model to pickle. Epoch in name is equal to 1.")
    act_def.save(DIR_def + "def_str_epoch" + str(1) + ".pkl")
    # game.def_str.append("def_str_epoch" + str(1) + ".pkl")
    game.add_def_str("def_str_epoch" + str(1) + ".pkl")