一维Convnet的准确率达到50%:我不知道为什么

时间:2019-05-16 10:28:15

标签: tensorflow keras

我正在尝试为时间序列二进制分类构建一维convnet。我尝试构建网络,但获得的准确率不超过50%:基本上,它是完全随机的。

查看权重后,我发现在网络的第一层中权重什么都看不到-时间序列中一些易于发现的峰值。

print(x.shape, y.shape)   “(1965,100,1)(1965,2)”

#My model
model = models.Sequential()

model.add(layers.Conv1D(filters = 1,
                        kernel_size = 10,
                        activation = 'relu',
                        input_shape=(timesteps,1)))
model.add(layers.GlobalMaxPooling1D())
model.add(layers.Flatten())
model.add(layers.Dense(1,
                       activation = 'sigmoid'))
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d (Conv1D)              (None, 91, 1)             11        
_________________________________________________________________
global_max_pooling1d (Global (None, 1)                 0         
_________________________________________________________________
flatten (Flatten)            (None, 1)                 0         
_________________________________________________________________
dense (Dense)                (None, 1)                 2         
=================================================================
Total params: 13
Trainable params: 13
Non-trainable params: 0
    model.compile(optimizer = 'rmsprop',
                  loss = 'binary_crossentropy',
                  metrics = ['accuracy'])

    network = model.fit(x, y[:,0],
                        epochs = 20,
                        batch_size = 32,
                        shuffle = True)
    Epoch 1/20
1965/1965 [==============================] - 0s 211us/sample - loss: 0.6929 - accuracy: 0.5247
Epoch 2/20
1965/1965 [==============================] - 0s 78us/sample - loss: 0.6925 - accuracy: 0.5288
Epoch 3/20
1965/1965 [==============================] - 0s 79us/sample - loss: 0.6922 - accuracy: 0.5288
Epoch 4/20
1965/1965 [==============================] - 0s 79us/sample - loss: 0.6920 - accuracy: 0.5288
Epoch 5/20
1965/1965 [==============================] - 0s 77us/sample - loss: 0.6919 - accuracy: 0.5288
Epoch 6/20
1965/1965 [==============================] - 0s 76us/sample - loss: 0.6917 - accuracy: 0.5288
Epoch 7/20
1965/1965 [==============================] - 0s 78us/sample - loss: 0.6917 - accuracy: 0.5288
Epoch 8/20
1965/1965 [==============================] - 0s 76us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 9/20
1965/1965 [==============================] - 0s 79us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 10/20
1965/1965 [==============================] - 0s 77us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 11/20
1965/1965 [==============================] - 0s 77us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 12/20
1965/1965 [==============================] - 0s 77us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 13/20
1965/1965 [==============================] - 0s 83us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 14/20
1965/1965 [==============================] - 0s 81us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 15/20
1965/1965 [==============================] - 0s 81us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 16/20
1965/1965 [==============================] - 0s 79us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 17/20
1965/1965 [==============================] - 0s 80us/sample - loss: 0.6916 - accuracy: 0.5288
Epoch 18/20
1965/1965 [==============================] - 0s 81us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 19/20
1965/1965 [==============================] - 0s 81us/sample - loss: 0.6915 - accuracy: 0.5288
Epoch 20/20
1965/1965 [==============================] - 0s 81us/sample - loss: 0.6915 - accuracy: 0.5288

这就是我所能得到的。


我尝试“手工”构建一个小型conv1D,它表明它实际上可以找到数据中的峰值。

我相信我在犯一些小错误,但无法解决。

0 个答案:

没有答案