|
@ -17,10 +17,9 @@ import pandas as pd |
|
|
import requests |
|
|
import requests |
|
|
import tensorflow as tf |
|
|
import tensorflow as tf |
|
|
from sklearn.preprocessing import MinMaxScaler |
|
|
from sklearn.preprocessing import MinMaxScaler |
|
|
from tensorflow.keras import backend |
|
|
import keras |
|
|
from tensorflow.keras import layers |
|
|
from keras import backend |
|
|
from tensorflow.keras.models import load_model |
|
|
from keras import layers |
|
|
from tensorflow.keras.models import model_from_json |
|
|
|
|
|
|
|
|
|
|
|
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" |
|
|
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" |
|
|
|
|
|
|
|
@ -53,7 +52,7 @@ def get_history_value(points, time, interval, typedata): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rmse(y_true, y_pred): |
|
|
def rmse(y_true, y_pred): |
|
|
return backend.sqrt(backend.mean(tf.keras.losses.mean_squared_error(y_true, y_pred), axis=-1)) |
|
|
return backend.sqrt(backend.mean(keras.losses.mean_squared_error(y_true, y_pred), axis=-1)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def TrainOffline(x_data, y_data, hidden_layers, epochsdata): |
|
|
def TrainOffline(x_data, y_data, hidden_layers, epochsdata): |
|
@ -73,7 +72,7 @@ def TrainOffline(x_data, y_data, hidden_layers, epochsdata): |
|
|
x_train = x_normal |
|
|
x_train = x_normal |
|
|
y_train = y_normal |
|
|
y_train = y_normal |
|
|
# 构建网络结构 |
|
|
# 构建网络结构 |
|
|
model = tf.keras.Sequential() |
|
|
model = keras.Sequential() |
|
|
model.add(layers.Dense(units=hidden_layers[0], input_dim=x_data.shape[1], activation="sigmoid")) |
|
|
model.add(layers.Dense(units=hidden_layers[0], input_dim=x_data.shape[1], activation="sigmoid")) |
|
|
for i in range(len(hidden_layers) - 1): |
|
|
for i in range(len(hidden_layers) - 1): |
|
|
model.add(layers.Dense(units=hidden_layers[i + 1], activation="sigmoid")) |
|
|
model.add(layers.Dense(units=hidden_layers[i + 1], activation="sigmoid")) |
|
@ -150,7 +149,7 @@ def Train(x_data, y_data, hidden_layers, valuetrs, epochsdata): |
|
|
x_train = x_normal |
|
|
x_train = x_normal |
|
|
y_train = y_normal |
|
|
y_train = y_normal |
|
|
# 构建网络结构 |
|
|
# 构建网络结构 |
|
|
model = tf.keras.Sequential() |
|
|
model = keras.Sequential() |
|
|
model.add(layers.Dense(units=hidden_layers[0], input_dim=x_data.shape[1], activation="sigmoid")) |
|
|
model.add(layers.Dense(units=hidden_layers[0], input_dim=x_data.shape[1], activation="sigmoid")) |
|
|
for i in range(len(hidden_layers) - 1): |
|
|
for i in range(len(hidden_layers) - 1): |
|
|
model.add(layers.Dense(units=hidden_layers[i + 1], activation="sigmoid")) |
|
|
model.add(layers.Dense(units=hidden_layers[i + 1], activation="sigmoid")) |
|
|