Batch Matrix-form Equations and Implementation of Multilayer Perceptrons
Preprint
Abstract
Multilayer perceptrons (MLPs) remain fundamental to modern deep learning, yet their algorithmic details are rarely presented in complete, explicit \emph{batch matrix-form}. Rather, most references express gradients per sample or rely on automatic differentiation. Although automatic differentiation can achieve equally high computational efficiency, the usage of batch matrix-form makes the computational structure explicit, which is essential for transparent, systematic analysis, and optimization in settings such as sparse neural networks. This paper fills that gap by providing a mathematically rigorous and implementation-ready specification of MLPs in batch matrix-form. We derive forward and backward equations for all standard and advanced layers, including batch normalization and softmax, and validate all equations using the symbolic mathematics library SymPy. From these specifications, we construct uniform reference implementations in NumPy, PyTorch, JAX, TensorFlow, and a high-performance C++ backend optimized for sparse operations. Our main contributions are: (1) a complete derivation of batch matrix-form backpropagation for MLPs, (2) symbolic validation of all gradient equations, (3) uniform Python and C++ reference implementations grounded in a small set of matrix primitives, and (4) demonstration of how explicit formulations enable efficient sparse computation. Together, these results establish a validated, extensible foundation for understanding, teaching, and researching neural network algorithms.Keywords
All Related Versions
This publication has 10 references indexed in Scilit:
- Activation functions in deep learning: A comprehensive survey and benchmarkNeurocomputing, 2022
- A review on weight initialization strategies for neural networksArtificial Intelligence Review, 2021
- Array programming with NumPyNature, 2020
- Accurately computing the log-sum-exp and softmax functionsIMA Journal of Numerical Analysis, 2020
- Demystifying Learning Rate Policies for High Accuracy Training of Deep Neural Networks2019
- SymPy: symbolic computing in PythonPeerJ Computer Science, 2017
- Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification2015
- The MNIST Database of Handwritten Digit Images for Machine Learning Research [Best of the Web]IEEE Signal Processing Magazine, 2012
- Deep Neural Networks for Acoustic Modeling in Speech Recognition: The Shared Views of Four Research GroupsIEEE Signal Processing Magazine, 2012
- Cognitron: A self-organizing multilayered neural networkBiological Cybernetics, 1975