39 lines
932 B
Python
39 lines
932 B
Python
|
|
|
|
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
|
|
|
|
import pymysql
|
|
import pickle
|
|
import os
|
|
import numpy
|
|
|
|
from data import load_pay_data
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
x_train, y_train, tx_train, ty_train = load_pay_data(80)
|
|
|
|
|
|
model = Sequential()
|
|
units = 500
|
|
model.add(LSTM(units, activation='relu', input_shape=(3,1)))
|
|
model.add(Dropout(0.3))
|
|
model.add(Dense(1))
|
|
model.summary()
|
|
model.compile(loss='mse', optimizer='adam')
|
|
|
|
model.fit(x_train, y_train, batch_size=1, epochs=50)
|
|
model.save("./predict_pay")
|
|
|
|
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])
|
|
|
|
|
|
|