# A Methodology to Design Quantized Deep Neural Networks for Automatic Modulation Recognition
## 4 Design Methodology for Quantization Selection
If, during the screening, a combination that meets the expected trade-off is found, e.g., by creating the Pareto front using the resulting accuracy and NICS metrics from the quantized models, then we can conclude our search. Otherwise, we can move to the second stage. Algorithm 1 shows the pseudocode of the first stage. Notice that the resulting accuracy and NICS metrics from the quantized models are returned in variable \(E\) in Algorithm 1. \[\rho=1-\frac{6\sum_{i=1}^{n}D_{i}^{2}}{n(n^{2}-1)} \tag{6}\]  
```
1:I/Q samples data set \(DS\). 2:DNN model \(M\). 3:Set I with different number of bits to quantize the input parameter. 4:Set a with different number of bits to quantize the activation function parameter on all layers. 5:Set W with different number of bits to quantize the weight parameter on all layers. 6:Initialize set \(E\) of experiments
7:for\(i\in I\)do
8: Quantize \(M\)'s input with \(i\) bits
9:for\(a\in A\)do
10: Quantize \(M\)'s activation functions with \(a\) bits
11:for\(w\in W\)do
12: Quantize \(M\)'s weights with \(w\) bits
13: Apply quantize-aware training to \(M\) and use dataset \(DS\)
14:\(Accuracy_{\{i,a,w\}}\leftarrow\) Calculate accuracy of \(M\)
15:\(NICS\{i,a,w\}\leftarrow\) Calculate NICS of \(M\)
16:\(Experiment\{i,a,w\}\leftarrow[NICS\{i,a,w\},Accuracy_{\{i,a,w\}}]\)
17:\(E=E\cap Experiment\{i,a,w\}\)
18:endfor
19:endfor
20:Calculate [PERSON]'s correlation analysis on \(E\)
21:Return \(E\) and the parameter with higher correlation with respect to accuracy and NICS
```  
**Algorithm 1** Screening: Detection of relevant parameters. Since modern DL models are composed of several layers, if the dominant parameters are activation or weights, we can evaluate in a layered way which layer has the highest effect on the trade-off (stage 2). Notice that the weights are more likely to significantly impact the accuracy and inference cost outputs compared to activations and inputs since there are more hidden units and connections among them than layers. During the second stage, we measure the degree of quantization per layer required to meet a given trade-off. Notice that if the input is the parameter that most impacts the outputs, then the second stage is the same, but the only layer to alter is the input one. A good starting point is to take the same quantization subset as in stage one. In this stage, we vary the quantization level of a given layer while keeping the quantization level of the non-dominant parameters and the remaining layers the same. Compared to previous works such as [13; 15], our second stage differs from them since they typically apply the same quantization level to all the model's layers. Suppose the trade-off between the model performance metric and the inference cost is met, then we conclude our search by obtaining an architecture in which we have identified which layer of the model has the highest impact. Otherwise, we can continue with the third stage. Algorithm 2 summarizes the procedure to analyze the effect of the quantization level in each layer of a DNN independently, assuming the weight parameter has the most impact in the output (from Algorithm 1). ```
1:I/Q samples data set \(DS\). 2:DNN model \(M\). 3:Set L with the layers of \(M\) to be quantized. 4:Fixed number of bits \(i\) to quantize the input parameter. 5:Fixed number of bits \(a\) to quantize the activation function parameter on all layers. 6:Set W with different number of bits to quantize the weight parameter.