| 引用本文: | 邢颖,赵梦赐,杨斌,张俞炜,李文瑾,顾佳伟,袁军.基于多源域适应的缺陷类别预测方法.软件学报,2024,35(7):3227-3244 |
| |
|
| |
|
|
| 本文已被:浏览 1800次 下载 4636次 |
 码上扫一扫! |
|
|
| 基于多源域适应的缺陷类别预测方法 |
|
邢颖1,2, 赵梦赐1,2, 杨斌3, 张俞炜4, 李文瑾5, 顾佳伟5, 袁军5
|
|
1.北京邮电大学 人工智能学院, 北京 100876;2.高安全系统的软件开发与验证技术工业和信息化部重点实验室(南京航空航天大学), 江苏 南京 211106;3.中国联通研究院, 北京 100048;4.中国科学院 软件研究所, 北京 100190;5.绿盟科技集团股份有限公司, 北京 100089
|
|
| 摘要: |
| 随着规模和复杂性的迅猛膨胀, 软件系统中不可避免地存在缺陷. 近年来, 基于深度学习的缺陷预测技术成为软件工程领域的研究热点. 该类技术可以在不运行代码的情况下发现其中潜藏的缺陷, 因而在工业界和学术界受到了广泛的关注. 然而, 已有方法大多关注方法级的源代码中是否存在缺陷, 无法精确识别具体的缺陷类别, 从而降低了开发人员进行缺陷定位及修复工作的效率. 此外, 在实际软件开发实践中, 新项目通常缺乏足够的缺陷数据来训练高精度的深度学习模型, 而利用已有项目的历史数据训练好的模型往往在新项目上无法达到良好的泛化性能. 因此, 首先将传统的二分类缺陷预测任务表述为多标签分类问题, 即, 使用CWE (common weakness enumeration)中描述的缺陷类别作为细粒度的模型预测标签. 为了提高跨项目场景下的模型性能, 提出一种融合对抗训练和注意力机制的多源域适应框架. 该框架通过对抗训练来减少域(即软件项目)差异,并进一步利用域不变特征来获得每个源域和目标域之间的特征相关性. 同时, 该框架还利用加权最大均值差异作为注意力机制, 以最小化源域和目标域特征之间的表示距离, 从而使模型可以学习到更多的域无关特征. 在构建的包含8个真实世界开源项目的数据集上的实验表明, 所提方法对比最先进的基线方法取得了显著的性能提升. |
| 关键词: 缺陷类别预测 多源域适应 对抗训练 注意力机制 |
| DOI:10.13328/j.cnki.jos.007109 |
| 分类号: |
| 基金项目:高安全系统的软件开发与验证技术工业和信息化部重点实验室资助项目(NJ2023031);云南省软件工程重点实验室开放基金(2023SE202);CCF-绿盟科技“鲲鹏”科研计划(CCF-NSFOCUS202212) |
|
| Defect Category Prediction Method Based on Multi-source Domain Adaptation |
|
XING Ying1,2, ZHAO Meng-Ci1,2, YANG Bin3, ZHANG Yu-Wei4, LI Wen-Jin5, GU Jia-Wei5, YUAN Jun5
|
|
1.School of Artificial Intelligence, Beijing University of Posts and Telecommunications, Beijing 100876, China;2.Key Laboratory for Safety-Critical Software Development and Verification (Nanjing University of Aeronautics and Astronautics), Ministry of Industry and Information Technology, Nanjing 211106, China;3.China Unicom Research Institute, Beijing 100048, China;4.Institute of Software, Chinese Academy of Sciences, Beijing 100190, China;5.NSFOCUS Technologies Group Co. Ltd., Beijing 100089, China
|
| Abstract: |
| With the rapid expansion of scale and complexity, defects inevitably exist within software systems. In recent years, defect prediction techniques based on deep learning have become a prominent research topic in the field of software engineering. These techniques can identify potential defects without executing the code, garnering significant attention from both industry and academia. Nevertheless, existing approaches mostly concentrate on determining the presence of defects at the method-level code, lacking the ability to precisely classify specific defect categories. Consequently, this undermines the efficiency of developers in locating and rectifying defects. Furthermore, in practical software development, new projects often lack sufficient defect data to train high-accuracy deep learning models. Models trained on historical data from existing projects frequently struggle to achieve satisfactory generalization performance on new projects. Hence, this study initially reformulates the traditional binary defect prediction task into a multi-label classification problem, employing defect categories described in the common weakness enumeration (CWE) as fine-grained predictive labels. To enhance the model performance in cross-project scenarios, this study proposes a multi-source domain adaptation framework that integrates adversarial training and attention mechanisms. Specifically, the proposed framework employs adversarial training to mitigate domain (i.e., software projects) discrepancies, and further utilizes domain-invariant features to capture feature correlations between each source domain and the target domain. Simultaneously, the proposed framework employs a weighted maximum mean discrepancy as an attention mechanism to minimize the representation distance between source and target domain features, facilitating model in learning more domain-independent features. The experiments on the dataset consisting of 8 real-world open-source projects constructed in this study show that the proposed approach achieves significant performance improvements compared with state-of-the-art baselines. |
| Key words: defect category prediction multi-source domain adaptation adversarial training attention mechanism |
|
|
|
|