def getData(projectname): x_train, y_train = preprocess.get_xy_train( projectname, tokenizer=tokenizer, mn_maxlen=MAX_SEQUENCE_LENGTH, embedding_matrix=embedding_matrix) x_test, y_test = preprocess.get_xy_test(projectname, tokenizer=tokenizer, maxlen=MAX_SEQUENCE_LENGTH, embedding_matrix=embedding_matrix) return x_train, y_train, x_test, y_test
W2V_MODEL_DIR = '/Users/knight/Desktop/GodClassDetection/embedding_model/new_model6_nltk.bin' TRAIN_SET_DIR = '/Users/knight/Desktop/GodClassDetection/trainset' # 直接改成自己的路径 FULL_MN_DIR = TRAIN_SET_DIR tokenizer = preprocess.get_tokenizer(FULL_MN_DIR) all_word_index = tokenizer.word_index embedding_matrix = preprocess.get_embedding_matrix(all_word_index, W2V_MODEL_DIR, dim=EMBEDDING_DIM) acc_list = [] loss_list = [] print("11111111111111111") x_train, y_train = preprocess.get_xy_train(TRAIN_SET_DIR + '/finetune', tokenizer=tokenizer, mn_maxlen=MAX_SEQUENCE_LENGTH, embedding_matrix=embedding_matrix) print('Fine tune model.') # 微调 model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc']) hist = model.fit(x_train, y_train, nb_epoch=10, batch_size=5, verbose=1) score = model.evaluate(x_train, y_train, verbose=0) # 模型保存JSON文件 model_json = model.to_json() with open( r'/Users/knight/Desktop/GodClassDetection/trained_model/fine_tune_model.json', 'w') as file: # with open(r'/Users/knight/Desktop/GodClassDetection-master-mao-new/trained_model/fine_tune_gru_model.json', 'w') as file: