(43-5) 19 * << * >> * Russian * English * Content * All Issues

Hardware implementation of a convolutional neural network using calculations in the residue number system

N.I. Chervyakov1, P.A. Lyakhov1, N.N. Nagornov1, M.V. Valueva1, G.V. Valuev1

North-Caucasus Federal University, 355009, Russia, Stavropol, Pushkin street 1

 PDF, 968 kB

DOI: 10.18287/2412-6179-2019-43-5-857-868

Pages: 857-868.

Full text of article: Russian language.

Modern convolutional neural networks architectures are very resource intensive which limits the possibilities for their wide practical application. We propose a convolutional neural network architecture in which the neural network is divided into hardware and software parts to increase performance and reduce the cost of implementation resources. We also propose to use the residue number system in the hardware part to implement the convolutional layer of the neural network for resource costs reducing. A numerical method for quantizing the filters coefficients of a convolutional network layer is proposed to minimize the influence of quantization noise on the calculation result in the residue number system and determine the bit-width of the filters coefficients. This method is based on scaling the coefficients by a fixed number of bits and rounding up and down. The operations used make it possible to reduce resources in hardware implementation due to the simplifying of their execution. All calculations in the convolutional layer are performed on numbers in a fixed-point format. Software simulations using Matlab 2017b showed that convolutional neural network with a minimum number of layers can be quickly and successfully trained. Hardware implementation using the field-programmable gate array Kintex7 xc7k70tfbg484-2 showed that the use of residue number system in the convolutional layer of the neural network reduces the hardware costs by 32.6% compared with the traditional approach based on the two’s complement representation. The research results can be applied to create effective video surveillance systems, for recognizing handwriting, individuals, objects and terrain.

convolutional neural networks, image processing, pattern recognition, residue number system.

Chervyakov NI, Lyakhov PA, Nagornov NN, Valueva MV, Valuev GV.  Hardware implementation of a convolutional neural network using calculations in the residue number system. Computer Optics 2019; 43(5): 857-868. DOI: 10.18287/2412-6179-2019-43-5-857-868.

This work was supported by the Government of the Russian Federation (State order No. 2.6035.2017/BCh), the Russian Foundation for Basic Research (Projects No. 18-07-00109 A, No. 19-07-00130 A and No. 18-37-20059 mol-a-ved), and by the Presidential Grant of the Russian Federation (Project No. SP-2245.2018.5).


  1. Chen Y, Duffner S, Stoian A, Dufour J-Y, Baskurta A. Deep and low-level feature based attribute learning for person re-identification. Image Vis Comput 2018; 79: 25-34.
  2. Cheng X, Lu J, Feng J, Yuan B, Zhou J. Scene recognition with objectness. Pattern Recogn 2018; 74: 474-487.
  3. Sarikan SS, Ozbayoglu AM, Zilcia O. Automated vehicle classification with image processing and computational intelligence. Procedia Computer Science 2017; 114: 515-522.
  4. Qayyum A, Anwar SM, Awais M, Majid M. Medical image retrieval using deep convolutional neural network. Neurocomputing 2017; 266: 8-20.
  5. Zhang J, Shao K, Luo X. Small sample image recognition using improved convolutional neural network. Journal of Visual Communication and Image Representation 2018; 55: 640-647.
  6. LeCun Y, Bottou L, Bengio Y, Haffiner P. Gradient-based learning applied to document recognition. Proc IEEE 1998; 86(11): 2278-2324.
  7. Krizhevsky A, Sutskever I, Hinton GE. ImageNet classification with deep convolutional neural networks. Advances in Neural Information Processing Systems 2012; 25(2): 1097-1105.
  8. Szegedy C, Liu W, Jia Y, Sermanet P, Reed S, Anguelov D, Erhan D, Vanhoucke V, Rabinovich A. Going deeper with convolutions. IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2015: 1-9.
  9. Jouppi N, Young C, Patil N, Patterson D. Motivation for and evaluation of the first tensor processing unit. IEEE Micro 2018; 38(3): 10-19.
  10. TensorFlow. An end-to-end open source machine learning platform. Source: <https://www.tensorflow.org/>.
  11. Aghdam HH, Heravi EJ. Guide to convolutional neural networks: A practical application to traffic-sign detection and classification. Springer International Publishing; 2017.
  12. danielholanda/LeFlow: Enabling flexible FPGA high-level synthesis of tensorflow deep neural networks. Source: <https://github.com/danielholanda/LeFlow>.
  13. Noronha DH, Salehpour B, Wilton SJE. LeFlow: Enabling flexible FPGA high-level synthesis of tensorflow deep neural networks. Fifth International Workshop on FPGAs for Software Programmers (FSP Workshop) 2018; 1-8.
  14. Cafee. Deep learning framework. Source: <https://caffe.berkeleyvision.org/>.
  15. dicecco1/fpga_caffe. Source: <https://github.com/dicecco1/fpga_caffe>.
  16. DiCecco R, Lacey G, Vasiljevic J, Chow P, Taylor G, Areibi S. Caffeinated FPGAs: FPGA framework For Convolutional Neural Networks. International Conference on Field-Programmable Technology (FPT) 2016; 265-268.
  17. Install Intel® Distribution of OpenVINO™ toolkit for Linux with FPGA support – OpenVINO Toolkit. Source: <https://docs.openvinotoolkit.org/2019_R1/_docs_install_guides_installing_openvino_linux_fpga.html>.
  18. MATLAB [In Russian]. Source: <https://matlab.ru/products/matlab>.
  19. Nakahara H, Sasao T. A deep convolutional neural network based on nested residue number system. 25th International Conference on Field Programmable Logic and Applications (FPL) 2015: 1-6.
  20. Nakahara H, Sasao T. A high-speed low-power deep neural network on an FPGA based on the Nested RNS: Applied to an object detector. IEEE International Symposium on Circuits and Systems (ISCAS) 2018: 1-5.
  21. Manabe T, Shibata Y, Oguri K. FPGA implementation of a real-time super-resolution system with a CNN based on a residue number system. International Conference on Field Programmable Technology (ICFPT) 2017: 299-300.
  22. Chervyakov NI, Lyakhov PA, Valueva MV. Increasing of convolutional neural network performance using residue number system. International Multi-Conference on Engineering, Computer and Information Sciences (SIBIRCON) 2017: 135-140.
  23. Chernov VM. Ternary number systems in finite fields [In Russian]. Computer Optics 2018; 42(4): 704-711. DOI: 10.18287/2412-6179-2018-42-4-704-711.
  24. Omondi A, Premkumar B. Residue number systems: Theory and implementation. London: Imperial College Press; 2007.
  25. Cardarilli GC, Nannarelli A, Re M. Residue number system for low-power DSP applications. 41st Asilomar Conference on Signals, Systems, and Computers 2007: 1412-1416.
  26. Vergos HT, Dimitrakopoulos G. On modulo 2^n+1 adder design. IEEE Transactions on Computers 2012; 61(2): 173-186.
  27. Živaljević D, Stamenković N, Stojanović V. Digital filter implementation based on the RNS with diminished-1 encoded channel. 35th International Conference on Telecommunications and Signal Processing (TSP) 2012: 662-666.
  28. Chervyakov NI, Molahosseini AS, Lyakhov PA, Babenko MG, Deryabin MA. Residue-to binary conversion for general moduli sets based on approximate Chinese remainder theorem. International journal of computer mathematics 2017; 94(9): 1833–1849.
  29. Hung CY, Parhami B. An approximate sign detection method for residue numbers and its application to RNS division. Computers and Mathematics with Applications 1994; 27(4): 23-25.
  30. Matos R, Paludo R, Chervyakov N, Lyakhov PA, Pettenghi H. Efficient implementation of modular multiplication by constants applied to RNS reverse converters. IEEE International Symposium on Circuits and Systems (ISCAS) 2017; 1-4.
  31. Rao KR, Yip PC. The transform and data compression handbook. London, New York: CRC Press; 2001.
  32. Chervyakov NI, Lyakhov PA, Nagornov NN. Quantization noise of multilevel discrete wavelet transform filters in image processing. Optoelectronics, Instrumentation and Data Processing 2018; 54(6): 608-616.
  33. Rothganger F, Lazebnik S, Schmid C, Ponce J. Object recognition database. Source: <http://www-cvr.ai.uiuc.edu/ponce_grp/data/objects>.
  34. Chervyakov NI, Lyakhov PA, Kalita DI, Shulzhenko KS. Effect of RNS dynamic range on grayscale images filtering. XV International Symposium Problems of Redundancy in Information and Control Systems (REDUNDANCY) 2016; 33-37.


© 2009, IPSI RAS
Россия, 443001, Самара, ул. Молодогвардейская, 151; электронная почта: ko@smr.ru ; тел: +7 (846) 242-41-24 (ответственный секретарь), +7 (846) 332-56-22 (технический редактор), факс: +7 (846) 332-56-20