[論文レビュー] On the Feasibility of Transfer-learning Code Smells using Deep Learning
本稿では、畳み込みニューラルネットワーク(CNN)および再帰ニューラルネットワーク(RNN)を用いた深層学習と転移学習を組み合わせ、C#およびJavaにおけるコードスモールの検出可能性を調査している。転移学習により、特に実装スモールにおいて、言語をまたいで効果的なスモール検出が可能であることが示されており、直接学習した場合と同等の性能を達成している。
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.
研究の動機と目的
- 手作業による特徴量設計を一切行わず、深層学習モデルがコードスモールを検出できるかどうかを評価すること。
- 異なるプログラミング言語間でコードスモールを効果的に検出するために、転移学習を適用できるかどうかを調査すること。
- C#およびJavaにおける多様なコードスモールタイプに対して、深層学習モデル(CNNおよびRNN)の性能を評価すること。
- 成熟した検出ツールが存在しない言語において、転移学習がスモール検出を可能にする可能性を探ること。
- スケーラブルで言語に依存しないコードスモール検出の基盤を確立すること。
提案手法
- C#およびJavaのコードサンプルを用いて、1次元および2次元の畳み込みニューラルネットワーク(CNN)および再帰ニューラルネットワーク(RNN)を学習した。
- ソースコードを数値シーケンスに変換するためのトークン化を実施し、C#およびJava間での言語的構造の同等性を保持した。
- スモール検出の正例として、DesigniteおよびDesigniteJavaを用い、一貫したメトリクスとしきい値を保証した。
- 言語間での学習と評価を実施:C#で学習しJavaで評価する、および逆にJavaで学習しC#で評価するという方法で、汎用性を評価した。
- ハイパーパrameterを体系的なチューニングにより最適化し、モデルの感度および性能のばらつきを評価した。
- モデルをある言語で初期化し、別の言語でファインチューニングすることで、転移学習を適用し、共有された学習表現を活用した。
実験結果
リサーチクエスチョン
- RQ1手作業による特徴量設計に依存せずに、深層学習モデルがコードスモールを効果的に検出できるか?
- RQ2異なる深層学習アーキテクチャ(1D-CNN、2D-CNN、RNN)が、さまざまなタイプのコードスモールに対してどのように性能を発揮するか?
- RQ3ある言語で学習し、別の言語でテストする場合、コードスモール検出に転移学習が適用可能か?
- RQ4転移学習は、ターゲット言語で直接学習した場合と同等の性能を達成できるか?
- RQ5クロス言語環境下で、どのタイプのコードスモールが転移学習によって最も恩恵を受けるか?
主な発見
- 特にRNNが、手作業による特徴量設計を一切行わずとも、コードスモール検出において競争力のある性能を示した。
- 1D-CNNは、空のcatchブロックおよび多様な抽象化スモールに対して2D-CNNを上回ったが、複雑なメソッドおよびマジックナンバースモールでは2D-CNNが優れた性能を示した。
- RNNは、空のcatchブロックおよびマジックナンバースモールの検出において、CNNよりも顕著に優れた性能を示した。
- 転移学習は、実装スモールに対して実用的であり、ターゲット言語で直接学習した場合と同等の性能を達成した。
- 本研究では、専用の検出ツールが存在しないプログラミング言語においても、転移学習がコードスモール検出の代替手段として有効であることが確認された。
- 本アプローチはプログラミング言語に依存せず、適切なツールとデータを備えた他の言語へも容易に拡張可能である。
この論文を読む
Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。
Nubintでこの論文を読むこのレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。