一句话:用 Prolog 为 TensorFlow 几乎所有层建立可执行语义,并据此实现 fuzzing 与模型验证。
神经网络可视为一种新编程范式,TensorFlow、PyTorch 等框架在其中扮演类似编译器的角色。然而,这些框架通常缺乏形式化的正确性规约,可能导致错误行为与安全问题。本文提出 ExAIS,用逻辑编程语言 Prolog 为 TensorFlow 的几乎所有层指定语义,从而为神经网络框架提供可执行的正确性规约。作者通过两个应用展示该语义的实用性:一是面向 TensorFlow 的 fuzzing 引擎,具备强 oracle,并能系统化生成合法神经网络;二是模型验证方法,可对 TensorFlow 模型进行一致的 bug 报告。
Neural networks can be regarded as a new programming paradigm, i.e., instead of building ever-more complex programs through (often informal) logical reasoning in the programmers' mind, complex ‘AI’ systems are built by optimising generic neural network models with big data. In this new paradigm, AI frameworks such as Ten-sorFlow and PyTorch play a key role, which is as essential as the compiler for traditional programs. It is known that the lack of a proper semantics for programming languages (such as C), i.e., a correctness specification for compilers, has contributed to many problematic program behaviours and security issues. While it is in general hard to have a correctness specification for compilers due to the high complexity of programming languages and their rapid evolution, we have a unique opportunity to do it right this time for neural networks (which have a limited set of functions, and most of them have stable semantics). In this work, we report our effort on providing a correctness specification of neural net-work frameworks such as TensorFlow. We specify the semantics of almost all TensorFlow layers in the logical programming language Prolog. We demonstrate the usefulness of the semantics through two applications. One is a fuzzing engine for TensorFlow, which features a strong oracle and a systematic way of generating valid neural networks. The other is a model validation approach which enables consistent bug reporting for TensorFlow models.