A Compositional Approach Using Keras for Neural Networks in Real-Time Systems

Xin Yanga, Partha Roopb, Hammond Pearcec and Jin Woo Rod

The University of Auckland Auckland, New Zealand
axyan510@aucklanduni.ac.nz
bp.roop@auckland.ac.nz
chammond.pearce@auckland.ac.nz
djro002@aucklanduni.ac.nz

ABSTRACT

Real-time systems are designed using model-driven approaches, where a complex system is represented as a set of interacting components. Such a compositional approach facilitates design of simpler components, which are easier to validate and integrate with the overall system. In contrast to such systems, data-driven systems like neural networks are designed as monolithic black-boxes to capture the non-linear relationship from inputs to outputs. Increasingly, such systems are being used in safety-critical real-time systems. Here, a compositional approach would be ideal. However, to the best of our knowledge, such a compositional approach is lacking while designing datadriven components based on neural networks. This paper formalises this problem by developing the concept of Composed Neural Networks (CpNNs) by extending the well known Keras python framework. CpNNs formalise the synchronous composition of several interacting neural networks in Keras. Further, using the developed semantics, we enable modular compilation from a given CpNN to C code. The generated code is suitable for the Worst-Case Execution Time (WCET) analysis. Using several benchmarks we demonstrate the superiority of the developed approach over a recently proposed approach using Esterel, as well as the popular Python package Tensorflow Lite. For the given benchmarks, our approach is superior to Esterel with an average WCET reduction of 64.06%, and superior to Tensorflow Lite with an average measured WCET reduction of 62.08%.

Keywords: Deep neural networks, Cyber Physical Systems, Real-Time.



Full Text (PDF)