Comparative Analysis of Neural Network Training Using NumPy and PyTorch on the MNIST Dataset

Authors

  • Dhimas Prayogi Universitas Pembangunan Panca Budi
  • Muhammad Iqbal Universitas Pembangunan Panca Budi

Keywords:

Neural Network, NumPy, PyTorch, MNIST, Digit Classification

Abstract

This study discusses a comparative analysis between artificial neural network training using NumPy and PyTorch in classifying digits in the MNIST dataset. These two approaches are compared to evaluate effectiveness in terms of accuracy, computational efficiency, and ease of implementation. The NumPy model is manually built with two layers, utilizing basic numerical operations for the forward and backward propagation processes, while the PyTorch model uses a Multilayer Perceptron (MLP) architecture with torch.nn and torch.optim libraries. The training results show that PyTorch excels in stability and training time, as well as delivering consistently higher accuracy than NumPy. Visualization through Principal Component Analysis (PCA) shows a more regular distribution of digit clusters, while decision boundary mapping between digits 3 and 8 shows a clearer class separation in the PyTorch model. This study shows that while manual implementation with NumPy is beneficial for learning basic neural network concepts, the use of PyTorch is more recommended for real-world applications that require efficiency and scalability. These results are expected to be a reference in the selection of machine learning tools according to the needs and resources of developers.

References

B. Antunes and D. R. C. Hill, "Reproducibility, energy efficiency and performance of pseudorandom number generators in machine learning: a comparative study of python, numpy, tensorflow, and pytorch implementations," arXiv preprint arXiv:2401.17345, 2024.

D. Beohar and A. Rasool, "Handwritten digit recognition of MNIST dataset using deep learning state-of-the-art artificial neural network (ANN) and convolutional neural network (CNN)," in 2021 International Conference on Emerging Smart Computing and Informatics (ESCI), 2021, pp. 542–548.

B. Gope, S. Pande, N. Karale, S. Dharmale, and P. Umekar, "Handwritten digits identification using mnist database via machine learning models," IOP Conference Series: Materials Science and Engineering, vol. 1022, no. 1, p. 12108, 2021.

I. Gridin, Automated Deep Learning Using Neural Network Intelligence: Develop and Design PyTorch and TensorFlow Models Using Python. Springer, 2022.

P. Holl and N. Thuerey, "Ф-ML: Intuitive Scientific Computing with Dimension Types for Jax, PyTorch, TensorFlow & NumPy," Journal of Open Source Software, vol. 9, no. 95, p. 6171, 2024.

F. J. J. Joseph, S. Nonsiri, and A. Monsakul, "Keras and TensorFlow: A hands-on experience," in Advanced deep learning for engineers and scientists: A practical approach, Springer, 2021, pp. 85–111.

O. Jouini, K. Sethom, A. Namoun, N. Aljohani, M. H. Alanazi, and M. N. Alanazi, "A survey of machine learning in edge computing: Techniques, frameworks, applications, issues, and research directions," Technologies, vol. 12, no. 6, p. 81, 2024.

L. Judijanto, A.-A. Al-Amin, and L. Nurhakim, "Implementasi Teknologi Artificial Intelligence dan Machine Learning dalam Praktik Akuntansi dan Audit: Sebuah Revolusi atau Evolusi," COSMOS: Jurnal Ilmu Pendidikan, Ekonomi Dan Teknologi, vol. 1, no. 6, pp. 470–483, 2024.

A.-H. M. NA, "Classification and analysis of the MNIST dataset using PCA and SVM algorithms," Vojnotehnički Glasnik, vol. 71, no. 2, pp. 221–238, 2023.

O. Nocentini, J. Kim, M. Z. Bashir, and F. Cavallo, "Image classification using multiple convolutional neural networks on the fashion-MNIST dataset," Sensors, vol. 22, no. 23, p. 9544, 2022.

O.-C. Novac et al., "Analysis of the application efficiency of TensorFlow and PyTorch in convolutional neural network," Sensors, vol. 22, no. 22, p. 8872, 2022.

H. B. P. D. A. Okatan, "Developing a basic neural network to classify images from the MNIST dataset," Humanities & Natural Sciences Journal, vol. 4, no. 7, pp. 128–138, 2023.

M. S. Rana, M. H. Kabir, and A. Sobur, "Comparison of the error rates of MNIST datasets using different type of machine learning model," North Am Acad Res, vol. 6, no. 5, pp. 173–181, 2023.

I. Hidayat, M. Iqbal, L. Marlina, A. Putera, and U. Siahaan, "Analysis Of Heart Failure Prediction With Random Forest Algorithm And Linear Regression(1)," 2025.

Z. Sitorus, M. Iqbal, D. Nasution, and R. F. Wijaya, "Penerapan Deep Learning dan Analisis Sentimen terhadap Gap Kompetensi Lulusan Lembaga Pendidikan dan Pelatihan Vokasi terhadap Dunia Kerja dengan Metode Long Short-Term Memory (LSTM)," vol. 6, no. 2, pp. 0–11, 2025.

Downloads

Published

2025-10-27

Most read articles by the same author(s)

1 2 > >>