示例#1
0
文件: cv.py 项目: zle1992/CIKM
def main(model_name):
    print('model name', model_name)
    if model_name == 'bimpm':
        model = bimpm()
    if model_name == 'drmmt':
        model = drmm_tks()

    if model_name == 'cnn':

        model = model_conv1D_()
    if model_name == 'slstm':

        model = Siamese_LSTM()

    if model_name == 'esim':
        model = esim()

    if model_name == 'dam':
        model = decomposable_attention()
    if model_name == 'abcnn':

        model = ABCNN(
            left_seq_len=config.word_maxlen, right_seq_len=config.word_maxlen, depth=3,
            nb_filter=100, filter_widths=[5, 4, 3],
            collect_sentence_representations=True, abcnn_1=True, abcnn_2=True,
            # mode="euclidean",
            mode="cos",
            # mode='dot'
        )
    do_train_cv(model_name, model, epoch_nums=1, kfolds=5)
def get_model(model_name):
    lr = 0.001
    if model_name == 'bimpm':  #3,no
        model = bimpm()
    if model_name == 'drmmt':  #3, yes, but all 1
        model = drmm_tks(num_layer=3, hidden_sizes=[100, 80, 1], topk=20)

    if model_name == 'msrnn':
        model = MATCHSRNN()
    if model_name == 'dssm':
        model = dssm()  #5

    if model_name == 'arc2':
        model = arc2()
    if model_name == 'test':
        model = test()
    if model_name == 'cnn':
        lr = 0.01
        model = model_conv1D_()
    if model_name == 'rnn':

        model = rnn_v1()
    if model_name == 'rnn0':  #3,yes
        model = my_rnn()
    if model_name == 'slstm':

        model = Siamese_LSTM()  #5,no
    if model_name == 'scnn':

        model = Siamese_CNN()  #not exit

    if model_name == 'esim':  #5,no
        lr = 0.01
        model = esim()

    if model_name == 'dam':  #3, yes
        model = decomposable_attention()
    if model_name == 'abcnn':

        model = ABCNN(
            left_seq_len=config.word_maxlen,
            right_seq_len=config.word_maxlen,
            depth=2,
            nb_filter=100,
            filter_widths=[5, 3],
            collect_sentence_representations=False,
            abcnn_1=True,
            abcnn_2=True,
            # mode="euclidean",
            # mode="cos",
            mode='dot')

    return model, lr
示例#3
0
def main(model_name):
    print('model name', model_name)
    x_train, y_train, x_dev, y_dev = load_data()

    if model_name == 'bimpm':
        model = bimpm()

    if model_name == 'cnn':

        model = model_conv1D_()
    if model_name == 'slstm':

        model = Siamese_LSTM()

    if model_name == 'esim':
        model = esim()

    if model_name == 'dam':
        model = decomposable_attention()
    if model_name == 'abcnn':

        model = ABCNN(
            left_seq_len=config.word_maxlen,
            right_seq_len=config.word_maxlen,
            depth=3,
            nb_filter=100,
            filter_widths=[5, 4, 3],
            collect_sentence_representations=True,
            abcnn_1=True,
            abcnn_2=True,
            #mode="euclidean",
            mode="cos",
            #mode='dot'
        )

    train(x_train, y_train, x_dev, y_dev, model_name, model)