|
@@ -13,10 +13,9 @@ from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau
|
|
|
import tensorflow as tf
|
|
|
from common.database_dml import get_data_from_mongo,insert_h5_model_into_mongo
|
|
|
from common.processing_data_common import missing_features,str_to_list
|
|
|
-import threading
|
|
|
+import time
|
|
|
+import random
|
|
|
app = Flask('model_training_lightgbm——service')
|
|
|
-# 创建一个锁对象
|
|
|
-lock = threading.Lock()
|
|
|
def rmse(y_true, y_pred):
|
|
|
return tf.math.sqrt(tf.reduce_mean(tf.square(y_true - y_pred)))
|
|
|
|
|
@@ -36,6 +35,8 @@ def create_sequences(data_features,data_target,time_steps):
|
|
|
|
|
|
|
|
|
def build_model(data, args):
|
|
|
+ sleep_time = random.uniform(1, 20) # 生成 5 到 20 之间的随机浮动秒数
|
|
|
+ time.sleep(sleep_time)
|
|
|
tf.keras.backend.clear_session() # 清除当前的图和会话
|
|
|
col_time, time_steps,features,target = args['col_time'], int(args['time_steps']), str_to_list(args['features']),args['target']
|
|
|
if 'is_limit' in data.columns:
|