David 4 dienas atpakaļ
vecāks
revīzija
fe7bce568c

+ 2 - 2
data_processing/data_operation/data_handler.py

@@ -103,7 +103,7 @@ class DataHandler(object):
         label_features = [col_time, target] if is_train is True else [col_time, target]
         nwp_cs = self.opt.features
         nwp = [feature_data.loc[i:i + time_step_loc, nwp_cs].reset_index(drop=True) for i in range(train_num - time_step*2 + 1)]  # 数据库字段 'C_T': 'C_WS170'
-        labels = [feature_data.loc[i+time_step:i+time_step_loc, label_features].reset_index(drop=True) for i in range(train_num - time_step*2 + 1)]
+        labels = [feature_data.loc[i: i+time_step_loc, label_features].reset_index(drop=True) for i in range(train_num - time_step*2 + 1)]
         features_x, features_y = [], []
         for i, row in enumerate(zip(nwp, labels)):
             features_x.append(row[0])
@@ -122,7 +122,7 @@ class DataHandler(object):
         label_features = [col_time, target] if is_train is True else [col_time, target]
         nwp_cs = self.opt.features
         nwp = [feature_data.loc[i:i + time_step_loc, nwp_cs].reset_index(drop=True) for i in range(train_num - time_step*3 + 1)]  # 数据库字段 'C_T': 'C_WS170'
-        labels = [feature_data.loc[i+time_step:i+time_step_m, label_features].reset_index(drop=True) for i in range(train_num - time_step*3 + 1)]
+        labels = [feature_data.loc[i: i+time_step_loc, label_features].reset_index(drop=True) for i in range(train_num - time_step*3 + 1)]
         features_x, features_y = [], []
         for i, row in enumerate(zip(nwp, labels)):
             features_x.append(row[0])

+ 3 - 3
models_processing/model_tf/tf_bilstm.py

@@ -37,16 +37,16 @@ class TSHandler(object):
             self.logger.info("加载模型权重失败:{}".format(e.args))
 
     @staticmethod
-    def get_keras_model(opt):
+    def get_keras_model(opt, time_series=3):
         loss = region_loss(opt)
         l2_reg = regularizers.l2(opt.Model['lambda_value_2'])
-        nwp_input = Input(shape=(opt.Model['time_step'], opt.Model['input_size']), name='nwp')
+        nwp_input = Input(shape=(opt.Model['time_step']*time_series, opt.Model['input_size']), name='nwp')
 
         con1 = Conv1D(filters=64, kernel_size=5, strides=1, padding='valid', activation='relu', kernel_regularizer=l2_reg)(nwp_input)
         con1_p = MaxPooling1D(pool_size=5, strides=1, padding='valid', data_format='channels_last')(con1)
         nwp_bi_lstm = Bidirectional(LSTM(units=opt.Model['hidden_size'], return_sequences=False,  kernel_regularizer=l2_reg), merge_mode='concat')(con1_p) # 默认拼接双向输出(最终维度=2*hidden_size)
 
-        output = Dense(opt.Model['output_size'], name='cdq_output')(nwp_bi_lstm)
+        output = Dense(opt.Model['time_step']*time_series, name='cdq_output')(nwp_bi_lstm)
 
         model = Model(nwp_input, output)
         adam = optimizers.Adam(learning_rate=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-7, amsgrad=True)

+ 1 - 1
models_processing/model_tf/tf_lstm.py

@@ -47,7 +47,7 @@ class TSHandler(object):
         con1_p = MaxPooling1D(pool_size=5, strides=1, padding='valid', data_format='channels_last')(con1)
         nwp_lstm = LSTM(units=opt.Model['hidden_size'], return_sequences=False, kernel_regularizer=l2_reg)(con1_p)
 
-        output = Dense(opt.Model['output_size'], name='cdq_output')(nwp_lstm)
+        output = Dense(opt.Model['time_step']*time_series, name='cdq_output')(nwp_lstm)
 
         model = Model(nwp_input, output)
         adam = optimizers.Adam(learning_rate=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-7, amsgrad=True)