parser.add_argument("-oracle_identifier", type=str, default='5297505520ab25d51eabb5e652843380', help='Oracle identifier')  # Use checkpoint id instead?
    parser.add_argument("-qgen_identifier", type=str, default='a2aac2dc381bd51f82332106efb14ecc', help='Qgen identifier')
    parser.add_argument("-guesser_identifier", type=str, default='4061b58d200976b96006f6dcea468aef', help='Guesser identifier')

    # parser.add_argument("-from_checkpoint", type=bool, default=False, help="Start from checkpoint?")
    parser.add_argument("-from_checkpoint", type=str, help="Start from checkpoint?")

    parser.add_argument("-gpu_ratio", type=float, default=0.95, help="How muany GPU ram is required? (ratio)")
    parser.add_argument("-no_thread", type=int, default=1, help="No thread to load batch")

    args = parser.parse_args()

    loop_config, exp_identifier, save_path = load_config(args.config, args.exp_dir)

    # Load all  networks configs
    oracle_config = get_config_from_xp(os.path.join(args.networks_dir, "oracle"), args.oracle_identifier)
    guesser_config = get_config_from_xp(os.path.join(args.networks_dir, "guesser"), args.guesser_identifier)
    qgen_config = get_config_from_xp(os.path.join(args.networks_dir, "qgen"), args.qgen_identifier)

    logger = logging.getLogger()

    ###############################
    #  LOAD DATA
    #############################

    # Load image
    logger.info('Loading images..')
    image_loader = get_img_loader(qgen_config['model']['image'], args.image_dir)
    crop_loader = None  # get_img_loader(guesser_config['model']['crop'], args.image_dir)

    # Load data
    parser.add_argument("-gpu_ratio", type=float, default=0.95, help="How muany GPU ram is required? (ratio)")
    parser.add_argument("-no_thread", type=int, default=4, help="No thread to load batch")
    parser.add_argument("-load_new",  type=lambda x: bool(strtobool(x)), default="True", help="Start from checkpoint?")
    parser.add_argument("-test_ini",  type=lambda x: bool(strtobool(x)), default="True", help="Start from checkpoint?")
    parser.add_argument("-use_redis",  type=lambda x: bool(strtobool(x)), default="False", help="Start from checkpoint?")

    args = parser.parse_args()

    no_epoch = args.train_epoch

    loop_config, xp_manager = load_config(args)
    logger = logging.getLogger()

    # Load all  networks configs
    oracle_config = get_config_from_xp(os.path.join(args.networks_dir, "oracle"), loop_config["oracle_identifier"])
    guesser_config = get_config_from_xp(os.path.join(args.networks_dir, "guesser"), loop_config["guesser_identifier"])
    qgen_config = get_config_from_xp(os.path.join(args.networks_dir, "qgen"), loop_config["qgen_identifier"])

    ###############################
    #  LOAD DATA
    #############################

    # Load image

    if args.load_new and qgen_config['model']['image']['image_input'] == "rcnn":
        rcnn = True
        print("rcnn!")
    else:
        rcnn = False
Exemple #3
0
        })

    tf.reset_default_graph()
    with tf.Session(config=config_gpu) as sess_loop:
        # compute the loop accuracy
        logger.info("==================loop===================")
        mode_to_evaluate = ["sampling", "greedy", "beam"]
        cpu_pool = create_cpu_pool(args.no_thread, use_process=False)

        train_batchifier = LooperBatchifier(tokenizer, generate_new_games=True)
        eval_batchifier = LooperBatchifier(tokenizer, generate_new_games=False)
        oracle_dir = "out/oracle/"
        oracle_checkpoint = "6e0ec7f150b27f46296406853f498af6"
        guesser_dir = "out/guesser/"
        guesser_checkpoint = "c48036b430ebca1c44a25188edb05034"
        oracle_config = get_config_from_xp(oracle_dir, oracle_checkpoint)
        guesser_config = get_config_from_xp(guesser_dir, guesser_checkpoint)

        qgen_network, qgen_batchifier_cstor = create_qgen(
            config["model"], num_words=tokenizer.no_words)
        qgen_var = [v for v in tf.global_variables()
                    if "qgen" in v.name]  # and 'rl_baseline' not in v.name
        for v in qgen_var:
            print(v.name)
        qgen_saver = tf.train.Saver(var_list=qgen_var)

        oracle_network, oracle_batchifier_cstor = create_oracle(
            oracle_config["model"], num_words=tokenizer.no_words - 1)
        oracle_var = [v for v in tf.global_variables() if "oracle" in v.name]
        oracle_saver = tf.train.Saver(var_list=oracle_var)
Exemple #4
0
    #############################

    # CPU/GPU option
    gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_ratio)

    with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:

        ###############################
        #  LOAD NETWORKS
        #############################

        '''User is the oracle'''
        oracle_wrapper = OracleUserWrapper(tokenizer)
        logger.info("No Oracle was registered >>> use user input")
        '''Build Guesser'''
        guesser_config = get_config_from_xp(os.path.join('./out/', "guesser"), args.guesser_identifier)
        guesser_network, guesser_batchifier_cstor, guesser_listener = create_guesser(guesser_config["model"],
                                                                                     num_words=tokenizer.no_words)

        # guesser_network = GuesserNetwork_v1(guesser_config["model"], num_words=tokenizer.no_words)

        guesser_var = [v for v in tf.global_variables() if "guesser" in v.name]
        guesser_saver = tf.train.Saver(var_list=guesser_var)
        guesser_saver.restore(sess, os.path.join('./out', 'guesser', args.guesser_identifier, 'best/params.ckpt'))
        guesser_batchifier = guesser_batchifier_cstor(tokenizer, sources=guesser_network.get_sources(sess))
        guesser_wrapper = GuesserWrapper(guesser_network, guesser_batchifier, tokenizer, guesser_listener)
        '''Build QGen'''
        qgen_config = get_config_from_xp(os.path.join('./out', "qgen"), args.qgen_identifier)
        qgen_network, qgen_batchifier_cstor = create_qgen(qgen_config["model"], num_words=tokenizer.no_words, policy_gradient = False)

        # qgen_network = QGenNetworkHREDDecoderUAQRAH(qgen_config["model"], num_words=tokenizer.no_words, policy_gradient=False)