Exemplo n.º 1
0
def main():
    import utils
    utils.pdb_on_error()

    ontology_path = os.path.join(xtrack2_config.data_directory,
                                 'dstc2/scripts/config/ontology_dstc2.json')
    with open(ontology_path) as f_in:
        dstc_ontology = json.load(f_in)
        ontology = dict(food=dstc_ontology['informable']['food'])

    xtrack_data2.prepare_experiment(
        experiment_name='e2_food_tagged',
        data_directory=xtrack2_config.data_directory,
        slots=['food'],
        slot_groups={'food': ['food']},
        ontology=ontology,
        builder_opts=dict(tagged=True, no_label_weight=True),
        skip_dstc_import_step=True)
Exemplo n.º 2
0
def main(skip_dstc_import_step, builder_type):
    import utils
    utils.pdb_on_error()

    ontology_path = os.path.join(xtrack2_config.data_directory,
                                 'dstc2/scripts/config/ontology_dstc2.json')
    with open(ontology_path) as f_in:
        dstc_ontology = json.load(f_in)
        ontology = dict(food=dstc_ontology['informable']['food'],
                        pricerange=dstc_ontology['informable']['pricerange'],
                        area=dstc_ontology['informable']['area'],
                        name=dstc_ontology['informable']['name'],
                        method=dstc_ontology['method'])

    data_utils.prepare_experiment(
        experiment_name='e2_tagged_%s' % builder_type,
        data_directory=xtrack2_config.data_directory,
        slots=[
            'food', 'area', 'pricerange', 'name', 'method', 'req_food',
            'req_area', 'req_pricerange', 'req_name', 'req_phone', 'req_addr',
            'req_postcode', 'req_signature'
        ],
        slot_groups=dict(food=['food'],
                         area=['area'],
                         pricerange=['pricerange'],
                         name=['name'],
                         method=['method'],
                         goals=['food', 'area', 'pricerange', 'name'],
                         requested=[
                             'req_food', 'req_area', 'req_pricerange',
                             'req_name', 'req_phone', 'req_addr',
                             'req_postcode', 'req_signature'
                         ]),
        ontology=ontology,
        builder_opts=dict(tagged=True, no_label_weight=True),
        skip_dstc_import_step=skip_dstc_import_step,
        builder_type=builder_type)
Exemplo n.º 3
0
                flags += ' INCORRECT'

            if (a1 == food_t):
                flags += ' BCORRECT'
            else:
                flags += ' BINCORRECT'

            print flags

            if a1 == food_t:
                acc_good += 1
            acc_total += 1

            if a2 == food_t:
                acc_good_our += 1
            acc_total_our += 1

            if a1 != '_null_' or a2 != '_null_' or food_t != '_null_':
                print '    bas: %.30s our: %.30s true: %s' % (food_d1, food_d2,
                                                              food_t)
                print

    print 'baseline accuracy', acc_good / acc_total
    print 'our accuracy', acc_good_our / acc_total_our


if __name__ == '__main__':
    from utils import pdb_on_error
    pdb_on_error()
    main()
Exemplo n.º 4
0
    parser.add_argument('--oclf_n_layers', default=0, type=int)
    parser.add_argument('--oclf_activation', default="tanh", type=str)

    parser.add_argument('--rnn_n_layers', default=1, type=int)

    parser.add_argument('--lstm_peepholes', default=False, action='store_true')
    parser.add_argument('--lstm_bidi', default=True, action='store_true')

    parser.add_argument('--debug', default=True, action='store_true')
    parser.add_argument('--track_log', default='track_log.txt', type=str)
    parser.add_argument(
        '--eval_on_full_train', default=False, action='store_true'
    )
    parser.add_argument(
        '--enable_branch_exp', default=False, action='store_true'
    )
    parser.add_argument(
        '--enable_token_supervision', default=False, action='store_true'
    )
    parser.add_argument('--ontology', required=True)

    return parser


if __name__ == '__main__':
    parser = build_argument_parser()
    args = parser.parse_args()
    pdb_on_error()
    args_lst = list(sorted(vars(args).iteritems()))
    main(args_lst, **vars(args))
Exemplo n.º 5
0
        env.new_episode()
        while not env.is_finished():
            env.step()
            if env.episode % episode_modulo == 0:
                print(unicode(env))

        env.finalize_episode()

        if env.episode % episode_modulo == 0:
            modulo_callback()


if __name__ == '__main__':
    import utils
    utils.pdb_on_error()

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--alpha', type=float, default=0.1)
    parser.add_argument('--gamma', type=float, default=1.0)
    parser.add_argument('--epsilon', type=float, default=0.1)
    parser.add_argument('--episode_modulo', type=float, default=1000)
    parser.add_argument('--agent', action='append')
    #parser.add_argument('--agent1_type', default='sarsa')
    #parser.add_argument('--agent2_type', default='sarsa')
    #parser.add_argument('--agent1_load', default=None)
    #parser.add_argument('--agent1_save', default=None)
    #parser.add_argument('--agent2_load', default=None)
    #parser.add_argument('--agent2_save', default=None)
Exemplo n.º 6
0
        'slots': data.slots
    }

    return context


def visualize_html(track_file, dataset, dest_file):
    context = visualize(track_file, dataset)
    add_common_context(context)

    env = Environment(loader=FileSystemLoader('xtrack2_vis'))
    tpl = env.get_template('xtrack2_track_index.html')

    with open(dest_file, 'w') as f_out:
        f_out.write(tpl.render(**context))


if __name__ == '__main__':
    import argparse
    import utils
    utils.pdb_on_error()

    parser = argparse.ArgumentParser()
    parser.add_argument('--track_file')
    parser.add_argument('--dataset')
    parser.add_argument('--dest_file')

    args = parser.parse_args()

    visualize_html(**vars(args))