# A Resource Constrained Neural Network for the Design of Embedded Human Posture Recognition Systems
## 2 The Proposed System and the Underlying Model
### The FCN Model  
The FCN is schematized in Figure 2. It is composed by 3 convolutional (CONV) layers, a Global Average Pooling (GAP) layer and a dense fully convolutional layer. In order to reduce the number of physical resources for the HW implementation of the network, all the weights of the CONV layers have been quantized. As it will be shown in the next section, the conventional binary and ternary quantization schemes have given an unacceptable low accuracy for laying posture recognition. Therefore, a quantization scheme has been introduced, which exploits weights from the set \(\{-2,-1,0,+1,+2\}\) in place of \(\{-1,0,+1\}\) of ternary and \(\{-1,+1\}\) of binarized neural networks, selected according to the following criteria:  
\[f(x)=\begin{cases}-2&\text{if }x<-1.5\\ -1&\text{if }-1.5\leq x\leq-0.01\\ 0&\text{if }|x|<0.01\\ +1&\text{if }0.01\leq x\leq 1.5\\ +2&\text{if }x>1.5\end{cases} \tag{1}\]  
Additionally, all the activations have been binarized, and the activation functions have been reduced to [4]:  
\[y=sign(x)=\begin{cases}-1&\text{if }x<0\\ +1&\text{if }x\geq 0\end{cases} \tag{2}\]  
The advantages of this choice with respect to a full precision implementation can be roughly estimated in reducing memory requirements by about 1 order of magnitude (a factor of 32/3 for quantized weights and 32 for binarized activations) since weights are coded with 3 bits and activations with 1 bit; Multiply-Accumulate (MAC) operations, typically required to implement the convolutions, are simplified into Shift-Accumulate (SAC) operations for the absence of floating point (FP) multiplications and the consequent reduction of about 2 orders of magnitude in the number of FPGA LUTs. Each CONV layer in Figure 2 is followed by a Batch Normalization (BN) layer, where, as schematized in Figure 3 with more details, each sample is scaled by a factor \(\sigma\) and subtracted by the mean value \(\mu\), defined during the training and stored in a devoted memory.  
Figure 2: Model of the FCN. All the stages have been quantized with a 3 Bit quantization scheme, taking values in the set \(\{-2,-1,0,1,2\}\). A 16-bits fixed point format is assumed as input.  
No padding has been used. The fourth stage is made up of a Global Average Pooling (GAP), which is very robust to translations of the inputs and enables the Class Activation Map (CAM), which, together with the SoftMax, provides the final classification with less resources than typical dense layers of CNNs [35]. The GAP also reduces the dimensions of the network with respect to a conventional MaxPool since it transforms N-30 inputs to 1 and reduces the complexity of the following stage. The last stage is composed of a Fully Connected (FC) layer and a SoftMax classifier. The output of this last stage represents the probability of belonging to each output class, therefore the number of units of the fully connected corresponds to the number of considered classes. As shown in Table 1, the computational complexity of each layer in terms of required math operations and memory requirements changes depending on the specific application. When the FCN is used for laying posture recognition, it receives 108 input samples coded with 12 bits, representing a snapshot of the posture. The first and second CONV stages are composed by 24 one-dimensional filters of length 11, and the third by 32 filters. Depending on the number of classes to be considered, the output layer produces 17 and 8 values for laying and sitting postures, respectively.