示例#1
0
def load_model(coach_path, model_path, args):
    if 'onehot' in coach_path:
        coach = ConvOneHotCoach.load(coach_path).to(device)
    elif 'gen' in coach_path:
        coach = RnnGenerator.load(coach_path).to(device)
    else:
        coach = ConvRnnCoach.load(coach_path).to(device)
    coach.max_raw_chars = args.max_raw_chars
    executor = Executor.load(model_path).to(device)
    executor_wrapper = ExecutorWrapper(coach, executor, coach.num_instructions,
                                       args.max_raw_chars, args.cheat)
    executor_wrapper.train(False)
    return executor_wrapper
示例#2
0
def load_model(coach_path, executor_path):
    if 'onehot' in coach_path:
        coach = ConvOneHotCoach.load(coach_path).to(device)
    elif 'gen' in coach_path:
        coach = RnnGenerator.load(coach_path).to(device)
    else:
        coach = ConvRnnCoach.load(coach_path).to(device)
    coach.max_raw_chars = 200
    executor = Executor.load(executor_path).to(device)
    executor_wrapper = ExecutorWrapper(coach, executor, coach.num_instructions,
                                       200, 0, 'full')
    executor_wrapper.train(False)
    return executor_wrapper
示例#3
0
# Copyright (c) Facebook, Inc. and its affiliates.
示例#4
0
文件: match.py 项目: apjacob/minirts
if __name__ == '__main__':
    args = parse_args()
    print('args:')
    pprint.pprint(vars(args))

    os.environ['LUA_PATH'] = os.path.join(args.lua_files, '?.lua')
    print('lua path:', os.environ['LUA_PATH'])

    if not os.path.exists(args.save_dir):
        os.makedirs(args.save_dir)
    logger_path = os.path.join(args.save_dir, 'train.log')
    sys.stdout = Logger(logger_path)

    device = torch.device('cuda:%d' % args.gpu)
    coach = ConvRnnCoach.load(args.coach_path).to(device)
    coach.max_raw_chars = args.max_raw_chars
    executor = Executor.load(args.model_path).to(device)
    executor_wrapper = ExecutorWrapper(coach, executor, coach.num_instructions,
                                       args.max_raw_chars, args.cheat,
                                       args.inst_mode)
    executor_wrapper.train(False)

    game_option = get_game_option(args)
    ai1_option, ai2_option = get_ai_options(args, coach.num_instructions)

    context, act_dc = create_game(args.num_thread, ai1_option, ai2_option,
                                  game_option)
    context.start()
    dc = DataChannelManager([act_dc])
示例#5
0
# Copyright (c) Facebook, Inc. and its affiliates.
示例#6
0
# Copyright (c) Facebook, Inc. and its affiliates.
示例#7
0
# Copyright (c) Facebook, Inc. and its affiliates.