如果预测值小于标签但如果预测值更大则如何增加损失

How to increase the loss if the predicted value is less than the label but not if it is greater

我使用 ai 模型使用 mse 预测值。对于数据集中的噪音,模型不可能给出完美的预测。我想要做的是,如果有两个与标签等距的预测,我希望较低的预测与较大的预测相比分配更大的损失。本质上,我希望模型更有可能超过该值而不是低于该值。

我假设这是在编译模型时完成的。

我将如何修改用于编译我的模型的代码段来完成此操作?

genModel.compile(optimizer='adam',
              loss='mean_squared_error',
              metrics=['mae', 'mean_squared_logarithmic_error'])

您可以根据均方误差损失api reference and compile your model with it. If you are using tenserflow you can refer to its implementation创建自己的自定义损失函数,并根据需要进行修改。