Spatiotemporal data vector compression storage method based on ai pattern discovery
By using a spatiotemporal data vector compression and storage method based on AI pattern discovery, the problem of high computational overhead in high-dimensional spatiotemporal data processing is solved, achieving efficient data compression and real-time processing, and possessing good system scalability and portability.
Patent Information
- Application Number
- CN202611033408.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-13
- Publication Date
- 2026-11-27
Smart Images

Figure CN123184656A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data storage technology, and in particular to a spatiotemporal data vector compression storage method based on AI pattern discovery. Background Technology
[0002] With the rapid development of fields such as the Internet of Things and ecological environment monitoring, various sensor networks, distributed monitoring systems, and smart terminal devices are generating massive amounts of spatiotemporal data every day. Spatiotemporal data typically has significant characteristics such as high dimensionality (including spatial coordinates, timestamps, and multidimensional sensor readings), temporal correlation (high correlation between data at adjacent time points), and massive volume.
[0003] In existing technologies, data compression techniques are typically used to reduce data volume in order to cope with the storage and transmission pressure of massive amounts of spatiotemporal data.
[0004] Current compression schemes are mainly based on dictionary encoding or entropy encoding principles. While these algorithms are highly versatile, they often overlook the inherent temporal and spatial correlations of high-dimensional spatiotemporal data when processing such data. As the amount of data increases, the computational overhead (CPU usage) during decompression rises significantly, making it difficult to meet the needs of large-scale real-time data processing. Summary of the Invention
[0005] (a) Technical problems to be solved In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a spatiotemporal data vector compression and storage method based on AI pattern discovery.
[0006] (II) Technical Solution To achieve the above objectives, the main technical solutions adopted by the present invention include: A spatiotemporal data vector compression and storage method based on AI pattern discovery, the method comprising: S101, Acquire spatiotemporal data; wherein, the spatiotemporal data is collected by at least one sensor device; S102, based on AI pattern discovery, performs temporal encoding and feature extraction of spatiotemporal data; among which, features include: temporal features, spatial features, semantic features, and anomaly patterns; S103, Determine the codeword index based on the codebook and extracted features; S104, Determine the residual code based on the codeword index; S105, compress the spatiotemporal data into compressed data by combining time encoding, codeword index, residual encoding and quality mark, and store the compressed data; wherein, the quality mark is determined based on the spatiotemporal data.
[0007] Optionally, S102 includes: Discover the engine through AI mode, and perform temporal encoding and feature extraction of spatiotemporal data; The AI pattern discovery engine includes: an input layer, a temporal coding layer, a Transformer encoder block, and a feature projection layer. The input layer is used to receive temporal tensors of shape [B, W, D]; where the temporal tensor is formed by dividing spatiotemporal data into windows; B is the number of data points in a single data session, W is the size of the window, and D is the feature dimension of the spatiotemporal data; The time coding layer is used to time-code each spatiotemporal data in each batch; The Transformer encoder block is used to determine the characteristics of each spatiotemporal data in each batch, and to determine the overall characteristics of each batch based on the characteristics of each spatiotemporal data. The feature projection layer is used to project the features of each spatiotemporal data in each batch and the overall features of each batch to obtain the extracted features.
[0008] Optionally, time encoding is performed on each spatiotemporal data in each batch, including: Determine the encoding of any dimension in any spatiotemporal data of any batch; wherein the encoding of any dimension in any spatiotemporal data of any batch is the basic encoding of that dimension, or the sum of the basic encoding of that dimension and the feature adjustment value of that dimension; The encoding of each dimension is used to construct the time encoding vector of any spatiotemporal data in any batch; In any batch of spatiotemporal data w, the basic encoding of the 2i-th dimension is sin(w / 10000^(2i / D)), and the encoding of the 2i+1-th dimension is cos(w / 10000^(2i / D)); w is the spatiotemporal data index, w=0,1, W-1; i is the semi-dimensional index, i=0,1, , D / 2-1; Alternatively, the basic encoding of the j-th dimension in any spatiotemporal data w within any batch is the value corresponding to the j-th row and column of the random parameter matrix; j is the dimension index, j=0,1, D; the random parameter matrix is obtained through pre-learning.
[0009] Optionally, the spatiotemporal data includes: the timestamp of the acquisition, the sensor identifier of the acquisition, the sensor location of the acquisition, and multi-dimensional attribute values; The sensor identifier occupies 4 bytes, the timestamp occupies 8 bytes, the sensor location occupies 12 bytes, and the multi-dimensional attribute values occupy 4 bytes (total number of dimensions).
[0010] Optionally, the codebook is divided into multiple layers, each containing A^(1 / L) cluster centers; where A is the total number of codewords; and L is the total number of layers. S103 includes: Initializing a search index f=1, and determining all clustering centers of the first layer as current clustering centers; Determining a distance between a feature vector formed by the extracted features and the current clustering center; If f=L, selecting one clustering center with a minimum distance, and determining an index corresponding to the selected clustering center as a codeword index; if f<L, selecting multiple clustering centers with a minimum distance, f=f+1, determining a clustering center corresponding to the selected clustering center in the fth layer as the current clustering center, and re-executing the step of determining a distance between a feature vector formed by the extracted features and the current clustering center.
[0011] Optionally, S104 includes: Determining a residual vector R=F_out-c_idx; where F_out is a feature vector formed by the extracted features, and c_idx is a codeword corresponding to the codeword index; Determining residual encoding according to the residual vector.
[0012] Optionally, the residual encoding includes a residual length and residual data; The residual data is determined in any of the following manners: If |R|<ε1, determining that the residual data is 0; where ε1 is a preset residual threshold; If |R|<2×ε2, determining the residual data based on a Huffman table; where ε2 is a preset residual standard deviation; if 2×ε2≤|R|<4×ε2, scaling |R| to a range of [0,255], converting into a multi-bit unsigned integer, and adding a range flag bit to obtain the residual data; if |R|≥4×ε2, adding a large residual flag bit to |R| to obtain the residual data.
[0013] Optionally, a feature adjustment value of a jth dimension in any spatiotemporal data w in any batch is tanh(α_j×u_j_w); where u_j_w is a bias of a feature value of the jth dimension in any spatiotemporal data w in any batch, α_j is a weight of the jth dimension, and tanh() is a hyperbolic tangent activation function; α_j is determined in advance according to original spatiotemporal data, and u_j_w is determined in advance according to the spatiotemporal data.
[0014] Optionally, α_j is determined through the following steps: Determining a valid annotation value of each dimension in each piece of original spatiotemporal data; where if a value of any dimension in any piece of original spatiotemporal data meets a requirement of the dimension, the valid annotation value is 1, otherwise the valid annotation value is 0; For any dimension j, performing the following steps S201 to S206 to obtain α_j: S201, determine the acquisition time of each original spatiotemporal data with an effective label value of 0 for dimension j, and form a time series of dimension j in order from farthest to nearest; S202, determine the time difference between the next element and the previous element in the time series of dimension j, and form the time difference series of dimension j; S203, determine the standard deviation σ_j of all elements in the time difference sequence of dimension j; S204, determine the outlier E_j=n_j_1 / N_1 for dimension j; where n_j_1 is the number of original spatiotemporal data with valid labeled values of 0 for dimension j, and N_1 is the total number of original spatiotemporal data. S205, determine the credibility of dimension j: C_j = 1 - [(σ_j - σ_min) / (σ_max - σ_min)] × [(E_j - E_min) / (E_max - E_min)]; Where σ_min is the minimum standard deviation of each dimension, σ_max is the maximum standard deviation of each dimension, E_min is the minimum outlier of each dimension, and E_max is the maximum outlier of each dimension. S206, determine α_j=e^[(C_j-C_max) / ∑ j (e^(C_j-C_max))]; Where C_max is the maximum value of the credibility of each dimension.
[0015] Alternatively, u_j_w is determined through the following steps: Get the value of the j-th dimension x_j_w in any spatiotemporal data w from any batch; If the j-th dimension is a numerical value, then u_j_w = softmax{(x_j_w-μ_j) / γ_j} is determined, where softmax{} is the normalization function, μ_j is the mean of the j-th dimension values in all spatiotemporal data, and γ_j is the standard deviation of the j-th dimension values in all spatiotemporal data. If the j-th dimension is a non-numerical value, then u_j_w = softmax{-log(n_j_2 / N_2)} is determined, where n_j_2 is the number of spatiotemporal data points in all spatiotemporal data points whose j-th dimension values are similar to x_j_w, and N_2 is the total number of all spatiotemporal data points.
[0016] (III) Beneficial Effects The beneficial effects of this invention are as follows: This invention relates to a spatiotemporal data vector compression and storage method based on AI pattern discovery. The method includes: acquiring spatiotemporal data; wherein the spatiotemporal data is collected by at least one sensor device; performing time encoding and feature extraction on the spatiotemporal data based on AI pattern discovery; wherein the features include: temporal features, spatial features, semantic features, and anomaly patterns; determining a codeword index based on the codebook and the extracted features; determining a residual code based on the codeword index; and constructing compressed spatiotemporal data from the time encoding, codeword index, residual code, and quality marker, and storing the compressed data; wherein the quality marker is determined based on the spatiotemporal data. This invention's method, when processing high-dimensional spatiotemporal data, considers the inherent temporal and spatial correlations of the data, reduces the computational overhead during decompression, and can meet the needs of large-scale real-time data processing. Attached Figure Description
[0017] Figure 1 A schematic diagram of a spatiotemporal data format provided by the present invention; Figure 2 A schematic diagram of the modular and layered system architecture used in the spatiotemporal data vector compression and storage method based on AI pattern discovery provided by the present invention; Figure 3 A flowchart illustrating a spatiotemporal data vector compression and storage method based on AI pattern discovery provided by this invention; Figure 4 A schematic diagram of a storage record format provided by the present invention; Figure 5 A schematic diagram of a residual distribution and coding strategy provided by the present invention; Figure 6 A schematic diagram of a storage record structure provided by the present invention; Figure 7 A schematic diagram of a residual encoder state machine provided by the present invention; Figure 8 A schematic diagram of a decoder state machine provided by the present invention; Figure 9 A schematic diagram of the structure of an index file provided by the present invention; Figure 10 A comparative diagram of technical solutions provided by the present invention; Figure 11 A quantitative comparison chart of compression performance is provided for this invention; Figure 12 A schematic diagram of an application scenario deployment architecture provided by the present invention; Figure 13 This is a schematic diagram of an end-to-end joint training framework provided by the present invention. Detailed Implementation
[0018] To better explain and facilitate understanding of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0019] In existing technologies, data compression techniques are commonly used to reduce data volume in order to cope with the storage and transmission pressure of massive spatiotemporal data. Current compression schemes are mainly based on dictionary encoding or entropy encoding principles. Although these algorithms are highly versatile, they often ignore the inherent temporal and spatial correlations of the data when processing high-dimensional spatiotemporal data. As the amount of data increases, the computational overhead (CPU usage) during decompression rises significantly, making it difficult to meet the needs of large-scale real-time data processing.
[0020] To address this problem, this invention relates to a spatiotemporal data vector compression and storage method based on AI pattern discovery. The method includes: acquiring spatiotemporal data; wherein the spatiotemporal data is collected by at least one sensor device; performing time encoding and feature extraction on the spatiotemporal data based on AI pattern discovery; wherein the features include: temporal features, spatial features, semantic features, and anomaly patterns; determining a codeword index based on a codebook and the extracted features; determining a residual code based on the codeword index; and constructing compressed spatiotemporal data from the time encoding, codeword index, residual code, and quality marker, and storing the compressed data; wherein the quality marker is determined based on the spatiotemporal data. This invention's method, when processing high-dimensional spatiotemporal data, considers the inherent temporal and spatial correlations of the data, reduces the computational overhead during decompression, and can meet the needs of large-scale real-time data processing.
[0021] This embodiment provides a spatiotemporal data vector compression and storage method based on AI pattern discovery. This method can be implemented using a modular, layered system architecture, breaking down the compression process into multiple independent and replaceable modules, each responsible for a specific function, and exchanging data through a standardized interface. This design has the following advantages: 1. Maintainability: Each module is developed, tested, and deployed independently.
[0022] 2. Scalability: New modules can be easily integrated into existing systems.
[0023] 3. Portability: Each module can be deployed independently on different hardware platforms.
[0024] For example, the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment can be achieved through methods such as... Figure 1 The four modules and storage media shown are implemented.
[0025] Module 1: Data Acquisition Layer The data acquisition layer is responsible for acquiring raw spatiotemporal data from various sensor devices, which can realize step S101 of acquiring spatiotemporal data.
[0026] The data acquisition layer supports multiple data interface protocols, such as those shown in Table 1.
[0027] Table 1
[0028] Spatiotemporal data includes: the timestamp of the acquisition, the sensor identifier of the acquisition, the sensor location of the acquisition, and multi-dimensional attribute values, such as... Figure 2 As shown.
[0029] Figure 2 The device identifier in the data is the sensor identifier that is collected. It uniquely identifies the sensor device and is used to distinguish data from multiple devices.
[0030] Figure 2 The timestamp in the data is the timestamp of the data collection. It is a Unix millisecond-level timestamp with an accuracy of ±1 millisecond.
[0031] Figure 2 The spatial coordinates in the data are the sensor positions acquired, and support two-dimensional (X,Y) or three-dimensional (X,Y,Z) coordinate systems.
[0032] Figure 2 Multidimensional attribute values refer to attribute values with multiple dimensions. Figure 2 In this context, N represents the total number of dimensions, and the value of N ranges from 1 to 256 depending on the type of sensor.
[0033] The data acquisition layer can acquire data in various formats, such as an exemplary structured data format: { "device_id": "SENSOR_001", "timestamp": 1713782400000, "location": {"x": 116.3, "y": 39.9, "z": 0.0}, "attributes": { Temperature: 25.3 "humidity": 65.2, "pressure": 1013.25 } } The binary data format acquired by the data acquisition layer is: [4-byte device ID][8-byte timestamp][12-byte coordinates][4N-byte attribute value] The data types collected support float32, float16, int16, etc.
[0034] Module 2: AI Pattern Discovery Engine The AI pattern discovery engine is a core intelligent component responsible for extracting latent patterns from raw high-dimensional data and generating compact feature representations. It enables step S102 to perform temporal encoding and feature extraction of spatiotemporal data based on AI pattern discovery.
[0035] The AI pattern discovery engine can perform the following processing: 1. Time series feature extraction: Extracting periodic and trend features from time series.
[0036] 2. Spatial feature extraction: Extracting distribution features from spatial location information.
[0037] 3. Semantic feature extraction: Extracting physical meaning from multi-dimensional attributes.
[0038] 4. Abnormal pattern recognition: Identify data points that deviate from the normal pattern.
[0039] In its implementation, the AI pattern discovery engine can adopt a lightweight Transformer architecture to reduce computational complexity; the AI pattern discovery engine supports online learning and incremental updates; the total number of parameters of the AI pattern discovery engine is controlled within 1MB, making it suitable for deployment on edge devices.
[0040] For example, an AI pattern discovery engine includes: an input layer, a temporal encoding layer, a Transformer encoder block, and a feature projection layer.
[0041] 1. Input layer The input layer is used to receive temporal tensors of shape [B, W, D].
[0042] The temporal tensor is formed by dividing spatiotemporal data into windows.
[0043] B represents the number of data points in a single dataset, W represents the window size, and D represents the feature dimension of the spatiotemporal data.
[0044] For example, [1, 8, 32] represents a single spatiotemporal data point with 8 time points and 32-dimensional features.
[0045] 2. Temporal Encoding Layer The time-coding layer is used to time-encode each spatiotemporal data in each batch.
[0046] 3. Transformer Encoder Block The Transformer encoder block is used to determine the characteristics of each spatiotemporal data in each batch, and to determine the overall characteristics of each batch based on the characteristics of each spatiotemporal data.
[0047] For example, a Transformer encoder block can have multiple layers, such as 1 to 4 layers. The number of layers is configurable. For example, if the number of layers is configured to be 2, then the Transformer encoder block will have 2 layers.
[0048] The parameters related to the multi-head self-attention mechanism used in the Transformer encoder block are as follows: The number of attention heads can be configured from 2 to 8, such as 4.
[0049] If the number of attention heads is 4 and the feature dimension D of the spatiotemporal data is 256, then the dimension of each head is 256 / 4=64.
[0050] The formula for calculating attention is: Attention(Q,K,V) = softmax{QK^T / sqrt(d)}V.
[0051] Where softmax{} is the normalization function, sqrt() is the square root function, T is the transpose operator, Q is the lookup matrix, K is the key matrix, and V is the value matrix.
[0052] The Transformer encoder block uses a feed-forward network with a hidden layer dimension of 512, and the activation function can be GELU, with a dropout rate of 0.1.
[0053] In practical implementation, the following optimization strategies can also be adopted: The parameter optimization strategies are shown in Table 2: Table 2
[0054] Inference delay control: Target latency: <1ms (edge device) Operator fusion: Combining multiple operations into a single GPU kernel.
[0055] Quantization inference: FP16 quantization reduces latency by 50%; INT8 quantization reduces latency by 75%.
[0056] Batch processing: Process multiple requests in batches to improve GPU utilization.
[0057] 4. Feature projection layer The feature projection layer is used to project the features of each spatiotemporal data in each batch and the overall features of each batch to obtain the extracted features.
[0058] The output dimension of the feature projection layer can be 64~512, and can be configured by relevant personnel during the specific implementation, such as configuring the output dimension to 128 dimensions.
[0059] The estimated number of network parameters for the AI pattern discovery engine described above is as follows: Time coding layer: 32 × 32 = 1,024; The first layer of the Transformer encoder block: 4 × (64×64×3 + 64×64 + 512×256×2)≈ 140,000; The second layer of the Transformer encoder block: 4 × (64×64×3 + 64×64 + 512×256×2)≈ 140,000; Feature projection layer: 256 × 128 = 32,768; Total: Approximately 300K parameters, approximately 1.2MB (FP32).
[0060] Module 3: Codebook Management Module The codebook management module is responsible for maintaining and managing the codebook used for vector quantization, and includes the functions shown in Table 3: Table 3
[0061] The codebook storage format (taking C language structures as an example) is as follows: typedef struct { uint16_t codebook_size; / / Codebook size C_K (e.g., 4096) uint8_tcode_dimension; / / Codeword dimension C_D (e.g., 128) float codewords[C_K][C_D]; / / Codeword data (C_K × C_D × 4 bytes) uint32_t usage_count[C_K]; / / Usage count (for analysis) uint32_t version; / / Codebook version number Codebook; Taking C_K=4096 and C_D=128 as an example, the storage overhead of the codebook corresponding to the above codebook storage format is: Codeword data: 4096 × 128 × 4 = 2,097,152 bytes ≈ 2MB; Additional information: 4096 × 4 × 2 = 32,768 bytes ≈ 32KB; Total: Approximately 2.1 MB.
[0062] Module 4: Hybrid Encoder The hybrid encoder, consisting of a vector quantization module and a residual calculation module, is key to achieving a high compression ratio.
[0063] 1. Vector Quantization Module The vector quantization module is used to receive features extracted by the AI pattern discovery engine, search for the most matching codeword in the codebook, and output the codeword index (replacing the original feature vector), that is, to implement step S103, which determines the codeword index based on the codebook and the extracted features.
[0064] 2. Residual Calculation Module The residual calculation module is used to calculate the difference between the feature vector and the codeword corresponding to the codeword index to obtain the residual vector. The residual vector is then adaptively encoded. The residual encoding is implemented in step S104, which determines the residual encoding based on the codeword index.
[0065] Compressed data that stores spatiotemporal data consisting of time encoding, codeword index, residual encoding, and quality markers in the storage medium.
[0066] The supported storage media are shown in Table 4: Table 4
[0067] See Figure 3 The implementation process of the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment is as follows: S101, acquire spatiotemporal data.
[0068] The spatiotemporal data is acquired by at least one sensor device. Step S101 is executed by the data acquisition layer.
[0069] Spatiotemporal data includes: timestamps of data collection, sensor identifiers of data collection, sensor locations of data collection, and multi-dimensional attribute values.
[0070] The sensor identifier occupies 4 bytes, the timestamp occupies 8 bytes, the sensor location occupies 12 bytes, and the multi-dimensional attribute values occupy 4 bytes (total number of dimensions).
[0071] In addition, after acquiring spatiotemporal data at the data acquisition layer, the validity of the acquired spatiotemporal data can be determined, valid spatiotemporal data can be retained, and invalid spatiotemporal data can be discarded.
[0072] Validity includes: timestamp validity, coordinate validity, attribute value validity, and format validity.
[0073] 1. Timestamp Validity If relevant personnel pre-set that the spatiotemporal data must be within ±24 hours of the current time, then the timestamp of the spatiotemporal data collection will be obtained. If the timestamp is within ±24 hours of the current time, the timestamp is considered valid; otherwise, the timestamp is considered invalid.
[0074] 2. Coordinate validity If the X, Y, and Z coordinates of the sensor collecting spatiotemporal data are pre-set by relevant personnel to be within a preset range (e.g., [-10000, 10000]), then the sensor position for spatiotemporal data collection will be obtained. If the X, Y, and Z coordinates of the sensor position are all within the preset range (e.g., [-10000, 10000]), then the coordinates are considered valid; otherwise, the coordinates are considered invalid.
[0075] 3. Attribute value validity If relevant personnel pre-set that each attribute value of the spatiotemporal data must be within a physically reasonable range, then each attribute value of the spatiotemporal data will be acquired. If all attribute values are within a physically reasonable range, the attribute values are considered valid; otherwise, the attribute values are considered invalid.
[0076] 4. Format validity If the frame length of the spatiotemporal data is set in advance by relevant personnel to meet expectations, then the frame length of the spatiotemporal data will be obtained. If the frame length meets expectations, the format is considered valid; otherwise, the format is considered invalid.
[0077] If any spatiotemporal data entry has invalid timestamps, coordinates, attribute values, or format, that entry will be deleted. If the number of consecutively deleted spatiotemporal data entries exceeds a preset threshold, a warning will be issued, but this will not affect subsequent data processing.
[0078] In other words, the spatiotemporal data obtained in step S101 is valid spatiotemporal data, not the original spatiotemporal data.
[0079] In addition, to ensure the processing stability and accuracy of the AI pattern discovery engine, the spatiotemporal data obtained in step S101 can be preprocessed.
[0080] Preprocessing includes, but is not limited to, normalization and window segmentation.
[0081] The normalization process can be implemented using existing processing methods.
[0082] For example, normalization is performed based on the normalization formula X_normalized = (X - X_min) / (X_max - X_min).
[0083] Where X represents the attribute value of the spatiotemporal data before normalization, X_normalized represents the attribute value of the spatiotemporal data after normalization, X_min represents the minimum value within the physically reasonable range, and X_max represents the maximum value within the physically reasonable range.
[0084] In addition, window segmentation can be based on a pre-set window size W (e.g., W represents 4 to 16 time points, with a default of 8). Spatiotemporal data collected at every W consecutive time points can be segmented into a time window according to the order of the timestamps of the spatiotemporal data acquisition.
[0085] Time window data can be used to capture the temporal dependencies of spatiotemporal data.
[0086] S102, based on AI pattern discovery, performs temporal encoding and feature extraction of spatiotemporal data.
[0087] The features include: temporal features, spatial features, semantic features, and anomaly patterns.
[0088] In practical implementation, an AI-driven engine can be used to perform temporal encoding and feature extraction of spatiotemporal data.
[0089] For example, an AI pattern discovery engine includes an input layer, a temporal encoding layer, a Transformer encoder block, and a feature projection layer. Therefore, the process of executing step S102 can be as follows: S102-1, the input layer receives a temporal tensor of shape [B, W, D].
[0090] Since the spatiotemporal data has been acquired in step S101 and then segmented into time window data, each time window data includes W spatiotemporal data with feature dimension D. The access layer initializes the batch identifier B, acquires the time window data sequentially according to time order, assigns a B to each acquired time window data, and increments B by 1. This results in a temporal tensor of shape [B, W, D], where B can be considered the sequence number of the time window data.
[0091] S102-2, the time coding layer performs time coding on each spatiotemporal data of each batch.
[0092] The implementation process of step S102-2 is as follows: S102-2-1, determine the encoding of any dimension in any spatiotemporal data in any batch.
[0093] There are multiple ways to implement step S102-2-1. Two feasible implementation schemes are illustrated below. In specific implementation, one of them can be selected.
[0094] The first feasible implementation scheme is: the encoding of any dimension in any spatiotemporal data in any batch is the basic encoding of that dimension.
[0095] The second feasible implementation scheme is: the encoding of any dimension in any spatiotemporal data in any batch is the sum of the basic encoding of that dimension and the feature adjustment value of that dimension, that is, the basic encoding of that dimension + the feature adjustment value of that dimension.
[0096] 1. Basic Coding For example, the basic encoding of the 2i-th dimension in any spatiotemporal data w in any batch is sin(w / 10000^(2i / D)), and the encoding of the 2i+1-th dimension is cos(w / 10000^(2i / D)).
[0097] Where w is the spatiotemporal data index, w=0,1, , W-1.
[0098] i is a semi-dimensional index, i=0,1 , D / 2-1.
[0099] For example, a basic encoding can be learned. That is, the basic encoding of the j-th dimension of any spatiotemporal data w in any batch is the value corresponding to the w-th row and j-th column of the random parameter matrix. The basic encoding is Embedding(random parameter matrix, j).
[0100] Where j is the dimension index, j=0,1, , D.
[0101] The random parameter matrix is obtained through pre-learning.
[0102] 2. Feature adjustment value The feature adjustment value of the j-th dimension in any spatiotemporal data w in any batch is tanh(α_j×u_j_w).
[0103] Where u_j_w is the bias of the j-th dimension feature value in any spatiotemporal data w in any batch, α_j is the weight of the j-th dimension, and tanh() is the hyperbolic tangent activation function.
[0104] α_j is determined in advance based on the original spatiotemporal data, and u_j_w is determined in advance based on the spatiotemporal data. The original spatiotemporal data here refers to the original spatiotemporal data acquired by various sensor devices, not the valid spatiotemporal data acquired in step S101.
[0105] It should be noted that in the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment, only the original spatiotemporal data obtained by various sensor devices when α_j is determined is used. The spatiotemporal data involved in other steps are all valid spatiotemporal data.
[0106] calculate (1) α_j is determined by the following steps: ① Determine the effective labeled values for each dimension in each original spatiotemporal data.
[0107] If the value of any dimension in any original spatiotemporal data meets the requirements of that dimension, its valid label value is 1; otherwise, its valid label value is 0.
[0108] For example, if relevant personnel pre-set that the value of each dimension of spatiotemporal data must be within a physically reasonable range, then the value of any dimension in any original spatiotemporal data has a valid label value of 1 if it is within its physically reasonable range, and a valid label value of 0 if it is not within its physically reasonable range.
[0109] ② For any dimension j, perform the following steps S201 to S206 to obtain α_j: S201, determine the acquisition time of each original spatiotemporal data with an effective label value of 0 for dimension j, and form a time series of dimension j in order from farthest to nearest.
[0110] Each element in the time series represents the time at which invalid raw spatiotemporal data was collected.
[0111] S202, determine the time difference between the next element and the previous element in the time series of dimension j, and form the time difference series of dimension j.
[0112] Each element in the time difference sequence represents the time difference between two consecutive acquisitions of invalid raw spatiotemporal data. The smaller the element value, the shorter the time interval between acquisitions of invalid raw spatiotemporal data.
[0113] S203, determine the standard deviation σ_j of all elements in the time difference sequence of dimension j.
[0114] The standard deviation σ_j characterizes the regularity of the time difference between two consecutive collections of invalid raw spatiotemporal data. A smaller standard deviation σ_j indicates a more regular periodicity in the time of invalid raw spatiotemporal data collection, suggesting stronger regularity. This could be due to regular interference (e.g., the same interference occurring at a fixed time each day, rendering the data collected at that fixed time for dimension j invalid). More regular data indicates higher reliability. Conversely, a larger standard deviation σ_j indicates higher randomness in the time of invalid raw spatiotemporal data collection, suggesting weaker regularity. This could be due to unpredictable random interference, and less regular data indicates lower reliability.
[0115] S204, determine the outlier E_j=n_j_1 / N_1 in dimension j.
[0116] Where n_j_1 is the number of original spatiotemporal data with a valid label value of 0 in dimension j, and N_1 is the total number of original spatiotemporal data.
[0117] The outlier E_j represents the proportion of invalid data in the original spatiotemporal data. The larger the value, the greater the possibility of invalid data in dimension j of the original spatiotemporal data, and the worse the data reliability. The smaller the value, the less likely the data in dimension j of the original spatiotemporal data is to be invalid, and the stronger the data reliability.
[0118] S205, determine the credibility of dimension j: C_j=1-[(σ_j-σ_min) / (σ_max-σ_min)] ×[(E_j-E_min) / (E_max-E_min)].
[0119] Where σ_min is the minimum standard deviation of each dimension, σ_max is the maximum standard deviation of each dimension, E_min is the minimum outlier of each dimension, and E_max is the maximum outlier of each dimension.
[0120] (σ_j-σ_min) / (σ_max-σ_min) represents the standard deviation of dimension j after normalization. It reflects the reliability of the data in dimension j from the perspective of regularity; a larger value indicates lower reliability. (E_j-E_min) / (E_max-E_min) represents the outliers of dimension j after normalization. It reflects the reliability of the data in dimension j from the perspective of invalidity probability; a larger value indicates lower reliability. [(σ_j-σ_min) / (σ_max-σ_min)] × [(E_j-E_min) / (E_max-E_min)] comprehensively reflects the reliability of the data in dimension j in the original spatiotemporal data from both reliability and invalidity probability perspectives; a larger value indicates lower reliability. The larger [(σ_j-σ_min) / (σ_max-σ_min)] × [(E_j-E_min) / (E_max-E_min)] is, the smaller 1-[(σ_j-σ_min) / (σ_max-σ_min)]×[(E_j-E_min) / (E_max-E_min)] is, the smaller C_j is. In other words, the smaller C_j is, the lower the reliability and credibility. Therefore, C_j reflects the credibility of the data in dimension j in the original spatiotemporal data. The larger this value is, the higher the credibility.
[0121] S206, determine α_j=e^[(C_j-C_max) / ∑ j (e^(C_j-C_max))).
[0122] Where C_max is the maximum value of the credibility of each dimension.
[0123] The larger C_j is, the higher the data feasibility of dimension j, and therefore its weight will also be larger, so α_j is larger.
[0124] (2) u_j_w is determined through the following steps: ① Obtain the value of the j-th dimension x_j_w in any spatiotemporal data w from any batch.
[0125] The spatiotemporal data here is valid.
[0126] ② If the j-th dimension is a numerical value, then u_j_w = softmax{(x_j_w - μ_j) / γ_j}. If the j-th dimension is a non-numerical value, then u_j_w = softmax{-log(n_j_2 / N_2)}.
[0127] Where softmax{} is the normalization function, μ_j is the mean of the j-th dimension values in all spatiotemporal data, and γ_j is the standard deviation of the j-th dimension values in all spatiotemporal data.
[0128] n_j_2 represents the number of spatiotemporal data points in the j-th dimension that are similar to x_j_w, and N_2 represents the total number of spatiotemporal data points.
[0129] Similar spatiotemporal data can be determined by distance. For example, a distance threshold can be pre-set, and the distance between x_j_w and the value of the j-th dimension in other spatiotemporal data (such as Euclidean distance or Manhattan distance) can be calculated. Other spatiotemporal data with a distance less than the distance threshold are considered similar spatiotemporal data. The number of other spatiotemporal data with a distance less than the distance threshold is n_j_2.
[0130] For numerical data, the larger the softmax{(x_j_w-μ_j) / γ_j}, the greater the difference between x_j_w and the mean of the j-th dimension of all spatiotemporal data in that batch, indicating that x_j_w is more anomalous. For non-numerical data, the larger the n_j_2 / N_2, the more similar the j-th dimension values of all spatiotemporal data are to x_j_w, indicating a lower degree of anomalousness in x_j_w. Furthermore, the larger the n_j_2 / N_2, the smaller the softmax{-log(n_j_2 / N_2)} value; therefore, the larger the softmax{-log(n_j_2 / N_2)}, the more anomalous x_j_w is. Thus, regardless of the type of the j-th dimension value, the larger u_j_w is, the more anomalous the j-th dimension value of any spatiotemporal data w in any batch is compared to the j-th dimension values of other spatiotemporal data in that batch.
[0131] In this way, tanh(α_j×u_j_w) reflects the overall reliability of the j-th dimension data and the anomalies of the data relative to other data, as well as the anomalies of the j-th dimension feature value in any spatiotemporal data w in any batch. The resulting encoding can integrate absolute time and data state, reflecting not only when the spatiotemporal data was collected, but also whether the j-th dimension feature value of the spatiotemporal data is obviously abnormal. The encoding can reflect the degree of anomaly of the j-th dimension feature value that actually occurred at a certain point in time.
[0132] S102-2-2 constructs a time encoding vector for any spatiotemporal data in any batch by encoding each dimension.
[0133] Step S102-2-1 determines the encoding of each dimension in any spatiotemporal data in any batch. In step S102-2-2, the corresponding encodings are arranged in dimensional order to form an encoding vector, thus obtaining the time encoding vector of any spatiotemporal data in any batch.
[0134] S102-3, the Transformer encoder block extracts features from each batch of spatiotemporal data.
[0135] The implementation process of step S102-3 is as follows: S102-3-1, the Transformer encoder block determines the characteristics of each spatiotemporal data in each batch.
[0136] For example, the Transformer encoder block uses a multi-head self-attention mechanism and a feedforward neural network to capture the long-distance dependencies and global contextual relationships between different time steps within any batch of spatiotemporal data, obtaining the features Z = Transformer_Encoder(X_pos) for each spatiotemporal data. Where Z ∈ ^(W×D_hidden), Let D be the set of real numbers, and D_hidden be the dimension of the hidden layer of the Transformer, that is, the dimension of the high-dimensional feature space inside the Transformer.
[0137] S102-3-2, Determine the overall characteristics of each batch based on the characteristics of each spatiotemporal data.
[0138] For example, global pooling is used to aggregate temporal dimension information to obtain the overall features of each batch. In this process, the features of all spatiotemporal data in each batch are aggregated into a single feature vector to obtain the overall features of that batch.
[0139] For example, the overall characteristic of any batch is F = Global_Average_Pool(Z), where F ∈ ^(D_hidden). Let D be the set of real numbers, and D_hidden be the dimension of the hidden layer, which is the dimension of the deep abstract features inside the Transformer.
[0140] F is the overall feature vector, which discards the specific temporal order but retains the global semantic information of the entire sequence. Unlike fully connected layers, it does not need to learn a large number of parameters and can effectively prevent overfitting.
[0141] 102-4, Feature Projection Layer The feature projection layer is used to project the features of each spatiotemporal data in each batch and the overall features of each batch to obtain the extracted features.
[0142] For example, the extracted feature F_out = W_proj × F.
[0143] Where F_out ∈ ^(D_feature), where D_feature is the dimension of the extracted feature, such as D_feature=128. W_proj is the learnable weight matrix.
[0144] This step uses AI pattern discovery to perform temporal encoding and feature extraction of spatiotemporal data because traditional methods (such as PCA and SVD) can only capture linear correlations and cannot handle complex nonlinear time series patterns. The AI pattern discovery of the Transformer architecture can (1) capture long-distance dependencies in time series; (2) identify nonlinear data patterns; (3) automatically learn the feature representation best suited to the current data; and (4) adapt to changes in data distribution through online learning.
[0145] S103, determine the codeword index based on the codebook and the extracted features.
[0146] The codebook is divided into multiple layers, each containing A^(1 / L) cluster centers.
[0147] Where A is the total number of codewords and L is the total number of layers. Additionally, the cluster boundaries for each layer can be pre-calculated.
[0148] The codebook is managed by the codebook management module.
[0149] The codebook design principles are: 1. Representativeness principle: Codewords should cover the main areas of data distribution and avoid codewords clustering in a few areas.
[0150] 2. Principle of uniformity: The frequency of use of each codeword should be as even as possible to avoid some codewords never being used.
[0151] 3. Separation principle: There should be sufficient distance between adjacent code words to avoid code word overlap.
[0152] The codebook training process is as follows: ① Randomly select the first character.
[0153] ② Calculate the distance D(a) from each sample to the nearest codeword (e.g., Euclidean distance).
[0154] ③ Select the next codeword with probability D(a)² / ΣD(a)².
[0155] ④ Repeat steps ②-③ until A codewords are selected.
[0156] ⑤ Use K-Means to optimize codeword positions.
[0157] Step S103 can map a vector in a high-dimensional space to a codeword in a finite codebook.
[0158] Let the codebook be {c_1, c_2, ..., c_A}, where c_a ∈ ^ D_feature.
[0159] For the input vector F_out ∈ ^(D_feature), and the quantization process is as follows: q(F_out) = c_idx, where idx = argmin_a d(F_out, c_a).
[0160] d(F_out, c_a) is a distance metric function, and the distance may be Euclidean distance.
[0161] argmin_a d(F_out, c_a) can obtain an index a when d(F_out, c_a) is the minimum.
[0162] An error of the foregoing process is ||F_out - q(F_out)||².
[0163] The step S103 may be implemented by a vector quantization module of the hybrid encoder, and an implementation process of the step S103 is as follows: S103-1. Initialize a search index f=1, and determine all cluster centers at a first layer as current cluster centers.
[0164] S103-2. Determine a distance between a feature vector formed by extracted features and the current cluster centers.
[0165] The distance may be Euclidean distance, cosine similarity, Manhattan distance, or the like.
[0166] During specific implementation, if the features are normalized features, the distance may be cosine similarity; and if the features are unnormalized features, the distance may be Euclidean distance.
[0167] S103-3. If f=L, it indicates that a current layer is a last layer, and then one cluster center with a minimum distance is selected, and an index corresponding to the selected cluster center is determined as a codeword index. If f<L, it indicates that the current layer is not the last layer, and then a plurality of cluster centers with minimum distances are selected, f=f+1, cluster centers corresponding to the selected cluster centers at an f-th layer are determined as the current cluster centers, and the step of determining the distance between the feature vector formed by the extracted features and the current cluster centers is re-executed (that is, the step S103-2 and the step S103-3 are re-executed).
[0168] If the feature vector formed by the extracted features is F_out, in the step S103, for f=1 to L: a distance between F_out and all cluster centers at the current layer is calculated, top FM cluster centers with minimum distances are selected, next-layer search is continued among the selected cluster centers, ... a codeword with a minimum distance is selected in a final layer, return the index of the codeword.
[0169] If L = 2 (i.e., two-level search), A = 4096 (total number of codewords), and FM = 10 (cluster centers selected at each level), then the complexity of the codeword index determination process is: Original full search: O(A) distance calculations.
[0170] Hierarchical search: O(2 × A^0.5) ≈ O(128) distance calculations.
[0171] Speedup ratio: 32x.
[0172] S104, determine the residual code based on the codeword index.
[0173] Residual encoding includes residual length and residual data. Step S104 can be implemented by the residual calculation module of the hybrid encoder, and the implementation process is as follows: S104-1, determine the residual vector R=F_out-c_idx.
[0174] Where F_out is the feature vector formed by the extracted features, and c_idx is the codeword corresponding to the codeword index.
[0175] F_out ∈ ^(D_feature), c_idx ∈ ^(D_feature), R ∈ ^(D_feature).
[0176] The residual vector R represents the difference between the extracted feature F_out and the best-matching codeword c_idx. This difference reflects two aspects: first, the degree of deviation of the input data from the typical pattern; and second, the instantaneous change of the current time relative to the historical pattern.
[0177] If the data perfectly matches the known pattern, then R ≈ 0; if the data deviates slightly from the pattern, then R is small; if the data deviates significantly from the pattern, then R is large.
[0178] S104-2, Determine the residual code based on the residual vector.
[0179] Since residual encoding includes residual length and residual data, the residual length is the length of the residual data. The residual data is determined in one of the following ways: 1. Zero residual coding If |R| < ε1, then the residual is zero, and the residual data is determined to be 0.
[0180] Where ε1 is a pre-set residual threshold, such as ε1 = 0.001.
[0181] The residual data only requires 1 flag bit "0", and its storage overhead is 1 bit, meaning the residual length is 1.
[0182] This approach is suitable for scenarios where patterns are highly matched and data changes are minimal.
[0183] 2. If |R| < 2 × ε², it is a small residual, and Huffman coding is performed, i.e., the residual data is determined based on the Huffman table. If 2 × ε² ≤ |R| < 4 × ε², it is a medium residual, and fixed-point quantization coding is performed, i.e., |R| is scaled to the range [0, 255] and converted into a multi-bit unsigned integer, and a range flag is added to obtain the residual data. The number of bits of the unsigned integer is 4 to 12 bits, which can be pre-configured. If |R| ≥ 4 × ε², it is a large residual, and floating-point storage is performed, i.e., a large residual flag is added to |R| to obtain the residual data.
[0184] Where ε2 is the pre-set residual standard deviation.
[0185] (1) The process of determining residual data based on Huffman table is as follows: use pre-trained Huffman table to entropy encode each dimension of residual.
[0186] This process supports incremental updates of the encoded probability.
[0187] Storage overhead for residual data: 2~4 bits / dimension, i.e., residual length is 2~4.
[0188] This method is suitable for scenarios with small fluctuations and data close to codewords.
[0189] (2) The process of scaling |R| to the range [0, 255], converting it to a multi-bit unsigned integer, and adding a range flag to obtain the residual data is as follows: If the pre-configured unsigned integer has 8 bits, then after scaling |R| to the range of [0, 255], it is converted into an 8-bit unsigned integer, and a range flag is added to obtain the residual data.
[0190] Storage overhead for residual data: 6~8 bits / dimension, i.e., residual length is 6~8.
[0191] This method is suitable for scenarios with moderate variation and requiring a certain level of precision.
[0192] (3) The process of obtaining residual data after adding a large residual flag to |R| is as follows: directly store the floating-point representation of |R| and add a large residual flag.
[0193] The floating-point representation of |R| is in IEEE 754 single-precision floating-point format and is stored as a 32-bit floating-point number.
[0194] Suitable for scenarios with large deviations that require high-precision preservation.
[0195] In practical implementation, it can be based on Figure 4 The residual encoder state machine shown performs residual encoding.
[0196] The necessity of storing residuals: - Vector quantization loses some detailed information; - Residual storage can recover these details; - The smaller the residual, the lower the storage overhead.
[0197] The relationship between residual and compression ratio is as follows: If F_out is 128 dimensions × 4 bytes = 512 bytes, the residual length is 2 bytes, and the average residual data is 4.4 bytes, then the total storage is 6.4 bytes, and the compression ratio is 512 / 6.4 ≈ 80:1. Furthermore, this storage method can retain reconstruction capabilities.
[0198] Residual storage requires only a small amount of additional storage (average 4.4 bytes) to significantly improve reconstruction quality (PSNR increases from 28dB to 43dB), and adaptive encoding ensures optimal efficiency, requiring only 1 bit for zero residual cases, with minimal additional overhead.
[0199] The compression ratio of this embodiment is much higher than that of traditional compression methods.
[0200] The residual distribution and coding strategy in this embodiment can be as follows: Figure 5 As shown.
[0201] For a typical sensor data residual distribution, if the test dataset is weather station sensor data (1 month), the residual statistics are shown in Table 5.
[0202] Table 5
[0203] The residual quantile distribution is shown in Table 6.
[0204] Figure 6
[0205] The distribution of encoding types is shown in Table 7.
[0206] Table 7
[0207] The encoding parameters are adaptively adjusted, such as by using the formula ε2=sqrt((1 / N_4) × Σ(R_r – μ_r)²) to calculate the adaptive threshold (i.e. ε2), where N_4 is the number of samples involved in the adjustment, r is the index of the sample involved in the adjustment, R_r is the residual vector of the r-th sample involved in the adjustment, and μ_r is the mean of all samples involved in the adjustment.
[0208] The rule for calculating the adaptive threshold (i.e., ε2) is as follows: 1. Recalculate the threshold (i.e., ε2) after processing every 1000 records.
[0209] 2. If the change in ε2 exceeds 20%, update the threshold (i.e., ε2).
[0210] 3. Changes in the threshold (i.e., ε2) are recorded in the log.
[0211] 4. Supports manual threshold locking (i.e., ε2).
[0212] S105, compresses the time encoding, codeword index, residual encoding and quality mark into spatiotemporal data, and stores the compressed data.
[0213] In this context, quality tags refer to metadata labels used to assess and record the "reliability," "fidelity," or "degree of information loss" of the compressed data. Quality tags are determined based on spatiotemporal data.
[0214] The quality flag can be determined based on factors such as the compression ratio, quantization error, residual size, and bitrate allocation of the spatiotemporal data during compression. For example, a quality flag of 0 indicates lossless mode.
[0215] The storage record assembly format for compressed data can be as follows: Figure 6 and / or Figure 7 As shown, Figure 6 or Figure 7 The residual length and residual data in the code are called residual codes.
[0216] Taking a single spatiotemporal data point as an example, where the sensor identifier occupies 4 bytes, the timestamp occupies 8 bytes, the sensor location occupies 12 bytes, and the multi-dimensional attribute values occupy 128 bytes, totaling 152 bytes, the average overhead of the compressed data is: Basic overhead: 7 bytes (4 bytes for time encoding + 2 bytes for codeword index + 1 byte for quality mark).
[0217] Residual overhead: 4.4 bytes (based on distribution statistics).
[0218] Total: 11.4 bytes.
[0219] Storage efficiency = Original data size / Compressed data size = 152 / 11.4 ≈ 13:1.
[0220] Extreme case analysis: 1. Best case (70% zero residual): Compressed size: 8 bytes.
[0221] Compression ratio: 152 / 8 ≈ 19:1.
[0222] 2. Worst-case scenario (5% residual): Compressed size: 24 bytes.
[0223] Compression ratio: 152 / 24 ≈ 6.3:1 3. Pure vector quantization (no residual): Compressed size: 8 bytes.
[0224] Compression ratio: 152 / 8 ≈ 19:1.
[0225] However, this will result in a loss of reconstruction accuracy.
[0226] After executing step S105, the stored compressed data will also be managed. For example, storage management policies: 1. Circular overwrite strategy: When storage space is insufficient, overwrite the oldest data; retain data from the most recent days.
[0227] 2. Tiered storage strategy: Hot data: Memory / SSD.
[0228] Warm data: ordinary hard drive.
[0229] Cold data: cloud storage.
[0230] 3. Compress the data before storing it. Compress the data again before storing it to save storage space.
[0231] After executing step S105, data decompression and reconstruction can be performed. The data decompression and reconstruction process is as follows: 1. Compressed data reading (1) Batch reading: Read multiple compressed data at a time to reduce the number of I / O operations.
[0232] (2) Prefetching mechanism: Prefetch adjacent compressed data according to the access mode.
[0233] (3) Cache management: Hot compressed data is cached in memory.
[0234] 2. Compressed data parsing (1) Check the integrity of the records (length check).
[0235] (2) Extract the values of each field.
[0236] (3) Validate the validity of the fields.
[0237] (4) Convert byte order (if necessary).
[0238] 3. Code recovery Lookup process: Codeword = Codebook [Codeword Index] Example (Python pseudocode): def get_codeword(codebook, index): return codebook.codewords[index] This process can use contiguous memory to store codewords, utilize CPU cache prefetching, and accelerate vector operations using SIMD (Single Instruction, Multiple Data) instructions.
[0239] 4. Residual Decoding It is possible Figure 8 The decoder state machine implementation is shown.
[0240] 5. Feature Reconstruction and Data Restoration Feature reconstruction can be performed using the formula F' = c_idx + R.
[0241] Where F' is the reconstructed feature vector, c_idx is the codeword corresponding to the codeword index, and R is the residual vector.
[0242] Data is restored using the formula X' = Decoder(F').
[0243] Where Decoder is a decoder neural network, and X' is the reconstructed spatiotemporal data.
[0244] The architecture of a decoder neural network includes: an input layer, a feature expansion layer, a temporal reconstruction layer, a Transformer decoder block, and an output projection layer.
[0245] (1) Input layer Input shape: [B, D_feature]. For example, B=1, D_feature=128.
[0246] (2) Feature expansion layer Fully connected layers can be extended from D-feature dimensions to higher-dimensional features (e.g., 128 → 256).
[0247] The activation function is ReLU, and the dropout rate is 0.1.
[0248] (3) Time reconstruction layer Expand a single feature vector into a time series and copy the feature W times (W is the window size).
[0249] (4) Transformer decoder block (×1 layer) The attention mechanism can be cross-attention (optional, corresponding to the Transformer encoder block).
[0250] (5) Output projection layer Fully connected layer: 256 → Raw_Feature_Dim×W.
[0251] Activation function: None (linear output).
[0252] The output can be converted back to the original data range through the denormalization process.
[0253] If the reconstruction quality is evaluated using N_3 sample data, the evaluation process is as follows: 1. Point-by-point error Mean absolute error MAE = (1 / N_3) × Σ|X_h - X'_h|.
[0254] The root mean square error (RMSE) is calculated as: ((1 / N_3) × Σ(X_h - X'_h)²)^0.5.
[0255] Where h is the sample data index, X_h is the original value of the h-th sample data, and X'_h is the reconstructed value of the h-th sample data.
[0256] 2. Relative error Mean absolute percentage error MAPE = (100 / N_3) × Σ|X_i - X'_i| / |X_i|.
[0257] 3. Structural similarity Structural similarity SSIM = (2μ_Xμ_X' + C1)(2σ_XX' + C2) / (μ_X² + μ_X'²)(σ_X² +σ_X'²).
[0258] Where μ_X is the mean of the original values of all sample data, and μ_X' is the mean of the reconstructed values of all sample data. C1 is the mean compensation value, used to avoid μ_X and μ_X' being both 0.
[0259] σ_XX' is the covariance between the original and reconstructed values of the sample data, and C2 is the covariance compensation value to avoid σ_XX' being 0.
[0260] σ_X is the standard deviation of the original values of the sample data, and σ_X' is the standard deviation of the reconstructed values of the sample data.
[0261] If MAE: <0.01 (after normalization), RMSE: <0.02 (after normalization), MAPE: <0.1, and SSIM: >0.95, then the reconstruction quality meets the requirements.
[0262] In practical implementation, an index file can also be created, and the structure of the index file can be as follows: Figure 9 As shown.
[0263] The spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment is compared with existing methods in terms of technical solutions. Figure 10 As shown, the quantitative comparison of compression performance is as follows: Figure 11 As shown in Table 8, the functional characteristics are compared, and the advantages are compared, as shown in Table 9.
[0264] Table 8
[0265] Table 9
[0266] The application scenario deployment architecture of the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment is as follows: Figure 12 As shown.
[0267] The following example, using an ecological environment monitoring station, illustrates the practical application of the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment.
[0268] Sensor equipment is configured at the monitoring station: - Types of sensor devices: soil temperature and humidity, air temperature and humidity, light intensity, CO2 concentration.
[0269] - Data collection frequency: 1 time / minute.
[0270] - Number of sensor devices: 10 sensor devices / monitoring stations.
[0271] - Data dimensions: Each sensor device. 4~8 dimensions. Data traffic calculation: - Raw spatiotemporal data: 10 × 8 dimensions × 4 bytes × 60 times / hour = 19.2KB / hour.
[0272] - After compression using the spatiotemporal data vector compression storage method based on AI pattern discovery provided in this embodiment: 19.2KB / hour × (1 / 12) ≈ 1.6KB / hour.
[0273] - Monthly storage requirement: Approximately 1.1MB (compressed).
[0274] The data acquisition layer is located at the edge gateway: Raw spatiotemporal data acquired by various sensor devices are aggregated to the edge gateway.
[0275] - Number of monitoring stations connected: 100.
[0276] - Data aggregation frequency: Real-time.
[0277] - Local storage capacity: 16GB.
[0278] - Network bandwidth: 4G (average 10Mbps).
[0279] After the data from each monitoring station is aggregated to the edge gateway via 4G, the edge gateway compresses and stores the data using the spatiotemporal data vector compression storage method based on AI mode discovery provided in this embodiment. The compressed data is stored on a local SSD and periodically synchronized to the cloud.
[0280] The bandwidth situation during this process is as follows: - Bandwidth requirement for raw out-of-control data: 100 stations × 19.2KB / hour = 1.92MB / hour ≈ 5.3Kbps.
[0281] - Bandwidth requirement after compression: 100 stations × 1.6KB / hour = 160KB / hour ≈ 0.4Kbps.
[0282] - Savings percentage: 92%.
[0283] Local storage status: - Daily data volume: 160KB × 24 = 3.84MB.
[0284] - Monthly data volume: approximately 115MB.
[0285] - 16GB of storage can retain approximately 11 years of data.
[0286] Furthermore, the end-to-end joint training framework in this example can be as follows: Figure 13 As shown, the training process is as follows: 1. Training data preparation Data collection requirements: (1) Data volume: at least 100,000 records (the more the better); (2) Data diversity: covering various working conditions and scenarios; (3) Data quality: No obvious errors or missing data; (4) Time span: Covering at least one complete cycle (e.g., one year).
[0287] Data preprocessing workflow: (1) Data cleaning - Remove outliers (those exceeding 3 standard deviations); - Fill in missing values (linear interpolation); - Remove duplicate records.
[0288] (2) Data labeling - No manual annotation required (self-supervised learning); - Automatically organizes data based on time continuity.
[0289] (3) Data partitioning - Training set: 70%; - Validation set: 15%; - Test set: 15%.
[0290] (4) Data augmentation - Time window jitter; - Add noise; - Random occlusion.
[0291] (5) Loss function design Multi-objective loss function: L_total = α × L_reconstruction + β × L_codebook + γ × L_quantization Where L_reconstruction is the reconstruction loss, L_codebook is the codebook distribution loss, and L_quantization is the quantization consistency loss.
[0292] ① Reconstruction loss L_reconstruction L_reconstruction = || X_h - X'_h ||1 or L_rec = || X_h - X'_h ||²2 The reconstruction loss L_reconstruction is used to ensure that the decoded data is as close as possible to the original data.
[0293] α is the weight of the reconstruction loss L_reconstruction, such as α = 1.0.
[0294] ② Codebook distribution loss L_codebook L_codebook = -Σ p_a × log(p_a) / log(A).
[0295] Where p_a is the frequency of use of the z-th codeword.
[0296] L_codebook is used to ensure balanced codebook usage and prevent certain codewords from being never used.
[0297] β is the weight of the codebook distribution loss L_codebook, such as β = 0.1.
[0298] ③ Quantization Consistency Loss L_quantization L_quantization = ||sg[F_out] - c_idx||²2 Here, sg[] is the stop gradient operation.
[0299] The quantization consistency loss L_quantization is used to ensure that the quantization process is differentiable and supports end-to-end training.
[0300] γ is the weight of the quantization consistency loss L_quantization, such as γ = 1.0.
[0301] The gradient update strategy for both the encoder and decoder is normal gradient update.
[0302] The codebook is updated using the EMA (Exponential Moving Average) update strategy.
[0303] The codebook online update process is as follows: Online update trigger condition: If the mean residual of multiple consecutive records (e.g., 100 records) is greater than the mean threshold (e.g., 0.1), then the codebook update is triggered.
[0304] # Moving average update c_idx_new = (1 - lr) × c_idx_old + lr × F_new.
[0305] Where: lr is the learning rate, such as lr = 0.01 (configurable). c_idx_old is the original codeword, c_idx_new is the new codeword, and F_new is the new feature vector.
[0306] Update restrictions: - Only update the codewords that are currently in use; - The update size should not exceed 20% of the original value; - After the update, the reconstruction quality was verified to be unaffected.
[0307] The spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment has an ultra-high compression ratio (up to 50:1), strong adaptive capability (online learning), can minimize residual overhead (70% of data has zero residual), and supports lossy / lossless switching. It is hardware-friendly and suitable for edge deployment.
[0308] In addition, the spatiotemporal data vector compression and storage method based on AI pattern discovery provided in this embodiment uses full-precision encoding of residuals in lossless mode, and stores the codebook and model parameters separately without participating in compression to ensure the reversibility of compression.
[0309] This embodiment provides a spatiotemporal data vector compression and storage method based on AI pattern discovery. The method acquires spatiotemporal data, which is collected by at least one sensor device. It performs time encoding and feature extraction of the spatiotemporal data based on AI pattern discovery. The features include temporal features, spatial features, semantic features, and anomaly patterns. A codeword index is determined based on the codebook and the extracted features. A residual code is determined based on the codeword index. The time encoding, codeword index, residual code, and quality marker are combined to form compressed spatiotemporal data, which is then stored. The quality marker is determined based on the spatiotemporal data. This method, when processing high-dimensional spatiotemporal data, considers the inherent temporal and spatial correlations of the data, reducing the computational overhead during decompression and meeting the needs of large-scale real-time data processing.
[0310] Since the systems / devices described in the above embodiments of the present invention are systems / devices used to implement the methods of the above embodiments of the present invention, those skilled in the art can understand the specific structure and modifications of the systems / devices based on the methods described in the above embodiments of the present invention, and therefore will not be repeated here. All systems / devices used in the methods of the above embodiments of the present invention fall within the scope of protection of the present invention.
[0311] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0312] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions.
[0313] It should be noted that any reference numerals placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In claims that enumerate several means, several of these means may be embodied by the same hardware. The use of the terms first, second, third, etc., is merely for convenience of expression and does not indicate any order. These terms can be understood as part of the component names.
[0314] Furthermore, it should be noted that in the description of this specification, the terms "one embodiment," "some embodiments," "embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0315] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the claims should be interpreted to include both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0316] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, then this invention should also include these modifications and variations.
Claims
1. A spatiotemporal data vector compression and storage method based on AI pattern discovery, characterized in that, The method includes: S101, acquiring spatiotemporal data; wherein the spatiotemporal data is collected by at least one sensor device; S102, performing temporal encoding and feature extraction on the spatiotemporal data based on AI pattern discovery; wherein the features include: temporal features, spatial features, semantic features, and anomaly patterns; S103, determining a codeword index according to a codebook and the extracted features; S104, determining a residual code according to the codeword index; S105, forming compressed data of the spatiotemporal data from the temporal encoding, the codeword index, the residual code, and a quality flag, and storing the compressed data; wherein the quality flag is determined according to the spatiotemporal data.
2. The method according to claim 1, characterized in that, The S102 includes: performing temporal encoding and feature extraction on the spatiotemporal data through an AI pattern discovery engine; wherein the AI pattern discovery engine includes: an input layer, a temporal encoding layer, a Transformer encoder block, and a feature projection layer; the input layer is configured to receive a temporal tensor with a shape of [B, W, D]; wherein the temporal tensor is formed by splitting the spatiotemporal data according to windows; B is the number of data samples per batch, W is the window size, and D is the feature dimension of the spatiotemporal data; the temporal encoding layer is configured to perform temporal encoding on each spatiotemporal data in each batch; the Transformer encoder block is configured to determine features of each spatiotemporal data in each batch, and determine an overall feature of each batch according to the features of each spatiotemporal data; the feature projection layer is configured to project the features of each spatiotemporal data in each batch and the overall feature of each batch, to obtain the extracted features.
3. The method according to claim 2, characterized in that, Performing temporal encoding on each spatiotemporal data in each batch includes: determining an encoding of any dimension in any spatiotemporal data in any batch; wherein the encoding of any dimension in any spatiotemporal data in any batch is a base encoding of the dimension, or a sum of the base encoding of the dimension and a feature adjustment value of the dimension; forming a temporal encoding vector of any spatiotemporal data in any batch from the encoding of each dimension; In any batch of spatiotemporal data w, the basic encoding of the 2i-th dimension is sin(w / 10000^(2i / D)), and the encoding of the 2i+1-th dimension is cos(w / 10000^(2i / D)); w is the spatiotemporal data index, w=0,1, W-1; i is the semi-dimensional index, i=0,1, , D / 2-1; Alternatively, the basic encoding of the j-th dimension in any spatiotemporal data w within any batch is the value corresponding to the j-th row and column of the random parameter matrix; j is the dimension index, j=0,1, D; the random parameter matrix is obtained through pre-learning.
4. The method according to claim 1, characterized in that, The spatiotemporal data includes: a collected timestamp, a collected sensor identifier, a collected sensor position, and multi-dimensional attribute values; wherein the collected sensor identifier occupies 4 bytes, the collected timestamp occupies 8 bytes, the collected sensor position occupies 12 bytes, and the multi-dimensional attribute values occupy a total number of dimensions × 4 bytes.
5. The method according to claim 1, characterized in that, The codebook is divided into multiple layers, each layer includes A^(1 / L) clustering centers; wherein A is the total number of codewords; L is the total number of layers; The S103 includes: initializing a search index f=1, and determining all clustering centers in a first layer as current clustering centers; determining a distance between a feature vector formed by the extracted features and the current clustering centers; if f=L, selecting one clustering center with the smallest distance, and determining an index corresponding to the selected clustering center as the codeword index; if f<L, selecting multiple clustering centers with the smallest distances, setting f=f+1, determining clustering centers corresponding to the selected clustering centers in an f-th layer as the current clustering centers, and re-executing the step of determining the distance between the feature vector formed by the extracted features and the current clustering centers.
6. The method according to claim 1, characterized in that, The S104 includes: Determine the residual vector R = F_out - c_idx; where F_out is the feature vector formed by the extracted features, and c_idx is the codeword corresponding to the codeword index; The residual code is determined based on the residual vector.
7. The method according to claim 6, characterized in that, The residual encoding includes residual length and residual data; The residual data is determined in one of the following ways: If |R| < ε1, then the residual data is determined to be 0; where ε1 is a pre-set residual threshold. If |R| < 2 × ε2, the residual data is determined based on the Huffman table; where ε2 is the pre-set residual standard deviation; if 2 × ε2 ≤ |R| < 4 × ε2, |R| is scaled to the range [0, 255] and converted into a multi-digit unsigned integer, and a range flag is added to obtain the residual data; if |R| ≥ 4 × ε2, a large residual flag is added to |R| to obtain the residual data.
8. The method according to claim 3, characterized in that, The feature adjustment value of the j-th dimension in any spatiotemporal data w in any batch is tanh(α_j×u_j_w); Where u_j_w is the bias of the j-th dimension feature value in any spatiotemporal data w in any batch, α_j is the weight of the j-th dimension, and tanh() is the hyperbolic tangent activation function; α_j is determined in advance based on the original spatiotemporal data, and u_j_w is determined in advance based on the spatiotemporal data.
9. The method according to claim 8, characterized in that, α_j is determined through the following steps: Determine the valid label values for each dimension in each original spatiotemporal data; where, if the value of any dimension in any original spatiotemporal data meets the requirements of that dimension, its valid label value is 1, otherwise the valid label value is 0; For any dimension j, perform the following steps S201 to S206 to obtain α_j: S201, determine the acquisition time of each original spatiotemporal data with an effective label value of 0 for dimension j, and form a time series of dimension j in order from farthest to nearest; S202, determine the time difference between the next element and the previous element in the time series of dimension j, and form the time difference series of dimension j; S203, determine the standard deviation σ_j of all elements in the time difference sequence of dimension j; S204, determine the outlier E_j=n_j_1 / N_1 for dimension j; where n_j_1 is the number of original spatiotemporal data with valid labeled values of 0 for dimension j, and N_1 is the total number of original spatiotemporal data. S205, determine the credibility of dimension j: C_j = 1 - [(σ_j - σ_min) / (σ_max - σ_min)] × [(E_j - E_min) / (E_max - E_min)]; Where σ_min is the minimum standard deviation of each dimension, σ_max is the maximum standard deviation of each dimension, E_min is the minimum outlier of each dimension, and E_max is the maximum outlier of each dimension. S206, determine α_j=e^[(C_j-C_max) / ∑ j (e^(C_j-C_max))]; Where C_max is the maximum value of the credibility of each dimension.
10. The method according to claim 8, characterized in that, u_j_w is determined through the following steps: Get the value of the j-th dimension x_j_w in any spatiotemporal data w from any batch; If the j-th dimension is a numerical value, then u_j_w = softmax{(x_j_w-μ_j) / γ_j} is determined, where softmax{} is the normalization function, μ_j is the mean of the j-th dimension values in all spatiotemporal data, and γ_j is the standard deviation of the j-th dimension values in all spatiotemporal data. If the j-th dimension is a non-numerical value, then u_j_w = softmax{-log(n_j_2 / N_2)} is determined, where n_j_2 is the number of spatiotemporal data points in all spatiotemporal data points whose j-th dimension values are similar to x_j_w, and N_2 is the total number of all spatiotemporal data points.
