Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我的模型同时具有较低的MAE和较低的R2分数?_Python_Tensorflow_Machine Learning_Keras_Conv Neural Network - Fatal编程技术网

Python 为什么我的模型同时具有较低的MAE和较低的R2分数?

Python 为什么我的模型同时具有较低的MAE和较低的R2分数?,python,tensorflow,machine-learning,keras,conv-neural-network,Python,Tensorflow,Machine Learning,Keras,Conv Neural Network,我试图建立一个CNN回归模型。输入数据为10年的卫星图像 输入形状为[10,256256,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层作

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

输入形状为
[10,256256,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层作为输入层,因为它提供了向模型提供体积数据的能力,而稠密层作为输出

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.08475626941395917
mean_squared_error: 0.1637630610914996
explained_variance_score: 0.19943303382780664
r2_score: 0.19214565669613703

在验证集上:

mean_absolute_error: 0.1923245317002776
mean_squared_error: 0.2579017795812263
explained_variance_score: -5.067052299015521
r2_score: -5.4177061135705475
mean_absolute_error: 0.15135902269457854
mean_squared_error: 0.2650686092962602
explained_variance_score: -1.7471740284409094
r2_score: -1.7776585146674124

我还尝试了以下不同的模式: 在这种情况下,只有第一层是Conv3D,其余是密集层

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.09013315520024737
mean_squared_error: 0.11449361186977994
explained_variance_score: -0.2407465861253424
r2_score: -0.9382254392540899
mean_absolute_error: 0.08475626941395917
mean_squared_error: 0.1637630610914996
explained_variance_score: 0.19943303382780664
r2_score: 0.19214565669613703

在验证集上:

mean_absolute_error: 0.1923245317002776
mean_squared_error: 0.2579017795812263
explained_variance_score: -5.067052299015521
r2_score: -5.4177061135705475
mean_absolute_error: 0.15135902269457854
mean_squared_error: 0.2650686092962602
explained_variance_score: -1.7471740284409094
r2_score: -1.7776585146674124

正如您所见,模型的MAE和MSE非常低,但R2分数和解释方差分数同时也很低

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

我注意到,对于这样的任务,参数的数量是如此巨大。可能正在遭受痛苦。尽量减少特征提取程序的尺寸。您也可以在应用退出和正则化之间进行选择。

您可以在此处查看:

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

在上面的教程中,输出图是广义的,这减少了误差。也许你可以试试女士的舞步