yufeng 1 year ago
parent
commit
e9aca2b692
1 changed files with 9 additions and 7 deletions
  1. 9 7
      linear/train_jqxx_lstm.py

+ 9 - 7
linear/train_jqxx_lstm.py

@@ -22,7 +22,7 @@ from keras import regularizers
22
 from keras.callbacks import EarlyStopping
22
 from keras.callbacks import EarlyStopping
23
 
23
 
24
 epochs= 330
24
 epochs= 330
25
-early_stopping = EarlyStopping(monitor='accuracy', patience=5, verbose=2)
25
+early_stopping = EarlyStopping(monitor='accuracy', patience=30, verbose=2)
26
 
26
 
27
 
27
 
28
 def curce_data(x,y,y_pred):
28
 def curce_data(x,y,y_pred):
@@ -102,9 +102,11 @@ def demo_1(file, model_file):
102
     # our final FC layer head will have two dense layers, the final one
102
     # our final FC layer head will have two dense layers, the final one
103
     # being our regression head
103
     # being our regression head
104
     x = Dense(128, activation="relu", kernel_regularizer=regularizers.l1(0.003))(cnn_0.input)
104
     x = Dense(128, activation="relu", kernel_regularizer=regularizers.l1(0.003))(cnn_0.input)
105
-    x = Dropout(0.2)(x)
106
-    x = Dense(128, activation="relu")(x)
107
-    x = Dense(256, activation="relu")(x)
105
+    x = Dropout(0.1)(x)
106
+    x = Dense(56, activation="relu")(x)
107
+    x = Dense(56, activation="relu")(x)
108
+    x = Dense(56, activation="relu")(x)
109
+    x = Dense(56, activation="relu")(x)
108
     x = Flatten()(x)
110
     x = Flatten()(x)
109
     # 在建设一层
111
     # 在建设一层
110
     x = Dense(2, activation="sigmoid")(x)
112
     x = Dense(2, activation="sigmoid")(x)
@@ -129,7 +131,7 @@ def demo_1(file, model_file):
129
     print("[INFO] training model...")
131
     print("[INFO] training model...")
130
     model.fit(
132
     model.fit(
131
         [train_x_a], Ytrain,
133
         [train_x_a], Ytrain,
132
-        # validation_data=([testAttrX, testImagesX], testY),
134
+        validation_data=([test_x_a], Ytest),
133
         # epochs=int(3*train_x_a.shape[0]/1300),
135
         # epochs=int(3*train_x_a.shape[0]/1300),
134
         epochs=epochs,
136
         epochs=epochs,
135
         batch_size=1024, shuffle=True,
137
         batch_size=1024, shuffle=True,
@@ -143,11 +145,11 @@ def demo_1(file, model_file):
143
 
145
 
144
 
146
 
145
 windows = 5
147
 windows = 5
146
-x_lenth = 15
148
+x_lenth = 19
147
 
149
 
148
 if __name__ == '__main__':
150
 if __name__ == '__main__':
149
     root_dir = 'D:\\data\\quantization\\jqxx2\\'
151
     root_dir = 'D:\\data\\quantization\\jqxx2\\'
150
     model_dir = 'D:\\data\\quantization\\jqxx2_svm_model\\'
152
     model_dir = 'D:\\data\\quantization\\jqxx2_svm_model\\'
151
-    m = '000004.SH.log'  # 12
153
+    m = '000007.SH.log'  # 12
152
     demo_1(root_dir + m, model_dir + str(m)[:6] + '.pkl')
154
     demo_1(root_dir + m, model_dir + str(m)[:6] + '.pkl')
153
 
155