Преглед на файлове

awg commit algorithm components

anweiguo преди 4 месеца
родител
ревизия
75b9e4c6bd
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      models_processing/model_train/model_training_lstm.py

+ 4 - 3
models_processing/model_train/model_training_lstm.py

@@ -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: