REVIEW 2 major objections 5 minor 33 references
CodeJeNN: A simple C++ neural network generator for physics applications
T0 review · 2 major / 5 minor · reviewed 2026-08-04 · deepseek-v4-flash
Pith's one-line read CodeJeNN auto-generates self-contained C++ code from trained Keras models, delivering 2–38× faster inference than Keras backends and enabling neural-network surrogates inside CFD solvers.
desk verdict CodeJeNN is a useful Keras-to-C++ transpiler with honest benchmarks, but the abstract oversells 'without sacrificing accuracy' and the paper never directly shows the generated C++ matches the trained Keras model. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
The paper reports two demonstrations. First, inference speed on an Apple M1 Pro: for a small multilayer perceptron, the generated C++ code processed 10,000 samples in 0.48 seconds, versus 12.01 seconds for Keras with a TensorFlow backend and 1.21 seconds for TensorFlow's JIT-compiled mode; for a small CNN the pattern was similar (1.05 s vs 19.14 s eager, 2.17 s JIT). Second, they replaced the viscosity equation in a hydrogen-air mixing-layer CFD simulation with a 385-parameter network trained on Wilke's mixing rule. The resulting velocity field differed from the reference by at most 0.25%.
Two caveats matter. The speed advantage depends on the model being small enough to fit in cache: for a larger CNN, the generated code took 10.75 seconds while TensorFlow JIT took 3.60 seconds, so the abstract's unqualified 'speedups' applies mainly to the small, compute-bound models the paper targets. And the viscosity surrogate itself had a mean relative error of 12% against Wilke's rule, with a maximum of 812%, before the flow-level test; the 'without sacrificing accuracy' claim therefore rests on that single flow case.
Extended reading notes
Core claim
The paper's load-bearing assertion: "We present CodeJeNN, which bridges this gap by auto-generating self-contained C++ code from trained Keras models for inference... showing speedups without sacrificing accuracy" (Abstract), concretely supported by "CodeJeNN executes roughly 25 times faster than Keras using a TensorFlow backend and achieves nearly 38 times speedup with PyTorch" (§4.1) and "The neural network introduces minimal error, reaching a maximum of 0.25%" in the mixing-layer velocity field (§4.2). If correct: a Keras model can be transpiled to a dependency-free C++ header that reproduces the network at inference speed competitive with, and often faster than, the training framework's own backends.
Load-bearing premise
The 'without sacrificing accuracy' portion of the claim rests on premises the paper never separates: (1) that a surrogate with mean relative viscosity error of 0.12 (max 8.12) against Wilke's rule (Eq. 7) is an acceptable constitutive-model replacement, and (2) that error statistics computed on the hand-selected 60/40 stratified training/verification distribution (§4.2, Eq. 6) transfer to states the CFD solver actually visits in the 350–1500 K mixing layer. The flow-level check is one simulation at one reported snapshot (Fig. 5), so the load-bearing premise — that constitutive-level errors of this size leave the flow field within 0.25% — is asserted for this case, not established as a general property.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. CodeJeNN is a Python tool that loads a trained Keras model and emits a self-contained C++ header implementing forward inference, supporting a specified set of layers (dense, convolution/transposed convolution, pooling, normalization, dropout, etc.) and activations. The paper describes the workflow, algorithm structure, and limitations; benchmarks generated-code inference against Keras with TensorFlow and PyTorch backends in eager and JIT modes on one MLP and two CNN configurations using 10,000 random samples; and demonstrates integration in an OpenFOAM/DetonationFOAM hydrogen-air mixing-layer simulation in which a 385-parameter MLP replaces Wilke's mixture-viscosity model. Reported results are roughly 25x/38x speedups over eager TensorFlow/PyTorch Keras for the MLP, about 2.5x/9x over the corresponding JIT baselines, and a maximum x-velocity error of 0.25% in the CFD demonstration.
Significance. If the claims hold, CodeJeNN is a useful and well-scoped tool: it emits dependency-free, inlined, user-modifiable C++ inference code from Keras models, and the paper ships a reproducible benchmark protocol (single thread, dry run, 10,000 samples, three runs with standard deviations) against fair external baselines (TF/PyTorch eager and JIT on the same trained models). The speedup arithmetic in Section 4.1 checks out (e.g., 12.01/0.48 ~ 25x; 18.20/0.48 ~ 38x). The paper is also unusually candid about its envelope: Table 2's third column shows CodeJeNN slower than both JIT baselines in the memory-bound CNN case, and Section 3.4 explicitly lists topology and configuration limits. The CFD demonstration is a genuine end-to-end embedding into an OpenFOAM solver. However, the central claim has two load-bearing premises -- that the generated C++ reproduces the trained Keras model, and that accuracy is not sacrificed -- and the evidence for both is presently incomplete, as detailed below.
major comments (2)
- [Sec. 3.4 / Sec. 4.1] No direct numerical comparison is reported between CodeJeNN-generated C++ and Keras inference on the same inputs. The debug API described in Sec. 3.4 prints the first ten per-layer values, but no such comparison is shown for either benchmark model; the verification in Sec. 4.2 (Eq. (7)) is the surrogate against Wilke's rule, not the generated C++ against the trained Keras model. This is load-bearing because the benchmark MLP includes BatchNormalization and Dropout and the CNN includes a transposed convolution -- classic inference-mode/scaling mismatch points -- and Sec. 3.4 concedes 'there can still be logic/algebraic errors' after successful generation. A mis-transpiled network that still approximates Wilke could equally yield the small flow-field error in Sec. 4.2, so that test does not close the loop. Request a per-layer and final-output equivalence check (e.g., max absolute/relative
- [Sec. 4.2, Eq. (7), Fig. 5] The 'without sacrificing accuracy' claim rests on one simulation and one reported snapshot. The surrogate has mean relative viscosity error 0.12 and maximum 8.12 against Wilke's rule over 2,000 random samples, yet the reported flow-field velocity error is at most 0.25% at the Fig. 5 snapshot. The paper does not connect these numbers: it reports neither viscosity-error statistics over the states the CFD solver actually visits nor time-averaged/multi-snapshot velocity-error statistics. Also, the surrogate is trained on Wilke's rule generated by the accompanying utility and then verified against the same Wilke rule, so the demonstration is a self-consistency test of the pipeline, not a validation of the constitutive model -- which is fine for the tool's purpose, but the transfer of the 0.25% figure to states outside this case is asserted. Request: (i) report surrogate viscosity error over t
minor comments (5)
- [Sec. 4.2 / Fig. 5 caption] The text says the error field is evaluated after 'five more flow-through times,' while the Fig. 5 caption says 'Error after one flow-through time.' Reconcile, since the snapshot time determines which flow state is compared.
- [Abstract / Table 2] The unbounded-memory CNN column (CodeJeNN 10.75 s vs JIT-TF 3.60 s and JIT-PyTorch 8.47 s) shows generated code slower than both JIT baselines. The surrounding text discusses this correctly as a memory-bound transition, but the abstract's unqualified 'showing speedups' should be qualified to match the demonstrated cases.
- [Sec. 4.1] The 25x/38x headline figures are for Keras in eager mode with JIT disabled (the stated baseline). TensorFlow default graph execution typically sits between eager and XLA; state explicitly that the headline speedups are versus eager mode to avoid overreading.
- [Sec. 4.1 / reproducibility] No random seeds are given for training the benchmark models or for generating the 10,000-sample inference sets. Please provide the exact trained .keras files or the seeds used for Table 2.
- [Throughout] Text issues: 'feedfoward' (Fig. 1); 'This allow pinpointing errors layer differences within a model' (Sec. 3.4); inconsistent 'detonatFOAM' vs 'DetonationFOAM' (Sec. 4.2). Also, Eq. (2) defines convolution without stride/dilation/padding indices although those are supported options; state the default convention.
Circularity Check
No load-bearing circularity: CodeJeNN's speed claim is benchmarked externally, and the CFD demonstration is a standard surrogate fit-to-target validation rather than a prediction derived from its inputs.
full rationale
The paper's central capability—generating standalone C++ inference code from a Keras model—is tested against external references. Table 2 compares CodeJeNN wall-clock times against Keras with TensorFlow, PyTorch, and JIT backends on the same trained models; this is an independent benchmark, so the speed claim is not circular. The CFD demonstration is also not circular in the derivation sense. The neural network is trained on states generated from Wilke's rule (Eqs. 3–5) and then compared against the same Wilke rule (Eq. 7); this is a surrogate-model fit-quality check, not a claim that the surrogate independently predicts physics. Because the stated goal is to replace Wilke's viscosity model in the solver, validating against Wilke is the appropriate and self-consistent target, and the flow-level 0.25% velocity error is a genuine forward-simulation result that could have been large if the surrogate were poor. The paper never claims to derive Wilke's rule from the network. The most notable gap—no direct numerical equivalence check between Keras outputs and generated C++ layer-by-layer outputs (only a debugging API is described in §3.4)—is a verification omission, not a circularity: nothing in the paper defines the C++ output in terms of the benchmark result. There are also no load-bearing self-citations or imported uniqueness/ansatz conclusions. Thus no circular step meeting the required quote-and-reduction standard is present.
Assumptions & free parameters
free parameters (3)
- Viscosity-surrogate network weights (385 parameters) =
trained (values not listed)
- Training-sample stratification (60% Dirichlet / 40% mixing line; δT ~ U(−200,200) K) =
60/40; δT range 400 K
- Benchmark architectures (MLP 1000-64-32-100; CNN 8/16 filters + 32-filter variant) =
as in §4.1/Table 2
assumptions (5)
- domain assumption Keras model files (.keras/.h5) contain complete weight/hyperparameter information that CodeJeNN's parser extracts faithfully.
- domain assumption The C++ implementations of the 13 activations and 24 layer types behave identically to the Keras backends.
- domain assumption Wilke's mixing rule (Eqs. 3–5) is an acceptable reference for mixture viscosity in this flow.
- domain assumption Random states drawn from the 60/40 stratified distribution (with T sampled up to 3000 K, beyond the 350–1500 K physical streams) cover the states the CFD solver actually visits.
- domain assumption Viscosity errors of ~12% mean (max 8.12) do not meaningfully change the mixing-layer velocity field.
Cite this review
Pith. "Pith review of CodeJeNN: A simple C++ neural network generator for physics applications." pith.science (2026). https://pith.science/paper/JEQA333O
@misc{pith2026260702746,
author = {Pith},
title = {Pith review of: CodeJeNN: A simple C++ neural network generator for physics applications},
year = {2026},
howpublished = {\url{https://pith.science/paper/JEQA333O}},
note = {Machine review of arXiv:2607.02746}
}
read the original abstract
Machine learning has shown speedups for numerical methods in physics applications, but integrating Python-based libraries into high-performance C++ solvers creates performance bottlenecks. We present CodeJeNN, which bridges this gap by auto-generating self-contained C++ code from trained Keras models for inference. This eliminates external dependencies through minimal inlined functions, allowing seamless integration into existing frameworks. We describe the Keras-to-C++ workflow, supported architectures, and limitations. CodeJeNN is demonstrated through inference benchmarks against Keras in eager and JIT modes and a CFD test case modeling viscosity in a hydrogen-air mixing layer, showing speedups without sacrificing accuracy.
Figures
Figures from the paper (2 more)
Reference graph
Works this paper leans on
-
[1]
P. Häusner, A. N. Juscafresa, J. Sjölund, Learning incomplete factorization precon- ditioners for GMRES (Dec. 2024).doi:10.48550/arXiv.2409.08262. URLhttp://arxiv.org/abs/2409.08262
-
[2]
Y. Li, P. Y. Chen, T. Du, W. Matusik, Learning Preconditioners for Conjugate Gra- dient PDE Solvers, in: A. Krause, E. Brunskill, K. Cho, B. Engelhardt, S. Sabato, J. Scarlett (Eds.), Proceedings of the 40th International Conference on Machine Learning, Vol. 202 of Proceedings of Machine Learning Research, PMLR, 2023, pp. 19425–19439. URLhttps://proceedin...
2023
-
[3]
J. N. Fuhg, G. Anantha Padmanabha, N. Bouklas, B. Bahmani, W. Sun, N. N. Vlas- sis, M. Flaschel, P. Carrara, L. De Lorenzis, A Review on Data-Driven Constitutive Laws for Solids, Archives of Computational Methods in Engineering 32 (3) (2025) 1841–1883.doi:10.1007/s11831-024-10196-2. URLhttps://doi.org/10.1007/s11831-024-10196-2
-
[4]
M. Raissi, P. Perdikaris, G. Karniadakis, Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations, Journal of Computational Physics 378 (2019) 686–707. doi:10.1016/j.jcp.2018.10.045. URLhttps://linkinghub.elsevier.com/retrieve/pii/S0021999118307125
-
[5]
C. Zhao, F. Zhang, W. Lou, X. Wang, J. Yang, A comprehensive review of advances in physics-informed neural networks and their applications in complex fluid dynamics, Physics of Fluids 36 (10) (2024) 101301.doi:10.1063/5.0226562. URLhttps://pubs.aip.org/pof/article/36/10/101301/3315125/ A-comprehensive-review-of-advances-in-physics
-
[6]
S. Cai, Z. Mao, Z. Wang, M. Yin, G. E. Karniadakis, Physics-informed neural net- works (PINNs) for fluid mechanics: a review, Acta Mechanica Sinica 37 (12) (2021) 1727–1738.doi:10.1007/s10409-021-01148-1. URLhttps://link.springer.com/10.1007/s10409-021-01148-1
-
[7]
R. Vinuesa, S. L. Brunton, Enhancing computational fluid dynamics with ma- chine learning, Nature Computational Science 2 (6) (2022) 358–366.doi:10.1038/ s43588-022-00264-7. URLhttps://doi.org/10.1038/s43588-022-00264-7
-
[8]
J. Bai, F. Lu, K. Zhang, others, ONNX: Open Neural Network Exchange (2019). URLhttps://github.com/onnx/onnx 12
2019
Show all 33 references
-
[9]
Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghe- mawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Y
Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghe- mawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Y. Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Ku...
2015
-
[10]
Chollet, others, Keras (2015)
F. Chollet, others, Keras (2015). URLhttps://keras.io
2015
-
[11]
Ansel, E
J. Ansel, E. Yang, H. He, N. Gimelshein, A. Jain, M. Voznesensky, B. Bao, P. Bell, D. Berard, E. Burovski, G. Chauhan, A. Chourdia, W. Constable, A. Desmai- son, Z. DeVito, E. Ellison, W. Feng, J. Gong, M. Gschwind, B. Hirsh, S. Huang, K. Kalambarkar, L. Kirsch, M. Lazos, M. L...
2024
-
[12]
A. Bati, S. H. Bryngelson, RoseNNa: A performant, portable library for neural net- work inference with application to computational fluid dynamics, Computer Physics Communications 296 (2024) 109052.doi:10.1016/j.cpc.2023.109052. URLhttps://linkinghub.elsevier.com/retrieve/pii/...
2024
-
[13]
C. R. Wilke, A Viscosity Equation for Gas Mixtures, The Journal of Chemical Physics 18 (4) (1950) 517–519.doi:10.1063/1.1747673. URLhttps://pubs.aip.org/jcp/article/18/4/517/314304/ A-Viscosity-Equation-for-Gas-Mixtures
1950 doi
-
[14]
Maruyama, B
Y.Yan, J.R.Hammond, C.Liao, A.E.Eichenberger, AProposaltoOpenMPforAd- dressing the CPU Oversubscription Challenge, in: N. Maruyama, B. R. De Supinski, M. Wahib (Eds.), OpenMP: Memory, Devices, and Tasks, Vol. 9903, Springer Inter- national Publishing, Cham, 2016, pp. 187–202.d...
2016 doi
-
[15]
V. Nair, G. E. Hinton, Rectified linear units improve restricted boltzmann machines, in: Proceedings of the 27th International Conference on International Conference on Machine Learning, ICML’10, Omnipress, Madison, WI, USA, 2010, pp. 807–814
2010
-
[16]
K. He, X. Zhang, S. Ren, J. Sun, Delving Deep into Rectifiers: Surpassing Human- Level Performance on ImageNet Classification, in: 2015 IEEE International Con- ference on Computer Vision (ICCV), IEEE, Santiago, Chile, 2015, pp. 1026–1034. 13 doi:10.1109/ICCV.2015.123. URLhttp:...
2015
- [17]
- [18]
- [19]
-
[20]
D. Misra, Mish: A Self Regularized Non-Monotonic Activation Function, in: Pro- ceedings of the British Machine Vision Conference 2020, British Machine Vision Association, Online, 2020, p. 191.doi:10.5244/C.34.191. URLhttps://www.bmva.org/bmvc/2020/conference/papers/paper_0928.html
2020 doi
-
[21]
Dugas, Y
C. Dugas, Y. Bengio, F. Bélisle, C. Nadeau, R. Garcia, Incorporating Second-Order Functional Knowledge for Better Option Pricing, in: Advances in Neural Informa- tion Processing Systems, Vol. 13, MIT Press, 2000. URLhttps://papers.nips.cc/paper_files/paper/2000/hash/ 44968aece...
2000
- [22]
- [23]
-
[24]
M. D. Zeiler, D. Krishnan, G. W. Taylor, R. Fergus, Deconvolutional networks, in: 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recog- nition, IEEE, San Francisco, CA, USA, 2010, pp. 2528–2535.doi:10.1109/CVPR. 2010.5539957. URLhttp://ieeexplore.ieee.org...
2010
-
[25]
Zhang, Y
T. Zhang, Y. Yi, Y. Xu, Z. X. Chen, Y. Zhang, W. E, Z.-Q. J. Xu, A multi- scale sampling method for accurate and robust deep neural network to predict combustion chemical kinetics, Combustion and Flame 245 (2022) 112319.doi: 10.1016/j.combustflame.2022.112319. URLhttps://linki...
2022
-
[26]
H. G. Weller, G. Tabor, H. Jasak, C. Fureby, A tensorial approach to computational continuum mechanics using object-oriented techniques, Computers in Physics 12 (6) (1998) 620–631.doi:10.1063/1.168744. URLhttps://pubs.aip.org/cip/article/12/6/620/510187/ A-tensorial-approach-t...
1998 doi
-
[27]
J. Sun, Y. Wang, B. Tian, Z. Chen, detonationFoam: An open-source solver for simulation of gaseous detonation based on OpenFOAM, Computer Physics Commu- nications 292 (2023) 108859.doi:10.1016/j.cpc.2023.108859. URLhttps://linkinghub.elsevier.com/retrieve/pii/S0010465523002047
2023
-
[28]
Salim, J
M. Salim, J. Latendresse, S. Khatoonabadi, E. Shihab, Tokenomics: Quantifying Where Tokens Are Used in Agentic Software Engineering, arXiv:2601.14470 [cs.SE] (Jan. 2026).doi:10.48550/arXiv.2601.14470. URLhttp://arxiv.org/abs/2601.14470
2026 doi
-
[29]
T. Han, Z. Wang, C. Fang, S. Zhao, S. Ma, Z. Chen, Token-Budget-Aware LLM Reasoning, in: W. Che, J. Nabende, E. Shutova, M. T. Pilehvar (Eds.), Find- ings of the Association for Computational Linguistics: ACL 2025, Association for Computational Linguistics, Vienna, Austria, 20...
2025 doi
- [30]
-
[31]
Gilmer, S
J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, G. E. Dahl, Neural Message Passing for Quantum Chemistry, in: Proceedings of the 34th International Confer- ence on Machine Learning, PMLR, 2017, pp. 1263–1272. URLhttps://proceedings.mlr.press/v70/gilmer17a.html
2017
- [32]
-
[33]
Guennebaud, B
G. Guennebaud, B. Jacob, others, Eigen (2010). URLhttps://libeigen.gitlab.io 15
2010
Reviewed August 4, 2026 · model on record in the stance chip above.
Discussion (0). Continue with ORCID to comment.