基于多头注意力机制和自定义损失函数LSTM的智能洪水预报OA
Multi-head Attention Mechanism and User-defined Loss Function LSTM Flood Forecast
洪水是全球范围内常见的自然灾害之一,准确的洪水预报对于灾害预防和应急管理具有重要意义.传统洪水预报模型在处理复杂降雨数据和洪峰特征时存在局限性,为此,研究提出了一种融合注意力机制和自定义Floss损失函数的LSTM模型.研究以南宁市邕江流域为案例,收集了南宁市邕江流域2008至2024年15场历史洪水事件的降雨及洪峰数据,通过滑动窗口方法扩展为320组训练样本.模型训练过程中引入K折交叉验证,以提升泛化能力与收敛效率;同时采用粒子群优化(PSO)算法对网络结构和学习率等关键超参数进行自动化调优.为降低洪峰水位低估风险,设计了包含低估惩罚项和水位加权项的Floss损失函数,用以强化模型对高水位区域的敏感性.在测试阶段,对比了含有多头注意力机制和不含该机制的LSTM模型在Floss损失函数下的预测效果,并进一步对比了传统损失函数Huber、MAE、MSE与自定义Floss损失函数的预测效果.结果表明:①引入注意力机制的模型预测精度显著提升,测试集RMSE较基础模型(1.964 2)降低41.6%,达到1.146 2;②Floss损失函数通过低估惩罚(β=1.206 9)和水位权重调整(α=1.0),有效减少预测低估现象,其RMSE(1.146 2)优于Huber(1.183 4)、MAE(1.186 4)和MSE(1.231 3);③融合注意力机制与Floss的LSTM模型在3场独立洪水事件中的洪峰水位未出现低估且误差在1.15 m内.结果表明通过引入注意力机制和自定义损失函数提升了模型的预测精度和鲁棒性,为洪水智能预报提供了新的方法路径与技术支撑.
Floods are among the most common natural disasters worldwide,and accurate flood forecasting is essential for disaster prevention and emergency management.Traditional flood forecasting models often face limitations in capturing complex rainfall patterns and peak flow characteristics.To address these challenges,this study proposes a Long Short-Term Memory(LSTM)model enhanced with a multi-head attention mechanism and a customized Floss loss function.Taking the Yongjiang River Basin in Nanning City as a case study,we collected rainfall and flood peak data from 15 historical flood events between 2008 and 2024.Using a sliding window approach,we expanded the dataset into 320 training samples.To improve the model's generalization and convergence performance,K-fold cross-validation was applied during training.In addition,Particle Swarm Optimization(PSO)was used to automatically tune key hyperparameters such as network structure and learning rate.To mitigate the risk of underestimating flood peak levels,we designed the Floss loss function,incorporating a penalty term for underestimation and a water-level-based weighting scheme to enhance sensitivity to high water levels.In the testing phase,we compared LSTM models with and without multi-head attention mechanism under the Floss loss setting,and further evaluated the impact of different loss functions—including Huber、MAE、MSE and the proposed Floss—on predictive performance.The results indicate that:①The attention mechanism significantly improves predictive accuracy,reducing the test RMSE by 41.6%from 1.9642 to 1.1462 compared to the baseline model.②The Floss loss function,through its underestimation penalty(β=1.206 9)and water-level weighting(α=1.0),effectively reduces underestimation errors,achieving a lower RMSE(1.1462)than Huber(1.1834),MAE(1.1864)and MSE(1.2313).③The attention-based LSTM model using Floss shows no underestimation in three independent flood events,with maximum errors within 1.15 meters.These findings demonstrate that incorporating attention mechanisms and a tailored loss function can significantly enhance model accuracy and robustness,offering new methodological and technical support for intelligent flood forecasting.
胡川;史宗浩;唐菲菲;朱洪洲
重庆交通大学智慧城市学院,重庆 400074重庆交通大学智慧城市学院,重庆 400074重庆交通大学智慧城市学院,重庆 400074重庆交通大学土木工程学院,重庆 400074
天文与地球科学
注意力机制自定义损失函数LSTM洪水预报特征融合
attention mechanismcustomized loss functionLSTMflood forecastingfeature fusion
《中国农村水利水电》 2026 (1)
30-36,44,8
国家重点研发计划课题(2021YFB2600603)重庆市自然科学基金项目资助(CSTB2022NSCQ-MSX1527).
评论