中国农村水利水电Issue(1):30-36,44,8.DOI:10.12396/znsd.2500363
基于多头注意力机制和自定义损失函数LSTM的智能洪水预报
Multi-head Attention Mechanism and User-defined Loss Function LSTM Flood Forecast
摘要
Abstract
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.关键词
注意力机制/自定义损失函数/LSTM/洪水预报/特征融合Key words
attention mechanism/customized loss function/LSTM/flood forecasting/feature fusion分类
天文与地球科学引用本文复制引用
胡川,史宗浩,唐菲菲,朱洪洲..基于多头注意力机制和自定义损失函数LSTM的智能洪水预报[J].中国农村水利水电,2026,(1):30-36,44,8.基金项目
国家重点研发计划课题(2021YFB2600603) (2021YFB2600603)
重庆市自然科学基金项目资助(CSTB2022NSCQ-MSX1527). (CSTB2022NSCQ-MSX1527)