简体   繁体   English

验证准确度波动

[英]Validation Accuracy is fluctuating

Data is comprised of time-series sensor data and an imbalanced Dataset.数据由时间序列传感器数据和不平衡数据集组成。 The data set contains 12 classes of data and needs prediction human physical activities.该数据集包含 12 类数据,需要预测人类的身体活动。

Architecture:建筑学:
Note : LSTM output is directly feeding to the output注意:LSTM 输出是直接馈送到输出

 con_l1 = tf.keras.layers.Conv2D(64, (5, 1), activation="relu")(
            input_layer) 
 con_l2 = tf.keras.layers.Conv2D(64, (5, 1), activation="relu")(con_l1)
 con_l3 = tf.keras.layers.Conv2D(64, (5, 1), activation="relu")(con_l2)
 con_l4 = tf.keras.layers.Conv2D(64, (5, 1), activation="relu")(con_l3)
 rl = Reshape((int(con_l4.shape[1]), int(con_l4.shape[2]) * int(con_l4.shape[3])))(con_l4)
 lstm_l5 = tf.keras.layers.LSTM(128, activation='tanh',
                                recurrent_initializer=tf.keras.initializers.Orthogonal(seed=0), dropout=0.5,
                                       recurrent_dropout=0.25, return_sequences=True)(
     rl)  # required output of each cell to feed into second LSTM layer, so thats why return_sequences=True
       
 lstm_l6 = tf.keras.layers.LSTM(128, activation='tanh',
                                           recurrent_initializer=tf.keras.initializers.Orthogonal(seed=1), dropout=0.5,
                                           recurrent_dropout=0.25, return_sequences=True)(lstm_l5)

Learning Rate with decay of 0.9 after each 10 epochs -每 10 个时期后衰减为 0.9 的学习率 -

tf.keras.optimizers.Adam(learning_rate=0.001)

model.compile(loss="categorical_crossentropy", optimizer=opt, metrics=["acc"])
early_Stopping = tf.keras.callbacks.EarlyStopping(monitor='val_loss', mode = 'min', patience=10, restore_best_weights=True)

The training accuracy and loss monotonically increase and decrease, respectively.训练准确率和损失分别单调增加和减少。 But, my validation data accuracy starts to fluctuate wildly.但是,我的验证数据准确性开始剧烈波动。 The fluctuation in validation loss and accuracy can be seen in the attached ScreenShot.验证损失和准确性的波动可以在随附的屏幕截图中看到。

Here is the Screen Shot of my training:这是我训练的屏幕截图: 在此处输入图片说明

I have set 300 epochs, but training stopped after some iterations like here only on 21 .我已经设置了300 个epoch,但是训练在像这里这样的一些迭代之后只在21上停止了。 I have read this post Why is the validation accuracy fluctuating?我已阅读这篇文章为什么验证准确度会波动? , somehow got the idea that it is an overfitting issue and can be overcome by using dropout. ,不知何故想到这是一个过度拟合的问题,可以通过使用 dropout 来克服。 So, change the value of dropout (a bit up-down) But, it doesn't stop the fluctuations.所以,改变dropout的值(有点上下)但是,它并不能阻止波动。 Could anyone help me figure out where I am going wrong?谁能帮我弄清楚我哪里出错了?

Looks like Overfitting to me also看起来也对我过度拟合

The following is a summary of what can be found here: https://www.tensorflow.org/tutorials/keras/overfit_and_underfit#strategies_to_prevent_overfitting以下是可在此处找到的内容摘要: https : //www.tensorflow.org/tutorials/keras/overfit_and_underfit#strategies_to_prevent_overfit

Reduce the size of your network缩小网络规模

simpler models are less likely to overfit than complex ones.与复杂模型相比,简单模型不太可能过度拟合。

This one is pretty simple, smaller networks do not have as much room to do the brittle kind of learning that leads to remembering the training set这个非常简单,较小的网络没有足够的空间来进行导致记住训练集的脆弱学习

Weight Regularisation权重正则化

a common way to mitigate overfitting is to put constraints on the complexity of a network by forcing its weights only to take small values减轻过度拟合的一种常见方法是通过强制其权重仅采用较小值来限制网络的复杂性

L2 weight regularisation is more common and is also know as weight decay, you can add this to your layers using the kernel_regularizer parameter eg: L2 权重正则化更常见,也称为权重衰减,您可以使用 kernel_regularizer 参数将其添加到您的层,例如:

tf.keras.layers.Conv2D(64, (5, 1), activation="relu", kernel_regularizer=regularizers.l2(0.001))

drop out退出

The intuitive explanation for dropout is that because individual nodes in the network cannot rely on the output of the others, each node must output features that are useful on their own dropout 的直观解释是因为网络中的单个节点不能依赖其他节点的输出,每个节点必须输出对自己有用的特征

You are already using some dropout, but try placing a dropout layer between every conv2d layer also, experiment find what value between 0.2 and 0.5 works best.您已经在使用一些 dropout,但也尝试在每个 conv2d 层之间放置一个 dropout 层,尝试找出 0.2 和 0.5 之间的哪个值效果最好。

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

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