TreeCaps: Tree-Based Capsule Networks for Source Code Processing

Authors

  • Nghi D. Q. Bui Trustworthy Open-Source Software Engineering Lab, Huawei Research Centre, Ireland
  • Yijun Yu The Open University, UK
  • Lingxiao Jiang Singapore Management University

Keywords:

Software Engineering, (Deep) Neural Network Algorithms, Applications

Abstract

Recently program learning techniques have been proposed to process source code based on syntactical structures (e.g., abstract syntax trees) and/or semantic information (e.g., dependency graphs). While graphs may be better than trees at capturing code semantics, constructing the graphs from code inputs through the semantic analysis of multiple viewpoints can lead to inaccurate noises for a specific software engineering task. Compared to graphs, syntax trees are more precisely defined on the grammar and easier to parse; unfortunately, previous tree-based learning techniques have not been able to learn semantic information from trees to achieve better accuracy than graph-based techniques. We have proposed a new learning technique, named TreeCaps, by fusing together capsule networks with tree-based convolutional neural networks to achieve a learning accuracy higher than some existing graph-based techniques while it is based only on trees. TreeCaps introduces novel variable-to-static routing algorithms into the capsule networks to compensate for the loss of previous routing algorithms. Aside from accuracy, we also find that TreeCaps is the most robust to withstand those semantic-preserving program transformations that change code syntax without modifying the semantics. Evaluated on a large number of Java and C/C++ programs, TreeCaps models outperform prior deep learning models of program source code, in terms of both accuracy and robustness for program comprehension tasks such as code functionality classification and function name prediction. Our implementation is publicly available at: https://github.com/bdqnghi/treecaps.

Downloads

Published

2021-05-18

How to Cite

Bui, N. D. Q., Yu, Y., & Jiang, L. (2021). TreeCaps: Tree-Based Capsule Networks for Source Code Processing. Proceedings of the AAAI Conference on Artificial Intelligence, 35(1), 30-38. Retrieved from https://ojs.aaai.org/index.php/AAAI/article/view/16074

Issue

Section

AAAI Technical Track on Application Domains