【问题标题】:Why my Model has a low MAE and low R2 score at the same time?为什么我的模型同时具有低 MAE 和低 R2 分数?
【发布时间】:2021-05-27 12:55:04
【问题描述】:

我正在尝试构建一个 CNN 回归模型。输入数据为 10 年的卫星图像。

输入形状是[10, 256,256, 10],代表[Year, Image shape, Image Shape, Channels/Bands]

模型的输出是一个介于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-Score 和 Explained-Variance-Score 同时也很低。

如何改进这些结果? 此外,当样本量增加时,模型开始预测所有输入的相似值。

【问题讨论】:

    标签: python tensorflow machine-learning keras conv-neural-network


    【解决方案1】:

    我只是注意到此类任务的参数数量如此庞大。可能患有Vanishing or Exploding gradient。尽量减少特征提取器的维度。您也可以在应用 dropout 和正则化之间。

    【讨论】:

      【解决方案2】:

      您可能想看看这里: https://online.stat.psu.edu/stat462/node/170/

      【讨论】:

        【解决方案3】:

        如果红线表示模型的预测线,那么我认为你的代码缺乏一些优化来更概括预测,本质上它至少应该是一条曲线。请参考下面的 url,这是 CNN 回归的教程:

        https://www.datatechnotes.com/2019/12/how-to-fit-regression-data-with-cnn.html?m=1

        在上面的教程中,输出图是泛化的,从而减少了错误。或许你可以试试老妇人的步骤。

        【讨论】:

          猜你喜欢
          • 2020-11-19
          • 2021-07-11
          • 1970-01-01
          • 2020-02-05
          • 2020-08-27
          • 1970-01-01
          • 1970-01-01
          • 2019-12-19
          • 2017-01-25
          相关资源
          最近更新 更多