Ejemplo n.º 1
0
for attr, value in sorted(args.__dict__.items()):
    print("\t{}={}".format(attr.upper(), value))
    file.write("\t{}={}\n".format(attr.upper(), value))
file.close()

# model
if args.snapshot is None:
    if args.CNN:
        print("loading CNN model.....")
        model = model_CNN.CNN_Text(args)
    elif args.DEEP_CNN:
        print("loading DEEP_CNN model......")
        model = model_DeepCNN.DEEP_CNN(args)
    elif args.LSTM:
        print("loading LSTM model......")
        model = model_LSTM.LSTM(args)
    elif args.GRU:
        print("loading GRU model......")
        model = model_GRU.GRU(args)
    elif args.BiLSTM:
        print("loading BiLSTM model......")
        model = model_BiLSTM.BiLSTM(args)
    elif args.BiLSTM_1:
        print("loading BiLSTM_1 model......")
        model = model_BiLSTM_1.BiLSTM_1(args)
    elif args.CNN_LSTM:
        print("loading CNN_LSTM model......")
        model = model_CNN_LSTM.CNN_LSTM(args)
    elif args.CLSTM:
        print("loading CLSTM model......")
        model = model_CLSTM.CLSTM(args)
Ejemplo n.º 2
0
    # 处理dev数据
    d_data_list_node = dp.datadeal('data/raw.clean.dev', is_traindata=False)
    # 处理test数据
    test_data_node = dp.datadeal('data/raw.clean.test', is_traindata=False)

    if args.out_word_v:
        args.word_embed = out_word_vec.add_word_v(data_v)

    args.embed_num = len(data_v)
    args.class_num = len(lab_v)

    print("\nParameters:")
    for attr, value in sorted(args.__dict__.items()):
        if attr == 'word_embed':
            continue
        print("\t{}={}".format(attr.upper(), value))

    return t_data_list_node, data_v, d_data_list_node, lab_v


if __name__ == "__main__":

    train_data_list_node, data_voc, dev_data_list_node, lab_voc = loaddata()
    lstm = model_LSTM.LSTM(args)

    try:
        train.train_lstm(train_data_list_node, data_voc, dev_data_list_node,
                         lab_voc, lstm, args)
    except KeyboardInterrupt:
        print('\nstop by human!!!')