简体   繁体   English

Keras:CNN模型不是在学习

[英]Keras: CNN model is not learning

I want to train a model to predict one's emotion from the physical signals. 我想训练一个模型来预测物理信号中的一个人的情绪。 I have a physical signal and using it as input feature; 我有一个物理信号并用它作为输入功能;

ecg(Electrocardiography) ECG(心电图)

In my dataset, there are 312 total records belonging to the participants and there are 18000 rows of data in each record. 在我的数据集中,共有312条记录属于参与者,每条记录中有18000行数据。 So when I combine them into a single data frame, there are 5616000 rows in total. 因此,当我将它们组合成一个数据框时,总共有5616000行。

Here is my train_x dataframe; 这是我的train_x数据帧;

            ecg  
0        0.1912 
1        0.3597 
2        0.3597 
3        0.3597 
4        0.3597 
5        0.3597 
6        0.2739 
7        0.1641 
8        0.0776 
9        0.0005 
10      -0.0375 
11      -0.0676 
12      -0.1071 
13      -0.1197 
..      ....... 
..      ....... 
..      ....... 
5616000 0.0226  

And I have 6 classes which are corresponding to emotions. 我有6个与情绪相对应的课程。 I have encoded these labels with numbers; 我用数字编码了这些标签;

anger = 0, calmness = 1, disgust = 2, fear = 3, happiness = 4, sadness = 5 愤怒= 0,冷静= 1,厌恶= 2,恐惧= 3,幸福= 4,悲伤= 5

Here is my train_y; 这是我的train_y;

         emotion
0              0
1              0
2              0
3              0
4              0
.              .
.              .
.              .
18001          1
18002          1
18003          1
.              .
.              .
.              .
360001         2
360002         2
360003         2
.              .
.              .
.              .
.              .
5616000        5

To feed my CNN, I am reshaping the train_x and one hot encoding the train_y data. 为了给我的CNN提供信息,我正在重新训练train_x和一个热编码train_y数据。

train_x = train_x.values.reshape(312,18000,1) 
train_y = train_y.values.reshape(312,18000)
train_y = train_y[:,:1]  # truncated train_y to have single corresponding value to a complete signal.
train_y = pd.DataFrame(train_y)
train_y = pd.get_dummies(train_y[0]) #one hot encoded labels

After these processes, here is how they look like; 在这些过程之后,这是它们的样子; train_x after reshape; 重塑后的train_x;

[[[0.60399908]
  [0.79763273]
  [0.79763273]
  ...
  [0.09779361]
  [0.09779361]
  [0.14732245]]

 [[0.70386905]
  [0.95101687]
  [0.95101687]
  ...
  [0.41530258]
  [0.41728671]
  [0.42261905]]

 [[0.75008021]
  [1.        ]
  [1.        ]
  ...
  [0.46412148]
  [0.46412148]
  [0.46412148]]

 ...

 [[0.60977509]
  [0.7756791 ]
  [0.7756791 ]
  ...
  [0.12725148]
  [0.02755331]
  [0.02755331]]

 [[0.59939494]
  [0.75514785]
  [0.75514785]
  ...
  [0.0391334 ]
  [0.0391334 ]
  [0.0578706 ]]

 [[0.5786066 ]
  [0.71539303]
  [0.71539303]
  ...
  [0.41355098]
  [0.41355098]
  [0.4112712 ]]]

train_y after one hot encoding; train_y经过一次热编码;

    0  1  2  3  4  5
0    1  0  0  0  0  0
1    1  0  0  0  0  0
2    0  1  0  0  0  0
3    0  1  0  0  0  0
4    0  0  0  0  0  1
5    0  0  0  0  0  1
6    0  0  1  0  0  0
7    0  0  1  0  0  0
8    0  0  0  1  0  0
9    0  0  0  1  0  0
10   0  0  0  0  1  0
11   0  0  0  0  1  0
12   0  0  0  1  0  0
13   0  0  0  1  0  0
14   0  1  0  0  0  0
15   0  1  0  0  0  0
16   1  0  0  0  0  0
17   1  0  0  0  0  0
18   0  0  1  0  0  0
19   0  0  1  0  0  0
20   0  0  0  0  1  0
21   0  0  0  0  1  0
22   0  0  0  0  0  1
23   0  0  0  0  0  1
24   0  0  0  0  0  1
25   0  0  0  0  0  1
26   0  0  1  0  0  0
27   0  0  1  0  0  0
28   0  1  0  0  0  0
29   0  1  0  0  0  0
..  .. .. .. .. .. ..
282  0  0  0  1  0  0
283  0  0  0  1  0  0
284  1  0  0  0  0  0
285  1  0  0  0  0  0
286  0  0  0  0  1  0
287  0  0  0  0  1  0
288  1  0  0  0  0  0
289  1  0  0  0  0  0
290  0  1  0  0  0  0
291  0  1  0  0  0  0
292  0  0  0  1  0  0
293  0  0  0  1  0  0
294  0  0  1  0  0  0
295  0  0  1  0  0  0
296  0  0  0  0  0  1
297  0  0  0  0  0  1
298  0  0  0  0  1  0
299  0  0  0  0  1  0
300  0  0  0  1  0  0
301  0  0  0  1  0  0
302  0  0  1  0  0  0
303  0  0  1  0  0  0
304  0  0  0  0  0  1
305  0  0  0  0  0  1
306  0  1  0  0  0  0
307  0  1  0  0  0  0
308  0  0  0  0  1  0
309  0  0  0  0  1  0
310  1  0  0  0  0  0
311  1  0  0  0  0  0

[312 rows x 6 columns]

After reshaping, I have created my CNN model; 重塑后,我创建了CNN模型;

model = Sequential()
model.add(Conv1D(100,700,activation='relu',input_shape=(18000,1))) #kernel_size is 700 because 18000 rows = 60 seconds so 700 rows = ~2.33 seconds and there is two heart beat peak in every 2 second for ecg signal.
model.add(Conv1D(50,700))
model.add(Dropout(0.5))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(MaxPooling1D(4))
model.add(Flatten())
model.add(Dense(6,activation='softmax'))

adam = keras.optimizers.Adam(lr=0.0001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False)

model.compile(optimizer = adam, loss = 'categorical_crossentropy', metrics = ['acc'])
model.fit(train_x,train_y,epochs = 50, batch_size = 32, validation_split=0.33, shuffle=False)

The problem is, accuracy is not going more than 0.2 and it is fluctuating up and down. 问题是,准确度不会超过0.2,而且会上下波动。 Looks like the model does not learn anything. 看起来模型没有学到任何东西。 I have tried to increase layers , play with the learning rate , changing the loss function , changing the optimizer , scaling the data , normalizing the data , but nothing helped me to solve this problem. 我试图增加图层使用学习速率更改损失函数更改优化器缩放数据规范化数据 ,但没有任何帮助我解决这个问题。 I also tried more simple Dense models or LSTM models but I can't find a way which works. 我也尝试过更简单的Dense模型或LSTM模型,但我找不到一种有效的方法。

How Can I solve this problem? 我怎么解决这个问题? Thanks in advance. 提前致谢。

Addition: 加成:

I wanted to add the training results after 50 epochs; 我希望在50个时期之后添加培训结果;

Epoch 1/80
249/249 [==============================] - 24s 96ms/step - loss: 2.3118 - acc: 0.1406 - val_loss: 1.7989 - val_acc: 0.1587
Epoch 2/80
249/249 [==============================] - 19s 76ms/step - loss: 2.0468 - acc: 0.1647 - val_loss: 1.8605 - val_acc: 0.2222
Epoch 3/80
249/249 [==============================] - 19s 76ms/step - loss: 1.9562 - acc: 0.1767 - val_loss: 1.8203 - val_acc: 0.2063
Epoch 4/80
249/249 [==============================] - 19s 75ms/step - loss: 1.9361 - acc: 0.2169 - val_loss: 1.8033 - val_acc: 0.1905
Epoch 5/80
249/249 [==============================] - 19s 74ms/step - loss: 1.8834 - acc: 0.1847 - val_loss: 1.8198 - val_acc: 0.2222
Epoch 6/80
249/249 [==============================] - 19s 75ms/step - loss: 1.8278 - acc: 0.2410 - val_loss: 1.7961 - val_acc: 0.1905
Epoch 7/80
249/249 [==============================] - 19s 75ms/step - loss: 1.8022 - acc: 0.2450 - val_loss: 1.8092 - val_acc: 0.2063
Epoch 8/80
249/249 [==============================] - 19s 75ms/step - loss: 1.7959 - acc: 0.2369 - val_loss: 1.8005 - val_acc: 0.2222
Epoch 9/80
249/249 [==============================] - 19s 75ms/step - loss: 1.7234 - acc: 0.2610 - val_loss: 1.7871 - val_acc: 0.2381
Epoch 10/80
249/249 [==============================] - 19s 75ms/step - loss: 1.6861 - acc: 0.2972 - val_loss: 1.8017 - val_acc: 0.1905
Epoch 11/80
249/249 [==============================] - 19s 75ms/step - loss: 1.6696 - acc: 0.3173 - val_loss: 1.7878 - val_acc: 0.1905
Epoch 12/80
249/249 [==============================] - 19s 75ms/step - loss: 1.5868 - acc: 0.3655 - val_loss: 1.7771 - val_acc: 0.1270
Epoch 13/80
249/249 [==============================] - 19s 75ms/step - loss: 1.5751 - acc: 0.3936 - val_loss: 1.7818 - val_acc: 0.1270
Epoch 14/80
249/249 [==============================] - 19s 75ms/step - loss: 1.5647 - acc: 0.3735 - val_loss: 1.7733 - val_acc: 0.1429
Epoch 15/80
249/249 [==============================] - 19s 75ms/step - loss: 1.4621 - acc: 0.4177 - val_loss: 1.7759 - val_acc: 0.1270
Epoch 16/80
249/249 [==============================] - 19s 75ms/step - loss: 1.4519 - acc: 0.4498 - val_loss: 1.8005 - val_acc: 0.1746
Epoch 17/80
249/249 [==============================] - 19s 75ms/step - loss: 1.4489 - acc: 0.4378 - val_loss: 1.8020 - val_acc: 0.1270
Epoch 18/80
249/249 [==============================] - 19s 75ms/step - loss: 1.4449 - acc: 0.4297 - val_loss: 1.7852 - val_acc: 0.1587
Epoch 19/80
249/249 [==============================] - 19s 75ms/step - loss: 1.3600 - acc: 0.5301 - val_loss: 1.7922 - val_acc: 0.1429
Epoch 20/80
249/249 [==============================] - 19s 75ms/step - loss: 1.3349 - acc: 0.5422 - val_loss: 1.8061 - val_acc: 0.2222
Epoch 21/80
249/249 [==============================] - 19s 75ms/step - loss: 1.2885 - acc: 0.5622 - val_loss: 1.8235 - val_acc: 0.1746
Epoch 22/80
249/249 [==============================] - 19s 75ms/step - loss: 1.2291 - acc: 0.5823 - val_loss: 1.8173 - val_acc: 0.1905
Epoch 23/80
249/249 [==============================] - 19s 75ms/step - loss: 1.1890 - acc: 0.6506 - val_loss: 1.8293 - val_acc: 0.1905
Epoch 24/80
249/249 [==============================] - 19s 75ms/step - loss: 1.1473 - acc: 0.6627 - val_loss: 1.8274 - val_acc: 0.1746
Epoch 25/80
249/249 [==============================] - 19s 75ms/step - loss: 1.1060 - acc: 0.6747 - val_loss: 1.8142 - val_acc: 0.1587
Epoch 26/80
249/249 [==============================] - 19s 75ms/step - loss: 1.0210 - acc: 0.7510 - val_loss: 1.8126 - val_acc: 0.1905
Epoch 27/80
249/249 [==============================] - 19s 75ms/step - loss: 0.9699 - acc: 0.7631 - val_loss: 1.8094 - val_acc: 0.1746
Epoch 28/80
249/249 [==============================] - 19s 75ms/step - loss: 0.9127 - acc: 0.8193 - val_loss: 1.8012 - val_acc: 0.1746
Epoch 29/80
249/249 [==============================] - 19s 75ms/step - loss: 0.9176 - acc: 0.7871 - val_loss: 1.8371 - val_acc: 0.1746
Epoch 30/80
249/249 [==============================] - 19s 75ms/step - loss: 0.8725 - acc: 0.8233 - val_loss: 1.8215 - val_acc: 0.1587
Epoch 31/80
249/249 [==============================] - 19s 75ms/step - loss: 0.8316 - acc: 0.8514 - val_loss: 1.8010 - val_acc: 0.1429
Epoch 32/80
249/249 [==============================] - 19s 75ms/step - loss: 0.7958 - acc: 0.8474 - val_loss: 1.8594 - val_acc: 0.1270
Epoch 33/80
249/249 [==============================] - 19s 75ms/step - loss: 0.7452 - acc: 0.8795 - val_loss: 1.8260 - val_acc: 0.1587
Epoch 34/80
249/249 [==============================] - 19s 75ms/step - loss: 0.7395 - acc: 0.8916 - val_loss: 1.8191 - val_acc: 0.1587
Epoch 35/80
249/249 [==============================] - 19s 75ms/step - loss: 0.6794 - acc: 0.9357 - val_loss: 1.8344 - val_acc: 0.1429
Epoch 36/80
249/249 [==============================] - 19s 75ms/step - loss: 0.6106 - acc: 0.9357 - val_loss: 1.7903 - val_acc: 0.1111
Epoch 37/80
249/249 [==============================] - 19s 75ms/step - loss: 0.5609 - acc: 0.9598 - val_loss: 1.7882 - val_acc: 0.1429
Epoch 38/80
249/249 [==============================] - 19s 75ms/step - loss: 0.5788 - acc: 0.9478 - val_loss: 1.8036 - val_acc: 0.1905
Epoch 39/80
249/249 [==============================] - 19s 75ms/step - loss: 0.5693 - acc: 0.9398 - val_loss: 1.7712 - val_acc: 0.1746
Epoch 40/80
249/249 [==============================] - 19s 75ms/step - loss: 0.4911 - acc: 0.9598 - val_loss: 1.8497 - val_acc: 0.1429
Epoch 41/80
249/249 [==============================] - 19s 75ms/step - loss: 0.4824 - acc: 0.9518 - val_loss: 1.8105 - val_acc: 0.1429
Epoch 42/80
249/249 [==============================] - 19s 75ms/step - loss: 0.4198 - acc: 0.9759 - val_loss: 1.8332 - val_acc: 0.1111
Epoch 43/80
249/249 [==============================] - 19s 75ms/step - loss: 0.3890 - acc: 0.9880 - val_loss: 1.9316 - val_acc: 0.1111
Epoch 44/80
249/249 [==============================] - 19s 75ms/step - loss: 0.3762 - acc: 0.9920 - val_loss: 1.8333 - val_acc: 0.1746
Epoch 45/80
249/249 [==============================] - 19s 75ms/step - loss: 0.3510 - acc: 0.9880 - val_loss: 1.8090 - val_acc: 0.1587
Epoch 46/80
249/249 [==============================] - 19s 75ms/step - loss: 0.3306 - acc: 0.9880 - val_loss: 1.8230 - val_acc: 0.1587
Epoch 47/80
249/249 [==============================] - 19s 75ms/step - loss: 0.2814 - acc: 1.0000 - val_loss: 1.7843 - val_acc: 0.2222
Epoch 48/80
249/249 [==============================] - 19s 75ms/step - loss: 0.2794 - acc: 1.0000 - val_loss: 1.8147 - val_acc: 0.2063
Epoch 49/80
249/249 [==============================] - 19s 75ms/step - loss: 0.2430 - acc: 1.0000 - val_loss: 1.8488 - val_acc: 0.1587
Epoch 50/80
249/249 [==============================] - 19s 75ms/step - loss: 0.2216 - acc: 1.0000 - val_loss: 1.8215 - val_acc: 0.1587

I would recommend taking several steps back and consider a much simpler approach. 我建议采取几个步骤,并考虑一个更简单的方法。
Based on the following... 基于以下内容......

I have tried to increase layers, play with the learning rate, changing the loss function, changing the optimizer, scaling the data, normalizing the data, but nothing helped me to solve this problem. 我试图增加图层,使用学习速率,更改损失函数,更改优化器,缩放数据,规范化数据,但没有任何帮助我解决这个问题。 I also tried more simple Dense models or LSTM models but I can't find a way which works. 我也尝试过更简单的Dense模型或LSTM模型,但我找不到一种有效的方法。

It doesn't sound like you have as strong of an understanding of your data and your tooling... which is fine cause it's an opportunity to learn. 这听起来并不像你对数据和工具的理解那么强烈......这很好,因为这是一个学习的机会。

A few questions 几个问题

  1. Do you have a base line model? 你有基线模型吗? Have you tried just running a multinomial logistic regression? 您是否尝试过运行多项Logistic回归? If not I would strongly suggest starting there. 如果不是,我强烈建议从那里开始。 Going through the feature engineering needed to make such a model will be invaluable as you increase the complexity of your model. 当您增加模型的复杂性时,完成制作此类模型所需的特征工程将是非常宝贵的。

  2. Did you check for class imbalances? 你检查了课堂失衡吗?

  3. Why are you using a CNN? 你为什么使用CNN? What do you want to accomplish with the convolutional layers? 你想用卷积层完成什么? For me when I'm constructing a vision model for let say classifying the shoes in my closet I use several convolutional layers to extract spatial features such as edges and curves. 对我来说,当我构建一个视觉模型,让我说在我的壁橱里对鞋子进行分类时,我会使用几个卷积层来提取边缘和曲线等空间特征。

  4. Related to the third question... Where did you get this architecture from? 与第三个问题相关...你从哪里获得这个架构? Is it from a publication? 它来自出版物吗? Is this the current state of the art model for ECG traces? 这是ECG迹线的现有技术模型吗? Or is this the most accessible model? 或者这是最容易获得的模型? Sometimes the two are not the same. 有时两者不一样。 I would dig into the literature and search the web a bit more to find some more information about neural networks and analyzing ECG traces. 我会深入研究文献并在网上搜索更多有关神经网络和分析心电图痕迹的更多信息。

I think if you can answer these questions you will be able to solve your problem yourself. 我想如果你能回答这些问题,你将能够自己解决问题。

Current problem in your implementation is, as you have used data with shape of (312,18000,1) for your model, you only have 312 samples and you have used 0.33 validation split so, you are using only 209 samples for training purpose. 您的实现中的当前问题是,因为您已经为模型使用了形状为(312,18000,1)数据,您只有312个样本,并且您使用了0.33验证分割,因此,您仅使用209个样本进行培训。

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d_1 (Conv1D)            (None, 17301, 100)        70100     
_________________________________________________________________
conv1d_2 (Conv1D)            (None, 16602, 50)         3500050   
_________________________________________________________________
dropout_1 (Dropout)          (None, 16602, 50)         0         
_________________________________________________________________
batch_normalization_1 (Batch (None, 16602, 50)         200       
_________________________________________________________________
activation_1 (Activation)    (None, 16602, 50)         0         
_________________________________________________________________
max_pooling1d_1 (MaxPooling1 (None, 4150, 50)          0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 207500)            0         
_________________________________________________________________
dense_1 (Dense)              (None, 6)                 1245006   
=================================================================
Total params: 4,815,356
Trainable params: 4,815,256
Non-trainable params: 100
_________________________________________________________________

As I seen model.summary() , your model has 4,815,256 total trainable parameters. 正如我看到的model.summary() ,您的模型总共有4,815,256个可训练参数。 So, your model is easily overfitting the training data. 因此,您的模型很容易过度拟合训练数据。 Issue is, you have so many parameters to learn without enough samples. 问题是,如果没有足够的样本,您需要学习很多参数。 You can try to reduce your model size as shown below: 您可以尝试缩小模型大小,如下所示:

model = Sequential()
model.add(Conv1D(100,2,activation='relu',input_shape=(18000,1))) 
model.add(Conv1D(10,2))
model.add(Dropout(0.5))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(MaxPooling1D(4))
model.add(Flatten())
model.add(Dense(6,activation='softmax'))
model.summary()
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv1d_1 (Conv1D)            (None, 17999, 100)        300       
_________________________________________________________________
conv1d_2 (Conv1D)            (None, 17998, 10)         2010      
_________________________________________________________________
dropout_1 (Dropout)          (None, 17998, 10)         0         
_________________________________________________________________
batch_normalization_1 (Batch (None, 17998, 10)         40        
_________________________________________________________________
activation_1 (Activation)    (None, 17998, 10)         0         
_________________________________________________________________
max_pooling1d_1 (MaxPooling1 (None, 4499, 10)          0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 44990)             0         
_________________________________________________________________
dense_1 (Dense)              (None, 6)                 269946    
=================================================================
Total params: 272,296
Trainable params: 272,276
Non-trainable params: 20
_________________________________________________________________

As I know you have 3 types of data ecg, gsr, temp. 据我所知,你有3种类型的数据ecg,gsr,temp。 So, you can use train_x as (312,18000,3). 因此,您可以使用train_x作为(312,18000,3)。 and your train_y will be (312,6) . 而你的train_y将是(312,6)

If above solution is not working than, 如果以上解决方案不起作用,

  1. Plot the class distribution from your dataset and check if there is any class imbalance in data. 从数据集中绘制类分布,并检查数据中是否存在任何类不平衡。
  2. As your model is overfitting the data, try to create more data (If this dataset is created by you) or find some data augmentation technique for this. 由于您的模型过度拟合数据,请尝试创建更多数据(如果您创建此数据集)或为此找到一些数据增强技术。

I believe your code is correct, but as the commenter said, you are likely overfitting your data. 我相信您的代码是正确的,但正如评论者所说,您可能会过度拟合您的数据。

You might want to plot validation accuracy and training accuracy over the epochs to visualize this. 您可能希望在时期内绘制验证准确性和训练准确性,以便将其可视化。

You should first consider seeing if your overfitting issue improves with a simpler model. 您应首先考虑使用更简单的模型来查看过度拟合问题是否有所改善。 Note that this will not likely improve your over all performance, but your validation accuracy will more closely match whatever your training accuracy becomes. 请注意,这不太可能提高您的所有性能,但您的验证准确性将更接近您的训练准确度。 Another option would be to add a pooling layer immediately after your convolution layers. 另一种选择是在卷积层之后立即添加池化层。

You may try to add regularizer(s) (L1 or L2), check kernel_initializer and/or adjust the learning rate during training via callbacks. 您可以尝试添加正规kernel_initializer (L1或L2),检查kernel_initializer和/或在训练期间通过回调调整学习速率。 The example below is from a regression model. 以下示例来自回归模型。

model = Sequential()
model.add(Dense(128, input_dim=dims, activation='relu'))
model.add(Dropout(0.2))
model.add(layers.BatchNormalization())
model.add(Dense(16, activation='relu', kernel_initializer='normal', kernel_regularizer=regularizers.l1(x)))
model.add(Dropout(0.2))
model.add(layers.BatchNormalization())
model.add(Dense(1, kernel_initializer='normal'))

model.compile(optimizer=optimizers.adam(lr=l), loss='mean_squared_error')

reduce_lr = ReduceLROnPlateau(monitor='val_loss', mode='min', factor=0.5, patience=3, min_lr=0.000001, verbose=1, cooldown=0)

history = model.fit(xtrain, ytrain, epochs=epochs, batch_size=batch_size, validation_split=0.3, callbacks=[reduce_lr])

I doubt that the way train_y was preprocessed, it could not properly sync with your train_x. 我怀疑train_y的预处理方式,它无法与您的train_x正确同步。 My question would be, did you compress your y_train following some frequency based technique ? 我的问题是,你是否按照基于频率的技术压缩你的y_train?
I think if you have compressed your labels (for each row) by some frequency based technique, you have already introduced high bias on your data. 我认为如果您通过某种基于频率的技术压缩了标签(每行),您已经对数据引入了高偏差。 Do let me know how the compression was done ! 请告诉我压缩是如何完成的! Thanks 谢谢

I would suggest the following: 我建议如下:

  1. I see that number of data points is less. 我看到数据点的数量较少。 More the complexity of the problem, more data points is required for a deep learning model to learn. 问题越复杂,深度学习模型需要更多的数据点才能学习。 Look for a similar dataset with large amount of data. 查找包含大量数据的类似数据集。 Train your network on that dataset and transfer it to your problem. 在该数据集上训练您的网络并将其转移到您的问题。

  2. Is there a way to augment data?? 有没有办法增加数据? I see your signal length as 18000. You can down sample the data by half using different techniques and augment the dataset. 我看到你的信号长度为18000.你可以使用不同的技术将数据下采样一半并增加数据集。 You will be working with signal of length 9000. 您将使用长度为9000的信号。

  3. Try reducing convolution kernel length to 3 or 5 and increase model depth by adding another conv layer. 尝试将卷积核心长度减少到3或5,并通过添加另一个转换层来增加模型深度。

  4. I would strongly suggest to try random forest an gradient boosted trees and see how they perform. 我强烈建议尝试随机森林梯度提升树木,看看它们是如何表现的。

I have face ECG problem when I did my final assignment in college a year ago, but with different approach and data (MIT-BIH). 一年前,当我在大学完成最后一次任务时,我面临着心电图问题,但使用不同的方法和数据(MIT-BIH)。

It seems you use single lead, isn't it? 看来你用的是单引线,不是吗? Have you try to prepare the data before like clean it up (mind the heartbeat noise)? 您是否尝试过准备数据(如清理心跳噪音)? My suggestion is, try to not combine all data into one single list for training, that can occur over fit due the nature of human heartbeat, try to make training based from gender or age. 我的建议是,尽量不将所有数据合并到一个单一的训练列表中,由于人类心跳的性质,可能会发生过度拟合,尝试根据性别或年龄进行训练。 In some literature, it pretty helps. 在一些文献中,它非常有帮助。

Model are not working properly, not because a wrong implementation, but sometimes how we prepare the data well. 模型不能正常工作,不是因为错误的实现,而是有时我们如何准备好数据。

Your model is clearly overfitting the dataset. 您的模型显然过度拟合数据集。 One suggestion that nobody has taken into account among the commenters is to increase the stride. 在评论者中没有人考虑过的一个建议是增加步伐。 Here you have kernel size = 700 , no padding and stride = 1 . 这里你的kernel size = 700 ,没有填充和stride = 1 So you will obtain an output with shape (None, 17301, 100) from the first Conv layer. 因此,您将从第一个Conv层获得具有形状(None, 17301, 100)的输出。

I would try to either increase the stride to a number in the order of 50 to 100 (shifting your kernel of a fraction of 2.33/(700/stride) seconds) or insert a Pooling layer after each of the Conv layers. 我会尝试将步幅增加到大约50到100的数字(将内核移动到2.33/(700/stride)秒的分数)或在每个Conv层之后插入Pooling层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM