Beispiel #1
0

if __name__ == "__main__":

    model_name = "TransformerText"  # TextRNN, TextCNN, lSTMATT, TextRCNN, TransformerText
    data_dir = "/search/hadoop02/suanfa/songyingxin/data/SST-2"
    cache_dir = ".cache/"
    embedding_folder = "/search/hadoop02/suanfa/songyingxin/data/embedding/glove/"

    model_dir = ".models/"
    log_dir = ".log/"

    if model_name == "TextCNN":
        from TextCNN import args, TextCNN

    elif model_name == "TextRNN":
        from TextRNN import args, TextRNN

    elif model_name == "LSTMATT":
        from LSTM_ATT import args, LSTMATT

    elif model_name == "TextRCNN":
        from TextRCNN import args, TextRCNN

    elif model_name == "TransformerText":
        from TransformerText import args, TransformerText

    main(
        args.get_args(data_dir, cache_dir, embedding_folder, model_dir,
                      log_dir))
Beispiel #2
0
        print('{}'.format(dev_report))

    model.load_state_dict(torch.load('tut2-model.pt'))

    test_loss, test_acc, test_report = evaluate(model, test_iterator,
                                                criterion, config.output_dim)
    print("-------------- Test -------------")
    print(f'\t \t Loss: {test_loss: .3f} | Acc: {test_acc*100: .2f} %')
    print('{}'.format(test_report))


if __name__ == "__main__":

    model_name = "TextRNN"  # TextRNN, TextCNN, lSTMATT, TextRCNN
    data_dir = "/home/songyingxin/datasets/SST-2"
    cache_dir = data_dir + "/cache/"
    embedding_folder = "/home/songyingxin/datasets/WordEmbedding/"

    if model_name == "TextCNN":
        from TextCNN import args, TextCNN
        main(args.get_args(data_dir, cache_dir, embedding_folder))
    elif model_name == "TextRNN":
        from TextRNN import args, TextRNN
        main(args.get_args(data_dir, cache_dir, embedding_folder))
    elif model_name == "LSTMATT":
        from LSTM_ATT import args, LSTMATT
        main(args.get_args(data_dir, cache_dir, embedding_folder))
    elif model_name == "TextRCNN":
        from TextRCNN import args, TextRCNN
        main(args.get_args(data_dir, cache_dir, embedding_folder))