コード例 #1
0
    if status == 'train':
        print('Model saved to: ', save_model_dir)
    sys.stdout.flush()

    if status == 'train':
        emb = args.wordemb.lower()
        print('Word Embedding: ', emb)
        if emb == 'glove':
            emb_file = '../data/embedding/glove.6B.100d.txt'
        else:
            emb_file = None
        char_emb_file = args.charemb.lower()
        print('Char Embedding: ', char_emb_file)

        name = 'MetaRNN'  # catnlp
        config = Config()
        config.lr = 0.0015
        config.number_normalized = True
        data_initialization(config, train_file, dev_file, test_file)
        config.gpu = gpu
        config.word_features = name
        print('Word features: ', config.word_features)
        config.generate_instance(train_file, 'train')
        config.generate_instance(dev_file, 'dev')
        config.generate_instance(test_file, 'test')
        if emb_file:
            print('load word emb file...norm: ', config.norm_word_emb)
            config.build_word_pretain_emb(emb_file)
        if char_emb_file != 'none':
            print('load char emb file...norm: ', config.norm_char_emb)
            config.build_char_pretrain_emb(char_emb_file)
コード例 #2
0
    if status == 'train':
        print('Model saved to: ', save_model_dir)
    sys.stdout.flush()

    if status == 'train':
        emb = args.wordemb.lower()
        print('Word Embedding: ', emb)
        if emb == 'glove':
            emb_file = '../../../../data/embedding/glove.6B.100d.txt'
        else:
            emb_file = None
        char_emb_file = args.charemb.lower()
        print('Char Embedding: ', char_emb_file)

        name = 'BaseLSTM'  # catnlp
        config = Config()
        config.layers = 2
        config.optim = 'Adam'
        config.char_features = 'CNN'
        config.lr = 0.015
        config.hidden_dim = 200
        config.bid_flag = True
        config.number_normalized = True
        data_initialization(config, train_file, dev_file, test_file)
        config.gpu = gpu
        config.word_features = name
        print('Word features: ', config.word_features)
        config.generate_instance(train_file, 'train')
        config.generate_instance(dev_file, 'dev')
        config.generate_instance(test_file, 'test')
        if emb_file:
コード例 #3
0
    if status == 'train':
        print('Model saved to: ', save_model_dir)
    sys.stdout.flush()

    if status == 'train':
        emb = args.wordemb.lower()
        print('Word Embedding: ', emb)
        if emb == 'glove':
            emb_file = 'data/embedding/glove.6B.100d.txt'
        else:
            emb_file = None
        char_emb_file = args.charemb.lower()
        print('Char Embedding: ', char_emb_file)

        name = 'BaseLSTM'  # catnlp
        config = Config()
        config.optim = 'SGD'
        config.lr = 0.015
        config.iteration = 200
        config.hidden_dim = 200
        # config.clip = True
        config.number_normalized = True
        config.gpu = gpu
        config.word_features = name
        print('Word features: ', config.word_features)
        count = 0
        with open(args.dataset, 'r') as f:
            for line in f:
                print(line)
                count += 1
                line = line.strip()