from keras.models import Sequential from keras.layers import Dense, Dropout, Embedding from keras.layers import InputLayer from keras.layers import LSTM from keras import backend from keras.layers.recurrent import SimpleRNN import pymysql import pickle import os import numpy from data import load_pay_data if __name__ == "__main__": region = "Region_Arab" x_train, y_train, tx_train, ty_train, input_shape = load_pay_data(80, region) model = Sequential() units = 500 model.add(LSTM(units, activation='relu', dropout=0.1, input_shape=input_shape)) # model.add(SimpleRNN(units, activation='relu')) # model.add(Dropout(0.1)) model.add(Dense(1)) model.summary() model.compile(loss = 'mse', optimizer = 'adam') model.fit(x_train, y_train, batch_size=96, epochs=1200) model.save("./predict_pay_" + region) p_data = model.predict(tx_train) for i in range(len(p_data)): print((p_data[i][0] - ty_train[i]) / ty_train[i], p_data[i][0], ty_train[i]) # print("测结果:", p_data[i][0], "测:", tx_train[i], "真实:", ty_train[i])