## 4 Machine Learning Approach
### Comparative Analysis between Computational Complexity of Neural Network and Sensor-Based Approach  
Ref. [26] shows that the RTT delay for messages sent from the end device to the controller and for responses returned from the controller to the end device over LoRaWAN ranges from 1.12 s to 6.59 s. Considering that, once the neural network has been trained, the response time is of the order of a few milliseconds [27]; therefore, the overall delay depends on the propagation (RTT) and not on the neural network architecture. In [28], it is shown how the computational complexity of a neural network can be calculated. Looking at the inference part of a feedforward neural network, we have forward propagation. Finding the asymptotic complexity of forward propagation can be performed similarly to how we found the runtime complexity of matrix multiplication. Assume the input vector can be written as \(x\in\mathbb{R}^{n}\). The input is treated like any other activation matrix and has the following indices: \(x=w^{(0)}\), the zeroth element, and \(w^{(0)}_{0}\) is a bias unit with a value of 1, as usual. Forward propagation can be written as (see Figure 7). \[z^{(k)}=\theta^{(k)}w^{(k-1)} \tag{1}\] \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Technique** & **Range (m)** & **Power** & **Precision (m)** & **Source** \\ \hline \hline \begin{tabular}{c} OwLL \\ Prior LP-WAN \\ \end{tabular} & \begin{tabular}{c} 500 \\ \(>\)500 \\ \(\approx\)50 \\ \end{tabular} & Low & \begin{tabular}{c} \(\approx\)9 \\ \(>\)100 \\ \(\approx\)5 \\ \end{tabular} & \begin{tabular}{c} [17] \\ [18,19] \\ \(\approx\)5 \\ \end{tabular} \\ \begin{tabular}{c} Cellular \\ \end{tabular} & \
\begin{tabular}{c} \(\approx\)50 \\ \(\approx\)15 \\ \end{tabular} & Medium &
\begin{tabular}{c} \(<\)0.05 \\ \end{tabular} & [24,25] \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison of different techniques for localization. \[z^{(k)}\in\mathbb{R}^{1\times(m|\theta^{(k)}\in\mathbb{R}^{m\times n})} \tag{2}\]  
\[w^{(k)}=g(z^{(k)}) \tag{3}\]  
From where \(g(x)\) is the activation function, which is evaluated element-wise. So, we know \(w^{(k)}\) are the same dimensions as \(z^{(k)}\). We can see that the matrix multiplication and activation functions for each layer are computed. From [28], the asymptotic execution time for simple matrix multiplication is \(O(n^{3})\); since \(g(x)\) is an element-wise function, the execution time is \(O(n)\). Analyzing the dimensionality of the feedforward neural network reveals the following:  
\[\theta^{(0)}\in\mathbb{R}^{n^{(0)}\times 1} \tag{4}\]  
\[\theta^{(1)}\in\mathbb{R}^{n^{(1)}\times n^{(0)}} \tag{5}\]  
\[\theta^{(2)}\in\mathbb{R}^{n^{(2)}\times n^{(1)}} \tag{6}\]  
More generally:  
\[\theta^{(k)}= \begin{cases}\mathbb{R}^{n^{(k)}\times 1},&\text{if }k=0\\ \mathbb{R}^{n^{(k)}\times n^{(k-1)}},&\text{if }k>0\end{cases}  \tag{7}\]  
where \(n^{(k)}\)is the number of neurons containing bias units in the layer \(k\). From [28], we know that  
\[w=n^{(k)} \tag{8}\]  
\[z=n^{(k-1)} \tag{9}\]  
\[d=n^{(k-2)} \tag{10}\]  
From this, we can see that:  
\[n_{mul}=\sum_{k=2}^{n_{layers}}(n^{(k)}n^{(k-1)}n^{(k-2)})+(n^{(0)}n^{(1)}1) \tag{11}\]  
Figure 7: Neural Network Layers. \[n_{g}=\sum_{k=1}^{n_{layers}}(n^{(k)}) \tag{12}\]  
where \(n_{mul}\) is the number of multiplications performed and \(n_{g}\) is the number of times the activation function \(g\) is applied. Note, however, that we assumed the following approximation, that is, \(w^{(k)}\) has the same dimensions as \(\theta^{(k)}\), but clearly it is not because \(w^{(k)}\in\mathbb{R}^{n^{(k)}\times 1}\). This returns:  
\[time=n_{mul}+n_{g}\iff \tag{13}\]  
\[time=\sum_{k=2}^{n_{layers}}(n^{(k)}n^{(k-1)}n^{(k-2)})+(n^{(0)}n^{(1)}1)+\sum_ {k=1}^{n_{layers}}(n^{(k)}) \tag{14}\]  
When analyzing matrix algorithms, it is common to assume that the matrix is square. That is, they have the same number of rows and columns.