## 4 Machine Learning Approach
### Comparative Analysis between Power Consumption of Neural Network and Sensor-Based Approach  
Using the training data, the Matlab Code trained the network and, using the validation data, it returned the accuracy at regular intervals in the course of the training process. It is also important to add some observations about the computational overhead introduced by the neural networks [30]. Using the MIT Deep Neural Network Energy Estimation Tool [31], we were able to quantify the energy estimation. The tool generates:  
* A txt file where each row gives the estimated energy dissipation for each layer in terms of the data movement and of the three data types (input feature map, weight and output feature map) and the computation. Energy units are normalized in terms of the energy for a MAC (multiply-and-accumulate) operation (that is, 102 = energy of 100 MACs). The output total energy is the energy required to process the dataset. * A png file which visualizes the energy estimation result. See Figure 8.  
MAC operations in CONV and FC layers account for more than 99% of the total operations in a modern CNN [31] and therefore dominate both processing time and power consumption. The results in Figure 8 show that the energy consumption is comparable with that of a standard CNN. Both of the two approaches we are comparing belong to the class of centralized systems, i.e., the systems in which the calculation takes place at the network level and not on individual nodes. In [32], it is reported that for the centralized case, the total energy dissipated per sensor is 132.7 uJ, regardless of the type of localization algorithm used. At the network level, instead, the energy complexity of the algorithm (see [33]) is obtained as  
\[O^{E}(f_{e}(n))=O_{c}(E_{c}\cdot f_{c}(n))+O_{p}(E_{p}\cdot f_{p}(n))+O_{s}(E _{s}\cdot f_{s}(n))+O_{n}(E_{n}\cdot f_{n}(n)) \tag{22}\]  
where \(O_{c}(f_{c}(n))\) is the CPU complexity equal to the known runtime, and \(O_{c}(E_{c}\cdot f_{c}(n))\) is the order of magnitude of runtime complexity multiplied by the energy required to operate. In the same way, \(O_{p}(f_{p}(n))\) handles primary memory usage complexity, the class \(O_{s}(f_{s}(n))\) characterizes the energy consumption of secondary storage and \(O_{n}(f_{n}(n))\) can represent the energy complexity of network resources. In [32], the comparison of communication and processing energy using the centralized architecture is reported. It shows that communication contribution is negligible when the number of sensor nodes exceeds 50 units, so we approximate the equation this way:  
\[O^{E}(f_{e}(n))=O_{c}(E_{c}\times f_{c}(n))+O_{p}(E_{p}\times f_{p}(n))+O_{s}( E_{s}\times f_{s}(n)) \tag{23}\]  
In the standard \"sensor-based\" case, we therefore have  
\[O^{E}(f_{e}(n))=O_{c}(E_{c}\times n^{3})+O_{p}(E_{p}\times f_{p}(n))+O_{s}(E_{ s}\times f_{s}(n)) \tag{24}\]  
For all Strassen-like algorithms (that is, those based algebraically on upper bounds on the rank of matrix multiplication) [34], the space usage is at most \(O(n^{2})\). Assuming that energy consumption on primary and secondary memory is comparable, using some experimental results of energy consumption, as in [32], and neglecting the contribution of \(n^{2}\), we obtained this equation:  
\[O^{E}(f_{e}(n))=0.0009271406\cdot n^{3} \tag{25}\]  
In the case of the neural network, we obtain  
\[O^{E}(f_{e}(n))=O_{c}(E_{c}\cdot n^{4})+O_{p}(E_{p}\cdot f_{p}(n))+O_{s}(E_{ s}\cdot f_{s}(n)) \tag{26}\]  
In [35], it is shown that layer depth, epoch and batch size are variable by trail and do not affect memory consumption. Regarding the learning rate, the smaller the learning rate, the higher the memory consumption. So, we must take into account the learning rate that we used in the simulation, that is 0.0007. In this situation, the memory usage is about 2700 Megabytes.