David 1 개월 전
부모
커밋
020103889d

+ 1 - 1
models_processing/model_tf/bp.yaml

@@ -1,5 +1,5 @@
 Model:
-  add_train: false
+  add_train: true
   batch_size: 64
   dropout_rate: 0.2
   epoch: 200

+ 1 - 1
models_processing/model_tf/cnn.yaml

@@ -1,5 +1,5 @@
 Model:
-  add_train: false
+  add_train: true
   batch_size: 64
   dropout_rate: 0.2
   epoch: 200

+ 1 - 1
models_processing/model_tf/lstm.yaml

@@ -1,5 +1,5 @@
 Model:
-  add_train: false
+  add_train: true
   batch_size: 64
   dropout_rate: 0.2
   epoch: 200

+ 0 - 27
models_processing/model_tf/test.py

@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# -*- coding:utf-8 -*-
-# @FileName  :test.py
-# @Time      :2025/3/5 18:11
-# @Author    :David
-# @Company: shenyang JY
-import numpy as np
-# import tensorflow as tf
-# print("TensorFlow 版本:", tf.__version__)
-# print("GPU 是否可用:", tf.config.list_physical_devices('GPU'))
-
-# 生成三个形状为 (2, 3, 4) 的三维数组
-
-
-# arrays = [np.random.rand(2, 3, 4) for _ in range(3)]
-#
-# # 沿新维度 axis=0 堆叠
-# stacked = np.stack(arrays, axis=2)
-#
-# print("堆叠后的形状:", stacked.shape)
-
-arrays = [np.random.rand(3, 3) for _ in range(2)]
-
-# 沿新维度 axis=0 堆叠
-stacked = np.stack(arrays, axis=0)
-
-print("堆叠后的形状:", stacked.shape)

+ 1 - 1
models_processing/model_tf/test.yaml

@@ -1,5 +1,5 @@
 Model:
-  add_train: false
+  add_train: true
   batch_size: 64
   dropout_rate: 0.2
   epoch: 200

+ 1 - 1
models_processing/model_tf/tf_bp_pre.py

@@ -60,7 +60,7 @@ def model_prediction_bp():
         bp.opt.cap = round(target_scaler.transform(np.array([[float(args['cap'])]]))[0, 0], 2)
         # ------------ 获取模型,预测结果------------
         bp.get_model(args)
-        dh.opt.features = json.loads(bp.model_params).get('features', bp.opt.features)
+        dh.opt.features = json.loads(bp.model_params).get('Model').get('features', ','.join(bp.opt.features)).split(',')
         scaled_pre_x, pre_data = dh.pre_data_handler(pre_data, feature_scaler, bp_data=True)
 
         res = list(chain.from_iterable(target_scaler.inverse_transform(bp.predict(scaled_pre_x))))

+ 1 - 0
models_processing/model_tf/tf_bp_train.py

@@ -68,6 +68,7 @@ def model_training_bp():
                 model = bp.get_keras_model(bp.opt)
         bp_model = bp.training(model, [train_x, train_y, valid_x, valid_y])
         # ------------ 保存模型 ------------
+        args['Model']['features'] = ','.join(dh.opt.features)
         args['params'] = json.dumps(args)
         args['descr'] = '测试'
         args['gen_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))

+ 1 - 1
models_processing/model_tf/tf_cnn_pre.py

@@ -60,7 +60,7 @@ def model_prediction_bp():
         cnn.opt.cap = round(target_scaler.transform(np.array([[float(args['cap'])]]))[0, 0], 2)
 
         cnn.get_model(args)
-        dh.opt.features = json.loads(cnn.model_params).get('features', cnn.opt.features)
+        dh.opt.features = json.loads(cnn.model_params).get('Model').get('features', ','.join(cnn.opt.features)).split(',')
         scaled_pre_x, pre_data = dh.pre_data_handler(pre_data, feature_scaler)
         logger.info("---------cap归一化:{}".format(cnn.opt.cap))
 

+ 1 - 1
models_processing/model_tf/tf_cnn_train.py

@@ -69,7 +69,7 @@ def model_training_bp():
             else:
                 model = cnn.get_keras_model(cnn.opt)
         bp_model = cnn.training(model, [train_x, train_y, valid_x, valid_y])
-
+        args['Model']['features'] = ','.join(dh.opt.features)
         args['params'] = json.dumps(args)
         args['descr'] = '测试'
         args['gen_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))

+ 1 - 1
models_processing/model_tf/tf_lstm_pre.py

@@ -59,7 +59,7 @@ def model_prediction_bp():
         feature_scaler, target_scaler = get_scaler_model_from_mongo(args)
         ts.opt.cap = round(target_scaler.transform(np.array([[float(args['cap'])]]))[0, 0], 2)
         ts.get_model(args)
-        dh.opt.features = json.loads(ts.model_params).get('features', ts.opt.features)
+        dh.opt.features = json.loads(ts.model_params).get('Model').get('features', ','.join(ts.opt.features)).split(',')
         scaled_pre_x, pre_data = dh.pre_data_handler(pre_data, feature_scaler)
         res = list(chain.from_iterable(target_scaler.inverse_transform(ts.predict(scaled_pre_x))))
         pre_data['farm_id'] = args.get('farm_id', 'null')

+ 1 - 1
models_processing/model_tf/tf_lstm_train.py

@@ -66,7 +66,7 @@ def model_training_bp():
             else:
                 model = ts.get_keras_model(ts.opt)
         ts_model = ts.training(model, [train_x, train_y, valid_x, valid_y])
-        args['features'] = dh.opt.features
+        args['Model']['features'] = ','.join(dh.opt.features)
         args['params'] = json.dumps(args)
         args['descr'] = '测试'
         args['gen_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))

+ 1 - 1
models_processing/model_tf/tf_test_pre.py

@@ -60,7 +60,7 @@ def model_prediction_test():
         ts.opt.cap = round(target_scaler.transform(np.array([[float(args['cap'])]]))[0, 0], 2)
 
         ts.get_model(args)
-        dh.opt.features = json.loads(ts.model_params).get('features', ts.opt.features)
+        dh.opt.features = json.loads(ts.model_params).get('Model').get('features', ','.join(ts.opt.features)).split(',')
         scaled_pre_x, pre_data = dh.pre_data_handler(pre_data, feature_scaler)
 
         res = list(chain.from_iterable(target_scaler.inverse_transform(ts.predict(scaled_pre_x))))

+ 1 - 0
models_processing/model_tf/tf_test_train.py

@@ -67,6 +67,7 @@ def model_training_test():
             else:
                 model = ts.get_keras_model(ts.opt)
         ts_model = ts.training(model, [train_x, train_y, valid_x, valid_y])
+        args['Model']['features'] = ','.join(dh.opt.features)
         args['params'] = json.dumps(args)
         args['descr'] = '测试'
         args['gen_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))