# Configurable Hardware Core for IoT Object Detection
## 2 Background and Related Work
### CNN Model Optimization  
The CNN execution can be accelerated by approximating the computation at the cost of minimal accuracy drop. One of the most common strategies is reducing the precision of operations. During training, the data are typically in single-precision floating-point format. For inference in FPGAs, the feature maps and kernels are usually converted to fixed-point format with less precision, typically 8 or 16 bits, reducing the storage requirements, hardware utilization, and power consumption [23].  
Quantization is done by reducing the operand bit size. This restricts the operand resolution, affecting the resolution of the computation result. Furthermore, representing the operands in fixed-point instead of floating-point translates into another reduction in terms of required resources for computation.  
The simplest quantization method consists of setting all weights and inputs to the same format across all layers of the network. This is referred to as static fixed-point (SFP). However, the intermediate values still need to be bit-wider to prevent further accuracy loss.  
In deep networks, there is a significant variety of data ranges across the layers. The inputs tend to have larger values at later layers, while the weights for the same layers are smaller in comparison. The wide range of values makes the SFP approach not viable since the bit width needs to expand to accommodate all values.  
This problem is addressed by dynamic fixed-point (DFP), which consists of the attribution of different scaling factors to the inputs, weights, and outputs of each layer.  
Table 2 presents an accuracy comparison between floating-point and DFP implementations for two known neural networks. The fixed-point precision representation led to an accuracy loss of less than 1%.  
Quantization can also be applied to the CNN used in YOLO or another object detector model. The accuracy drop caused by the conversion to fixed-point of Tiny-YOLOv3 was determined for the MS COCO 2017 test dataset. The results show that a 16-bit fixed-point model presented a mAP\({}_{50}\) drop below 1.4 compared to the original floating-point model and 2.1 for 8-bit quantization.  
Batch-normalization folding [27] is another important optimization method that folds the parameters of the batch-normalization layer into the preceding convolutional layer. This reduces the number of parameters and operations of the model. The method updates the pre-trained floating-point weights \(w\) and biases \(b\) to \(w^{\prime}\) and \(b^{\prime}\) according to Equation (2) before applying quantization.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model Accuracy Comparison** & **Single Float Precision** & \multicolumn{3}{c}{**Fixed-Point Precision**} \\ \hline
**CNN Model** & **Top-1** & **Top-5** & **Top-1** & **Top-5** \\ \hline AlexNet [25] & 56.78\% & 79.72\% & 55.64\% & 79.32\% \\ \hline NIN [26] & 56.14\% & 79.32\% & 55.74\% & 78.96\% \\ \hline \hline \end{tabular}
\end{table}
Table 2: Accuracy comparison with the ImageNet dataset, adapted from [24].  
\[w^{\prime}=\frac{\gamma\times w}{\sqrt{\sigma^{2}+\epsilon}}\qquad b^{\prime}=b- \frac{\mu\times\gamma}{\sqrt{\sigma^{2}+\epsilon}} \tag{2}\]