An RSSI fingerprint localization method based on autoencoder and attention mechanism
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-06
- Publication Date
- 2026-03-10
Smart Images

Figure CN116338571B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of indoor positioning technology, and more specifically, to an RSSI fingerprint positioning method based on an autoencoder and attention mechanism. Background Technology
[0002] In recent years, researchers both domestically and internationally have conducted extensive research on indoor positioning technology and achieved many significant results. Compared with other indoor positioning technologies, WLAN-based indoor positioning technology has advantages such as wide coverage, low deployment cost, ease of installation, and non-line-of-sight propagation, thus exhibiting superior universality. Among WLAN positioning technologies, wireless fingerprinting is a widely used method, offering advantages such as low dependence on access point (AP) location and no need for additional customized hardware.
[0003] In fingerprint positioning methods, RSSI is widely used for location functionality because it can be easily obtained from most WiFi receivers, such as mobile phones, tablets, and laptops. RSSI-based fingerprint positioning methods typically consist of offline and online phases. Specifically, several signal access points are deployed in an indoor space. In the offline phase, the mobile device collects RSSI values corresponding to a series of wireless access points at a reference point and uses these values as the corresponding fingerprint. In the online phase, the user sends the observed RSSI values received at their location to a fingerprint database, and the corresponding location coordinates are estimated based on the positioning algorithm. The RSSI fingerprint positioning process is as follows: Figure 1 As shown.
[0004] To improve the positioning accuracy of positioning systems, researchers have conducted extensive research on positioning algorithms. Microsoft's RADAR system was the first to use the K-Nearest Neighbor (KNN) positioning algorithm, achieving a positioning performance with a 50% probability of positioning error within 3 meters. The Horus positioning algorithm proposed a statistical method of fitting the fingerprint at each reference point to a Gaussian distribution, combined with a maximum likelihood estimation algorithm for positioning, achieving a positioning performance with an 80% probability of positioning error within 13 meters. Classic positioning algorithms also include kernel function methods, random forests, support vector machines, and Naive Bayes. In recent years, leveraging the advantages of deep learning's superior feature learning capabilities, some deep learning methods have been widely applied to RSSI fingerprint positioning algorithms, achieving better positioning performance compared to traditional positioning algorithms.
[0005] Currently, fingerprint-based localization algorithms estimate user location using signal matching. This method first collects environmental RSSI signals and constructs an RSSI fingerprint database during the training phase. During online localization, the fingerprint-based algorithm compares the current RSSI observations with the fingerprints recorded in the database and uses the optimal matching criterion to obtain the target location.
[0006] Fingerprint localization algorithms are generally divided into deterministic methods and probabilistic methods. Deterministic methods complete the localization process by matching fingerprints, such as the KNN algorithm which uses Euclidean distance to measure the similarity between fingerprints. Probabilistic methods locate fingerprints based on probability, such as the Bayesian decision algorithm which uses maximum a posteriori probability to estimate the location.
[0007] With the development of machine learning, many machine learning models have been applied to fingerprint localization. Machine learning-based fingerprint localization methods can be further divided into regression methods represented by Artificial Neural Networks (ANNs) and Support Vector Machines (SVMs), as well as classification methods. SVMs were first applied to fingerprint localization as both a regressor and a classifier in 2002. Support Vector Regression (SVR) was also used in GSM in 2006 and achieved good localization performance. In addition, deep learning achieves more accurate localization results by finding the mapping relationship between fingerprints and locations. For example, Rizk et al. built a deep fully connected network structure to learn the complex relationships in WiFi data. Hsieh et al. formulated the localization problem as a classification problem and combined MLPs and CNNs to build a classification model to estimate the target's location. Song et al. developed a CNN-based indoor localization system that uses RSSI fingerprints for multi-building and multi-layer localization. Specifically, they combined a stacked autoencoder (SAE) and a CNN to design a classification and localization model. The SAE was used to extract key features from sparse RSSI fingerprint data, while the CNN was trained for classification during the localization phase. Soro et al. used continuous wavelet transform (CWT) to extract temporal features from raw WiFi data and employed a standard CNN classifier to predict target locations. Hsieh et al. designed an indoor positioning system using LSTM. To identify floors, they established an LSTM-based classification model, and after estimating the floor height, used an LSTM-based regression model to predict unknown locations.
[0008] While the aforementioned methods have made significant progress in location fingerprint-based localization, they all suffer from the following shortcomings: 1) WiFi signals not only change with distance from the target location but also with time. Therefore, RSSI measured solely using WiFi at the current moment cannot accurately distinguish between different locations with similar instantaneous fingerprints. 2) As neural networks become deeper, gradient degradation issues become apparent, leading to increased errors. Summary of the Invention
[0009] In order to address the shortcomings and defects of the existing technology, this invention provides an RSSI fingerprint localization method based on an autoencoder and attention mechanism, which can effectively reduce localization errors and improve localization accuracy.
[0010] To achieve the above-mentioned objectives of this invention, the technical solution adopted is as follows:
[0011] An RSSI fingerprint localization method based on autoencoder and attention mechanism, the method comprising the following steps:
[0012] The raw RSSI data is preprocessed, and the fingerprint database is constructed using the preprocessed RSSI data.
[0013] Based on the relationship of reference positions, a motion trajectory sequence is randomly generated. From the RSSI set corresponding to each trajectory point position in the constructed fingerprint database, a set of values is randomly selected as the RSSI sequence corresponding to the motion trajectory sequence.
[0014] The RSSI sequence is input to construct a feature extraction network based on an autoencoder and an attention mechanism to achieve localization; the feature extraction network includes an input layer, an autoencoder, an attention network, and an output layer;
[0015] The input layer is used to unify the input data format;
[0016] The autoencoder is used to extract local spatial features and long-term dependencies from motion trajectory data;
[0017] The attention network is used to extract RSSI values that are more important to the sequence representation, and to obtain the final RSSI sequence representation vector based on the obtained weights;
[0018] The output layer is used to output position coordinates.
[0019] Preferably, the preprocessing is as follows: first, the original WiFi data is preprocessed, including missing value filling and normalization; then, the normalized data is used to construct a fingerprint database.
[0020] Furthermore, the random generation of the motion trajectory sequence based on the relationship of the reference positions is as follows:
[0021] Let there be n reference positions in total, and let the i-th and j-th reference positions be l and l, respectively. i =(x i ,y i ),l j =(x j ,y j), where i,j=0,1,…,n; the distance from the i-th reference position to the j-th reference position is d. ij Then the distance relationship between each pair of reference positions is obtained, which can be represented by a distance matrix;
[0022] Based on the distance matrix, under certain assumptions, calculate the probability that a pedestrian, at a certain reference position, will appear at another reference position after one RSSI sampling period; let the position of the currently generated trajectory point be l. i =(x i ,y i Let P(l) i ) represents the pedestrian's movement from l within the current RSSI sampling period. i Move to point (x) pre ,y pre The probability of ).
[0023] The maximum distance a pedestrian moves within a time interval Δt is σ = v max Let ×Δt represent the maximum walking speed of a pedestrian, v. max Between 0.4 m / s and 2.0 m / s; assuming the probability that a pedestrian moves to a certain position in the next RSSI sampling period follows a Gaussian distribution with a standard deviation of σ, then the normalized probability P(l i )as follows:
[0024]
[0025] Where, d max The current position is l i The maximum distance to the farthest location in the region of interest;
[0026] The probability P(l) is calculated according to equation (3). i This process involves generating a probability matrix, summing the values of each row and column from left to right, and filling them into the corresponding positions to obtain the cumulative probability distribution matrix. Then, a random number R (0-1) is generated, and the current position is set to l. i The position of the next moment is represented by the column containing the value with the smallest difference from R and greater than R in the i-th row of the probability cumulative distribution matrix; thus, a motion trajectory sequence is generated.
[0027] Preferably, the input layer is used to input three-dimensional data, and the format of the input data is: number of samples, time step, and number of features;
[0028] The number of samples mentioned above refers to the number of samples in a batch, and a batch consists of one or more samples.
[0029] The time step is defined as follows: one time step represents one observation point in the sample.
[0030] The number of features mentioned is 13, which includes 11 RSSI readings and position coordinates (X,Y).
[0031] Preferably, the autoencoder includes an encoder and a decoder; the encoder includes a single one-dimensional convolutional layer, a residual unit, and an LSTM layer; the decoder includes a residual unit and an LSTM layer; wherein the residual unit is composed of two one-dimensional convolutional layers and one LSTM layer.
[0032] Furthermore, the RSSI fingerprint sequence is input into the residual unit, and the specific processing is as follows:
[0033] First, it is processed through two one-dimensional convolutional layers; the kernel length of both one-dimensional convolutional layers is 4, and the output channels are both 100.
[0034] After processing through two one-dimensional convolutional layers, the output time series data has a length of 9 and 100 channels. This data is then input into the LSTM layer, which obtains the representation vector of the RSSI sequence. The number of neurons in the LSTM layer is set to 100.
[0035] Furthermore, the LSTM layer employs a long short-term memory network, which acquires long-term dependency features through the collaboration between the forget gate, input gate, and output gate; the output of multiple one-dimensional convolutional layers is used as the input of the LSTM; for each time interval, the LSTM layer is operated on simultaneously as input, and the two output results are concatenated to obtain the output vector of the LSTM layer.
[0036] Furthermore, an attention network is used to extract RSSI values that are more important to the sequence representation, and the final RSSI sequence representation vector is obtained based on the obtained weights, as follows:
[0037] Attention is achieved by an attention function, which will... m The query Q, key K, and value V are mapped to the output. Specifically, the similarity between query Q and key K is calculated, and the weight is assigned to value V based on this similarity. The multi-head attention mechanism projects query Q, key K, and value V into a low-dimensional space. The projection is performed h times, and then the attention function is performed h times to obtain h low-dimensional outputs. Finally, the h low-dimensional outputs are merged and projected to obtain the final output.
[0038] Furthermore, before using the feature extraction network for localization, it is first trained, specifically as follows:
[0039] D1: The motion trajectory sequence is used as the training set to input the feature extraction network for training, and the loss value between the input data and the output data is calculated through the loss function.
[0040] D2: Update network weights and biases using the stochastic gradient descent algorithm;
[0041] D3: Determine if the maximum number of iterations has been reached. If yes, output the position estimate; otherwise, return to step D2.
[0042] A computer system includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the steps of the method described above.
[0043] The beneficial effects of this invention are as follows:
[0044] This invention proposes an RSSI fingerprint localization method based on an autoencoder and an attention mechanism. The autoencoder extracts features from the input RSSI sequence, extracts feature information from the time series, models the sequential dependency of RSSI signals between different time periods, and uses an attention layer to filter out more important features based on the importance of information. This allows for more complete extraction of information from the data, resulting in a smaller final localization error.
[0045] This invention transforms the RSSI fingerprint localization problem into a time series prediction problem, and uses an attention layer to estimate the location coordinates.
[0046] Furthermore, to address the degradation problem of deep networks, this invention introduces residual connections, thus avoiding gradient vanishing and gradient explosion. Attached Figure Description
[0047] Figure 1 This is a schematic diagram of existing RSSI fingerprint positioning technology.
[0048] Figure 2 This is a flowchart of the steps of the RSSI fingerprint localization method based on autoencoder and attention mechanism described in this invention.
[0049] Figure 3 This is a schematic diagram of the feature extraction network described in this invention.
[0050] Figure 4 This is a schematic diagram of the structure of an autoencoder.
[0051] Figure 5 This is a schematic diagram of the attention mechanism.
[0052] Figure 6 This is a schematic diagram of the multi-head attention mechanism.
[0053] Figure 7 These are the specific parameters of the feature extraction network described in this invention.
[0054] Figure 8 This relates to the impact of multi-head attention mechanisms on localization errors.
[0055] Figure 9 This refers to the impact of residual connections on positioning errors.
[0056] Figure 10 It is the cumulative distribution function of the positioning error. Detailed Implementation
[0057] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0058] Example 1
[0059] like Figure 2 As shown, an RSSI fingerprint localization method based on autoencoders and attention mechanisms is described, and the method includes the following steps:
[0060] In order to input reasonable data into the method of the present invention, it is necessary to first preprocess the original collected RSSI data, and then use the preprocessed RSSI data to construct a fingerprint database.
[0061] Based on the relationship of reference positions, a motion trajectory sequence is randomly generated. From the RSSI set corresponding to each trajectory point position in the constructed fingerprint database, a set of values is randomly selected as the RSSI sequence corresponding to the motion trajectory sequence.
[0062] Localization is achieved by constructing a feature extraction network based on an autoencoder and attention mechanism using RSSI sequence input; for example... Figure 3 As shown, the feature extraction network includes an input layer, an autoencoder, an attention network, and an output layer;
[0063] The input layer is used to unify the input data format;
[0064] The autoencoder is used to extract local spatial features and long-term dependencies from motion trajectory data;
[0065] The attention network is used to extract RSSI values that are more important to the sequence representation, and to obtain the final RSSI sequence representation vector based on the obtained weights;
[0066] The output layer is used to output position coordinates.
[0067] Example 2
[0068] Based on the RSSI fingerprint localization method based on autoencoder and attention mechanism described in Example 1, more specifically,
[0069] In order to input reasonable data into the algorithm, the fingerprint database constructed in this embodiment first preprocesses the original WiFi data, including filling missing values and normalization; then the normalized data is used to construct the fingerprint database.
[0070] The missing value padding mentioned above is necessary because some WiFi signals cannot be collected at certain locations, so missing values need to be filled for the uncollected WiFi signals. Considering that the RSSI value of WiFi signals ranges from -110dBm to 0dBm, the missing RSSI observation value is set to -110dBm. After filling in all missing values, the range of all WiFi data is [-110dBm, 0dBm].
[0071] The original WiFi data is normalized using equation (1) to obtain normalized data. By normalizing the original data, the distribution of the normalized WiFi data is unbiased and has low variance. Directly using the original asymmetric WiFi data may lead to network model training failure. Where rssi i This represents the RSSI value of the i-th WiFi network. min Represents the minimum value of all RSSIs, rssi max This represents the maximum value of all RSSIs;
[0072]
[0073] A fingerprint database is constructed using normalized data, as shown in equation (2). Here, n represents the number of features, and m represents the number of samples. Let j represent the j-th feature of the i-th sample, (target) xi ,target yi ) represents the position coordinates of the i-th sample.
[0074]
[0075] In one specific embodiment, simply generating training data in a fixed order cannot effectively simulate the randomness of pedestrian movement speed and direction in indoor spaces, and it easily leads to monotonous training data, which is detrimental to neural network training and results in weak generalization ability. Instead, random and reasonable movement trajectories are generated based on the relationship of reference positions. Then, a set of values is randomly selected from the RSSI set corresponding to each trajectory point in the fingerprint database as the RSSI for that trajectory point. This simulates the RSSI and trajectory points obtained from random pedestrian movement, generating training data.
[0076] The random generation of motion trajectory sequences based on the relationship of reference positions is as follows:
[0077] Let there be n reference positions in total, and let the i-th and j-th reference positions be l and l, respectively. i =(x i ,y i ),l j =(x j ,y j ), where i,j=0,1,…,n; the distance from the i-th reference position to the j-th reference position is d. ij Then the distance relationship between each pair of reference positions is obtained, which can be represented by a distance matrix;
[0078] Based on the distance matrix, under certain assumptions, calculate the probability that a pedestrian, at a certain reference position, will appear at another reference position after one RSSI sampling period; let the position of the currently generated trajectory point be l. i =(x i ,y j Let P(l) i ) represents the movement of a pedestrian from li to point (x) within the current RSSI sampling period. pre ,y pre The probability of ).
[0079] Since pedestrians move randomly and at a limited speed, the user's position is updated within each sampling time interval Δy; the maximum distance a pedestrian moves within a time interval Δt is σ = v. max Let ×Δt represent the maximum walking speed of a pedestrian, v. max Between 0.4 m / s and 2.0 m / s; assuming the probability that a pedestrian moves to a certain position in the next RSSI sampling period follows a Gaussian distribution with a standard deviation of σ, then the normalized probability P(l i )as follows:
[0080]
[0081] Where, d max The current position is l i The maximum distance to the farthest location in the region of interest;
[0082] The probability P(l) is calculated according to equation (3). i This process involves generating a probability matrix, summing the values of each row and column from left to right, and filling them into the corresponding positions to obtain the cumulative probability distribution matrix. Then, a random number R (0-1) is generated, and the current position is set to l. i The position of the next moment is represented by the column containing the value with the smallest difference from R and greater than R in the i-th row of the probability cumulative distribution matrix; thus, a motion trajectory sequence is generated.
[0083] Clearly, points that are closer to each other have a higher probability of becoming the next trajectory point. The trajectory sequence generated using the above method is then fed into the feature extraction network for training.
[0084] In one specific embodiment, an autoencoder is an unsupervised artificial neural network primarily used for data dimensionality reduction and feature learning. It can provide a better feature description than the original data and possesses strong feature learning capabilities. An autoencoder consists of two parts: an encoder and a decoder. The encoder extracts features from the original input data, while the decoder reconstructs the original input data from the feature information, ensuring that the reconstructed data is as close as possible to the original data. Figure 4 The diagram shows the structure of a 3-layer autoencoder.
[0085] An autoencoder consists of an input layer, an output layer, and a hidden layer. The input layer takes in the original data, the output layer outputs the reconstructed data with features, and the hidden layer extracts features. The input and output layers have the same number of neurons. Through simple learning, the autoencoder can make the output closely resemble the input, but the reconstructed data still has some error compared to the original data. To make the output as close to the input as possible, the features extracted by the hidden layer must be more representative of the original data.
[0086] In one specific implementation, the attention mechanism is a weighted pooling method that, through the mapping of queries to keys and values, achieves a stronger ability to capture sequences with long-term dependencies and can reduce information loss during network training. Figure 5 This explains the principle of the attention mechanism. The attention mechanism has three main advantages: fewer model parameters, faster computation speed, and better prediction performance. Compared to models like convolutional neural networks and recurrent neural networks, the attention mechanism model has very low complexity and few parameters, thus requiring less sophisticated hardware. Furthermore, while the next step in a recurrent neural network depends on the result of the previous step, the attention mechanism's computation at each step does not depend on the result of the previous step, thus enabling parallel computation. When the distance in a data sequence is too long, it can weaken during training, gradually losing past information. The attention mechanism, however, can focus on key information, preventing information loss due to excessively long sequences.
[0087] An attention function can be described as follows: Based on the task, relevant query vectors (Query) and each element are stored in the Source in key-value pairs. When a Query matches a Key, the corresponding Value is obtained. Unlike traditional query methods, the value is not retrieved by address; instead, it uses the similarity between the Query and Key to perform addressing. The Value obtained through similarity is then compared with the Key to obtain the attention value.
[0088] However, a drawback of self-attention mechanisms is that when encoding information about the current position, the model may excessively focus its attention on its own location. This problem can be solved by using multi-head attention mechanisms. Instead of using a single attention pooling, h different linear projections are learned independently to transform the query, key, and value. These h transformed query, key, and value sets are then attention-pooled in parallel. Finally, the outputs of these h attention pooling are concatenated and transformed through another learnable linear projection to produce the final output. This design is called multi-head attention, where each output of the attention pooling is called a multi-head.
[0089] Figure 6 This is a multi-head self-attention mechanism layer model structure. First, h input sequences X = (x1, x2, x3, ..., x...) are set. n The initial weight matrix is composed of the value (Value), key (Key), and query (Query). Where i = 1, 2, 3, ..., h. Then calculate the correlation matrix of sequence X:
[0090]
[0091]
[0092]
[0093] Among them, V i K i Q i Let Value be the i-th head value of the input sequence X, Key be the key, and Query be the query matrix.
[0094] Then, the attention outputs of h heads are computed in parallel. This is done using feature x. k Query vector (k = 1, 2, 3, ..., n) The attention weights are obtained by taking the inner product of the key at each position and normalizing it. The attention weights represent the features x. k The higher the weight of the relationship with other positions in the sequence, the more important the data feature is:
[0095]
[0096] in, For the feature x in the input sequence k The query vector; For feature x k The attention weight of the i-th head; softmax() is the normalization exponential function used to normalize the attention score; This is an adjustment factor to prevent the inner product from becoming too large so that softmax() can be calculated.
[0097] Furthermore, the feature x is obtained by weighting and summing the attention weights with their corresponding values. k Attention score:
[0098]
[0099] Where attention() represents the attention score function; For feature x k The value vector corresponding to the i-th head, r i For x k The attention score corresponding to the i-th head.
[0100] Finally, the outputs of the h head attention mechanisms are concatenated and combined with the weight matrix W. O Multiplication yields the final output of the multi-head attention mechanism:
[0101] MultiheadAttention(Q,K,V)=Concat(r 1 ,r 2 ,r 3 ,…,r h W O (9)
[0102] Multi-head attention mechanisms process sequential data by using different heads to access representations of different subspaces at different sequence positions. These subspaces originate from different subspace representations of queries, keys, and values. Multi-head attention enhances network stability and robustness by calculating attention scores at multiple positions in the data sequence and fusing features.
[0103] The feature extraction network structure described in this embodiment is as follows: Figure 3As shown, the autoencoder includes an encoder and a decoder; the encoder includes a single one-dimensional convolutional layer, a residual unit, and an LSTM layer; the decoder includes a residual unit and an LSTM layer; wherein the residual unit consists of two one-dimensional convolutional layers and one LSTM layer. After being processed by the autoencoder, the data is input into an attention network to further extract feature information from the data, and finally outputs the position coordinates through a fully connected layer to achieve position estimation.
[0104] In one specific embodiment, the input layer (corresponding to) Figure 7 The `input_1:InputLayer` is used to input 3D data. The format of the input data is: number of samples (batch_size), time step (timesteps), and number of features (features).
[0105] The number of samples mentioned above refers to the number of samples in a batch, and a batch consists of one or more samples.
[0106] The time step is defined as follows: one time step represents one observation point in the sample; in this embodiment, the time step is 9, meaning that RSSI values need to be measured at 9 different times.
[0107] The number of features mentioned is 13, which includes 11 RSSI readings and position coordinates (X,Y).
[0108] Following the input layer is a one-dimensional convolutional layer with 100 kernels (corresponding to...) Figure 7 In the conv1d:Conv1D, the kernel length of this convolutional layer is 4, the output has 100 channels, and the convolution stride is 1.
[0109] In one specific embodiment, an autoencoder is a method that uses a neural network to reconstruct an input vector, thereby obtaining a dimensionality-reduced vector of the hidden layer as the input vector for training the network. The RSSI fingerprint is input into the autoencoder neural network, where the autoencoder performs data compression and training. During this process, a relevant loss function is set. The encoder and decoder are parameterized equations, and the loss function can be differentiated.
[0110] After the data passes through the input layer, it will go through the encoder part of the autoencoder (corresponding to...). Figure 3 The encoder comprises a one-layer one-dimensional convolutional network (corresponding to...). Figure 7 (conv1d) and a residual unit (corresponding to) Figure 3 Residual Block 1) and one LSTM layer (corresponding to Figure 7In the LSTM (Laser-Stagem), the residual unit consists of two layers of one-dimensional convolutions and one LSTM layer. The reason for using residual connections is that the connection method in the residual unit can maintain the stability of deep network training, avoid gradient vanishing, and introduce residual modules to deepen the convolutional network in the case of high-dimensional input. After introducing one-dimensional fully convolution, regardless of the size of the input layer, padding can be used to ensure that the length of the time series remains unchanged, while ensuring that each input at each time step has a corresponding output.
[0111] In one specific embodiment, the RSSI fingerprint sequence is input into the residual unit, and the specific processing is as follows:
[0112] First, it is processed through two one-dimensional convolutional layers; the kernel length of both one-dimensional convolutional layers is 4, and the output channels are both 100.
[0113] In this embodiment, the first convolutional layer in the two-layer one-dimensional convolutional layer processing (corresponding to...) Figure 7 The first convolutional layer (conv1d_1) uses a one-dimensional convolutional kernel; the second convolutional layer (corresponding to...) Figure 7 (conv1d_2 in the middle).
[0114] After processing through two one-dimensional convolutional layers, the output time-series data has a length of 9 and 100 channels, which is then input into the LSTM layer (corresponding to...). Figure 7 In the LSTM_2 layer, the representation vector of the RSSI sequence is obtained through the LSTM layer, and the number of neurons in the LSTM layer is set to 100.
[0115] In one specific embodiment, the LSTM layer employs a long short-term memory network, which acquires long-term dependent features through the collaboration between the forget gate, input gate, and output gate; the output of multiple one-dimensional convolutional layers is used as the input of the LSTM; for each time interval, the LSTM layer is operated on simultaneously as input, and the two output results are concatenated to obtain the output vector of the LSTM layer.
[0116] A Long Short-Term Memory (LSTM) network is chosen to establish the mapping relationship between RSSI fingerprint data and motion trajectory models. The feature windows are temporally related; after convolution, the feature vectors are still divided into sequences in units of windows to construct the input data for the LSTM layer. After processing by the encoder, the input data is fed into the decoder of the autoencoder (corresponding to...). Figure 3 The decoder part consists of a residual block (corresponding to the decoder). Figure 3 Residual Block 2) and one LSTM layer (corresponding to Figure 7The residual unit of the decoder section described in this embodiment has the same network structure and parameters as the residual unit of the encoder. The number of neurons in the LSTM layer is 100, and the length of the input sequence is 9.
[0117] In one specific embodiment, the data is passed through an autoencoder and then fed into a multi-head attention layer (corresponding to...). Figure 7 Multi-Head Attention (MGA) in this context selects more important features based on the importance of information (weights). The principle of the attention mechanism is to assign different importance (weights) to different parts of the input sequence, while assigning different weights to different parts of the output sequence. In other words, the output sequence is composed of the output from the previous stage and the input from the current stage. As the RSSI sequence increases, the difference in the amount of information in RSSI measurements at different time slices and spatial locations becomes significant, making the model's ability to capture features based on time steps increasingly poor. The attention mechanism can effectively utilize the sequence difference information and improve sequence learning performance. Therefore, this paper introduces a multi-head attention mechanism to extract RSSI values that are more important to the sequence representation and obtains the final RSSI sequence representation vector based on the obtained weights.
[0118] An attention network is used to extract RSSI values that are more important to the sequence representation, and the final RSSI sequence representation vector is obtained based on the obtained weights, as follows:
[0119] Attention is achieved by an attention function, which will... m The query Q, key K, and value V are mapped to the output. Specifically, the similarity between query Q and key K is calculated, and the weight is assigned to value V based on this similarity. The multi-head attention mechanism projects query Q, key K, and value V into a low-dimensional space. The projection is performed h times, and then the attention function is performed h times to obtain h low-dimensional outputs. Finally, the h low-dimensional outputs are merged and projected to obtain the final output.
[0120] The output layer, after data has undergone feature extraction via an autoencoder and an attention layer, is output via a fully connected layer with a dimension of 2, thus realizing the output of position coordinates.
[0121] In this embodiment, the kernel size of all one-dimensional Conv1D convolutional layers is set to 4, and the stride is set to 1. 100 convolutional kernels are used to extract features from the original time series. The LSTM layer contains 100 neurons. The input gate, forget gate, and output gate of the LSTM are used to process the time memory of nine time slices to learn effective temporal features. Using the feature extraction network model constructed in this embodiment, the RSSI time series is input to train the entire feature extraction network, and the output is location coordinates, thereby achieving coordinate localization. The specific structure of the entire feature extraction network is as follows: Figure 7 As shown.
[0122] In one specific embodiment, the feature extraction network is trained before localization, and the training is performed as follows:
[0123] D1: The motion trajectory sequence is used as the training set to input the feature extraction network for training, and the loss value between the input data and the output data is calculated through the loss function.
[0124] D2: Update network weights and biases using the stochastic gradient descent algorithm;
[0125] D3: Determine if the maximum number of iterations has been reached. If yes, output the position estimate; otherwise, return to step D2.
[0126] Experimental setup
[0127] To verify the effectiveness of the RSSI fingerprint localization method in this invention, an experiment was conducted. The experimental environment consisted of a Core™ i7-8700K CPU, 16GB of RAM, and a GTX 1080 Ti GPU, implemented using Python and the Tensorflow framework.
[0128] The dataset used in this experiment is wifi-rssi-indoor-localization[3]. In this dataset, the RSSI data for training and testing were collected using an autonomous robot. The three-wheeled robot has multiple sensors, including wheel odometers, inertial measurement units (IMUs), lidar, sonar sensors, and color and depth (RGB-D) cameras. It can navigate to the target location with an accuracy of 0.07±0.02m. The robot also carries a mobile device to collect RSSI fingerprints. The offline training dataset was collected by the robot carrying the mobile phone at 365 RPs. At each location, 100 RSSI measurement scans (S1=100) were collected. At each location in the training trajectory, one of the 100 stored RSSIs was randomly selected as the RSSI associated with that location. A total of 365,000 randomly generated training trajectories were generated. This approximates the random walking characteristics of the user well and helps to reduce spatial ambiguity. The user's initial position in the entire test trajectory is known. In the online phase, the robot moves along a predetermined route with an average speed of about 0.6m / s. The robot will follow the trajectory
[0129] Table 1 Experimental parameter settings
[0130]
[0131] RSSI was collected at 175 test points. At each location, only one or two RSSI scans (S² = 1 or 2) were collected and transmitted to the server in real time. The server predicted the user's location based on the proposed algorithm and calculated the prediction accuracy. 80% of the data was randomly selected as the training dataset, and the remaining 20% was used as the test set. Experimental parameters are shown in Table 1.
[0132] Experimental results:
[0133] The experiment is mainly divided into three parts. First, the influence of multi-head attention mechanism on localization error is verified through experiments. Second, the influence of residual connection on localization error is verified. Third, the present invention is compared with the schemes in other literature to compare their cumulative probability function and average localization error.
[0134] 1) The impact of multi-head attention mechanisms
[0135] In principle, multi-head attention mechanisms play a crucial role in the localization process. During localization, different RSSI fingerprints correspond to specific location coordinates. Multi-head attention mechanisms can better utilize relevant information from different contexts, such as... Figure 8 As shown, the multi-head attention mechanism has a significant impact on positioning accuracy. The positioning error results are compared below.
[0136] 2) The effect of residual connectivity
[0137] To verify the impact of residual connections on localization error, one approach is to simply stack the one-dimensional convolutional layers and LSTM layers in the residual block without using a residual connection structure. This approach is compared with the method of this invention. Here, the convolutional kernel size is uniformly set to 4, and the batch size is set to 512. The results are as follows. Figure 9 As shown.
[0138] 3) Horizontal comparison with other methods
[0139] This experiment selected three algorithms—AE-LSTM[1], LF-DLSTM[2], and P-MIMO RNN[3]—as comparison algorithms for the experiment, and obtained the following results: Figure 10 The experimental results are shown below. The horizontal axis represents the positioning error in meters, and the vertical axis represents the cumulative distribution function.
[0140] from Figure 10 As can be seen, when the positioning error is less than or equal to 1 meter, the cumulative distribution probability of the method of this invention is 75%, the cumulative distribution probability of the AE-LSTM algorithm is 70%, the cumulative distribution probability of the LF-DLSTM algorithm is 55%, and the cumulative distribution probability of the P-MIMORNN algorithm is 67%.
[0141] When the positioning error is less than or equal to 1.5 meters, the cumulative distribution probability of the method of this invention is 90%, the cumulative distribution probability of the AE-LSTM algorithm is 85%, the cumulative distribution probability of the LF-DLSTM algorithm is 70%, and the cumulative distribution probability of the P-MIMO RNN algorithm is 81%. The average positioning error results of various schemes are shown in Table 2.
[0142] Table 2 Comparison of the average positioning errors of the four algorithms
[0143]
[0144] The comprehensive experiment yields the following conclusions: when the method of the present invention is compared with the three algorithms AE-LSTM[1], LF-DLSTM[2], and P-MIMORNN[3], the cumulative distribution function of the positioning error and the average positioning error are compared respectively. It can be seen that compared with the three algorithms AE-LSTM[1], LF-DLSTM[2], and P-MIMO RNN[3], the positioning error distribution and average error of the method of the present invention are smaller, which shows that the method of the present invention has obvious advantages.
[0145] The AE-LSTM algorithm employs a novel deep learning model that connects an autoencoder with a long short-term memory network for WiFi fingerprint localization. First, an autoencoder is used to extract representative latent variables from the fingerprint; this algorithm uses fully connected layers to implement the autoencoder. Then, a series of latent variables are injected into the LSTM network to achieve location estimation.
[0146] The LF-DLSTM algorithm is a deep long short-term memory network method based on local features. The idea behind this approach is to extract local features from the raw RSSI data to eliminate the influence of noise, thereby improving localization accuracy. Its overall structure includes a sliding window for extracting local features from the input data, and then the data is fed into a stacked deep LSTM network for temporal encoding and high-level feature learning. The output of the deep LSTM is then fed into a fully connected layer, and a linear regression layer is used for the final location mapping.
[0147] The P-MIMO RNN algorithm uses a multiple-input multiple-output LSTM structure, which takes multiple RSSIs and previously predicted positions as inputs and generates multiple positions for the output. The overall network structure consists of two LSTM layers and one fully connected layer. To prevent overfitting, Dropout is added after each LSTM layer.
[0148] This invention proposes an RSSI fingerprint localization method that combines an autoencoder with a multi-head attention mechanism. The autoencoder extracts features from the input RSSI sequence, and a one-dimensional convolutional network and a long short-term memory network extract feature information from the time series. The method models the sequential dependence of RSSI signals between different time periods and uses a multi-head attention layer to filter out more important features based on the importance of the information. This allows for more complete extraction of information from the data, resulting in a smaller final localization error.
[0149] Meanwhile, to address the degradation problem of deep networks, residual connections are introduced to avoid gradient vanishing and gradient exploding. This invention transforms the RSSI fingerprint localization problem into a time series prediction problem, utilizes relevant methods in deep learning to build a neural network, extracts features from the input RSSI sequence, and trains the neural network to obtain accurate location estimation.
[0150] Example 3
[0151] A computer system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the method described in Embodiment 1 or Embodiment 2.
[0152] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0153] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. A RSSI fingerprint positioning method based on an auto-encoder and an attention mechanism, characterized in that: The method includes the following steps: The raw RSSI data is preprocessed, and the fingerprint database is constructed using the preprocessed RSSI data. Based on the relationship of reference positions, a motion trajectory sequence is randomly generated. From the RSSI set corresponding to each trajectory point position in the constructed fingerprint database, a set of values is randomly selected as the RSSI sequence corresponding to the motion trajectory sequence. The RSSI sequence is input to construct a feature extraction network based on an autoencoder and an attention mechanism to achieve localization; the feature extraction network includes an input layer, an autoencoder, an attention network, and an output layer; The input layer is used to unify the input data format; The autoencoder is used to extract local spatial features and long-term dependencies from motion trajectory data; The attention network is used to extract RSSI values that are more important to the sequence representation, and to obtain the final RSSI sequence representation vector based on the obtained weights; The output layer is used to output position coordinates. 2.The RSSI fingerprinting method based on auto-encoder and attention mechanism according to claim 1, wherein: The preprocessing is as follows: First, the original collected WiFi data is preprocessed, including missing value filling and normalization; then, the normalized data is used to construct a fingerprint database.
3. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 1, characterized in that: The random generation of motion trajectory sequences based on the relationship of reference positions is as follows: Let there be n reference positions, let the i and the j reference positions be ; No. i The reference position to the first j The distance between each reference position is Then the distance relationship between each pair of reference positions is obtained, which can be represented by a distance matrix; According to the distance matrix, under certain assumption conditions, a probability that the pedestrian appears at another reference position after a RSSI sampling period when the pedestrian is at a certain reference position is obtained; a current generated track point position is denoted as , and a probability that the pedestrian moves from to a point in a current RSSI sampling period is denoted as . Maximum distance of the inner movement of the pedestrian is , the maximum moving speed of the pedestrian in normal walking is , and the maximum moving speed of the pedestrian in normal walking is between 0.4 m / s and 2.0 m / s; assuming that the probability of the pedestrian moving to a certain position in the next RSSI sampling period obeys a Gaussian distribution with as a standard deviation, the normalized probability is as follows: (3) wherein, is the current position the maximum distance between the current position and the farthest position in the region of interest; The probability is calculated according to formula (3) and a probability matrix is obtained. The values of each column in each row of the probability matrix are accumulated from left to right one by one and filled in the corresponding positions to obtain a probability cumulative distribution value matrix. Then a 0-1 random number R is generated. The current position is set as . The position represented by the column in which the value of the row of the probability cumulative distribution value matrix is the smallest and greater than R is selected as the position of the next moment. i This generates a sequence of motion trajectories.
4. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 1, characterized in that: The input layer is used to input three-dimensional data, and the format of the input data is: number of samples, time step, and number of features; The number of samples mentioned above refers to the number of samples in a batch, and a batch consists of one or more samples. The time step is defined as follows: one time step represents one observation point in the sample. The number of features mentioned is 13, which includes 11 RSSI readings and position coordinates (X,Y).
5. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 1, characterized in that: The autoencoder includes an encoder and a decoder; the encoder includes a single one-dimensional convolutional layer, a residual unit, and an LSTM layer; the decoder includes a residual unit and an LSTM layer; wherein the residual unit is composed of two one-dimensional convolutional layers and one LSTM layer.
6. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 5, characterized in that: The RSSI fingerprint sequence is input into the residual unit, and the specific processing is as follows: First, it is processed through two one-dimensional convolutional layers; the kernel length of both one-dimensional convolutional layers is 4, and the output channels are both 100. After processing through two one-dimensional convolutional layers, the output time series data has a length of 9 and 100 channels. This data is then input into the LSTM layer, which obtains the representation vector of the RSSI sequence. The number of neurons in the LSTM layer is set to 100.
7. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 6, characterized in that: The LSTM layer described above uses a long short-term memory network to obtain long-term dependency features through the cooperation between the forget gate, input gate, and output gate. The outputs of multiple one-dimensional convolutional layers are used as the inputs to the LSTM. For each time interval, the LSTM layer is operated on simultaneously as input, and the two outputs are concatenated to obtain the output vector of the LSTM layer.
8. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 1, characterized in that: An attention network is used to extract RSSI values that are more important to the sequence representation, and the final RSSI sequence representation vector is obtained based on the obtained weights, as follows: Attention is implemented by an attention function that takes The query Q, key K, value V of the dimension are mapped to an output, specifically the similarity of the query Q and the key K is calculated, and the weight assigned to the value V is calculated based on this; the multi-head attention mechanism projects the query Q, key K, value V into a low-dimensional space h times, and then performs the attention function h times to obtain h low-dimensional outputs, and finally combines the h low-dimensional outputs and projects to obtain the final output.
9. The RSSI fingerprinting method based on autoencoder and attention mechanism according to claim 1, characterized in that: Before positioning by using the feature extraction network, training is performed, and the training is specifically as follows: D1: inputting a motion trajectory sequence as a training set into the feature extraction network for training, and calculating a loss value between input data and output data by using a loss function; D2: updating network weights and biases according to a stochastic gradient descent algorithm; D3: judging whether a maximum iteration number is reached, if yes, outputting position estimation, and if not, returning to step D2.
10. A computer system comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that: The processor executes the computer program, and steps of the method in any one of claims 1-9 are implemented.
Citation Information
Patent Citations
Positioning method and device based on received signal strength indication
CN107305246A
WiFi fingerprint indoor positioning method based on random forest and auto-encoder
CN111461251A