arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1904.03031cs.SE
收藏

基于深度学习的代码坏味迁移学习可行性研究

On the Feasibility of Transfer-learning Code Smells using Deep Learning

Tushar Sharma, Vasiliki Efstathiou, Panos Louridas, Diomidis Spinellis

AI总结:

本文研究仅用标记化源代码训练深度学习模型检测代码坏味的可行性,并验证从C#到Java的迁移学习效果,发现实现坏味检测可通过迁移学习达到与直接学习相当的性能。

摘要:

背景:已有大量工作使用基于度量和基于启发式的方法来检测源代码中的坏味。机器学习方法最近已被应用于检测源代码坏味;然而,当前实践被认为远未成熟。目标:首先,探索在不进行大量特征工程的情况下,仅以标记化形式输入源代码,应用深度学习模型检测坏味的可行性。其次,研究在用于坏味检测的深度学习模型背景下应用迁移学习的可能性。方法:我们使用现有的基于度量的最先进方法检测C#代码中的三种实现坏味和一种设计坏味。利用这些结果作为标注的金标准,我们在三种不同的深度学习架构上训练坏味检测模型。这些架构使用一维或二维卷积神经网络(CNNs)或循环神经网络(RNNs)作为其主要隐藏层。对于本研究的第一目标,我们在C#样本上进行训练和评估;而对于第二目标,我们使用C#代码训练模型,并在Java代码样本上评估模型。我们针对每个模型使用各种超参数组合进行实验。结果:我们发现使用深度学习方法检测坏味是可行的。我们的对比实验发现,CNN-1D和CNN-2D之间没有明显更优的方法。我们还观察到深度学习模型的性能具有坏味特异性。我们的迁移学习实验表明,对于实现坏味,迁移学习绝对是可行的,其性能可与直接学习相媲美。这项工作开辟了一种通过迁移学习检测代码坏味的新范式,尤其是对于那些缺乏全面代码坏味检测工具的编程语言。

英文摘要:

Context: A substantial amount of work has been done to detect smells in source code using metrics-based and heuristics-based methods. Machine learning methods have been recently applied to detect source code smells; however, the current practices are considered far from mature. Objective: First, explore the feasibility of applying deep learning models to detect smells without extensive feature engineering, just by feeding the source code in tokenized form. Second, investigate the possibility of applying transfer-learning in the context of deep learning models for smell detection. Method: We use existing metric-based state-of-the-art methods for detecting three implementation smells and one design smell in C# code. Using these results as the annotated gold standard, we train smell detection models on three different deep learning architectures. These architectures use Convolution Neural Networks (CNNs) of one or two dimensions, or Recurrent Neural Networks (RNNs) as their principal hidden layers. For the first objective of our study, we perform training and evaluation on C# samples, whereas for the second objective, we train the models from C# code and evaluate the models over Java code samples. We perform the experiments with various combinations of hyper-parameters for each model. Results: We find it feasible to detect smells using deep learning methods. Our comparative experiments find that there is no clearly superior method between CNN-1D and CNN-2D. We also observe that performance of the deep learning models is smell-specific. Our transfer-learning experiments show that transfer-learning is definitely feasible for implementation smells with performance comparable to that of direct-learning. This work opens up a new paradigm to detect code smells by transfer-learning especially for the programming languages where the comprehensive code smell detection tools are not available.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑