论文标题

Treecaps:用于源代码处理的基于树的胶囊网络

TreeCaps: Tree-Based Capsule Networks for Source Code Processing

论文作者

Bui, Nghi D. Q., Yu, Yijun, Jiang, Lingxiao

论文摘要

最近,已经提出了程序学习技术来基于句法结构(例如抽象的语法树)和/或语义信息(例如依赖关系图)处理源代码。尽管图表可能比树捕获代码语义的各种观点更好,但与树相比,从代码中构造图形输入需要静态代码语义分析,这可能不准确并在学习过程中引入噪声。尽管语法树是根据语言语法精确定义的,并且比图形更易于构造和过程,但先前基于树的学习技术无法从树上学习语义信息,从而比基于图的技术获得了更好的准确性。我们通过将胶囊网络与基于树的卷积神经网络融合在一起,提出了一种名为Treecaps的新技术,以实现比现有基于图的技术更高的学习精度,而仅基于树木。 Treecaps将新颖的变量到静态路由算法引入胶囊网络,以补偿先前的路由算法的损失。除了准确性外,我们还发现,Treecaps是承受那些具有语义保留的程序转换的最强大的,这些程序转换可以改变代码语法而无需修改语义。 Treecaps对大量Java和C/C ++程序进行了评估,就程序理解任务(例如代码功能分类和功能名称预测)的精确性和鲁棒性而言,都超过了程序源代码的先前深度学习模型

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). Although graphs may be better at capturing various viewpoints of code semantics than trees, constructing graph inputs from code needs static code semantic analysis that may not be accurate and introduces noise during learning. Although syntax trees are precisely defined according to the language grammar and easier to construct and process than graphs, previous tree-based learning techniques have not been able to learn semantic information from trees to achieve better accuracy than graph-based techniques. We propose a new learning technique, named TreeCaps, by fusing together capsule networks with tree-based convolutional neural networks, to achieve learning accuracy higher than 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

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源