我正在使用 TensorFlow Keras 构建和拟合深度神经网络 (DNN)。我读过的文献鼓励我使用 Dropout 层。但是,当我添加dropout
值为 的图层时0.5
,我的渐变体面进展表现得很奇怪。具体来说,训练准确度和验证准确度似乎有一定的硬性限制。
这是什么效果?为什么会这样?任何意见或反馈将不胜感激。
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dropout_1 (Dropout) (None, 136) 0
_________________________________________________________________
dense_1 (Dense) (None, 84) 11508
_________________________________________________________________
dropout_2 (Dropout) (None, 84) 0
_________________________________________________________________
batch_normalization_1 (Batch (None, 84) 336
_________________________________________________________________
dense_2 (Dense) (None, 42) 3570
_________________________________________________________________
batch_normalization_2 (Batch (None, 42) 168
_________________________________________________________________
dropout_3 (Dropout) (None, 42) 0
_________________________________________________________________
dense_3 (Dense) (None, 21) 903
=================================================================
Total params: 16,485
Trainable params: 16,233
Non-trainable params: 252
这是一些代码:
InputCount = 136
OutputCount = 21
H1_Count = 84
H2_Count = 42
H3_Count = 0
H4_Count = 0
initializer = 'he_normal'
activation = ['' ,'elu','elu','elu','elu']
dropout = [0.5,0.5 ,0.5 ,0.5 ,0.5 ]
batch_norm = 1
optimizer = optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False)
loss = 'mse'
epochs = 500
batch_size = 10000 #Stochatic mini-batch size
model = Sequential()
if (dropout[0] > 0) :
model.add(Dropout(dropout[0], input_shape=(InputCount,)) )
model.add(Dense(H1_Count, activation=activation[1], kernel_initializer=initializer ))
if (dropout[1] > 0) : model.add(Dropout(dropout[1]))
else :
model.add(Dense(H1_Count, activation=activation[1], kernel_initializer=initializer, input_shape=(InputCount,) ))
if (dropout[1] > 0) : model.add(Dropout(dropout[1]))
if (batch_norm == 1) : model.add(BatchNormalization())
if (H2_Count > 0) :
model.add(Dense(H2_Count,activation=activation[2], kernel_initializer=initializer))
if (batch_norm == 1) : model.add(BatchNormalization())
if (dropout[2] > 0) : model.add(Dropout(dropout[2]))
if (H3_Count > 0) :
model.add(Dense(H3_Count, activation=activation[3], kernel_initializer=initializer))
if (batch_norm == 1) : model.add(BatchNormalization())
if (dropout[3] > 0) : model.add(Dropout(dropout[3]))
if (H4_Count > 0) :
model.add(Dense(H4_Count, activation=activation[4], kernel_initializer=initializer))
if (batch_norm == 1) : model.add(BatchNormalization())
if (dropout[4] > 0) : model.add(Dropout(dropout[4]))
model.add(Dense(OutputCount, activation='linear'))
model.summary()