yufeng0528 hace 4 años
padre
commit
17cc5652a9
Se han modificado 2 ficheros con 5 adiciones y 8 borrados
  1. 2 1
      stock/cnn_predict.py
  2. 3 7
      stock/cnn_train.py

+ 2 - 1
stock/cnn_predict.py

@@ -18,6 +18,7 @@ def read_data(path):
18 18
 
19 19
 
20 20
 test_x,test_y=read_data("D:\\data\\quantization\\stock6_test.log")
21
+test_x = test_x.reshape(test_x.shape[0], 1,80,5)
21 22
 
22 23
 path="15min_model_seq.h5"
23 24
 model=load_model(path)
@@ -36,7 +37,7 @@ for r in result:
36 37
         if r[0] > 0.5:
37 38
             up_right = up_right + 1
38 39
         elif r[1] > 0.5:
39
-            up_right = up_right + 0.5
40
+            up_right = up_right + 0.9
40 41
         up_num = up_num + 1
41 42
 
42 43
     i = i + 1

+ 3 - 7
stock/cnn_train.py

@@ -42,11 +42,7 @@ def read_data(path):
42 42
 train_x,train_y,test_x,test_y=read_data("D:\\data\\quantization\\stock6.log")
43 43
 train_x = train_x.reshape(train_x.shape[0], 1,80,5)
44 44
 test_x = test_x.reshape(test_x.shape[0], 1,80,5)
45
-# train_y = train_y.reshape(train_y.shape[0],3)
46
-# 调用此次训练的数据集
47
-from keras.datasets import mnist
48
-import numpy as np
49
-np.random.seed(1337)
45
+
50 46
 
51 47
 # 加载数据
52 48
 # (X_train,Y_train),(X_test,Y_test) = mnist.load_data()
@@ -60,7 +56,7 @@ model = Sequential()
60 56
 model.add(Conv2D(
61 57
     nb_filter=32,  # 第一层设置32个滤波器
62 58
     nb_row=3,
63
-    nb_col=15,  # 设置滤波器的大小为5*5
59
+    nb_col=20,  # 设置滤波器的大小为5*5
64 60
     padding='same',  # 选择滤波器的扫描方式,即是否考虑边缘
65 61
     input_shape=(1,80,5),  # 设置输入的形状
66 62
     # batch_input_shape=(64, 1, 28, 28),
@@ -91,7 +87,7 @@ model.compile(optimizer=adam,
91 87
     metrics=['accuracy'])
92 88
 
93 89
 print("Starting training ")
94
-h=model.fit(train_x, train_y, batch_size=64, epochs=14, shuffle=True)
90
+h=model.fit(train_x, train_y, batch_size=64, epochs=10, shuffle=True)
95 91
 score = model.evaluate(test_x, test_y)
96 92
 print(score)
97 93
 print('Test score:', score[0])