Indoor positioning method and device based on hard sample perception and bcl pso optimization
Patent Information
- Application Number
- CN202511093080.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-05
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2045-08-05
AI Technical Summary
[0005]针对复杂室内环境中的多径效应、动态干扰源以及设备异构性等因素,导致相邻位置指纹特征相似度显著升高,定位精度低问题,本发明提供一种基于硬样本感知与BCLPSO优化的室内定位方法和装置
[0042] (1) This invention proposes a hard-sample-aware triplet network dynamic fine-tuning mechanism during the offline training phase. By combining confidence scores and classification error rates to select hard samples, a pre-trained neural network (such as Resi-Net) is embedded into the triplet network architecture, and triplet training samples are dynamically constructed based on hard samples to fine-tune the triplet network. This fine-tuning mechanism significantly improves the robustness of the fingerprint database by adaptively optimizing the boundary representation of hard samples.
Smart Images

Figure CN121099266B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication technology, and in particular to an indoor positioning method based on hard sample perception and BCLPSO optimization. Background Technology
[0002] Indoor fingerprint positioning methods utilize the characteristic differences of signals at different spatial locations, using the signal characteristics of a specific location as a unique identifier (i.e., a "fingerprint") to construct a mapping between location and fingerprint, thereby achieving location estimation. Commonly used signal characteristics include WiFi, magnetism, optical, and RFID. Among these, WiFi has been widely used due to its wide availability, low hardware cost, and low technical implementation threshold. The first WiFi-based fingerprint positioning method was the RADAR system. This system uses radio frequency (RF) signals as fingerprint features and employs a deterministic matching algorithm to complete the positioning and tracking tasks. Subsequently, Youssef et al. further developed this approach, proposing a statistical positioning method based on received signal strength (RSS)—the Horus system. In Horus, the wireless fingerprint of each location is modeled as a Gaussian distribution, and matching is performed using maximum likelihood estimation. However, RSS-based positioning systems are susceptible to environmental factors such as multipath effects, leading to significant fluctuations in positioning accuracy. To address this, some researchers have begun exploring the extraction of finer-grained CSI (Channel State Information) from wireless signals and using features such as amplitude, phase, and phase difference as location fingerprints to improve positioning performance. Wang et al. proposed an indoor positioning method called CiFi. This method first theoretically and experimentally verifies the feasibility of using AoA (Angle-of-Arrival) values for indoor positioning. Then, it constructs a CSI image using AoA, inputs the constructed image into a deep convolutional neural network for training, and finally predicts the estimated location.
[0003] With the rapid development of machine learning technology, fingerprint localization has been modeled as a subspace matching problem. Metric learning methods have been introduced into this field to mine the correlations between data points. Li et al. proposed combining amplitude and spatial features (two-dimensional location) as fingerprints and using Siamese convolutional neural networks for matching and localization. To address the problem of time-varying features, Pandey et al. proposed a localization method based on Siamese neural networks. This method utilizes powerful Siamese embeddings to solve the localization challenges of heterogeneous devices and time-varying IoT networks, reducing the labor-intensive task of building large offline fingerprint databases to some extent. Yang et al. proposed an indoor localization method based on triple matching networks. This method uses amplitude as a fingerprint, feeds the constructed fingerprint into a triple network, and mines the hidden correspondence between CSI fingerprints and physical space by designing a triple loss function based on distance and angle, to achieve feature extraction and high-precision localization. To reduce manual and time consumption, Liu et al. proposed a CSI fingerprint WiFi indoor localization method (SiFi) based on Siamese networks. This method constructs tensors from the acquired CSI data and uses only a small number of training samples during training. Experimental results show that the proposed SiFi method achieves higher localization results compared with the basic CNN scheme.
[0004] Overall, fingerprint-based indoor positioning technology has become a research hotspot in smart cities and the Industrial Internet of Things (IIoT) due to its advantages such as low cost, easy deployment, and high scalability. However, issues such as multipath effects, dynamic interference sources, and device heterogeneity in complex indoor environments lead to a significant increase in the similarity of fingerprint features at adjacent locations, severely restricting the improvement of positioning accuracy. Summary of the Invention
[0005] To address the issue of low positioning accuracy caused by significantly increased fingerprint feature similarity between adjacent locations due to factors such as multipath effects, dynamic interference sources, and device heterogeneity in complex indoor environments, this invention provides an indoor positioning method and device based on hard sample perception and BCLPSO optimization.
[0006] In a first aspect, the present invention provides an indoor positioning method based on hard sample perception and BCLPSO optimization, comprising: an offline training phase and an online positioning phase;
[0007] The offline training phase includes: collecting raw CSI data from different locations to form an initial training set and preprocessing the initial training set to obtain a corresponding CSI image training set; performing hard sample mining on the CSI image training set; using the obtained hard samples to fine-tune a preset triplet network to obtain a fine-tuned triplet network; and using the fine-tuned triplet network to construct a location-fingerprint database.
[0008] The online positioning stage includes: acquiring raw CSI data of the current location and preprocessing it to obtain a corresponding CSI image; inputting the CSI image into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image; performing similarity matching between the fingerprint feature vector of the CSI image and preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity; generating an initial particle swarm centered on the locations corresponding to the top k preset fingerprint features; and using the initial particle swarm centered on the BCLPSO (Bayesian Iterative Particle Swarm Optimization) algorithm to estimate the location using the BCLPSO algorithm.
[0009] Furthermore, the preprocessing includes: sequentially unwinding and linearly transforming the original CSI data, removing outliers, and denoising.
[0010] Furthermore, hard sample mining is performed on the CSI image training set, specifically including:
[0011] The fingerprint features of the CSI image training set are extracted and classified using a preset neural network. Based on the classification results, the CSI image samples corresponding to the top t positions with high classification error rates are selected from the CSI image training set and added to the hard sample candidate set.
[0012] Data augmentation is performed on the CSI image samples in the hard sample candidate set, and a comprehensive score for each candidate sample is calculated according to the following formula, wherein the candidate samples include the original samples and the corresponding augmented samples in the hard sample candidate set;
[0013]
[0014] Among them, Score i Let p represent the overall score of CSI image sample i, where ij represents the j-th augmented sample corresponding to CSI image sample i, j = 1, 2, ..., n; and n represents the total number of augmented samples corresponding to CSI image sample i. ij The maximum value (p) represents the class probability corresponding to the augmented sample ij. ij ) represents the maximum class probability, second_max(p ij ) represents the probability of the second largest category, y ij This represents the true label corresponding to the augmented sample ij. This represents the predicted label corresponding to the enhanced sample ij, and α is the confidence difference weight;
[0015] Candidate samples with higher overall scores are selected as the final hard samples.
[0016] Furthermore, the preset triplet network is composed of three preset neural networks with shared weights;
[0017] Correspondingly, the obtained hard samples are used to fine-tune the preset triplet network, specifically including:
[0018] A two-order dynamic triplet hybrid strategy is used to construct triplets, and the constructed triplets are used to fine-tune the preset triplet network; wherein, the two-order dynamic triplet hybrid strategy includes:
[0019] In the initial training phase, the total triplets are composed of 70% triplets constructed according to the first strategy and 30% triplets constructed according to the second strategy.
[0020] During the mid-training phase, the total number of triplets is composed of 40% triplets constructed according to the first strategy, 40% triplets constructed according to the second strategy, and 20% triplets constructed according to the third strategy.
[0021] In the later stages of training, the total triplet is composed of 50% triplets constructed according to the third strategy, 25% triplets constructed according to the first strategy, and 25% triplets constructed according to the second strategy.
[0022] During the mid- and late-stage training phases, the average loss change rate is calculated every few rounds. If the average loss change rate indicates that the training is unstable, the weights of the triples constructed based on the third strategy are reduced, and the released weights are evenly distributed to the other two strategies. Otherwise, the weights are kept unchanged, and the model is optimized with the current weights.
[0023] The triples constructed by the first strategy consist of anchor samples, hard positive samples, and negative samples; the triples constructed by the second strategy consist of anchor samples, positive samples, and hard negative samples; and the triples constructed by the third strategy consist of anchor samples, hard positive samples, and hard negative samples.
[0024] Furthermore, based on the initial particle swarm, the Comprehensive Learning Particle Swarm Optimization Algorithm (BCLPSO) based on the Bayesian iterative method is used for position estimation, specifically including:
[0025] Update the velocity and position of the current particle swarm to obtain a new particle swarm;
[0026] The fitness of each particle in the new particle swarm is calculated using a fitness function; the fitness function is:
[0027]
[0028] Among them, weight The distance between the two embedding vectors is σ, which controls the weight decay rate. i ,y i (x) represents the coordinates of the test location. j ,yj () represents the coordinates of the reference point, and N represents the total number of reference points;
[0029] If a particle fails to improve its fitness for m consecutive trials, its individual learning probability Pc is updated according to the following formula. i :
[0030]
[0031] Update the particle guide sample exemplar according to the following formula. i :
[0032] exemplar i =α·pbest i +(1-α)·pbest β
[0033] Where α is the random weight and β (β≠i) is the randomly selected particle index;
[0034] Update the individual optimal position and the global optimal position;
[0035] When the location region boundary constraints and iteration termination conditions are met, the latest global optimal position is output as the final predicted position.
[0036] Secondly, the present invention provides an indoor positioning device based on hard sample perception and BCLPSO optimization, comprising:
[0037] The offline training module is used to collect raw CSI data from different locations to form an initial training set and preprocess the initial training set to obtain the corresponding CSI image training set. Hard sample mining is performed on the CSI image training set, and the obtained hard samples are used to fine-tune the preset triplet network to obtain the fine-tuned triplet network. The fine-tuned triplet network is then used to construct a location-fingerprint database.
[0038] An online positioning module is used to acquire and preprocess the raw CSI data of the current location to obtain the corresponding CSI image. The CSI image is then input into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image. The fingerprint feature vector of the CSI image is then matched with preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity. An initial particle swarm is generated centered on the locations corresponding to the top k preset fingerprint features. Based on the initial particle swarm, a Brilliant Learning Particle Swarm Optimization Algorithm (BCLPSO) based on the Bayesian iterative method is used to estimate the location.
[0039] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in the first aspect.
[0040] Fourthly, the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in the first aspect.
[0041] The beneficial effects of this invention are as follows:
[0042] (1) This invention proposes a hard-sample-aware triplet network dynamic fine-tuning mechanism during the offline training phase. By combining confidence scores and classification error rates to select hard samples, a pre-trained neural network (such as Resi-Net) is embedded into the triplet network architecture, and triplet training samples are dynamically constructed based on hard samples to fine-tune the triplet network. This fine-tuning mechanism significantly improves the robustness of the fingerprint database by adaptively optimizing the boundary representation of hard samples.
[0043] (2) This invention introduces a Comprehensive Learning Particle Swarm Optimization (BCLPSO) algorithm that integrates Bayesian inference into the online localization stage. By updating particle weights through Bayesian iteration and combining global search and local correction strategies, it effectively overcomes the premature convergence problem of traditional particle swarm optimization algorithms in complex multipath environments. This optimization mechanism improves the accuracy and stability of position estimation, especially in interference scenarios such as non-line-of-sight (NLOS). Attached Figure Description
[0044] Figure 1 A flowchart illustrating an indoor positioning method based on hard sample perception and BCLPSO optimization provided in an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of phase preprocessing provided for embodiments of the present invention: (a) original phase; (b) unwound phase; (c) phase after linear transformation;
[0046] Figure 3 The present invention provides a method for removing phase outliers using a Hampel identifier.
[0047] Figure 4 Phase denoising using wavelet filtering is provided in this embodiment of the invention;
[0048] Figure 5 Three selection strategies for triples provided for embodiments of the present invention: (a) a first strategy; (b) a second strategy; and (c) a third strategy;
[0049] Figure 6The influence of the number k of high-weight reference points provided in the embodiments of the present invention;
[0050] Figure 7 A schematic diagram of an indoor positioning device based on hard sample perception and BCLPSO optimization provided in an embodiment of the present invention;
[0051] Figure 8 This is a structural block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0053] like Figure 1 As shown, this invention provides an indoor positioning method based on hard sample perception and BCLPSO optimization (HSTLoc for short), which mainly includes two stages: offline training and online positioning.
[0054] The offline training phase includes: collecting raw CSI data from different locations to form an initial training set and preprocessing the initial training set to obtain a corresponding CSI image training set; performing hard sample mining on the CSI image training set; using the obtained hard samples to fine-tune a preset triplet network to obtain a fine-tuned triplet network; and using the fine-tuned triplet network to construct a location-fingerprint database. Specifically, the triplet network in this embodiment consists of three Resi-Net networks with shared weights.
[0055] Specifically, due to factors such as multipath effects, dynamic environmental interference, and channel time-varying characteristics, the feature distribution of some CSI samples exhibits complex or ambiguous characteristics. These samples typically possess the following characteristics: (1) located in the ambiguous decision boundary region of the feature space; (2) exhibiting significant intra-class differences due to dynamic environmental interference; and (3) exhibiting feature confusion with reference points in similar scenarios. This embodiment of the invention defines these as "hard samples." However, the continuous disturbance of the dynamic environment causes the difficulty of samples to exhibit non-stationary characteristics over time, and channel time-varying characteristics further exacerbate the ambiguity of the feature space, making it difficult for traditional static threshold-based screening methods to effectively capture dynamically changing decision boundaries. Furthermore, feature confusion is particularly prominent in dense scenarios, and existing training strategies often treat all samples equally, resulting in limited model discrimination capabilities for complex boundary conditions. Therefore, this embodiment of the invention proposes a hard sample-aware model fine-tuning strategy, using screened hard samples to achieve refined reconstruction of the feature extractor.
[0056] The online localization phase includes: acquiring and preprocessing the raw CSI data of the current location to obtain the corresponding CSI image; inputting the CSI image into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image; performing similarity matching between the fingerprint feature vector of the CSI image and preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity; generating an initial particle swarm centered on the locations corresponding to the top k preset fingerprint features; and using the initial particle swarm centered on the BCLPSO (Bayesian Iterative Particle Swarm Optimization) algorithm to estimate the location using the BCLPSO algorithm.
[0057] The indoor positioning method provided in this invention fine-tunes the triplet network using hard samples mined from the training set during the offline training phase. This adaptively optimizes the boundary representation of difficult samples, enhances the discriminative power of fingerprint features, and significantly improves the robustness of the fingerprint database. During the online positioning phase, a Comprehensive Learning Particle Swarm Optimization (BCLPSO) algorithm with Bayesian inference is introduced. By iteratively updating particle weights through Bayesian methods and combining global search and local correction strategies, the premature convergence problem of traditional particle swarm algorithms in complex multipath environments is effectively overcome. This optimization mechanism improves the accuracy and stability of position estimation, especially in interference scenarios such as non-line-of-sight (NLOS).
[0058] In one embodiment, such as Figure 2 As shown, in this embodiment of the invention, the acquired raw CSI data is preprocessed in the following manner to obtain the corresponding CSI image.
[0059] (1) Unwinding and linear transformation
[0060] Specifically, phase data is typically extracted from complex signals using the arctangent function (atan2 or arctan). Since the output range of the arctangent function is limited to [-π, π] or [0, 2π], a "phase wrapping" phenomenon occurs when the phase crosses this range, such as... Figure 2 As shown in (a). This phenomenon introduces discontinuities, thus affecting subsequent analysis. The purpose of phase unwinding is to recover the original continuous phase information and eliminate the discontinuities caused by winding, such as... Figure 2 As shown in (b). The formula for unwinding is as follows:
[0061] ψ unwrapped (n)=ψ wrapped (n)+2π·k(n)(1)
[0062] Where ψ wrapped This represents the wound phase, where k(n) is an integer representing the addition or subtraction of a multiple of zπ to the wound phase at the nth point to recover continuous phase values. n represents the index position or sampling point number in the phase data sequence. To facilitate subsequent processing, we use a linear transformation to map the phase data to a specific range, such as... Figure 2 As shown in (c).
[0063] (2) Outlier removal
[0064] The Hampel detector was used to handle outliers in the phase data. Specifically, the phase data was first divided into a fixed-length sliding window W = 20, and the median μ and median absolute deviation σ of the data points were calculated within each window. If a variable e exceeds the threshold range |e-μ| > 1.4826 × γ × σ, it will be considered an outlier, where γ is a constant with a value of 3. Figure 3 The preprocessed phase is shown, and the results demonstrate that using the Hampel identifier not only improves the robustness of the phase but also preserves the main features of the signal while removing outliers.
[0065] (3) Noise reduction
[0066] Wireless signal propagation is often affected by multipath effects and environmental interference, resulting in a large amount of noise in the phase data, which significantly reduces the accuracy of phase measurement. Therefore, this embodiment of the invention selects a wavelet filter to denoise the phase. Due to its excellent time-frequency localization capability, the wavelet filter can accurately distinguish signal features from noise components. Compared with traditional filtering methods (such as low-pass filters), it is more adaptable to the characteristics of non-stationary signals, while avoiding signal distortion caused by excessive smoothing. Figure 4 The images show the phase before and after using wavelet filtering, and it is clear that this method not only removes phase noise but also preserves the key features of the signal well.
[0067] After the above preprocessing, the AoA is estimated using phase difference, and then the AoA is used to construct CSI images. The specific process is as follows: An Intel 5300NIC (Network Interface Card) is used to acquire 30 subcarriers from each of the three antennas. Then, two sets of CSI data are calculated: 30 phase differences between antenna 1 and antenna 2, and 30 phase differences between antenna 2 and antenna 3. Based on this, 60 AoA values can be obtained from each received data packet. At each training location, 960 data packet samples are acquired. Therefore, 50 images of size 60×60 can be constructed at each location, where rows represent the number of data packets in each image, and columns represent the number of estimated AoA values for each data packet.
[0068] In one embodiment, this invention provides a dynamic hard sample mining strategy, mainly including coarse-grained screening, a comprehensive scoring mechanism, and fine-grained screening. Specifically:
[0069] (1) Coarse-grained screening: The trained Resi-Net was used to predict the CSI image training set, initially screening out the top 10 locations with high classification error rates (each location contains 30 CSI images). The k most frequently misclassified locations were selected as preliminary hard sample candidates based on their classification error rates. Table 1 shows this screening process, where T represents the number of correct classifications and Acc represents the classification accuracy. Bold positions indicate the categories with high classification error rates at each Top-k location.
[0070] Table 1: Positions most prone to misclassification under the Top-6 threshold.
[0071]
[0072] As shown in Table 1 above, the classification success rate at all positions increases with the increase of the k value. When the k value reaches its maximum, some positions have achieved an accuracy of 70%. However, the classification success rates at positions L.22, L.92, L.73, L.97, and L.60 are still relatively low, indicating that the CSI features extracted from these positions have low discriminative power and are insensitive to changes in Top-k. Therefore, the samples corresponding to these positions are initially considered as hard samples.
[0073] (2) Comprehensive Scoring Mechanism: For samples with high classification error rates, a dynamic weight allocation strategy is introduced. Data augmentation is used to expand the sample size, and a comprehensive scoring mechanism is constructed by combining classification error rate and prediction confidence. This is achieved through an indicator function. Only misclassified samples are assigned non-zero scores to avoid misclassifying easy samples as hard samples, thus focusing on the model's current weak areas; the indicator function indicates that if the condition in parentheses is true, the indicator value is 1, otherwise it is 0. This utilizes the maximum class probability max(p ij ) and the second largest class probability second_max(p ij The difference in confidence level is used to design a confidence penalty term (1-max(p)). ij )+α×(1-(max(p ij )-second_max(p ij This reflects both the model's lack of confidence in the correct category and captures the ambiguity of inter-class features. Specifically, the overall score for sample i is calculated as follows:
[0074]
[0075]
[0076] Among them, Score i Let p represent the overall score of sample i, ij represent the j-th augmented sample corresponding to sample i, j = 1, 2, ..., n; n represent the total number of augmented samples corresponding to sample i. ij The maximum value (p) represents the class probability corresponding to the augmented sample ij. ij ) represents the maximum class probability, second_max(p ij ) represents the probability of the second largest category, y ij This represents the true label corresponding to the augmented sample ij. This represents the predicted label corresponding to the enhanced sample ij, and α is the confidence differential weight, used to balance the model's sensitivity to prediction confidence and inter-class similarity.
[0077] (3) Fine-grained screening: Among the hard samples selected in the coarse-grained screening, a comprehensive scoring mechanism is used to identify hard samples. Specifically, the comprehensive score of each candidate sample (including the coarsely screened candidate hard samples and each candidate hard sample to the enhanced sample) is calculated, and the sample with the higher comprehensive score is selected as the hard sample. Here, softmax is used as the activation function, α is set to 0.5, which means that the confidence level of the sample and the confidence difference have the same importance, and n is 20, which represents the number of enhanced samples after each sample is enhanced.
[0078] Table 2. Overall scoring results of the 10 augmented samples
[0079]
[0080] According to Table 2, misclassified samples typically received higher scores, especially the S.78 samples, which had the highest score of 0.6275. This is because their confidence scores were low and their confidence differences were small, indicating that the model had high uncertainty in predicting these samples. Therefore, these samples will ultimately be selected as hard samples.
[0081] In one embodiment, this invention employs a two-stage dynamic triplet hybrid strategy to construct triplets, and uses the constructed triplets to fine-tune the preset triplet network. Hard samples typically contain more complex information than ordinary samples, posing a challenge in the model learning process. Their misclassification may occur for two reasons: one is that they are in the same position as the anchor sample (a sample used as a known reference) but have significantly different features; these are called hard positive samples. The other is that they have similar features to the anchor sample but are located in different positions; these are called hard negative samples. Based on this, the following three strategies are first constructed:
[0082] First strategy: such as Figure 5 As shown in (a), the triplet consists of anchor samples, hard positive samples, and negative samples. Selecting "hard positive samples," that is, samples in the hard samples that have low similarity to anchor samples but are in the same position, as positive samples can help the model better cope with intra-class variations and enhance the model's robustness to differences in samples of the same class.
[0083] Second strategy: such as Figure 5 As shown in (b), the triplet consists of an anchor sample, a positive sample, and a hard negative sample. Selecting "hard negative samples," that is, samples in the hard samples that are very close to the anchor sample but do not actually belong to the same category, as negative samples can effectively improve the inter-class discrimination ability of the model.
[0084] Third strategy: such as Figure 5 As shown in (c), the triplet consists of anchor samples, hard positive samples, and hard negative samples, and also includes indistinguishable samples within and between classes, which prompts the model to learn more discriminative feature representations.
[0085] Using the three strategies described above to construct triples and conduct independent experiments, we draw the following conclusions: Strategies 1 and 2 respectively address the issues of high intra-class scatter or low inter-class discriminative power, but the model faces the challenge of unstable gradient updates in the early stages of training. While strategy 3 significantly improves classification accuracy, the excessive number of hard samples reduces model convergence efficiency. In summary, each strategy has its unique advantages and limitations. To achieve a more efficient and stable model training process, based on the three strategies mentioned above, this invention further proposes a hybrid strategy for two-stage dynamic triples, as detailed below:
[0086] (1) Stage-adaptive weight allocation:
[0087] In the initial stage (25% of the total Epochs): adopt 70% of the first strategy (hard positive samples) + 30% of the second strategy (hard negative samples). By simply alternating between hard positive and negative samples, a preliminary feature space can be quickly established, avoiding interference from complex samples.
[0088] Mid-term phase (50% of total Epochs): 40% first strategy + 40% second strategy + 20% third strategy (hard positive + hard negative), a small number of composite hard samples (i.e., the third strategy) are introduced to improve the model’s sensitivity to boundary samples by mixing them in a fixed ratio, while maintaining training stability.
[0089] Later stage (25% of total Epochs): 50% third strategy + 25% first strategy + 25% second strategy, with composite hard samples as the main force, continuously optimizing the feature distribution of highly confusing regions, and the remaining weights maintaining intra-class / inter-class balance.
[0090] (2) Gradient-sensing dynamic adjustment:
[0091] The average rate of change of loss is calculated every 5 epochs, using the following formula:
[0092]
[0093] like If the training is deemed unstable, immediately reduce the weight of the third strategy (by 20%), and redistribute the released weights equally among the first and second strategies. This maintains the current stage proportions, allowing the model to continue to optimize.
[0094] To intuitively evaluate the impact of the four triplet selection strategies on the classification results, this invention uses t-SNE technology to visualize the classification results. In comparison, the two-order dynamic triplet hybrid strategy proposed in this embodiment exhibits clearer inter-class boundaries and tighter intra-class aggregation in the feature space. This result not only verifies the hybrid strategy's ability to accurately characterize complex data distributions but also confirms its superior discriminative performance.
[0095] In one embodiment, during the online localization phase, CSI image test samples are feature-encoded to obtain query embedding vectors, which are then measured using Euclidean distance (L2 norm) to measure their similarity to all reference embeddings in the fingerprint database. Traditional methods such as KNN-based similarity matching use the nearest reference point in the embedding space as the estimated location, but these methods cannot explicitly model the deep discriminative feature space extracted by the triple network, making it difficult to accurately distinguish subtle differences between adjacent locations. Therefore, this embodiment of the invention proposes using a Comprehensive Learning Particle Swarm Optimization (BCLPSO) algorithm based on a Bayesian iterative method for location estimation.
[0096] The BCLPSO algorithm fully utilizes prior and historical information about particles approaching the global optimum, enabling particles to effectively avoid getting trapped in local optima while also not missing any potential global optima during the search process. Therefore, the BCLPSO algorithm enhances the diversity and accuracy of the optimization process while maintaining exploration efficiency. The steps for position estimation based on the BCLPSO algorithm are as follows:
[0097] S201: Initialize parameters and particle swarm.
[0098] Specifically, based on the embedding similarity between the test sample and the reference points, the position coordinates of the top k high-weight reference points are selected as the center, and the initial particle position X is generated according to a normal distribution. i Speed V i Initialize to zero. Particle swarm size ps = 30, dimension D = 2, maximum iteration max_iteration = 100, stage threshold m = 5, maximum function evaluation count max_fes = 3000.
[0099] S202: Fitness Function Design. The fitness function is the weighted sum of physical distances between the test location and the reference point:
[0100]
[0101] Among them, weight The distance between the two embedding vectors is σ, which controls the weight decay rate. i ,y i (x) represents the coordinates of the test location. j ,y j ) represents the coordinates of the reference point, and N represents the total number of reference points.
[0102] S203: Update the velocity and position of the current particle swarm. The velocity and position of the i-th particle are updated using the following equation:
[0103]
[0104] Where ω = 0.9 - 0.5·(t / max_iteration), dynamically decreasing from 0.9 to 0.4, and c1 = c2 = 2.0.
[0105] S204: The fitness of the updated particle swarm is calculated using the fitness function. If a particle's fitness does not improve after m = 5 consecutive iterations (i.e., Stage(i) > m), the individual learning probability Pc of that particle is adjusted using the following formula. i :
[0106]
[0107] S205: Dynamically update the exemplar (guide sample). Select the historical best pbest from other particles. β As a temporary guiding sample, the update formula is:
[0108] exemplar i =α·pbest i +(1-α)·pbest β (8)
[0109] Here, α is a random weight, and β (β≠i) is a randomly selected particle index, thereby increasing diversity.
[0110] S206: Phase Management and Global Optimization.
[0111] Specifically, after each iteration, if the particle's current position X i Its fitness is better than its all-time best pbestval i Then update pbestval i And reset Stage(i) = 0; otherwise, increase Stage(i) by 1. The global optimal gbestval always tracks the minimum fitness value in the swarm, guiding the particle swarm to converge toward the optimal region.
[0112] S207: Determine the boundary constraints of the positioning region and the termination condition of the iteration.
[0113] Specifically, if a particle exceeds the positioning area (such as a room boundary), its coordinates are projected to the nearest edge, and its velocity direction is reset. The process stops when max_iteration = 100 or max_fes = 3000, and the globally optimal position gbest is output as the final predicted position.
[0114] In summary, the indoor positioning method based on hard sample perception and BCLPSO optimization provided by this invention, in the offline training phase, firstly performs linear transformation, outlier removal based on Hampel detector, and wavelet filtering denoising on the original CSI data sequentially; then, it extracts deep features of CSI through a designed Resi-Net network and performs classification, combining confidence scores and classification error rates to filter hard samples; finally, it embeds Resi-Net as a sub-network with shared weights into a triple network architecture, dynamically constructs triples based on hard samples, and designs a contrastive loss function based on boundary constraints to fine-tune the triple network, extracting sample features through the fine-tuned triple network, generating high-dimensional feature embeddings, and constructing a location fingerprint database. In the online positioning phase, the preprocessing procedure for the CSI signal to be predicted is the same as in the offline training phase; the fine-tuned triple network is mapped to a low-dimensional embedding space to obtain discriminative feature vectors; finally, the Integrated Learning Particle Swarm Optimization (BCLPSO) algorithm based on the Bayesian iterative method is used for location estimation, further improving the positioning performance of the HSTLoc method in complex environments.
[0115] Extensive testing was conducted in typical laboratory and conference room settings. Experimental results show that the HSTLoc method outperforms the comparative method in both mean error and standard deviation in laboratory and conference room environments.
[0116] To evaluate the effectiveness of the proposed HSTLoc method, this invention was tested in two typical indoor scenarios: a laboratory and a conference room. The experimental results were compared with CiFi, Siamese-CNN, SELE, Triplet MatchNet, and SiFi. Mean Absolute Error (MAE), Root Mean Square Error (RMSE), Standard Deviation of Error (STDE), and Maximum Error (MAXE) were used as performance metrics. MAE and RMSE were calculated as follows:
[0117]
[0118] Where N represents the total number of test samples. and Let represent the estimated position and the actual position of the j-th sample, respectively.
[0119] In addition, the cumulative distribution function (CDF) is used for statistical analysis of positioning errors, where 1-σ (68.27%) and 2-σ (95.45%) represent the percentages of all positioning errors used to calculate the error interval, respectively.
[0120] Table 3 shows the parameter settings for Resi-Net.
[0121] Table 3 Resi-Net parameter settings
[0122]
[0123] This network progressively extracts CSI image features through a hierarchical structure: First, an initial convolutional layer (32 filters, 3×3 kernels) combined with batch normalization and ReLU suppresses high-frequency noise. Then, four residual layers (layers 1-4) progressively extract features. Layer 1 starts with 32 channels to capture local features, while layers 2 through 4 repeatedly fuse multipath association patterns and integrate global spatial fingerprints using residual blocks with different channel numbers (64, 128, 256). The network incorporates batch normalization and high-intensity Dropout to balance model complexity and generalization ability; global average pooling preserves frequency domain structural information; and finally, a fully connected layer completes the classification mapping. Furthermore, the optimization algorithm uses AdamW to handle gradient fluctuations caused by hard samples during training, stabilize parameter update directions, and improve convergence efficiency. The initial learning rate (ε), batch size (bz), asymptotic boundary parameter (m0), gradient suppression strength coefficient (λ), distribution smoothing strength coefficient (μ), and number of high-weight reference points (k) were set to 1e-3, 32, 0.3, 0.5, 0.3, and 5, respectively. All evaluations in this experiment were performed using PyTorch framework version 1.9.01 in Python 3.9, running on... Core TM It features an i9-11900K at 3.50GHz, 64GB of RAM, and an NVIDIA Tesla V100 GPU. The comparison results are shown in Table 4.
[0124] Table 4 Performance Comparison
[0125]
[0126] Table 4 shows that the 1-σ and 2-σ localization errors of HSTLoc in the conference room setting are 2.16 m and 4.38 m, respectively. Compared with CiFi, Siamese-CNN, SELE, Triplet MatchNet, and SiFi, HSTLoc reduces the 1-σ error by 36.4%, 33.1%, 28.2%, 21.2%, 29.4%, and 17.2%, respectively, and reduces the 2-σ and maximum errors by 7.8%–28.8% and 17.3%–37.2%, respectively. The 1-σ and 2-σ localization errors of HSTLoc in the laboratory setting are 3.21 m and 5.60 m, respectively. Compared with CiFi, Siamese-CNN, SELE, Triplet MatchNet, and SiFi, HSTLoc reduced the 1-σ error by 32.8%, 25.5%, 36.1%, 16.0%, 23.8%, and 10.3%, respectively, and reduced the 2-σ and maximum errors by 7.4%–32.1%, 9.1%, and 35.5%, respectively. These results demonstrate the superiority of HSTLoc in localization accuracy. This is attributed to two factors: firstly, the use of coarse-grained hard sample selection optimizes feature boundaries, improving inter-class and intra-class feature extraction capabilities; secondly, the introduced BCLPSO algorithm accurately corrects the position estimation, effectively suppressing noise interference.
[0127] According to Table 4, the STDE of HSTLoc in the conference room is 1.02m, while the STDEs of CiFi, Siamese-CNN, SELE, TripletMatchNet, and SiFi are 1.49, 1.58, 1.42, 1.26, 1.33, and 1.18m, respectively. In the laboratory, the STDE of HSTLoc is 1.50m, while the STDEs of CiFi, Siamese-CNN, SELE, TripletMatchNet, and SiFi are 2.03, 1.97, 2.29, 1.73, 1.89, and 1.65m, respectively. These results demonstrate that the HSTLoc method has a significant advantage in localization stability, indicating that the proposed ADBL loss function enhances the intra-class compactness and inter-class separability of features, suppressing error propagation. Furthermore, it is noted that the stability of the SELE method under laboratory conditions is significantly lower than that in the conference room. This is because SELE uses RSS for localization, and RSS is prone to decay and fluctuation in complex environments, leading to unstable localization results.
[0128] According to Table 4, in the conference room environment, the signal propagation path is direct, the multipath effect is weak, and the CSI features are less affected by interference. In this environment, HSTLoc's MAE (1.59m) and RMSE (1.81m) are both low, indicating high positioning accuracy; the STDE (1.02m) and 1-σ (2.16m) statistics are also small, indicating more concentrated prediction results and better stability. In the laboratory environment, the dense equipment leads to complex multipath reflections, and the CSI features are severely affected by interference. In this environment, HSTLoc's MAE (2.02m) and RMSE (2.38m) are significantly higher, while STDE (1.50m) and 1-σ (3.21m) are higher, indicating greater error fluctuations and decreased stability.
[0129] Figure 6 The study demonstrates that the number of high-weight reference points, *k*, significantly impacts localization accuracy (MAE) and robustness (MAXE) in both conference room and laboratory environments. As *k* increases from 1 to 7, MAE continuously decreases from 3.20m to 1.59m. When *k* exceeds 7, MAE increases again to 1.85m. This indicates that in sparse scenarios, reference points are widely distributed, and increasing *k* expands the initial search range of the particle swarm, covering more potential localization areas. However, excessively increasing *k* introduces low-quality reference points, causing particles to disperse into irrelevant areas and reducing localization stability. In the laboratory environment, as *k* increases, the particle swarm coverage expands to the vicinity of more high-weight reference points, effectively capturing the true location. However, when *k* exceeds 5, due to the small spacing between reference points in the laboratory environment, excessively high *k* introduces noise from low-similarity reference points, leading to excessive particle dispersion and deviation from the target area. Simultaneously, as *k* increases, MAXE decreases significantly in both environments. However, further increases in *k* may cause some particles to fall into abnormal areas far from the true location, resulting in a significant increase in MAXE. Therefore, a reasonable selection of the *k* value can achieve a balance between accuracy and robustness in different scenarios.
[0130] Based on the same inventive concept, such as Figure 7 As shown, this embodiment of the invention provides an indoor positioning device based on hard sample perception and BCLPSO optimization, including an offline training module and an online positioning module.
[0131] The offline training module collects raw CSI data from different locations to form an initial training set and preprocesses it to obtain a corresponding CSI image training set. Hard sample mining is performed on the CSI image training set, and the obtained hard samples are used to fine-tune a preset triplet network to obtain a fine-tuned triplet network. This fine-tuned triplet network is then used to construct a location-fingerprint database. The online positioning module acquires raw CSI data for the current location and preprocesses it to obtain a corresponding CSI image. This CSI image is input into the fine-tuned triplet network to obtain a fingerprint feature vector. The fingerprint feature vector of the CSI image is then matched with preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k most similar preset fingerprint features. An initial particle swarm is generated centered on these locations, and the location is estimated using the Comprehensive Learning Particle Swarm Optimization Algorithm (BCLPSO) based on a Bayesian iterative method.
[0132] It should be noted that the indoor positioning device provided in this embodiment of the invention is for implementing the above method, and its specific function can be referred to the above method embodiments, which will not be repeated here.
[0133] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8As shown, the electronic device may include: a processor 801, a communication interface 802, a memory 803, and a communication bus 804. The processor 801, communication interface 802, and memory 803 communicate with each other via the communication bus 804. The processor 801 can call logical instructions in the memory 803 to execute an indoor positioning method based on hard sample perception and BCLPSO optimization. This method includes an offline training phase and an online positioning phase. The offline training phase includes: collecting raw CSI data from different locations to form an initial training set and preprocessing the initial training set to obtain a corresponding CSI image training set; performing hard sample mining on the CSI image training set; using the obtained hard samples to fine-tune a preset triplet network to obtain a fine-tuned triplet network; and using the fine-tuned triplet network to construct a location-fingerprint database. The online positioning phase... The process includes: acquiring raw CSI data of the current location and preprocessing it to obtain the corresponding CSI image; inputting the CSI image into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image; performing similarity matching between the fingerprint feature vector of the CSI image and preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity; generating an initial particle swarm centered on the locations corresponding to the top k preset fingerprint features; and using the initial particle swarm centered on the BCLPSO (Comprehensive Learning Particle Swarm Optimization) algorithm based on the Bayesian iterative method to estimate the location.
[0134] Furthermore, when the logical instructions in the aforementioned memory 803 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0135] This invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the indoor positioning method based on hard sample perception and BCLPSO optimization provided in the above-described method embodiments.
[0136] This invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the indoor positioning method based on hard sample perception and BCLPSO optimization provided in the above-described method embodiments.
[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An indoor positioning method based on hard sample perception and BCLPSO optimization, characterized in that, include: Offline training phase and online localization phase; The offline training phase includes: collecting raw CSI data from different locations to form an initial training set and preprocessing the initial training set to obtain a corresponding CSI image training set; performing hard sample mining on the CSI image training set; using the obtained hard samples to fine-tune a preset triplet network to obtain a fine-tuned triplet network; and using the fine-tuned triplet network to construct a location-fingerprint database. The online positioning stage includes: acquiring raw CSI data of the current location and preprocessing it to obtain a corresponding CSI image; inputting the CSI image into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image; performing similarity matching between the fingerprint feature vector of the CSI image and preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity; generating an initial particle swarm centered on the locations corresponding to the top k preset fingerprint features; and using the initial particle swarm centered on the BCLPSO (Bayesian Iterative Particle Swarm Optimization) algorithm to estimate the location using the BCLPSO algorithm.
2. The indoor positioning method based on hard sample perception and BCLPSO optimization according to claim 1, characterized in that, The preprocessing includes: sequentially unwinding and linearly transforming the raw CSI data, removing outliers, and denoising.
3. The indoor positioning method based on hard sample perception and BCLPSO optimization according to claim 1, characterized in that, Hard sample mining is performed on the CSI image training set, specifically including: The fingerprint features of the CSI image training set are extracted and classified using a preset neural network. Based on the classification results, the CSI image samples corresponding to the top t positions with high classification error rates are selected from the CSI image training set and added to the hard sample candidate set. Data augmentation is performed on the CSI image samples in the hard sample candidate set, and a comprehensive score for each candidate sample is calculated according to the following formula, wherein the candidate samples include the original samples and the corresponding augmented samples in the hard sample candidate set; in, Represents CSI image samples Overall score Represents CSI image samples The corresponding number One enhanced sample, ; Represents CSI image samples The corresponding total number of augmented samples, Indicates augmented samples The corresponding category probability, Represents the maximum class probability. Indicates the probability of the second largest category. Indicates augmented samples The corresponding real tags, Indicates augmented samples The corresponding predicted label, It is the confidence level difference weight; Candidate samples with higher overall scores are selected as the final hard samples.
4. The indoor positioning method based on hard sample perception and BCLPSO optimization according to claim 3, characterized in that, The preset triplet network consists of three preset neural networks sharing weights; Correspondingly, the obtained hard samples are used to fine-tune the preset triplet network, specifically including: A two-order dynamic triplet hybrid strategy is used to construct triplets, and the constructed triplets are used to fine-tune the preset triplet network; wherein, the two-order dynamic triplet hybrid strategy includes: In the initial training phase, the total triplets are composed of 70% triplets constructed according to the first strategy and 30% triplets constructed according to the second strategy. During the mid-training phase, the total number of triplets is composed of 40% triplets constructed according to the first strategy, 40% triplets constructed according to the second strategy, and 20% triplets constructed according to the third strategy. In the later stages of training, the total triplet is composed of 50% triplets constructed according to the third strategy, 25% triplets constructed according to the first strategy, and 25% triplets constructed according to the second strategy. During the mid- and late-stage training phases, the average loss change rate is calculated every few rounds. If the average loss change rate indicates that the training is unstable, the weights of the triples constructed based on the third strategy are reduced, and the released weights are evenly distributed to the other two strategies. Otherwise, the weights are kept unchanged, and the model is optimized with the current weights. The triples constructed by the first strategy consist of anchor samples, hard positive samples, and negative samples; the triples constructed by the second strategy consist of anchor samples, positive samples, and hard negative samples; and the triples constructed by the third strategy consist of anchor samples, hard positive samples, and hard negative samples.
5. The indoor positioning method based on hard sample perception and BCLPSO optimization according to claim 1, characterized in that, Position estimation is performed based on the initial particle swarm using the Comprehensive Learning Particle Swarm Optimization Algorithm (BCLPSO) based on a Bayesian iterative method, specifically including: Update the velocity and position of the current particle swarm to obtain a new particle swarm; The fitness of each particle in the new particle swarm is calculated using a fitness function; the fitness function is: Among them, weight , The distance between two embedding vectors. To control the rate of weight decay, ( , ) represents the coordinates of the test location, ( , () represents the coordinates of the reference point, and N represents the total number of reference points; If a particle fails to improve its fitness after m consecutive iterations... If the value is greater than m, then the individual learning probability of the particle is updated according to the following formula. : Update the particle guide sample according to the following formula. : in, For random weights, For randomly selected particle indices, ; Update the individual optimal position and the global optimal position; When the location region boundary constraints and iteration termination conditions are met, the latest global optimal position is output as the final predicted position.
6. An indoor positioning device based on hard sample perception and BCLPSO optimization, characterized in that, include: The offline training module is used to collect raw CSI data from different locations to form an initial training set and preprocess the initial training set to obtain the corresponding CSI image training set. Hard sample mining is performed on the CSI image training set, and the obtained hard samples are used to fine-tune the preset triplet network to obtain the fine-tuned triplet network. The fine-tuned triplet network is then used to construct a location-fingerprint database. An online positioning module is used to acquire and preprocess the raw CSI data of the current location to obtain the corresponding CSI image. The CSI image is then input into a fine-tuned triplet network to obtain the fingerprint feature vector of the CSI image. The fingerprint feature vector of the CSI image is then matched with preset fingerprint features in the location-fingerprint database to obtain the locations corresponding to the top k preset fingerprint features with the highest similarity. An initial particle swarm is generated centered on the locations corresponding to the top k preset fingerprint features. Based on the initial particle swarm, a Brilliant Learning Particle Swarm Optimization Algorithm (BCLPSO) based on the Bayesian iterative method is used to estimate the location.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Robust scene recognition method and system based on capsule network
CN112733701A
Target detection performance optimization method
WO2018137357A1