TreeCaps: Tree-Based Capsule Networks for Source Code Processing

TreeCaps: Tree-Based Capsule Networks for Source Code Processing
复制标题

DOI:
10.1609/aaai.v35i1.16074
复制
发表时间:
2020-09
期刊:
ArXiv
影响因子:
--
通讯作者:
Nghi D. Q. Bui;Yijun Yu;Lingxiao Jiang
Nghi D. Q. Bui;Yijun Yu;Lingxiao Jiang
中科院分区:
其他
文献类型:
--
作者:
Nghi D. Q. Bui;Yijun Yu;Lingxiao Jiang

文献摘要

相似文献

最近,程序学习技术被提出来处理基于语法结构(如抽象语法树)和/或语义信息(如依赖图)的源代码。虽然图在捕获代码语义方面可能比树更好,但通过多视点的语义分析从代码输入构建图可能会导致特定软件工程任务产生不准确的噪声。与图相比,语法树在语法上定义更精确,更容易解析;不幸的是,以前基于树的学习技术还不能从树中学习语义信息,以达到比基于图的技术更好的准确性。我们提出了一种新的学习技术,名为TreeCaps,通过将胶囊网络与基于树的卷积神经网络融合在一起,实现了比现有的基于图的技术更高的学习精度,而它只基于树。TreeCaps在胶囊网络中引入了新的可变到静态路由算法,以弥补以前路由算法的不足。除了准确性之外,我们还发现TreeCaps是最健壮的,可以承受那些保留语义的程序转换,这些转换在不修改语义的情况下更改代码语法。通过对大量Java和C/ c++程序的评估,在代码功能分类和函数名预测等程序理解任务的准确性和稳健性方面,TreeCaps模型优于先前的程序源代码深度学习模型。我们的实现可以在:https://github.com/bdqnghi/treecaps上公开获得。
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.