An Edge-based WiFi Fingerprinting Indoor Localization Using
  Convolutional Neural Network and Convolutional Auto-Encoder
With the ongoing development of Indoor Location-Based Services, the location
information of users in indoor environments has been a challenging issue in
recent years. Due to the widespread use of WiFi networks, WiFi fingerprinting
has become one of the most practical methods of locating mobile users. In
addition to localization accuracy, some other critical factors such as latency,
and users' privacy should be considered in indoor localization systems. In this
study, we propose a light Convolutional Neural Network-based method for edge
devices (e.g. smartphones) to overcome the above issues by eliminating the need
for a cloud/server in the localization system. The proposed method is evaluated
for three different open datasets, i.e., UJIIndoorLoc, Tampere and
UTSIndoorLoc, as well as for our collected dataset named SBUK-D to verify its
scalability. We also evaluate performance efficiency of our localization method
on an Android smartphone to demonstrate its applicability to edge devices. For
UJIIndoorLoc dataset, our model obtains approximately 99% building accuracy,
over 90% floor accuracy, and 9.5 m positioning mean error with the model size
and inference time of 0.5 MB and 51 us, respectively, which demonstrate high
accuracy in range of state of the art works as well as amenability to the
resource-constrained edge devices.
Amin Kargar-Barzi, Ebrahim Farahmand, Nooshin Taheri Chatrudi, Ali Mahani, Muhammad Shafique
CAE-CNNLoc: An Edge-based WiFi Fingerprinting Indoor Localization Using Convolutional Neural Network and Convolutional Auto-Encoder

###### Abstract

With the ongoing development of Indoor Location-Based Services, accurate location information of users in indoor environments has been a challenging issue in recent years. Due to the widespread use of WiFi networks, WiFi fingerprinting has become one of the most practical methods of locating mobile users. In addition to localization accuracy, some other critical factors such as cost, latency, and users' privacy should be considered in indoor localization systems. In this study, we propose a lightweight Convolutional Neural Network (CNN)-based method for edge devices (such as smartphones) to overcome the above issues by eliminating the need for a cloud/server in the localization system. To enable the use of the proposed model on resource-constraint edge devices, post-training optimization techniques including quantization, pruning and clustering are used to compress the network model. The proposed method is evaluated for three different open datasets, i.e., UJIIndoorLoc, Tampere and UTSIndoorLoc, as well as for our collected dataset named SBUK-D to verify its scalability. The results demonstrate the superiority of the proposed method compared to state-of-the-art studies. We also evaluate performance efficiency of our localization method on an android smartphone to demonstrate its applicability to edge devices. For UJIIndoorLoc dataset, our model with post-training optimizations obtains approximately 99% building accuracy, over 98% floor accuracy, and 4 m positioning mean error with the model size and inference time of 60 KB and 270 us, respectively, which demonstrate high accuracy as well as amenability to the resource-constrained edge devices.

**Keywords:** Indoor Positioning, Deep Learning, Convolutional Neural Network, WiFi Fingerprinting, Edge-based model

## 1 Introduction

Nowadays, users' position related information in indoor environment has received remarkable attention in the majority of applications [1], especially Indoor Location-Based Services (ILBSs). In the contemporary era, ILBSs can be used in various areas such as indoor navigation and tracking, location-based advertising (shopping advertisements), location-based information retrieval (tourists guiding services in a museum), and many more [1][2]. An accurate and low-cost localization system is an important component of ILBSs, which has been taken into consideration in academic and industrial sectors. Generally, in the outdoor environment, this issue has been solved by GPS technique, but this method is not a suitable approach for indoor places because of blockage, attenuation or reflection of satellite signals [1]. Consequently, finding an accurate and low-cost indoor localization system is known as an ongoing challenge in this area.

In recent years, different technologies like Camera [3], visible Light [4], Bluetooth [5], WiFi [6], Ultra Wide Band (UWB) [7] and RFID [8] have been used for indoor localization. Among these technologies, WiFi technology has attracted lots of attention because WiFi networks and their infrastructures are available in most public buildings, such as offices and shopping centers. Moreover, most users have a smartphone with Wifi technology. Therefore, the position related information can be obtained by this technology without any additional hardware and cost.

Traditional localization algorithms, such as trilateration or triangulation, are based on measured information like distance or angle from some references node to estimate the position [9]. These methods need line-of-sight (LOS) communication to measure accurate distances or angles. Hence, it is clear that these methods are not suitable for indoor environments with lots of walls and other types of obstacles [10]. Among different methods, the _WiFi fingerprinting_ method can easily overcome the mentioned issue without the need for distance or angle information, so this is a proper method for non-line-of-sight (NLOS) environments. Actually, in WiFi fingerprinting methods, just the Received Signal Strength Indicator (RSSI) of WiFi signals from each Access Point (AP) is used to calculate users' location. In these methods, it is assumed that RSSI of several WiFi signals in one point is unique; therefore, this pattern (i.e. a WiFi fingerprint) can be used to estimate the location [11].

Generally, the WiFi fingerprinting localization has two main phases, including offline and online phases. In the _offline phase_, WiFi fingerprint dataset, also known as radio map, is constructed by collecting RSSI values of accessible APs at several known points in the interested area (each RSSI pattern labeled by its location). In the _online phase_, users utilize the collected dataset to estimate their position. In this phase, a user measures the RSSI pattern at his/her place and sends this data to the system (server or cloud) to find its position by matching the RSSI pattern with the available patterns in the dataset. The matching part aims to find the most similar pattern from the dataset with the measured RSSI pattern.
There are different methods for matching part of WiFi fingerprinting to estimate the position, ranging from probabilistic to K-nearest-neighbor (KNN) and Support Vector Machine (SVM) [12]. These methods require complex filtering and parameter adjustments that are time-consuming and computationally intensive.. In order to reduce the time-consuming and intensive computation, Deep Neural Networks (DNN) is recently used in localization [13]. Although a different number of studies attempt to decrease intensive computation and time-consuming, the main issue still remains to be how to effectively optimized DNN based methods for indoor localization applications. Towards this, in this paper, we propose a light-weight CNN-based model to solve the above issues.

Moreover, most of the state-of-the-art approaches are cloud-based or fog-based which gather the data and send them to a server/cloud or other devices to analyze and compute the location [14]. _This procedure has the following drawbacks which significantly affect the efficiency of the localization process._

* Privacy and security concerns by transmitting user's data to third-party platforms, such as a cloud or server.
* Increased latency of the localization process because the data have to be sent to a server for computation followed by the server sending the location response to the user.
* Increased network traffic and system cost coupled with a centralized method that needs a server or cloud for computation.

Recently, edge-based systems are mostly used in different applications in which all computations are performed on edge; so there is no need to transfer data elsewhere. Therefore, to address the mentioned drawbacks, an edge-based indoor localization system is employed to have a better performance in terms of privacy, latency and cost. However, the edge devices are not able to execute complex algorithms such as complex CNN which were recently proposed for indoor localization. For this purpose, a light CNN-based model is proposed to run on edge devices with limited resources. This suggested model can be implemented on edge devices, such as smartphones, which significantly improves the localization performance in terms of accuracy, latency, and cost. **The main contributions of this article are as follows:**

* A light CNN-based model to run on the edge device with limited resources in terms of energy, processor, and memory, such as smartphones for indoor localization application.
* A light Convolutional auto-encoder is utilized for feature extracting, denoising and dimension reduction; also, Global-Average-Pooling is used instead of fully-connected layer to reduce the network parameters, complexity and size for indoor localization application.
* In terms of pre-processing, region griding approach is used to improve the network performance by enhancing the localization accuracy and decreasing network size and complexity.
* Post-training optimization techniques including quantization, pruning and clustering are used to compress the network and shrink the model parameters, size and complexity.
* Validate the scalability of the proposed model by evaluating it on three different public datasets and also our collected dataset named SBUK-D.
* Evaluate the suggested network model on an android smartphone.

**Paper Organization:** The rest of this paper is organized as follows: In Section 2, an overview of several related works on indoor localization methods is presented. Then, In Section 3, we describe our proposed model and its structure in three main subsections. Afterwards, model evaluation and experimental results are reported in Section 4 and ultimately, concluding remarks are drawn in Section 7.

## 2 Related work

In the following, some recent indoor localization studies are briefly discussed with their features and problems. Totally, indoor positioning methods are categorized into two main groups named device-free and device-based methods. As is clear from their names in device-free approaches, the location is estimated without any special device carrying by users, for example, using CCTV to detect and locate a person in indoor environments. Conversely, device-based ways need some particular attached devices to compute the location of users [2], for instance, using smartphones WiFi or its other sensors for user localization.

The majority of device-free localization (DFL) techniques need some infrastructures to estimate the position. Some DFL studies, such as [15][16], benefit from wireless sensor network (WSN) for localization which their main idea is to place several wireless sensors around the desired area communicating with each other. These wireless links are affected if a person locates or moves in this area. Hence, the position can be estimated based on these wireless link variations. For instance, authors in [17] used this method and formulated their DFL problem as an image classification problem. Afterwards, a three-layer convolutional auto-encoder neural network suggested extracting features and computing position by raw data with various patterns associated with different positions. Besides, in [18], authors suggested a DFL method by using orthogonal RFID Tags attached on two adjacent walls and utilized some RFID readers to measure phase information and RSSI. The gathered information is fed to a PSO-based algorithm to estimate the position of an object in a 2D place.
It is observed that device-free methods need several extra infrastructures that increase the localization cost. Also, they are not suitable for large buildings, and in most cases, they need LOS communication and can use for one-floor buildings.

Conversely, device-based localization methods attempt to estimate the position by a device carrying with users. These portable devices utilize various types of modules, such as Bluetooth or Inertial Sensors, to estimate the user location in indoor environments. Nowadays, most people use smart mobile phones with different types of equipment, such as WiFi, Bluetooth and Inertial Sensors; hence, researchers recently attract to benefit from user's smartphones for localization. WiFi-based methods have attracted enormous interest in indoor positioning among various technologies because of their wide availability in most buildings [2]. In WiFi-based methods, some studies like [19] use Time Of Arrival (TOA) technique to estimate the position, while the main disadvantage of TOA is synchronization among all transceivers. In addition, several studies estimate the position based on Angle of Arrival (AOA) approach that requires APs with multiple antennas known as their drawbacks. Besides, some studies locate the user based on WiFi fingerprinting method. The main idea of fingerprinting is to estimate the location by matching the collected RSSI set from surrounding APs named fingerprint with prebuilt WiFi fingerprint dataset [20]. In [21], authors proposed DeepFi for WiFi fingerprinting localization which is a Deep Learning based approach. This method uses Channel State Information (CSI) from all antennas and their all subcarrier which are analyzed with four hidden layers deep network. Generally, CSI-based methods are more accurate than RSS-based ones because they use amplitude and phase of the signal. However, it must be considered that modern smartphones cannot extract CSI; so it seems that CSI-based methods are not suitable approaches for ILBS.

Unlike CSI-based methods, today's smartphones can easily calculate RSS; hence most prior studies focus on RSS-based WiFi fingerprinting. In this regard, authors in [22] improve the accuracy of WiFi fingerprinting localization by using Weighted K-Nearest Neighbor (WKNN) based on RSSI similarity and spatial position while other KNN-based methods, such as [23], are based on euclidean distance. In recent years, deep learning methods were used for WiFi fingerprinting. In [21] a deep learning model was suggested for WiFi fingerprinting localization. Moreover, several studies use Auto-encoder (AE) with their DNN model to improve the localization accuracy. For instance, in [24], authors proposed a DNN system for building and floor classification and employ stacked auto-encoders (SAE) to reduce feature space and improve accuracy. Also, a different DNN architecture with SAE was proposed in [25] for multilabel classification of building ID, floor ID and position.

Generally, DNN models achieve higher accuracy by increasing their hidden layers. However, a deeper DNN model increases the computational complexity and also computation time. To overcome aforesaid issues, a convolutional neural network (CNN) based structure was proposed in [26] for building and floor classification, which decreases the complexity and reduces the sensitivity of the model to the signal variations. Additionally, CNNLoc method was proposed for WiFi fingerprinting in [13], a CNN-based model including an SAE and one-dimensional CNN. These methods are cloud/server based which all data processing are done on third-party platforms. Hence, the data transmission between user and cloud leads to privacy and security concerns and significant time overhead.

_In summary, the main focus of most studies is to achieve the highest possible accuracy that needs high computation and memory requirements which are mostly based on the cloud/server platform_. So, these cloud/server-based models are not suitable and efficient to directly run on edge devices with limited power, memory and computational resources. In addition, there are some other critical factors for indoor localization, such as cost, latency and privacy/security concerns, which must be considered during system designing. Hence, this study proposes a new edge-based WiFi fingerprinting approach to address these issues along with the highest possible accuracy needed for ILBS in multi-building and multi-floor places.

\begin{tabular}{|p{42.7pt}|p{113.8pt}|p{113.8pt}|p{113.8pt}|} \hline
**Study** & **Category** & **Method** & **Technique** & **Attributes and Limitations** \\ \hline
15,16, 17 & Devised-Free & Wireless Sensor Network (WSN) & Signal variation when an object places between nodes & \(\bullet\) Extra infrastructures are needed \\ \hline
18 & Devised-Free & RFID Tags & Phase and RSSI information feed to PSO algorithm to estimate the position & \(\bullet\) Not suitable for large buildings \\ \hline
19 & Device-Based & Wifi signal & TOA of wifi signal is used to estimate the position & Need synchronization among all transceivers \\ \hline
21 & Device-Based & CSI-based WiFi fingerprint & Deep Learning (DL) & \(\bullet\) CSI-based methods are more accurate than RSS-based \(\bullet\) Modern smartphones and devices cannot extract CSI \\ \hline
22 & Device-Based & RSSI-based WiFi fingerprint & Weighted K-Nearest Neighbor (WKNN) & \(\bullet\) Modern smartphones and devices support RSS \\ \hline
23 & Device-Based & RSSI-based WiFi fingerprint & Euclidean Distance & \(\bullet\) Not edge based methods a that lead to privacy and security concerns and time overhead \\ \hline
13,24, 25,26 & Device-Based & RSSI-based WiFi fingerprint & Deep Learning (DL) & \(\bullet\) Not edge based methods a that lead to privacy and security concerns and time overhead \\ \hline \end{tabular}
## 3 Proposed method

This section introduces a new WiFi fingerprinting system to estimate a person's location in an indoor environment. The suggested architecture is based on CNN classifier that identifies the position of an individual in indoor places. The system diagram of the proposed method is shown in Fig. 1. As shown in this figure, the localization system consists of three main phases, including pre-processing, network training and post-training optimization. The details of each part are elaborated in the following.

### Data Pre-Processing and Dataset Preparation

The first step is to modify raw input data, such that the data is fed into the proposed network in an appropriate format, and only the relevant data is fed. There are three main phases to prepare data for our network as follow:

#### 3.1.1 Normalization

The normalization technique aims at decreasing the input distribution without losing information and facilitate the model training. In this paper, input data are Received Signal Strength Indicator (RSSI) value of neighbouring access points which are normalized and mapped into [0,1] by the following equation:

\[RSS_{inew}=\left\{\begin{aligned} 0,& RSS_{i}>0\ (no\ signal)\\ \frac{RSS_{l}-RSS_{min}}{-RSS_{min}},& otherwise \end{aligned}\right.\]

Where \(RSS_{min}\) is the lowest value in the dataset. For example, in UJIIndoorLoc dataset, RSSI values are between -104 dBm to 0 dBm; hence for this dataset \(RSS_{min}=-104\).

#### 3.1.2 Region Griding

Generally, users' exact position is not required in the majority of ILBS applications [1]. Therefore, to improve the localization performance, we benefit from griding technique [27]; hence we divided the location area into some square cells with the length of \(L\), and considered a unique coordinate for each cell representing the user's location in the given region. This procedure for UJIIndoorLoc dataset with \(L\)=20 is shown in Fig. 2. As is evident from this figure, each cell has several samples in which the cell coordinate is assumed for their position. For each cell, this unique coordinate is calculated by averaging all samples' positions inside it.

This method decreases the number of classes in the proposed network model, which leads to a remarkable reduction in the network parameters and size.

Figure 1: Our localization system diagram
#### 3.1.3 Dataset and Input preparation

To have identically and independently (i.i.d) feature for datasets, which is a vital factor to train the network model, we combine the training and testing set. Afterwards, the combined set is randomly split into training, validation and testing. Additionally, as we develop a CNN-based method for WiFi fingerprinting localization, where the input is a 2-D array of RSSI values. Hence, for UJIndoorLoc dataset, we create a 2-D array from the input, which is a vector with 520 elements. For this purpose, we reshape the input array to 23x23 2-D array with 9 dummy elements (zero value). Note, based on the simulation, the best place for the dummy data is the corners of the image as shown in Fig. 3.

### Network Architecture

In this paper, a Convolutional Neural Network (CNN) is used as the base of the network and a Convolutional Auto-encoder (CAE) is deployed to enhance the performance of the network. Besides that, we use dropout, batch normalization, pooling and Global Average Pooling (GAP) layers to improve the network performance. In the following, we elaborate the proposed network, which is shown in Fig. 5.

#### 3.2.1 Convolutional Neural Network

As mentioned above, this paper proposes a light network for WiFi fingerprinting localization with the highest possible accuracy that can be run on user devices. We leverage a Convolutional Neural Network (CNN) to reduce the input size that is also easier to process without losing important features. Morever, compared with other machine learning methods, such as SVM and KNN, CNN networks are more robust to the sensitivity of input data variation [26]. This is a critical property in WiFi fingerprinting localization since signal strengths can easily be changed in indoor environments by different factors ranging from multipath effect (as a major factor) or electromagnetic interference to temporary obstacles blocking the WiFi signal [28][29].

As mentioned in sub-section 3.1.3, we reshape input data from a vector to a 2D form, so the input can be considered a grayscale image represented radio map in which each pixel is equal to RSSI value from different APs. Hence, the proposed CNN-based network can learn from RSSI values (pixel value) and also the radio maps (pattern) of surrounding APs [26].

#### 3.2.2 Convolutional Auto-encoder

Convolutional Auto-encoder (CAE) benefits from both CNNs and Auto-encoders (AEs) features. AEs are unsupervised learning methods which generally used for denoising, dimension reduction and feature extraction by reconstructing the input data in the output. Therefore, in WiFi fingerprinting localization, this is a suitable way to shrink the RSSI value fluctuation caused by different noise sources in indoor environments, such as multipath effect and other sources mentioned before.

Figure 3: Input preparation for UJIndoorLoc dataset

Figure 2: UJIndoorLoc dataset with L=20 Region Griding
Unlike general AE with some fully connected layers, CAE uses some convolution layers which decrease network parameters that subsequently reduce network size. As shown in Fig. 4, a CAE has two main parts: a convolutional encoder with some convolution and pooling layers and the complementary deconvolutional decoder with several deconvolutions (transposed convolution) and unpooling (upsampling) layers.

#### 3.2.3 Network design

The proposed network architecture is shown in Fig. 5. The network comprises Input, CAE and Classifier parts. Input is a grayscale radio map image fed to CAE layer which is indeed the encoding part of CAE that compresses and extracts the main features of the input. Then, the classifier is used to identify the building, floor and location of a user. To enhance the performance of this network we use some layers as follow:

* **Dropout layer:** Dropout is generally used to overcome the over-fitting problem and the main idea is to randomly omit some units in each training iteration; therefore, the network will not train too accurately for the training set which leads to preventing over-fitting. In our proposed, network we use this technique before the last layer to avoid over-fitting.
* **Batch Normalization (BN):** This layer is utilized to address the Internal Covariance Shift problem by modification of input distribution in various layers for each mini-batch; hence the convergence rate of the network will be increased by using batch normalization [30]. In the proposed method, BN is used after each convolutional layer and also after GAP, as shown in Fig. 5.
* **Global Average Pooling (GAP):** It is widely used instead of the fully-connected layer in CNN models by averaging each feature map. This layer decreases the model parameters, leading to a significant decline in model size and avoiding the over-fitting problem [31].

### Post-training optimization

In this phase, the proposed model is optimized because it should be implemented on smart mobile phones with limited memory and computational power. In this study, three different optimization methods are used to optimize the trained model leading to a significant reduction in model size and also inference latency as is shown in Fig. 1.

A model with a smaller size not only occupies less storage on the phone but also utilizes less RAM when it runs. Hence, there is more memory for other application that improves performance and stability. Besides, a model with lower latency is faster and also has a direct impact on power consumption. It must be noted that generally, post-training optimization decreases the model accuracy; thus, there is a trade-off between accuracy and model size or latency which must be considered during the designing process. For post-training optimization, the following methods are used [32].

**Pruning** is one of the most effective techniques for network optimization. In this technique, unnecessary weights which have the lowest impact on the network are set to zero, i.e., eliminated. This technique leads to a significant reduction in model size.

Fig. 4: Convolutional Auto-encoder

Fig. 5: Proposed network architecture
**Clustering**, also known as weight sharing, is another useful method for network compression. In this technique, in each layer, weights are divided into N clusters. The centroid value of each cluster is used as the values of all weights in the cluster; so, the number of unique weights is considerably reduced, leading to a notable decrease in model size.

**Quantization:** To reduce the model size and also computation time, the precision of numbers in the model, such as weights, are reduced. The default type of numbers is float32; in this paper, float16 and int8 quantization are used, and their impact on model performance in terms of model size and latency are evaluated.

## 4 Model Evaluation and Experimental Results

In this section, the superiority of the proposed CAE-CNNLoc is evaluated in comparison with state-of-the-art methods. To examine the performance of the proposed method, first, we apply CAE-CNNLoc on UJIIndoorLoc dataset [23], then to test the scalability, we apply our model on two other public datasets named Tampere [33] and UTSIndoorLoc [13]. Moreover, we use the proposed model for indoor localization in our department by collecting its WiFi fingerprinting dataset named SBUK-D as a case study. Additionally, the CAE-CNNLoc network model is implemented with Tensorflow 2.4.0 framework on Google Collaboratory Cloud with Tesla 4 GPU and then its performance is tested on an android smartphone. The network parameters are considered as follows (Table 1).

In this study, three various public datasets are used which their details are explained as follow.

**UJIIndoorLoc**: This is the most common dataset for WiFi fingerprinting localization that includes 3 buildings with 4 or 5 floors and covers 108,703 m\({}^{2}\) region at the University of Jaume I in Spain. This dataset has training and testing sets with 19,938 and 1,111 samples respectively and each sample has 529 features. The first 520 features show the RSSI value from different APs between -104 dBm to 0 dBm and the null value is shown by 100 that represents inaccessible AP. The location information of each sample consists of Building ID, Floor ID and Longitude - Latitude values in meters [23].

**Tampere:** This dataset was collected at a university building in Tampere, Finland. The building covers approximately 22,750 m\({}^{2}\) area with five floors, but just four floors were used to create this dataset. Totally, there are 991 APs in the building; hence in each point, the RSSI value was recorded from these APs. The location in Tampere dataset contains X, Y and Z, which the Z represents the floor [33].

**UTSIndoorLoc:** This dataset was gathered in the FEIT Building at the University of Technology Sydney (UTS). This building covers nearly 44,000 m\({}^{2}\) region and includes 18 floors which 16 floors were used to create UTSIndoorLoc dataset. The position information consists of X, Y and Floor Id, and also each sample has 590 RSSI values from different APs [13].

### CAE and CNN optimization

First, various structures of the proposed model are investigated to find the best possible model for our application. For this aim, different layers such as convolutional and pooling layers with different parameters are tested to achieve the best structure. Table 2 shows some different structures and their performance in which _Cx_ represents a convolutional layer with x channels, \(M\) refers to a maxpooling layer, also we use slash symbol ( / ) to distinguish the CAE part and classifier part. For instance, _C16+C32/C32+C64+M_ refers to a model which its CAE part includes two convolutional layers with 16 and 32 channels and the classifier part composes two convolutional layers with 32 and 64 channels and a maxpooling layer. It must be noted that we only investigate small structures because our goal is to have a light network. As is clear from this table, the best performance is gained by the model of _C16+M/C32+C64_.

\begin{table}
\begin{tabular}{l l|l l} \hline
**Parameter** & **Value** & **Parameter** & **Value** \\ \hline Activation Function & Relu & Optimizer & Nadam \\ \hline CAE Loss Function & MSE & Output Layer & Softmax \\  & & Activation Function & \\ \hline CNN Loss Function & Sparse Categorical & & \\  & Crosentropy & & \\ \hline \end{tabular}
\end{table}
Table 1: General network parameters

\begin{table}
\begin{tabular}{c c c c c c} \hline
**Model** & **Euclidean** & **Building** & **Floor** & **Total params** & **File Size** \\  & **Mean error** & **hitrate** & **hitrate** & & **(KB)** \\ \hline
**c16/c32+64** & 34.57 & 0.89153 & 0.751 & 129,756 & 469.69 \\ \hline
**c16+M+c32/64** & 2.65 & 0.99921 & 0.991 & 129,628 & 469.40 \\ \hline
**c16/M+c32+64+M** & 3.02 & 0.99762 & 0.990 & 129,756 & 468.97 \\ \hline
**c16+c32/c32+64+M** & 5.52 & 0.9929 & 0.986 & 139,004 & 503.67 \\ \hline
**c16+c32/c32+64+ \(\epsilon\)128** & 4.82 & 0.99367 & 0.979 & 317,820 & 1,151.58 \\ \hline
**c16+M/c32** & 3.13 & 0.99921 & 0.989 & 66,972 & 212.57 \\ \hline
**c32+M/c32+64** & 2.73 & 0.99842 & 0.990 & 134,524 & 487.07 \\ \hline
**c32+c64+c128/c32+64** & 3.92 & 0.99604 & 0.985 & 254,524 & 921.97 \\ \hline
**c16/c32** & 18.54 & 0.95724 & 0.852 & 58,780 & 212.76 \\ \hline
**c16+M/c32+64** & **2.36** & 0.99921 & 0.993 & 129,756 & 469.91 \\ \hline \end{tabular}
\end{table}
Table 2: Different structures and their performance
### Impact of Improving Techniques on Localization Accuracy

In the proposed method section, some techniques are suggested to improve the localization performance. In this sub-section, we evaluate the effect of these techniques.

**Dropout**: The first one is dropout layer added to CAE-CNNLoc to address the over-fitting problem. This method has a _rate_ that refers to the fraction of input units that drop in each epoch in the training phase. The impact of this method on localization accuracy is shown in Table 3. Based on this table, the best localization accuracy is achieved when the dropout rate is 0.6.

**Global-Average-Pooling (GAP)** replaces fully-connected layer in the network model and reduces the network parameters. The impact of this layer for our network with \(L\)=\(1\) is shown in Table 4. It can be seen that by replacing fully-connected layer with GAP layer, although the number of parameters is declined from 965,340 to 129,756, the localization accuracy is not affected much. Meanwhile, this parameter reduction significantly impacts model size, decreasing from nearly 3.5 to 0.5 MB. Therefore, GAP layer is a suitable way for our application to reduce the network size without any remarkable change in accuracy.

### Impact of Region Griding on localization performance

In this sub-section, the effect of region griding on localization performance is examined. The region griding has a parameter \(L\) which shows the length of each square in the localization area. The CAE-CNNLoc results for different amounts of \(L\) are reported in Table 5 in which the localization accuracy and model parameters and size are compared. Based on the given data, by growing \(L\) the localization accuracy experiences a decline and also, the model parameters and size show a considerable reduction. It is reasonable because by increasing \(L\) the number of classes is decreased which leads to a reduction in model parameters and consequently it reduces the model size. Additionally, longer \(L\) generates a bigger square covering more points that their position is actually considered the unique coordinate of the square; hence it increases the localization error. Therefore, it reveals a trade-off between localization accuracy and model size, so based on the application we can adjust \(L\) to achieve the best performance.

### Comparison with the existing methods

Now, to evaluate the performance efficiency of CAE-CNNLoc method, we compare it with some recent studies. Some of the existing studies just focus on the building and floor accuracy, but in this study in addition to the building and floor accuracy, the positioning mean error has also been investigated. Table 6 reports the localization accuracy of CAE-CNNLoc and some related methods. It can be observed that the proposed method achieves a superior improvement in localization accuracy. In this regard, the floor hitrate of CAE-CNNLoc is 0.9929 while all other studies are under 0.96; hence the proposed method enhances the floor accuracy by nearly 3%. Moreover, the positioning mean error of CAE-CNNLoc is 2.36 that shows about 4 meters improvement compared with other studies, and finally, like some of the other methods, building accuracy is approximately 100%.

\begin{table}
\begin{tabular}{c c c c c c} \hline
**Euclidean** & **Building** & **Floor** & **Total** & **Num layers** \\
**Mean error** & **hitrate** & **hitrate** & & \\ \hline \end{tabular}
\end{table}
Table 6: CAE-CNNLoc in comparison with other methods

\begin{table}
\begin{tabular}{c c c c c} \hline  & **Euclidean** & **Building** & **Floor** & **Total** & **File Size** \\
**Mean error** & **hitrate** & **hitrate** & **parameters** & **(KB)** \\ \hline
**Flatten** & 2.21 & 1 & 0.993 & 965,340 & 3,494.83 \\ \hline
**GAP** & 2.36 & 0.9992 & 0.993 & 129,756 & 469.91 \\ \hline \end{tabular}
\end{table}
Table 4: Comparison of GAP and Flatten layer results

\begin{table}
\begin{tabular}{c c c c c} \hline
**L** & **Euclidean** & **Building** & **Floor** & **Num** & **File Size** \\
**(m)** & **Mean error** & **hitrate** & **hitrate** & **Classes** & **(KB)** \\ \hline
**1** & 2.36 & 0.9992 & 0.993 & 1628 & 469.91 \\ \hline
**3** & 2.71 & 0.9992 & 0.992 & 1139 & 354.07 \\ \hline
**5** & 2.89 & 0.9992 & 0.992 & 865 & 289.97 \\ \hline
**7** & 3.52 & 0.9992 & 0.990 & 724 & 256.94 \\ \hline
**10** & 3.94 & 0.9992 & 0.992 & 541 & 214.01 \\ \hline
**20** & 6.41 & 0.9992 & 0.994 & 274 & 151.84 \\ \hline
**30** & 8.86 & 0.9992 & 0.994 & 182 & 130.40 \\ \hline \end{tabular}
\end{table}
Table 5: Region Griding effects on localization performance
### Noise resistance of CAE-CNNLoc

WiFi signals in indoor environments are really vulnerable to noise; hence the RSSI value changes easily based on different conditions mentioned in sub-section III-2-a. Therefore, for indoor localization methods, it is critical to resist against noise. In this sub-section, we check out the performance of our model by adding noise to the data. For this aim, we randomly add 3, 5, 7 and 10 dBm noise to the test data and evaluate the model's accuracy. As is shown in Fig. 6, the localization accuracy is declined by adding noise to signals which is reasonable, but it must be noted that in the worst case with 10 dBm noise, CAE-CNNLoc model shows 6.7 (for L=1) and 7.6 (for L=5) meter of error which has still a better accuracy in comparison with other methods. Therefore, these results properly verify the denoising feature of the convolution auto-encoder part of CAE-CNNLoc model.

### CAE-CNNLoc performance on android smartphone

As mentioned before, the main purpose of this paper is to suggest an on-device indoor localization model which can be run on the user's device. Thus, we examined the performance of CAE-CNNLoc model in the real world on an android smartphone. In this regard, the proposed CAE-CNLoc model was tested on Redmi Note 8 and the results were reported. As two critical factors in on-device implementation, inference time (latency) and model size were taken into consideration and the impact of different techniques were reported.

**Region griding:** First, the effect of region griding method was examined; in this regard, the results of the proposed method with different amounts of \(L\) are depicted in Fig. 7. From sub-section IV-3, it is clear that by increasing \(L\), the number of classes is decreased, leading to a remarkable reduction in network parameters which consequently declines the latency and network size as shown in Fig. 7. For example, by set \(L\)=10, we can decrease the latency by about 20% (65 us) and reduce the network size over 2 times (255 KB) while the localization accuracy declines just nearly 1.6m compared with \(L\)=1. Hence, Region griding method is a suitable way for on-device WiFi fingerprinting localization.

Fig. 6: Effects of noise on CAE-CNNLoc performance

Fig. 7: Effects of region griding on localization error, latency and model size
**GAP:** The second effective approach is to use Global-Average-Pooling layer instead of fully-connected layer in the network model. Fig. 8 illustrates the latency and network size of CAE-CNLoc model with GAP and Flatten layer. It is completely obvious that GAP layer has a significant impact on network performance. Based on the results, the total network parameters with GAP are 129,756, while the network with Flatten layer has 965,340 parameters which show over 7 times reduction. Consequently, the network size and latency decreased over 7 and 3 times respectively, whereas the positioning error has just decreased 0.15 meter as reported in Table 4.

**Pruning:** The first method of optimization is pruning. Fig 9-a shows the impact of this technique on system performance in terms of localization error and model size. Based on this figure, it is clear that by increasing the pruning percentage, the localization error increases but the model size reduces constantly; so as mentioned, there is a trade-off between localization accuracy and model size.

**Clustering:** Fig. 9-b depicts the efficiency of the clustering method as a compression technique. For instance, by considering 128 clusters for each layer, we can reduce the model size approximately 3 times with a slight increase in localization error. Therefore, by means of this method, we obtain a remarkable reduction in model size without any considerable decrease in the system accuracy.

Note, in this study, the pruning and clustering methods do not affect latency because the weights are not removed from the network and are just set to zero (for pruning) or set to cluster value (for clustering). Hence, the computation time remains unchanged because the computation procedure is still executed by the same numbers of weights. However, this is true for smartphones while in the case of hardware-level designing, we can ignore the zero weight (pruning) or use lower weights (clustering) in computation operations which lead to better performance and lower latency [35].

**Quantization:** In this paper, we utilize float16 and int8 quantization which their results are shown in Fig. 10. First, by using float16 quantization, weights type change from float32 to float16. As is clear from Fig. 10, for float16 quantization, although the network size reduces about 2 times, it does not affect localization accuracy. Furthermore, this quantization increases the latency a little bit. This increase returns to the fact that the mobile processor can only do the computation in float32, so numbers must be converted to float32 for computation which takes time and increases the latency. Moreover, Int8 quantization has the ability to decline the network size about 3.8 times and improve the latency by nearly 32% without any effective reduction in localization accuracy.

Fig. 8: Effects of GAP layer on latency and model size

Fig. 9: Effects of pruning and clustering on localization error and model size
Finally, we can benefit from combining all mentioned optimization techniques to have the best possible network model that is as light as possible to run on end-devices. Fig. 11 shows the performance of the combined model in comparison with the original model and different optimization techniques. Based on this figure, a model that benefits from pruning 50%, clustering with 16 clusters and int8 quantization, leads to a nearly 7.8 times reduction in model size and about 1.8 meter increase in localization error compared with the original model without any optimization. Also the building and floor accuracy are approximately 99% and 98% respectively which are not shown a considerable reduction.

### CAE-CNNLoc Scalability

In this sub-section, CAE-CNNLoc model is applied on two other public WiFi fingerprinting datasets to evaluate the scalability of the proposed model. Table 7 shows the performance of CAE-CNNLoc on Tampere and UTSIndoorLoc datasets compared with recent studies. As is clear from this table, our model has superior performance on mentioned datasets, proving the scalability of CAE-CNNLoc.

### Experiments on our dataset (SBUK-D dataset)

In this sub-section, we evaluate the performance of the proposed network model for localization in our department. For this aim, we generated the WIFI fingerprinting dataset named SBUK-D. The details of this dataset are as follow:

**SBUK-D dataset:** The authors gathered this dataset in the Engineering department at the Shahid Bahonar University of Kerman (SBUK). This building includes 3 floors that cover nearly 11,500 m\({}^{2}\) region. The position information consists of Floor Id, X and Y, and there are 198 different APs in the building used to record the RSSI value in each location. The recorded RSSI are between -100 dBm to 0 dBm, and like other datasets, inaccessible APs are set to 100. The dataset has 2292 samples for 70 different locations collected with 4 android smartphones.

Table 8 reports the results of the CAE-CNNLoc on the SBUK-D dataset in comparison with three different datasets. As is clear from this table, CAE-CNNLoc has a significant performance for all datasets, and SBUK-D achieved just 1.73 m error

\begin{table}
\begin{tabular}{c|c c c|c c c} \hline  & \multicolumn{3}{c|}{**Best of CAE-CNNLoc**} & \multicolumn{3}{c}{**Best of other studies**} \\ \hline
**Dataset** & **Mean** & **Building** & **Floor** & **Mean** & **Building** & **Floor** \\
**error** & **hitrate** & **hitrate** & **error** & **hitrate** & **hitrate** \\ \hline
**UJIIndoorLoc** & 2.36 & 0.9992 & 0.993 & 6.20 & 1 & 0.937 \\ \hline
**Tampere** & 6.30 & - & 0.961 & 10.88 & - & 0.942 \\ \hline
**UTSIndoorLoc** & 1.72 & - & 0.996 & 7.60 & - & 0.946 \\ \hline \end{tabular}

* * Best of UJIIndoorLoc from [34], Tampere and UTSIndoorLoc from [13]

\end{table}
Table 7: Scalability of CAE-CNNLoc model

Figure 11: Performance of the integration model (P: Pruning, C: Clustering, Q: Quantization)

Figure 10: Effects of quantization on localization error, latency and model size
with over 98 percent accuracy to predict the floor. Moreover, the model size for our dataset is about 103 KB and the inference time on an android phone is 198 \(\upmu\)s.

### User trajectory tracking

In this sub-section, the proposed model is used for indoor tracking. In this regard, several artificial trajectories were designed with some points from UJIndoorLoc dataset and then CAE-CNNLoc model was utilized to track the path. Fig. 12 shows a path and it's predicted one by CAE-CNNLoc model for a system with L=5. As is clear from this figure, in most cases, the model correctly tracks the trajectory. In the situation in which the location is not predicted accurately, it predicts the surrounding cells with the lowest error; hence the tracking accuracy is still acceptable and the model can be utilized for indoor tracking as well.

### Conclusion

This paper presents a light WiFi fingerprinting localization method named CAE-CNNLoc to estimate user position in indoor environments. CAE-CNNLoc is based on the Convolutional Neural Network (CNN) network joined Convolutional Auto-encoder (CAE) that leads to a significant reduction in the input dimension and the model sensitivity to the input fluctuation. To compress the network model, three compression techniques (pruning, clustering and quantization) are used. As CAE-CNNLoc is a light model, it can be easily run on edge devices such as smartphones, leading to a remarkable improvement in localization performance in terms of cost, latency, and users' privacy. The experimental results illustrate that the proposed model outperforms other studies in terms of mean positioning error, building and floor accuracy. In this regard, for UJIIndoorLoc dataset, a model that benefits from pruning 50%, clustering with 16 clusters and int8 quantization is just 60 KB in size and obtains about 270 \(\upmu\)s in inference time with just 4 m positioning error. While, a model without any post-training optimizations achieves 2.36 m positioning mean error with the size and inference time of 470 KB and 355 \(\upmu\)s, respectively. Besides, the proposed model shows significant performance on our new dataset named SBUK-D with 1.73 m positioning error, 98% accuracy of floor detection, inference time of 198 \(\upmu\)s and the model size of 103 KB.

**Acknowledgment:** This research is partly supported by the NYUAD's Research Enhancement Fund (REF) Award on "eDLAuto: An Automated Framework for Energy-Efficient Embedded Deep Learning in Autonomous Systems", and by the NYUAD Center for Artificial Intelligence and Robotics (CAIR), funded by Tamkeen under the NYUAD Research Institute Award CG010.

## Declarations

**Conflict of interest:** The authors have no conflict of interest for publication of this paper.

**Data availability:**

Fig. 12: Trajectory tracking using the proposed model

\begin{table}
\begin{tabular}{c c c c c c} \hline  & **Mean** & **Building** & **Floor** & **Inference** & **Model size** \\  & **error** & **hitrate** & **hitrate** & **Time (us)** & **(KB)** \\ \hline
**SBUK-D** & 1.73 & - & 0.985 & 198 & 103.49 \\ \hline
**UJIIndoorLoc** & 2.36 & 0.9992 & 0.993 & 355 & 469.91 \\ \hline
**Tampere** & 6.30 & - & 0.961 & 644 & 307.15 \\ \hline
**UTSIndoorLoc** & 1.72 & - & 0.996 & 360 & 272.31 \\ \hline \end{tabular}
\end{table}
Table 8: Best results of CAE-CNNLoc model
**SBUK-D dataset:** The dataset generated during the current study are not publicly available due to privacy and other restrictions.

The following datasets analyzed during the current study are available in the following public domain resources:

**UJIL indoorLoc dataset:** [https://archive.ics.uci.edu/ml/datasets/ujiindoorloc](https://archive.ics.uci.edu/ml/datasets/ujiindoorloc)

**Tampere dataset:** [https://zenodo.org/record/889798](https://zenodo.org/record/889798)

**UTSIndoorLoc dataset:** [https://github.com/XudongSong/CNNLoc-Access](https://github.com/XudongSong/CNNLoc-Access)
