我的数据集为12,311,并且我将80%,20%的比例用于验证数据。我正在使用批处理生成器应用4种不同的随机增强,因为我已经对其进行了测试,所以效果很好。当我训练我的模块时,精度似乎在每次大约7个纪元后就不再提高。
我的模特:
def nvidiaModel():
model = Sequential()
model.add(Conv2D(24, (5, 5), padding="same", subsample=(2, 2), input_shape=(112, 256, 3), activation="elu"))
model.add(Convolution2D(36, 5, 5, subsample=(2, 2), activation="elu")) # Second CNN
model.add(Convolution2D(48, 5, 5, subsample=(2, 2), activation="elu")) # Third CNN
model.add(Convolution2D(64, 3, 3, activation="elu")) # Fourth CNN # No need for more stride skipping.
model.add(Convolution2D(64, 3, 3, activation="elu")) # Fifth CNN
model.add(Flatten())
model.add(Dense(100, activation="elu"))
model.add(Dense(50, activation="elu"))
model.add(Dense(10, activation="elu"))
model.add(Dense(3, activation="softmax")) # Which will hold the steering angel.
optimizer = Adam(lr=1e-5)
model.compile(loss="mse", optimizer=optimizer, metrics=["accuracy"])
return model
摘要:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_1 (Conv2D) (None, 56, 128, 24) 1824
_________________________________________________________________
conv2d_2 (Conv2D) (None, 26, 62, 36) 21636
_________________________________________________________________
conv2d_3 (Conv2D) (None, 11, 29, 48) 43248
_________________________________________________________________
conv2d_4 (Conv2D) (None, 9, 27, 64) 27712
_________________________________________________________________
conv2d_5 (Conv2D) (None, 7, 25, 64) 36928
_________________________________________________________________
flatten_1 (Flatten) (None, 11200) 0
_________________________________________________________________
dense_1 (Dense) (None, 100) 1120100
_________________________________________________________________
dense_2 (Dense) (None, 50) 5050
_________________________________________________________________
dense_3 (Dense) (None, 10) 510
_________________________________________________________________
dense_4 (Dense) (None, 3) 33
=================================================================
Total params: 1,257,041
Trainable params: 1,257,041
Non-trainable params: 0
训练参数:
history = model.fit_generator(batchGenerator(X_train, y_train, 1000, 1),
steps_per_epoch = 25,
epochs = 30,
validation_data = batchGenerator(X_valid, y_valid, 300, 0),
validation_steps = 20,
verbose = 1,
shuffle = 1)
时代:
Epoch 1/30
25/25 [==============================] - 52s 2s/step - loss: 0.1709 - acc: 0.6624 - val_loss: 0.1618 - val_acc: 0.6718
Epoch 2/30
25/25 [==============================] - 48s 2s/step - loss: 0.1579 - acc: 0.6764 - val_loss: 0.1524 - val_acc: 0.6767
Epoch 3/30
25/25 [==============================] - 48s 2s/step - loss: 0.1535 - acc: 0.6686 - val_loss: 0.1444 - val_acc: 0.6737
Epoch 4/30
25/25 [==============================] - 48s 2s/step - loss: 0.1460 - acc: 0.6748 - val_loss: 0.1311 - val_acc: 0.7063
Epoch 5/30
25/25 [==============================] - 48s 2s/step - loss: 0.1366 - acc: 0.7076 - val_loss: 0.1262 - val_acc: 0.7370
Epoch 6/30
25/25 [==============================] - 48s 2s/step - loss: 0.1322 - acc: 0.7249 - val_loss: 0.1238 - val_acc: 0.7485
Epoch 7/30
25/25 [==============================] - 48s 2s/step - loss: 0.1313 - acc: 0.7294 - val_loss: 0.1238 - val_acc: 0.7508
Epoch 8/30
25/25 [==============================] - 48s 2s/step - loss: 0.1276 - acc: 0.7370 - val_loss: 0.1173 - val_acc: 0.7538
Epoch 9/30
25/25 [==============================] - 48s 2s/step - loss: 0.1275 - acc: 0.7380 - val_loss: 0.1181 - val_acc: 0.7513
Epoch 10/30
25/25 [==============================] - 50s 2s/step - loss: 0.1260 - acc: 0.7414 - val_loss: 0.1177 - val_acc: 0.7537
Epoch 11/30
25/25 [==============================] - 48s 2s/step - loss: 0.1256 - acc: 0.7430 - val_loss: 0.1159 - val_acc: 0.7553
Epoch 12/30
25/25 [==============================] - 49s 2s/step - loss: 0.1245 - acc: 0.7453 - val_loss: 0.1185 - val_acc: 0.7578
Epoch 13/30
25/25 [==============================] - 49s 2s/step - loss: 0.1232 - acc: 0.7491 - val_loss: 0.1183 - val_acc: 0.7582
Epoch 14/30
25/25 [==============================] - 48s 2s/step - loss: 0.1224 - acc: 0.7501 - val_loss: 0.1219 - val_acc: 0.7423
Epoch 15/30
25/25 [==============================] - 48s 2s/step - loss: 0.1222 - acc: 0.7510 - val_loss: 0.1162 - val_acc: 0.7582
Epoch 16/30
25/25 [==============================] - 49s 2s/step - loss: 0.1218 - acc: 0.7487 - val_loss: 0.1165 - val_acc: 0.7587
Epoch 17/30
25/25 [==============================] - 48s 2s/step - loss: 0.1234 - acc: 0.7454 - val_loss: 0.1185 - val_acc: 0.7442
Epoch 18/30
25/25 [==============================] - 49s 2s/step - loss: 0.1208 - acc: 0.7539 - val_loss: 0.1159 - val_acc: 0.7572
Epoch 19/30
25/25 [==============================] - 49s 2s/step - loss: 0.1215 - acc: 0.7509 - val_loss: 0.1165 - val_acc: 0.7543
Epoch 20/30
25/25 [==============================] - 49s 2s/step - loss: 0.1216 - acc: 0.7507 - val_loss: 0.1171 - val_acc: 0.7590
Epoch 21/30
25/25 [==============================] - 48s 2s/step - loss: 0.1217 - acc: 0.7515 - val_loss: 0.1140 - val_acc: 0.7618
Epoch 22/30
25/25 [==============================] - 49s 2s/step - loss: 0.1208 - acc: 0.7496 - val_loss: 0.1170 - val_acc: 0.7565
Epoch 23/30
25/25 [==============================] - 48s 2s/step - loss: 0.1200 - acc: 0.7526 - val_loss: 0.1169 - val_acc: 0.7575
Epoch 24/30
25/25 [==============================] - 49s 2s/step - loss: 0.1209 - acc: 0.7518 - val_loss: 0.1105 - val_acc: 0.7705
Epoch 25/30
25/25 [==============================] - 48s 2s/step - loss: 0.1198 - acc: 0.7540 - val_loss: 0.1176 - val_acc: 0.7543
Epoch 26/30
25/25 [==============================] - 48s 2s/step - loss: 0.1206 - acc: 0.7528 - val_loss: 0.1127 - val_acc: 0.7608
Epoch 27/30
25/25 [==============================] - 48s 2s/step - loss: 0.1204 - acc: 0.7526 - val_loss: 0.1185 - val_acc: 0.7532
我曾尝试增加批量大小,但结果相同,经过一定数量的时间后它将停止改进。我尝试添加辍学层,结果相同。
有人对这里可能出什么问题有建议吗?
答案 0 :(得分:0)
如果不了解您要解决的问题的类型以及所涉及的数据集,就无法确定地说。例如,您可能有一个肮脏的数据集或一个困难的问题,对于该问题,您可能会得到75%的质量(尽管我说这不太可能)。另一种可能性是,您的示例中有75%来自单个班级,而您的模型只是在学习模式(即总是猜测该班级)。
乍看之下,我会尝试另一种损失-mse
的输出上的softmax
可能会导致梯度消失。如果您要进行分类,我将从(sparse_categorical_)crossentropy
开始。
答案 1 :(得分:0)