我正在尝试构建 CNN 回归模型。输入数据为10年的卫星图像。
输入形状为[10, 256,256, 10]
,表示[年份、图像形状、图像形状、 channel /频段]
模型的输出是0-1之间的数字,即图像中区域的百分比值。
这些是使用的参数
CHANNELS=5
BATCH_SIZE=16
INPUT_SHAPE=(10,IMG_SIZE,IMG_SIZE,CHANNELS)
SAMPLES=100
LR=1e-7
EPOCHES=10
我使用 Conv3D 层作为输入层,因为它能够向模型提供体积数据,并使用 Dense 层作为输出。
Model: sequential_FLATTEN_100_5_16_SGD_1e-07_30_v1
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv3d_3 (Conv3D) (None, 10, 254, 254, 32) 1472
_________________________________________________________________
max_pooling3d_3 (MaxPooling3 (None, 10, 127, 127, 32) 0
_________________________________________________________________
conv3d_4 (Conv3D) (None, 10, 125, 125, 64) 18496
_________________________________________________________________
max_pooling3d_4 (MaxPooling3 (None, 10, 62, 62, 64) 0
_________________________________________________________________
flatten_3 (Flatten) (None, 2460160) 0
_________________________________________________________________
dense_24 (Dense) (None, 256) 629801216
_________________________________________________________________
dense_25 (Dense) (None, 1) 257
=================================================================
Total params: 629,821,441
Trainable params: 629,821,441
Non-trainable params: 0
_________________________________________________________________
该模型在训练集上给出以下分数:
mean_absolute_error: 0.09013315520024737
mean_squared_error: 0.11449361186977994
explained_variance_score: -0.2407465861253424
r2_score: -0.9382254392540899
在验证集上:
mean_absolute_error: 0.1923245317002776
mean_squared_error: 0.2579017795812263
explained_variance_score: -5.067052299015521
r2_score: -5.4177061135705475
我还尝试了以下不同的模型: 其中只有第一层是 Conv3D,其余都是 Dense 层
Model: "sequential_FLATTEN_100_5_16_Adam_1e-07_30_v1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv3d_1 (Conv3D) (None, 4, 250, 250, 32) 54912
_________________________________________________________________
max_pooling3d_1 (MaxPooling3 (None, 1, 83, 83, 32) 0
_________________________________________________________________
flatten_2 (Flatten) (None, 220448) 0
_________________________________________________________________
dense_16 (Dense) (None, 512) 112869888
_________________________________________________________________
dense_17 (Dense) (None, 256) 131328
_________________________________________________________________
dense_18 (Dense) (None, 128) 32896
_________________________________________________________________
dense_19 (Dense) (None, 64) 8256
_________________________________________________________________
dense_20 (Dense) (None, 32) 2080
_________________________________________________________________
dense_21 (Dense) (None, 16) 528
_________________________________________________________________
dense_22 (Dense) (None, 8) 136
_________________________________________________________________
dense_23 (Dense) (None, 1) 9
=================================================================
Total params: 113,100,033
Trainable params: 113,100,033
Non-trainable params: 0
_________________________________________________________________
这给了我在训练集上的以下分数:
mean_absolute_error: 0.08475626941395917
mean_squared_error: 0.1637630610914996
explained_variance_score: 0.19943303382780664
r2_score: 0.19214565669613703
在验证集上:
mean_absolute_error: 0.15135902269457854
mean_squared_error: 0.2650686092962602
explained_variance_score: -1.7471740284409094
r2_score: -1.7776585146674124
正如您所看到的,该模型的 MAE 和 MSE 非常低,但 R2 得分和解释方差得分同时也很低。
如何改进这些结果? 此外,当样本量增加时,模型开始预测所有输入的相似值。
最佳答案
我只是注意到此类任务的参数数量如此之大。可能患有Vanishing or Exploding gradient 。尝试将特征提取器的维度减小得尽可能小。您也可以在两者之间应用 dropout 和正则化。
关于python - 为什么我的模型同时具有较低的 MAE 和较低的 R2 分数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66363862/