# Hardware Platform-Aware Binarized Neural Network Model Optimization
## 4 Proposed Architecture Search Solution
### Architectural Search via Deepbit Method  
**Deepbit** algorithm is the most crucial part of the proposed solution, which is responsible for training and hardware evaluation to explore the optimal model for a specific hardware platform. In particular, the training process is performed first for a series of BNN models to reduce the searching scope. Next, hardware cost for output BNN models is estimated according to the hardware cost estimation charts. Finally, the ultimate optimal BNN model is determined based on hardware cost comparison among BNN models. The detail of an example used for our experiments is described with the following input:  
1. The set L defines the range for the depth (the number of convolution layers) of the BNN model. In our experiments: \[\text{L}=\{3,4,5,6,7,8\}\]
2. The maximum number of uniform channels per layer. In our experiments, we set this value at 50. 3. The threshold for an acceptable model. In most cases, the threshold is the minimum acceptable accuracy. As introduced in the previous section, the target platforms of this paper are FPGA devices with streaming BNN architecture, RRAM devices with the influence of the IR drop and sneak path [59, 60] and GPU. For FPGA devices, because streaming BNN architectures are fully implemented on FPGA, with a certain number of layers, an increase in the number  
\begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline
**Channels\textbackslash\textbackslash\textbackslash\textbackslash\textbackslash \textbackslash  
of channels on each layer directly increases the hardware resources and power consumption, as shown in Figure 5. Hence, minimizing the number of channels on each layer becomes the target of the **Deepbit** algorithm during the searching process. Similar to FPGA devices with streaming BNN architecture, RRAM devices affected by IR drop and sneak path also consider minimizing the number of channels on each layer an essential factor needed to perform. In particular, as shown in Figure 6, when increasing the number of channels into each layer, the accuracy is affected more severely, and the accuracy deviation consequently increases. In conclusion, during the searching process, to reduce impacts on critical target results for RRAM and FPGA devices, in this work, the **Deepbit** algorithm aims to minimize the number of channels on each layer. In doing so, the output of the **Deepbit** algorithm is a series of optimal BNN models. Each of them is an optimal BNN model with the minimum number of channels per layer, and the number of layers is the corresponding value in the set of L input. Therefore, the number of output models is the same as the size of set L.  
The **Deepbit** method is performed in three phases. In the first phase, for any given model, the width of the network (the number of output channels of each convolution layer) is reduced uniformly for each layer. In other words, for a given model, the width of the network remains constant across all layers. The first phase is started by defining a model with a depth equal to the minimum number in set L, while the width of the network is defined by the mentioned second input (50 for our experiments). The binary search algorithm is used to explore the BNN model with a minimal uniform width that matches the minimum accuracy threshold defined in the third input to our method. The algorithm for phase 1 is explained in Algorithm 1. More specifically, the result of Algorithm 1 is \(optimal\_uniform\_width\), which is the minimum uniform width for the model with a certain number of layers. Meanwhile, inputs of the algorithm are \(max\_width\) from the second input of the Deepbit, _layers_ (the number of convolution layers of the searching model), and _thresh_, which is the accuracy threshold (the third input of the Deepbit). To start the searching process in this algorithm, firstly, a range of model width is initialized (\(low\_width,high\_width\)). Next, a binary searching process is performed on this range until \(high\_width-low\_width<1\).