第一个模型针对 10 个不平衡类进行了训练。
-------------------------------------------------
DATA SUMMARY
-------------------------------------------------
Class0 2794 images
Class1 1037 images
Class2 2867 images
Class3 6767 images
Class4 4951 images
Class5 500 images
Class6 1257 images
Class7 1401 images
Class8 93 images
Class9 1371 images
Class10 4262 images
TOTAL: 27300 images
-------------------------------------------------
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 140, 160, 32) 896
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 70, 80, 32) 0
_________________________________________________________________
spacing_dummy_layer (Spacing (None, 70, 80, 32) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 70, 80, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 35, 40, 64) 0
_________________________________________________________________
spacing_dummy_layer_1 (Spaci (None, 35, 40, 64) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 35, 40, 128) 73856
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 17, 20, 128) 0
_________________________________________________________________
flatten (Flatten) (None, 43520) 0
_________________________________________________________________
spacing_dummy_layer_2 (Spaci (None, 43520) 0
_________________________________________________________________
dense (Dense) (None, 128) 5570688
_________________________________________________________________
dropout (Dropout) (None, 128) 0
_________________________________________________________________
dense_1 (Dense) (None, 11) 1419
=================================================================
Total params: 5,665,355
Trainable params: 5,665,355
Non-trainable params: 0
_________________________________________________________________
所以结果是这样的: 第一个模型
在平衡数据(每个类超过 1k 样本)并保持相同的模型后,结果如下:在前几个训练 epoch 中损失突然下降,然后出现过拟合(?)
-------------------------------------------------
DATA SUMMARY
-------------------------------------------------
Class0 1360 images
Class1 1037 images
Class2 1350 images
Class3 1441 images
Class4 1110 images
Class5 1000 images
Class6 1257 images
Class7 1401 images
Class8 1093 images
Class9 1371 images
Class10 1562 images
TOTAL: 13082 images
-------------------------------------------------
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 140, 160, 32) 896
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 70, 80, 32) 0
_________________________________________________________________
spacing_dummy_layer (Spacing (None, 70, 80, 32) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 70, 80, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 35, 40, 64) 0
_________________________________________________________________
spacing_dummy_layer_1 (Spaci (None, 35, 40, 64) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 35, 40, 128) 73856
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 17, 20, 128) 0
_________________________________________________________________
flatten (Flatten) (None, 43520) 0
_________________________________________________________________
spacing_dummy_layer_2 (Spaci (None, 43520) 0
_________________________________________________________________
dense (Dense) (None, 128) 5570688
_________________________________________________________________
dropout (Dropout) (None, 128) 0
_________________________________________________________________
dense_1 (Dense) (None, 11) 1419
=================================================================
Total params: 5,665,355
Trainable params: 5,665,355
Non-trainable params: 0
_________________________________________________________________
当试图简化模型(通过减少层和/或减少它们的深度)时,acc 冻结。例如在模型 3 中
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 140, 160, 32) 896
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 70, 80, 32) 0
_________________________________________________________________
spacing_dummy_layer (Spacing (None, 70, 80, 32) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 70, 80, 64) 18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 35, 40, 64) 0
_________________________________________________________________
spacing_dummy_layer_1 (Spaci (None, 35, 40, 64) 0
_________________________________________________________________
flatten (Flatten) (None, 89600) 0
_________________________________________________________________
spacing_dummy_layer_2 (Spaci (None, 89600) 0
_________________________________________________________________
dense (Dense) (None, 64) 5734464
_________________________________________________________________
dropout (Dropout) (None, 64) 0
_________________________________________________________________
dense_1 (Dense) (None, 11) 715
=================================================================
Total params: 5,754,571
Trainable params: 5,754,571
Non-trainable params: 0
知道发生了什么吗?