← Latest papers
🤖 machine learning

CodeJeNN: A simple C++ neural network generator for physics applications

CodeJeNN is a tool that bridges the performance gap between Python-based machine learning and high-performance C++ physics solvers by auto-generating self-contained C++ inference code from trained Keras models, thereby eliminating external dependencies and achieving significant speedups without sacrificing accuracy.

Original authors: Jay Arcities, Pavel Popov, Eric J Ching, Kamal Viswanath, Ryan F Johnson

Published 2026-07-07
📖 5 min read🧠 Deep dive

Original authors: Jay Arcities, Pavel Popov, Eric J Ching, Kamal Viswanath, Ryan F Johnson

Original paper dedicated to the public domain under CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a brilliant, highly trained robot brain (a neural network) built in Python, a language that's great for learning and experimenting but can be a bit slow and clumsy when you try to run it inside a high-speed race car engine (a physics simulation written in C++).

Usually, trying to plug that Python brain into the C++ engine is like trying to run a marathon while wearing heavy, clunky boots. The engine has to stop, wait for the Python language to translate instructions, and then run them. This "translation lag" slows everything down, which is a problem when you need your simulation to run at the speed of light.

CodeJeNN is the tool that solves this problem. Think of it as a universal translator and tailor that takes your Python-trained robot brain and instantly rewrites its entire instruction manual into a sleek, custom-fitted C++ suit.

Here is how it works, broken down simply:

1. The Problem: The "Language Barrier"

In the world of physics simulations (like predicting how air flows around a rocket or how hydrogen mixes with air), scientists use super-fast, compiled languages like C++ or Fortran. However, the best tools for training AI brains are in Python.

  • The Issue: If you try to use the Python AI directly inside the C++ simulation, the computer has to constantly switch languages. It's like a chef trying to cook a gourmet meal but having to stop every second to ask a translator what the ingredients are. It creates a bottleneck.

2. The Solution: CodeJeNN (The "Magic Tailor")

CodeJeNN is a piece of software that acts as a bridge.

  • How it works: You train your AI model using Keras (a popular Python tool). Once the model is ready, you feed it to CodeJeNN.
  • The Magic: CodeJeNN doesn't just copy the model; it generates brand new, self-contained C++ code that looks exactly like the model but runs natively in the C++ world.
  • No Heavy Boots: The generated code is "inlined." Imagine instead of calling a separate department to get a tool, the tool is built directly into your hand. This means there are no external libraries to load, no heavy dependencies, and no language switching. It's pure, fast C++.

3. What Can It Do?

CodeJeNN is designed to handle the most common types of AI architectures:

  • MLPs (Multi-Layer Perceptrons): Think of these as standard, layered decision-making networks.
  • CNNs (Convolutional Neural Networks): These are great at spotting patterns in images or spatial data (like layers of a cake).
  • Customization: It supports many different "activation functions" (the rules the AI uses to make decisions) and can even handle custom rules if you teach it how to write them.

4. Real-World Proof: The Speed Test

The authors tested CodeJeNN to see if it was actually faster.

  • The Race: They compared their generated C++ code against the standard Python-based Keras code (running on TensorFlow and PyTorch).
  • The Result: CodeJeNN was massively faster.
    • For standard tasks, it was about 25 to 38 times faster than the unoptimized Python versions.
    • Even when compared to highly optimized Python versions (using "JIT" compilation), CodeJeNN was still 2 to 9 times faster.
  • The Analogy: If the Python version took 12 seconds to solve a problem, CodeJeNN did it in less than half a second.

5. The Big Test: Mixing Hydrogen and Air

To prove it works in a real physics scenario, the authors used CodeJeNN to replace a complex math formula (Wilke's model) used to calculate how thick (viscous) a mixture of hydrogen and air is.

  • The Setup: They simulated a high-speed mixing layer where hydrogen and air streams collide.
  • The Swap: They swapped the heavy math formula for their lightweight, CodeJeNN-generated AI.
  • The Outcome: The simulation ran smoothly. The AI predicted the viscosity with extremely high accuracy (less than 0.25% error compared to the original math). It proved that you can swap out heavy, slow math for a fast AI without losing precision.

Why Does This Matter?

CodeJeNN is like a "plug-and-play" kit for scientists.

  • No Infrastructure Headaches: Researchers don't need to be experts in C++ or spend months building complex systems to connect AI to their physics codes.
  • Self-Contained: The result is a single file of code that can be dropped right into existing simulations.
  • Future-Proof: If a scientist wants to try a new type of AI architecture, the code is structured so that an AI assistant (like an LLM) can easily write the missing pieces, making it very easy to experiment.

In summary: CodeJeNN takes the "slow and heavy" Python AI models and transforms them into "fast and light" C++ code, allowing physics simulations to run significantly faster without sacrificing accuracy. It removes the friction between training AI and using it in the real world of high-performance computing.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →