-1

我对此很陌生,我正在用 keras 写我的学士论文。我有这个大的 CNN,构建类似于 vgg,但有点不同,因为我有更大的分辨率图像,而且我的池更多一点。我在顶部添加了一个 2048 密集层。我使用什么 Dropout。我想要一个高辍学,因为我的数据很少(请阅读下文)并且我添加了许多神经元。但是当它太高时会发生什么?

我问是因为我的时间有限,而且网络需要 3 天的时间来训练。如果有人以任何方式知道答案或提示,我将不胜感激。任何其他关于改变或做什么的建议/提议,什么对你有用,也非常受欢迎。

提前致谢!这是我构建模型的方式:

model = Sequential()
model.add(Conv2D(64, (3, 3), strides=1, activation='swish', input_shape = input_shape, trainable=True))
model.add(MaxPooling2D((2, 2), name='pool0'))
model.add(Conv2D(64, (3, 3), strides=1, activation='swish', trainable=True))
model.add(MaxPooling2D((2, 2), name='pool1'))

model.add(Conv2D(128, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(128, (3, 3), strides=1, activation='swish', trainable=True))
model.add(MaxPooling2D((2, 2),name='pool2'))

model.add(Conv2D(256, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(256, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(256, (3, 3), strides=1, activation='swish', trainable=True))
model.add(MaxPooling2D((2, 2),name='pool3'))

model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(MaxPooling2D((2, 2),name='pool4'))

model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(Conv2D(512, (3, 3), strides=1, activation='swish', trainable=True))
model.add(MaxPooling2D((2, 2),name='pool5')) 

model.add(Flatten())
model.add(Dense(2048,activation='swish', name='vgg_int'))
model.add(Dropout(0.65))
model.add(Dense(17,activation='softmax')) 

I also wanna add that I have very little data to train from. that is why I want the big dropout. I have around 100 pics per class. sometimes even only 60, sometimes 200:


Found 1807 images belonging to 17 classes.
Found 170 images belonging to 17 classes.

I am confident it can go over 90% on validation-set, but what is the best way to go here, I dont really know. What happens if I go 90% dropout? I currently run 60% but with a smaller model, only 1024 neurons on that top:

Epoch 19/50
226/226 [==============================] - 4966s 22s/step - loss: 0.5661 - accuracy: 0.8307 - val_loss: 0.5752 - val_accuracy: 0.8412
Epoch 20/50
226/226 [==============================] - 4157s 18s/step - loss: 0.5511 - accuracy: 0.8329 - val_loss: 0.5042 - val_accuracy: 0.8647

I am running batch_size = 8 and: optimizer=optimizers.Adam(learning_rate=0.0000015)

again, thanks a lot!

4

1 回答 1

2

Dropout is used to prevent overfitting of the model. I can understand why you would want to use high dropout as your dataset is really small. But using a high dropout value is detrimental to your model and will get in the way of your model learning properly. Since you have a validation set, use it to understand whether your model is overfitting. You can stop training your model when there is a large gap between training accuracy and validation accuracy. I recommend you start with a Dropout of 0.5 and gradually increase it, if you feel unsatisfied with your model's performance.

于 2020-10-10T02:17:52.030 回答