A community multi-task prediction method based on space-time features and related equipment
By acquiring observational data and spatiotemporal characteristics of community scenarios, and utilizing a multi-head cross-attention model and a rolling adaptation scheme, a multi-task prediction model for smart communities is constructed. This solves the problems of data silos and poor generalization ability in smart community systems, and achieves more efficient multi-task collaborative prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- E-SURFING DIGITAL LIFE TECH CO LTD
- Filing Date
- 2025-11-13
- Publication Date
- 2026-08-04
AI Technical Summary
Existing smart community systems lack multi-task collaborative analysis capabilities, resulting in low data utilization, delayed decision-making, and difficulty in meeting the needs for real-time and precise management.
By acquiring observational data, spatial features, and temporal features of the target community scenario, an interaction feature is constructed using a multi-head cross-attention model, and commonalities between tasks are extracted through a rolling adaptation scheme to build a prediction model.
It enables the integration and collaborative analysis of multi-source data, improves data utilization, supports more real-time and accurate predictive decision-making, and adapts to new community environments and data distributions.
Smart Images

Figure CN121502666B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a community multi-task prediction method and related equipment based on spatiotemporal characteristics. Background Technology
[0002] With the deepening of smart city construction, the level of intelligence in communities, as the basic unit of the city, directly affects residents' quality of life and urban management efficiency. Currently, smart community systems have made some progress in areas such as security monitoring, energy consumption management, vehicle management, and service recommendation. However, each functional module usually operates independently, lacking collaborative analysis and multi-task joint prediction capabilities, resulting in low data utilization, delayed decision-making, and difficulty in meeting the needs of real-time and precise management.
[0003] Traditional predictive models are often designed for specific scenarios (such as pedestrian flow prediction, security early warning, or energy consumption prediction) and are built independently. This not only results in computational redundancy but also makes it difficult to uncover potential correlations between cross-domain data, leading to low data utilization and poor generalization ability. For example, changes in community pedestrian flow may simultaneously affect public safety, elevator scheduling, and energy consumption, but existing systems cannot achieve multi-task collaborative optimization. Furthermore, because community systems are typically dynamic, multi-source, and have unevenly distributed data, models designed for specific tasks cannot generalize to new community environments or adapt to new domains without clearly modeling the interdependencies between various dimensions and types of data, thus isolating the models. Summary of the Invention
[0004] The main objective of this invention is to propose a community multi-task prediction method, device, electronic device, storage medium, and program product based on spatiotemporal characteristics, aiming to solve at least one problem of the prior art.
[0005] To achieve the above objectives, one aspect of this invention proposes a community multi-task prediction method based on spatiotemporal features, the method comprising: The main observation data and associated spatiotemporal index data of the target in the target community scenario are obtained, and the first input features are obtained through preprocessing; wherein, the first input features include observation features, spatial features and temporal features; Based on the known main observation data of each task, a task prompt is constructed. The task prompt is then concatenated with the first input feature of the corresponding task to obtain the second input feature of each task. Based on the second input feature, an interaction feature is constructed through a multi-head cross-attention model. The interaction feature is then superimposed on the second input feature to perform spatiotemporal self-interaction, resulting in a third input feature to determine the training dataset for each task. The interaction feature includes a first interaction feature between spatial features and observation features, and a second interaction feature between temporal features and observation features. Based on the training dataset for each task, a predictive model is obtained by extracting and modeling the commonalities between different tasks through a rolling adaptation scheme. Apply the prediction model to multi-task prediction in the target community scenario.
[0006] In some embodiments, the spatiotemporal indicator data includes spatial indicator data and temporal indicator data. The main observation data and associated spatiotemporal indicator data of the target in the target community scenario are obtained, and the first input feature is obtained through preprocessing, including the following steps: The main observation data of the target of interest with various attributes are collected by multiple sensors preset in the target community scene; The targets of attention include traffic flow, speed, pedestrian flow, and risk level; Spatial index data is obtained by locating the coordinate information of the target of interest based on the location information of the sensors that collect the main observation data; Time index data is obtained based on the time points when the main observation data is collected by the sensors; Based on the main observation data, spatial index data, and temporal index data, observation features, spatial features, and temporal features are obtained through a multilayer perceptron.
[0007] In some embodiments, task cues are constructed based on the known key observation data for each task, including the following steps: Based on the main observation data of each task, the initial task features of each task are learned through an autoencoder. By aligning the initial task features with the first input features using a fully connected model, the target task features are obtained as task prompts.
[0008] In some embodiments, when the interaction feature is the first interaction feature, the interaction feature is constructed using a multi-head cross-attention model, including the following steps: Extract the first slice of spatial features and the second slice of observation features from the second input features; Based on the first slice, a first query matrix is constructed by combining the preset first query weight; Based on the second slice, a first key matrix is constructed by combining the preset first key weights, and a first value matrix is constructed by combining the second slice with the preset first value weights. Based on the first query matrix, the first key matrix, and the first value matrix, the first feature representation of space and observation is fused through a multi-head cross-attention structure; Based on the result of the fusion of the first feature representation, the first interactive feature is obtained by sequentially passing through a fully connected network and layer normalization processing.
[0009] In some embodiments, when the interaction feature is a second interaction feature, the interaction feature is constructed using a multi-head cross-attention model, including the following steps: Based on the temporal features and observation features in the second input features, we obtain the observation feature vector in time sequence; Location encoding is constructed based on the feature dimensions and time sequence of time features; The location code is added to the time-series observation feature vector to obtain the coded feature representation; The third slice of temporal features and the fourth slice of observation features are extracted from the encoded feature representation; Based on the third slice, a second query matrix is constructed by combining the preset second query weights; Based on the fourth slice, a second key matrix is constructed by combining the preset second key weights; based on the fourth slice, a second value matrix is constructed by combining the preset second value weights. Based on the second query matrix, the second key matrix, and the second value matrix, the second feature representation of time and observation is fused through a multi-head cross-attention structure; Based on the result of the second feature representation fusion, the second interaction feature is obtained by sequentially processing through a fully connected network and layer normalization.
[0010] In some embodiments, the interaction feature is superimposed on the second input feature to perform spatiotemporal self-interaction, resulting in a third input feature, including the following steps: The first and second interaction features are superimposed onto the second input feature according to their respective dimensions, and then input into the multi-head self-attention module. Based on the output of the multi-head self-attention module, the third input feature is obtained by sequentially passing through a fully connected network, a non-linear activation function, and layer normalization.
[0011] In some embodiments, a predictive model is obtained by extracting and modeling the commonalities among different tasks through a rolling adaptation scheme, including the following steps: Based on the preset initial weights, the preset model is trained independently using the training dataset of the first task, and the first weights are obtained in response to the model convergence. Use the first weight as the initial weight for training and the second task as the training task; Based on the initial training weights, the preset model is trained for several rounds using the training dataset of the training task. The weight set is obtained by organizing the updated weights of each round before the model converges. Based on the elements at the same position in the updated weights of different rounds in the weight set, construct the variance of each element in the weight, and mark the set of elements with variance less than the variance threshold as stable weights; The stable weights in the updated weights of the last round are frozen as the initial weights for training, and the next task of the training task is taken as the training task. Return to the steps of training the preset model for several rounds based on the initial training weights and the training dataset of the training task, until all tasks have been traversed; The updated weight of the last task in the last round is used as the target weight, and the target weight is applied to the preset model to obtain the prediction model.
[0012] To achieve the above objectives, another aspect of this invention proposes a community multi-task prediction device based on spatiotemporal features, the device comprising: The first module is used to acquire the main observation data and associated spatiotemporal index data of the target in the target community scenario, and obtain the first input features through preprocessing; wherein, the first input features include observation features, spatial features and temporal features; The second module is used to construct task prompts based on the known main observation data of each task, and to concatenate the task prompts with the first input features of the corresponding task to obtain the second input features of each task. The third module is used to construct interaction features based on the second input features through a multi-head cross-attention model, and to superimpose the interaction features onto the second input features to perform spatiotemporal self-interaction, thereby obtaining the third input features to determine the training dataset for each task; wherein, the interaction features include the first interaction feature between spatial features and observation features and the second interaction feature between temporal features and observation features; The fourth module is used to extract and model the commonalities between different tasks based on the training dataset for each task, and obtain a prediction model through a rolling adaptation scheme. The fifth module is used to apply the prediction model to multi-task prediction in the target community scenario.
[0013] To achieve the above objectives, another aspect of the present invention provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned method.
[0014] To achieve the above objectives, another aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned method.
[0015] To achieve the above objectives, another aspect of the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the aforementioned method.
[0016] The embodiments of the present invention include at least the following beneficial effects: The present invention provides a community multi-task prediction method, device, electronic device, storage medium, and program product based on spatiotemporal features. This scheme obtains the main observation data and associated spatiotemporal index data of the target interest in a target community scenario, and obtains a first input feature through preprocessing. The first input feature includes observation features, spatial features, and temporal features. Based on the known main observation data of each task, a task prompt is constructed, and the task prompt is concatenated with the first input feature of the corresponding task to obtain a second input feature for each task. Based on the second input feature, an interaction feature is constructed through a multi-head cross-attention model, and the interaction feature is superimposed on the second input feature for spatiotemporal self-interaction to obtain a third input feature to determine the training dataset for each task. The interaction feature includes a first interaction feature between spatial features and observation features, and a second interaction feature between temporal features and observation features. Based on the training dataset for each task, a rolling adaptation scheme is used to extract and model the commonalities between different tasks to obtain a prediction model. The prediction model is then applied to multi-task prediction in the target community scenario. This invention integrates multi-source data by acquiring key observational data and spatiotemporal index data of the target community and preprocessing it to obtain a first input feature that fuses observational, spatial, and temporal characteristics, thus avoiding data silos. Simultaneously, this invention enhances the correlation mining between multiple tasks by concatenating task prompts with input features and constructing interactive features using a multi-head cross-attention model. This enables the model to collaboratively analyze the potential connections between different tasks, thereby improving data utilization. Furthermore, this invention extracts commonalities between tasks through a rolling adaptation scheme to construct a predictive model, allowing the model to jointly process multiple tasks and reduce computational redundancy, thereby supporting more real-time and accurate predictive decisions and meeting the management needs of smart communities. Specifically, the method of this invention, through spatiotemporal self-interaction and a rolling adaptation scheme, enables the model to adapt to new community environments and data distributions, overcoming the problem of poor generalization ability caused by traditional models independently modeling for specific scenarios. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of an implementation environment for a community multi-task prediction method based on spatiotemporal features provided in an embodiment of the present invention. Figure 2 This is a flowchart illustrating a community multi-task prediction method based on spatiotemporal features provided in an embodiment of the present invention. Figure 3 This is a schematic diagram of the unfolding process of step S100 provided in the embodiment of the present invention; Figure 4 This is a schematic diagram of the expansion process of the build task prompt provided in an embodiment of the present invention; Figure 5This is a schematic diagram of the spatiotemporal self-interaction unfolding process provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the unfolding process of modeling the rolling adaptation scheme provided in the embodiments of the present invention; Figure 7 This is a schematic diagram illustrating the principle and process of model training provided in the embodiments of the present invention; Figure 8 This is a schematic diagram of the structure of the community multi-task prediction system based on spatiotemporal features provided in an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of a community multi-task prediction device based on spatiotemporal features provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of this invention; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this invention as detailed in the appended claims.
[0019] It is understood that the terms “first,” “second,” etc., used in this invention may be used herein to describe various concepts, but unless specifically stated otherwise, these concepts are not limited by these terms. These terms are used only to distinguish one concept from another. For example, first information may also be referred to as second information without departing from the scope of embodiments of the invention, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to determination” as used herein may be interpreted as “when…” or “when…” or “in response to determination.”
[0020] The terms “at least one,” “multiple,” “each,” “any,” etc., used in this invention, “at least one” includes one, two, or more than two; “multiple” includes two or more than two; “each” refers to each of the corresponding multiple; and “any” refers to any one of the multiple.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0022] To facilitate understanding of the technical solution of this invention, the technical terms that may be applied in the technical solution of this invention will first be explained: Spatiotemporal characteristics: Spatiotemporal characteristics refer to data points collected by sensors deployed in the environment, such as traffic dynamics on roads.
[0023] Spatiotemporal prediction: refers to capturing dynamic spatial and temporal evolution in order to make various predictions.
[0024] Multitasking: refers to predicting various elements from different domains in an ensemble model.
[0025] An autoencoder (AE) is a type of artificial neural network (ANN) used in semi-supervised and unsupervised learning. Its function is to learn representations of the input information by using the input information as the learning target. An autoencoder consists of two parts: an encoder and a decoder.
[0026] In related technologies, traditional prediction models are mostly designed for specific scenarios (such as pedestrian flow prediction, security early warning, or energy consumption prediction) and are independently modeled. This not only results in computational redundancy but also makes it difficult to uncover potential correlations between cross-domain data, leading to low data utilization and poor generalization ability.
[0027] In view of this, this embodiment of the invention provides a community multi-task prediction method and related equipment based on spatiotemporal features. This scheme obtains the main observation data and associated spatiotemporal index data of the target interest in the target community scene, and obtains a first input feature through preprocessing. The first input feature includes observation features, spatial features, and temporal features. Based on the known main observation data of each task, a task prompt is constructed, and the task prompt is concatenated with the first input feature of the corresponding task to obtain a second input feature for each task. Based on the second input feature, an interaction feature is constructed through a multi-head cross-attention model, and the interaction feature is superimposed on the second input feature to perform spatiotemporal self-interaction, obtaining a third input feature to determine the training dataset for each task. The interaction feature includes a first interaction feature between spatial features and observation features, and a second interaction feature between temporal features and observation features. Based on the training dataset for each task, a rolling adaptation scheme is used to extract and model the commonalities between different tasks to obtain a prediction model. The prediction model is then applied to multi-task prediction in the target community scene. This invention integrates multi-source data by acquiring key observational data and spatiotemporal index data of the target community and preprocessing it to obtain a first input feature that fuses observational, spatial, and temporal characteristics, thus avoiding data silos. Simultaneously, this invention enhances the correlation mining between multiple tasks by concatenating task prompts with input features and constructing interactive features using a multi-head cross-attention model. This enables the model to collaboratively analyze the potential connections between different tasks, thereby improving data utilization. Furthermore, this invention extracts commonalities between tasks through a rolling adaptation scheme to construct a predictive model, allowing the model to jointly process multiple tasks and reduce computational redundancy, thereby supporting more real-time and accurate predictive decisions and meeting the management needs of smart communities. Specifically, the method of this invention, through spatiotemporal self-interaction and a rolling adaptation scheme, enables the model to adapt to new community environments and data distributions, overcoming the problem of poor generalization ability caused by traditional models independently modeling for specific scenarios.
[0028] It is understood that the community multi-task prediction method based on spatiotemporal features provided by this invention can be applied to any computer device with data processing and computing capabilities, and this computer device can be various terminals or servers. When the computer device in the embodiment is a server, the server is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Optionally, the terminal can be a smartphone, tablet, laptop, or desktop computer, but it is not limited to these.
[0029] like Figure 1 The diagram shown is a schematic representation of an implementation environment provided by an embodiment of the present invention. (Refer to...) Figure 1 The implementation environment includes at least one terminal 102 and a server 101. The terminal 102 and the server 101 can be connected via a network, either wirelessly or via a wired connection, to complete data transmission and exchange.
[0030] Server 101 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0031] Additionally, server 101 can also be a node server in a blockchain network. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms.
[0032] Terminal 102 can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. Terminal 102 and server 101 can be directly or indirectly connected via wired or wireless communication, and this embodiment of the invention does not impose any limitations.
[0033] For example, based on Figure 1 The implementation environment shown in this embodiment of the invention provides a community multi-task prediction method based on spatiotemporal features. The following description uses the application of this community multi-task prediction method based on spatiotemporal features in server 101 as an example. It can be understood that this community multi-task prediction method based on spatiotemporal features can also be applied to terminal 102.
[0034] Reference Figure 2 , Figure 2 This is an optional flowchart of a community multi-task prediction method based on spatiotemporal features provided in an embodiment of the present invention. The execution subject of the community multi-task prediction method based on spatiotemporal features can be any of the aforementioned computer devices (including servers or terminals). Figure 2 The method may include, but is not limited to, steps S100 to S500.
[0035] Step S100: Obtain the main observation data and associated spatiotemporal index data of the target in the target community scenario, and obtain the first input feature through preprocessing; The first input features include observation features, spatial features, and temporal features; It should be noted that spatiotemporal indicator data includes spatial indicator data and temporal indicator data. In some embodiments, such as... Figure 3 Step S100 may include the following steps: S110, collecting key observation data of various attributes of the target of interest through multiple preset sensors in the target community scene; wherein, the target of interest includes traffic flow, speed, pedestrian flow and risk level; S120, locating the coordinate information of the target of interest based on the location information of the sensors that collect the key observation data to obtain spatial index data; S130, obtaining temporal index data based on the time node when the sensors collect the key observation data; S140, obtaining observation features, spatial features and temporal features through a multilayer perceptron based on the key observation data, spatial index data and temporal index data.
[0036] Specifically, this invention collects data on multi-attribute targets of interest (such as traffic flow, speed, and pedestrian flow) through multiple sensors, and combines this data with location information and time nodes to generate spatial and temporal index data, ensuring data diversity and completeness. Furthermore, this invention uses a multilayer perceptron to automatically extract observation, spatial, and temporal features, reducing reliance on manual feature engineering and improving the effectiveness of feature representation. In particular, this invention explicitly transforms spatial coordinates and time nodes into features, enabling the model to more accurately capture the spatiotemporal dynamics of the community environment, laying the foundation for subsequent multi-task prediction, and addressing the problem of traditional models neglecting spatiotemporal correlations.
[0037] For example, in some specific implementations, data is acquired and preprocessed to obtain the desired input features; specifically, this can be implemented as follows: Step 1.1: Obtain key observation data, namely the targets of interest in the community scenario (including: vehicle flow, speed, pedestrian flow, risk level, etc.), and perform periodic sampling, denoted as... Where t represents the t-th discrete time point, n represents the spatial node corresponding to the n-th sensor position, and c represents the c-th attribute.
[0038] Step 1.2: Obtain spatial index data, namely longitude and latitude coordinates, denoted as... .
[0039] Step 1.3: Obtain time indicator data, including the day of the week, the time of day, and the timestamp, denoted as... .
[0040] Step 1.4: Analysis of key observation data Spatial index data and time indicator data Each observation feature is obtained by passing it through a multilayer perceptron (MLP). Spatial features and time characteristics The formula is as follows:
[0041]
[0042]
[0043] in, , and The main observation data are listed in order. Spatial index data and time indicator data Multilayer perceptron in application ( , and The weight parameters of ).
[0044] Step S200: Construct task prompts based on the known main observation data of each task, and concatenate the task prompts with the first input features of the corresponding task to obtain the second input features of each task; It should be noted that in some embodiments, such as Figure 4 As shown, constructing task prompts based on the known main observation data of each task may include the following steps: S210, learning the initial task features of each task through an autoencoder based on the main observation data of each task; S220, aligning the initial task features with the first input features through a fully connected model to obtain the target task features as task prompts.
[0045] Specifically, this embodiment of the invention learns initial task features through an autoencoder, which can compress and extract the essential information of the task, reduce the redundancy of task representation, and then perform feature dimension alignment through a fully connected model to ensure the consistency between task prompts and input features, making multi-task learning more efficient. Specifically, the introduction of task prompts in this embodiment of the invention helps the model to clearly distinguish different tasks, avoids interference between tasks, and thus provides accuracy and synergy for multi-task joint prediction, which can effectively solve the shortcomings of traditional models in not being able to effectively handle task association.
[0046] For example, in some specific implementations, feature vectors are constructed in order to enable the model to adapt to multiple tasks simultaneously. This is used to represent the differences between different tasks; specifically, it can be implemented as follows: Step 2.1: Observation data for the k-th task Through an autoencoder, the feature representation of the k-th task is learned. .
[0047] Step 2.2: Through a fully connected model ( , Align the weight parameters and feature dimensions. This ultimately yields the feature representation for the k-th task. The formula is as follows:
[0048] Step 2.3: Task It concatenates all features to obtain the input features of the multi-task prediction model: .
[0049] Step S300: Based on the second input feature, construct interaction features through a multi-head cross-attention model, superimpose the interaction features onto the second input feature to perform spatiotemporal self-interaction, and obtain the third input feature to determine the training dataset for each task. Among them, the interaction features include the first interaction feature between spatial features and observation features, and the second interaction feature between temporal features and observation features; It should be noted that in some embodiments, when the interaction feature is the first interaction feature, constructing the interaction feature through a multi-head cross-attention model may include the following steps: extracting a first slice of spatial features and a second slice of observation features from the second input features; constructing a first query matrix based on the first slice and a preset first query weight; constructing a first key matrix based on the second slice and a preset first key weight, and constructing a first value matrix based on the second slice and a preset first value weight; fusing the first feature representations of space and observation through a multi-head cross-attention structure based on the first query matrix, the first key matrix, and the first value matrix; and obtaining the first interaction feature by sequentially passing the result of the first feature representation fusion through a fully connected network and layer normalization processing.
[0050] Specifically, this embodiment of the invention constructs a first interactive feature between spatial features and observation features through a multi-head cross-attention model. By utilizing a query, key, and value matrix mechanism, it captures the complex correlation between spatial location and observation data (such as pedestrian and vehicle traffic), thereby improving the flexibility of feature fusion. Specifically, the multi-head attention mechanism applied in this embodiment of the invention allows the model to process information from different subspaces in parallel. Combined with fully connected networks and layer normalization, it can stabilize the training process, enabling the model to more accurately reflect the impact of spatial factors on observation data, thus solving the problem of traditional models processing spatial data in isolation.
[0051] For example, in some specific implementations, constructing the interaction between spatial features and key observation features can be specifically implemented as follows: Let the slice of spatial features in feature H be denoted as . The slices of observed features are Let query Q, key K, and value V be represented as follows: , and , , and These are the weights corresponding to Q, K, and V.
[0052] Feature representations of spatial and primary observation information are fused using a multi-head cross-attention structure (MHCA), then the learning ability is enhanced by a fully connected network (FFN), and finally layer normalization (LN) is performed to obtain the interaction features between spatial features and primary observation features. The formula is as follows (details of attention matrix construction are not described):
[0053] It should be noted that in some embodiments, when the interaction feature is the second interaction feature, constructing the interaction feature through a multi-head cross-attention model may include the following steps: organizing the temporal and observational features in the second input features to obtain a temporally ordered observation feature vector; constructing a positional encoding based on the feature dimensions and temporal order of the temporal features; adding the positional encoding to the temporally ordered observation feature vector to obtain an encoded feature representation; extracting a third slice of the temporal features and a fourth slice of the observational features from the encoded feature representation; constructing a second query matrix based on the third slice and a preset second query weight; constructing a second key matrix based on the fourth slice and a preset second value weight; fusing the temporal and observational second feature representations through a multi-head cross-attention structure based on the second query matrix, the second key matrix, and the second value matrix; and obtaining the second interaction feature by sequentially processing the result of the second feature representation fusion through a fully connected network and layer normalization.
[0054] Specifically, the embodiments of the present invention preserve temporal sequence information through location encoding and time series processing, enabling the model to effectively capture temporal dependencies. Furthermore, by constructing a second interactive feature between time and observed features through a multi-head cross-attention model, the model's ability to model the correlation between temporal dynamics (such as peak periods and event sequences) and observed data can be enhanced. Specifically, the embodiments of the present invention can solve the problem of traditional models neglecting the time dimension, making predictions more consistent with the temporal changes in actual community scenarios, thereby supporting applications with high real-time requirements (such as energy consumption prediction and security early warning).
[0055] For example, in some specific implementations, the interaction between the construction of temporal features and the main observation features can be specifically implemented as follows: First, the position encoding formula is introduced as follows: , Where D is the feature dimension, t is the index of the time sequence, and d is the index of the dimension. This represents the positional encoding of the t-th time sequence and the 2d-th dimension. This represents the positional encoding of the t-th time sequence and the (2d+1)-th dimension.
[0056] Adding positional encoding to the time-series observed feature vectors yields a new feature representation. .
[0057] Remember the characteristics The slices with time features are The slices of observed features are Let query Q, key K, and value V be represented as follows: , and .
[0058] By employing a multi-head cross-attention structure (MHCA), followed by a fully connected network (FFN), and finally layer normalization (LN), the interaction features between temporal features and main observation features are obtained. .
[0059] It should be noted that in some embodiments, such as Figure 5 As shown, the interaction features are superimposed on the second input features to perform spatiotemporal self-interaction, resulting in the third input features. This can include the following steps: S310, superimposing the first and second interaction features on the second input features according to their respective dimensions, and then inputting them into the multi-head self-attention module; S320, based on the output of the multi-head self-attention module, sequentially passing through a fully connected network, a nonlinear activation function, and layer normalization to obtain the third input features.
[0060] Specifically, this embodiment of the invention superimposes the first interaction feature (spatial-observation) and the second interaction feature (temporal-observation) onto the second input feature, and utilizes a multi-head self-attention module for self-interaction, further extracting the complex dependencies within the feature and enriching the feature representation. Furthermore, this embodiment of the invention, through fully connected networks, nonlinear activation functions, and layer normalization, can improve the model's expressive power and stability, enabling the model to better handle nonlinear relationships in community data and addressing the shortcomings of insufficient feature interaction in traditional models.
[0061] For example, in some specific implementations, the self-interaction of constructing spatial and temporal indicators can be specifically achieved by: and The corresponding features are superimposed onto the original feature H according to their respective dimensions, and then passed through a multi-head self-attention (MHA) module. The output is then passed through a fully connected network FFN and a non-linear activation function, and finally normalized. Step S400: Based on the training dataset for each task, extract and model the commonalities between different tasks using a rolling adaptation scheme to obtain a prediction model; It should be noted that in some embodiments, such as Figure 6 As shown, the commonalities between different tasks are extracted and modeled through a rolling adaptation scheme to obtain a prediction model, which may include the following steps: S410, based on preset initial weights, the preset model is independently trained using the training dataset of the first task, and the first weight is obtained in response to model convergence; S420, the first weight is used as the initial training weight, and the second task is used as the training task; S430, based on the initial training weight, the preset model is trained for several rounds using the training dataset of the training task, and the updated weights of each round before model convergence are organized to obtain a weight set; S441, based on the weight set, the commonalities between different tasks are extracted and modeled to obtain a prediction model; S451, the commonalities between different tasks are extracted and modeled to obtain a prediction model. In the same round of weight updates, elements at the same position are used to construct the variance of each element in the weights, and the set of elements with variance less than the variance threshold is marked as stable weights; S450, the stable weights in the last round of weight updates are frozen as the initial weights for training, and the next task of the training task is taken as the training task; S460, return to execute the step of training the preset model for several rounds based on the initial weights and the training dataset of the training task, until all tasks have been traversed; S470, the updated weights of the last task in the last round are taken as the target weights, and the target weights are applied to the preset model to obtain the prediction model.
[0062] It should be noted that the focus of the technical solution of this invention is on the technical means of data preparation and model training schemes related to data feature processing and interactive mining. The preset model (i.e. the model for training applications) can be set and adjusted according to actual needs. For example, a general deep learning model or machine learning model that can learn the mapping relationship between data features and task prediction can be used. The embodiments of this invention do not limit the specific model structure.
[0063] Specifically, the embodiments of the present invention employ a rolling adaptation scheme, sequentially training tasks and identifying and freezing stable weights based on variance thresholds. This preserves shared parameters between tasks, thereby reducing overfitting of the model to specific tasks and significantly improving generalization ability. Furthermore, the embodiments of the present invention enable the model to gradually learn commonalities of tasks and quickly adapt to new community scenarios or data distributions, solving the problem of poor generalization ability of traditional models under dynamic multi-source data. Simultaneously, rolling training reduces computational redundancy, thereby improving model efficiency.
[0064] For example, in some specific embodiments, to ensure continuous task learning, this invention proposes a rolling adaptation scheme for extracting and modeling commonalities between different tasks. Specifically, it can be implemented as follows: Step 4.1: Initialization. From the task... Begin by independently training the model until it converges. Let the initial weights be 1. , For the task The training dataset, These are the weights after the model has converged. (Task) The training process is recorded as follows:
[0065] Step 4.2: First Task Training. For the task... Based on its training dataset The model is trained, with the initial weights set to... Record the weight values updated in each epoch before the model converges. , where i represents the i-th epoch. Task The training process is recorded as follows:
[0066] Let the weight set be... Includes training tasks Convergence weights and training task The weights updated in each iteration, i.e. Calculate the variance for elements at the same position in different iteration weights. Introducing a variance threshold , denoted by variance less than The set of elements is a stable weight. .
[0067] Step 4.3: Freeze stable weights for training. For the task... Based on its training dataset The model is trained, with the initial weights set to... , among which in the task Stable weights during training Some values are frozen during training. The updated weight values for each epoch before model convergence are recorded. The training process for task T3 is denoted as follows:
[0068] Step 4.4: Rolling training for subsequent tasks. This process is repeated for each task. Based on its training dataset The model is trained, with the initial weights set to... , among which in the task Stable weights during training Some tasks are frozen during training. After training for all K tasks is completed, the tasks are retrained. To complete the closed loop, the system eventually learns weights that represent the common characteristics of all tasks. .
[0069] Step S500: Apply the prediction model to multi-task prediction in the target community scenario; For example, in some specific implementations, by loading a prediction model that has already been trained, multi-task prediction can be achieved based on new spatiotemporal data (i.e., real-time observation data and its associated spatiotemporal index data).
[0070] To explain in detail the principle of the technical solution of the present invention, the overall process of the present invention will be described below with reference to some specific embodiments. It is easy to understand that the following is an explanation of the technical principle of the present invention and should not be regarded as a limitation of the present invention.
[0071] In view of the shortcomings of existing technologies, this invention proposes a community multi-task prediction method based on spatiotemporal features. Specifically, this invention integrates diverse data such as community security, pedestrian flow, and energy consumption, and achieves joint modeling and collaborative prediction of multiple tasks through a multi-dimensional spatiotemporal interaction network. This invention can understand the spatiotemporal system from a holistic perspective, utilizing information from different data domains to enhance each individual task. Simultaneously, multi-task learning can improve model generalization ability, increase data utilization, and reduce training costs through shared feature representations. Therefore, this invention is applicable to various community scenarios, achieving collaborative learning between tasks, balancing the commonalities and individual characteristics of tasks, and meeting the requirements for flexible, accurate, and universal prediction.
[0072] In some specific embodiments, the method of the present invention can be implemented through the following process: Step 1: Acquire data and preprocess it to obtain the required input features; specifically: Step 1.1: Obtain key observation data, namely the targets of interest in the community scenario (including: vehicle flow, speed, pedestrian flow, risk level, etc.), and perform periodic sampling, denoted as... Where t represents the t-th discrete time point, n represents the spatial node corresponding to the n-th sensor position, and c represents the c-th attribute.
[0073] Step 1.2: Obtain spatial index data, namely longitude and latitude coordinates, denoted as... .
[0074] Step 1.3: Obtain time indicator data, including the day of the week, the time of day, and the timestamp, denoted as... .
[0075] Step 1.4: Analysis of key observation data Spatial index data and time indicator data Each observation feature is obtained by passing it through a multilayer perceptron (MLP). Spatial features and time characteristics The formula is as follows:
[0076] Step 2: Construct task prompts. To enable the model to adapt to multiple tasks simultaneously, feature vectors are constructed. This is used to represent the differences between different tasks; specifically: Step 2.1: Observation data for the k-th task Through an autoencoder, the feature representation of the k-th task is learned. .
[0077] Step 2.2: Through a fully connected model ( , Align the weight parameters and feature dimensions. This ultimately yields the feature representation for the k-th task. The formula is as follows: Step 2.3: Task It concatenates all features to obtain the input features of the multi-task prediction model: .
[0078] Step 3: Learn the interaction between observations, spatial and temporal features using a multi-head cross-attention model; specifically: Step 3.1: Construct the interaction between spatial features and main observed features. Let the slice of spatial features in feature H be denoted as . The slices of observed features are Let query Q, key K, and value V be represented as follows: , and , , and These are the weights corresponding to Q, K, and V.
[0079] Feature representations of spatial and primary observation information are fused using a multi-head cross-attention structure (MHCA), then the learning ability is enhanced by a fully connected network (FFN), and finally layer normalization (LN) is performed to obtain the interaction features between spatial features and primary observation features. .
[0080] Step 3.2: Constructing the interaction between temporal features and key observation features. First, the location encoding formula is introduced as follows: , Where D is the feature dimension, t is the index of the time sequence, and d is the index of the dimension. This represents the positional encoding of the t-th time sequence and the 2d-th dimension. This represents the positional encoding of the t-th time sequence and the (2d+1)-th dimension.
[0081] Adding positional encoding to the time-series observed feature vectors yields a new feature representation. .
[0082] Similar to step 3.1, record the features. The slices with time features are The slices of observed features are Let query Q, key K, and value V be represented as follows: , and .
[0083] By employing a multi-head cross-attention structure (MHCA), followed by a fully connected network (FFN), and finally layer normalization (LN), the interaction features between temporal features and main observation features are obtained. .
[0084] Step 3.3: Construct self-interaction between spatial and temporal metrics. and The corresponding features are superimposed onto the original features H according to their respective dimensions, and then passed through a multi-head self-attention (MHA) module. The output is then passed through a fully connected network FFN and a non-linear activation function, and finally normalized.
[0085] Step 4: To ensure continuous task learning, this invention proposes a rolling adaptation scheme for extracting and modeling commonalities between different tasks. For example... Figure 7 As shown, specifically: Step 4.1: Initialization. From the task... Begin by independently training the model until it converges. Let the initial weights be 1. , For the task The training dataset, These are the weights after the model has converged. (Task) The training process is recorded as follows: Step 4.2: First Task Training. For the task... Based on its training dataset The model is trained, with the initial weights set to... Record the weight values updated in each epoch before the model converges. , where i represents the i-th epoch. Task The training process is recorded as follows: Let the weight set be... Includes training tasks Convergence weights and training task The weights updated in each iteration, i.e. Calculate the variance for elements at the same position in different iteration weights. Introducing a variance threshold , denoted by variance less than The set of elements is a stable weight. .
[0086] Step 4.3: Freeze stable weights for training. For the task... Based on its training dataset The model is trained, with the initial weights set to... , among which in the task Stable weights during training Some values are frozen during training. The updated weight values for each epoch before model convergence are recorded. The training process for task T3 is denoted as follows: Step 4.4: Rolling training for subsequent tasks. This process is repeated for each task. Based on its training dataset The model is trained, with the initial weights set to... , among which in the task Stable weights during training Some tasks are frozen during training. After training for all K tasks is completed, the tasks are retrained. To complete the closed loop, the system eventually learns weights that represent the common characteristics of all tasks. .
[0087] like Figure 8As shown in some specific embodiments, the technical solution based on the embodiments of the present invention can realize a community multi-task intelligent system based on spatiotemporal characteristics, including: Data input layer: used to collect sensor data (i.e., the main observation data) and its corresponding spatial coordinates and time data (i.e., spatiotemporal index data); Data preprocessing module: responsible for data cleaning, standardization, and task prompt generation; Model training module: performs model training, records weight evolution, and freezes stable weights; Prediction module: Loads sub-models to make predictions on new spatiotemporal data; Parameter storage module: Stores weight sequences, stable weights, and sub-model parameters.
[0088] In summary, this invention utilizes a multi-dimensional spatiotemporal interaction network to represent the interactions between data dimensions, including context-space, context-time, and self-interactions within the spatial and temporal dimensions. This invention learns the commonalities between different tasks by modeling weighted behaviors, while simultaneously capturing the characteristics of each task through autoencoder data compression to enhance performance. This invention aims to address the problems of task isolation, catastrophic forgetting, and imbalance between commonalities and individual characteristics in existing multi-task spatiotemporal learning, providing a rolling adaptation method and system to achieve efficient collaborative learning of multiple tasks in dynamic spatiotemporal scenarios.
[0089] Compared with the prior art, the embodiments of the present invention have at least the following beneficial effects: 1. This invention utilizes a multi-dimensional spatiotemporal interactive network and spatiotemporal data for training, which helps improve the accuracy of simulating the entire community environment.
[0090] 2. This invention preserves the unique patterns of different tasks by constructing task prompts and captures commonalities between tasks through stable weights in rolling training, thereby achieving multi-task collaborative learning, improving data utilization, and reducing training costs.
[0091] 3. By jointly modeling multiple tasks, this invention can improve the model's generalization ability and prediction performance by leveraging shared common knowledge in scenarios with sparse data or new tasks.
[0092] 4. The multi-task model training method in this invention supports the dynamic addition of new tasks and continuously optimizes the model through rolling training, which is beneficial to the dynamic evolution of the system.
[0093] like Figure 9 As shown, this embodiment of the invention also provides a community multi-task prediction device 900 based on spatiotemporal features, which can implement the above-described method. This device may include: The first module 910 is used to acquire the main observation data and associated spatiotemporal index data of the target of interest in the target community scenario, and obtain the first input features through preprocessing; wherein, the first input features include observation features, spatial features and temporal features; The second module 920 is used to construct task prompts based on the known main observation data of each task, and to concatenate the task prompts with the first input features of the corresponding task to obtain the second input features of each task. The third module 930 is used to construct interaction features based on the second input features through a multi-head cross-attention model, and to superimpose the interaction features onto the second input features to perform spatiotemporal self-interaction to obtain the third input features to determine the training dataset for each task; wherein, the interaction features include the first interaction feature between spatial features and observation features and the second interaction feature between temporal features and observation features; The fourth module, 940, is used to extract and model the commonalities between different tasks based on the training dataset for each task, and obtain a prediction model through a rolling adaptation scheme. Module 5, 950, is used to apply the prediction model to multi-task prediction in the target community scenario.
[0094] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0095] This invention also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0096] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0097] like Figure 10 As shown, Figure 10 The hardware structure of an electronic device 1000 according to another embodiment is illustrated. The electronic device 1000 includes: The processor 1001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (aSIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention. The memory 1002 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RaM). The memory 1002 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called and executed by the processor 1001. Input / output interface 1003 is used to implement information input and output; The communication interface 1004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 1005 transmits information between various components of the device (e.g., processor 1001, memory 1002, input / output interface 1003, and communication interface 1004); The processor 1001, memory 1002, input / output interface 1003 and communication interface 1004 are connected to each other within the device via bus 1005.
[0098] The electronic device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0099] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0100] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0101] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0102] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0103] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0104] The present invention provides a method, apparatus, electronic device, storage medium, and program product for multi-task prediction of communities based on spatiotemporal features. It acquires key observation data and associated spatiotemporal index data of the target community scenario, and obtains a first input feature through preprocessing. The first input feature includes observation features, spatial features, and temporal features. Based on the known key observation data of each task, a task prompt is constructed, and the task prompt is concatenated with the first input feature of the corresponding task to obtain a second input feature for each task. Based on the second input feature, an interaction feature is constructed using a multi-head cross-attention model, and the interaction feature is superimposed on the second input feature to perform spatiotemporal self-interaction, resulting in a third input feature to determine the training dataset for each task. The interaction feature includes a first interaction feature between spatial features and observation features, and a second interaction feature between temporal features and observation features. Based on the training dataset for each task, a rolling adaptation scheme is used to extract and model the commonalities between different tasks to obtain a prediction model. The prediction model is then applied to multi-task prediction of the target community scenario. This invention integrates multi-source data by acquiring key observational data and spatiotemporal index data of the target community and preprocessing it to obtain a first input feature that fuses observational, spatial, and temporal characteristics, thus avoiding data silos. Simultaneously, this invention enhances the correlation mining between multiple tasks by concatenating task prompts with input features and constructing interactive features using a multi-head cross-attention model. This enables the model to collaboratively analyze the potential connections between different tasks, thereby improving data utilization. Furthermore, this invention extracts commonalities between tasks through a rolling adaptation scheme to construct a predictive model, allowing the model to jointly process multiple tasks and reduce computational redundancy, thereby supporting more real-time and accurate predictive decisions and meeting the management needs of smart communities. Specifically, the method of this invention, through spatiotemporal self-interaction and a rolling adaptation scheme, enables the model to adapt to new community environments and data distributions, overcoming the problem of poor generalization ability caused by traditional models independently modeling for specific scenarios.
[0105] The embodiments described in this invention are for the purpose of more clearly illustrating the technical solutions of the embodiments of this invention, and do not constitute a limitation on the technical solutions provided by the embodiments of this invention. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this invention are also applicable to similar technical problems.
[0106] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present invention, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0107] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0108] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0109] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and spirit of the present invention should be within the scope of the claims of the present invention.
Claims
1. A community multi-task prediction method based on spatiotemporal features, characterized in that, The method includes the following steps: The observation data and associated spatiotemporal index data of the target of interest in the target community scenario are obtained, and the first input feature is obtained through preprocessing; wherein, the first input feature includes observation features, spatial features and temporal features; Based on the known observation data for each task, a task prompt is constructed, and the task prompt is concatenated with the first input feature of the corresponding task to obtain the second input feature of each task; Based on the second input feature, an interaction feature is constructed through a multi-head cross-attention model. The interaction feature is then superimposed on the second input feature to perform spatiotemporal self-interaction, resulting in a third input feature to determine the training dataset for each task. The interaction feature includes a first interaction feature between the spatial feature and the observation feature, and a second interaction feature between the temporal feature and the observation feature. Based on the training dataset for each task, a predictive model is obtained by extracting and modeling the commonalities between different tasks through a rolling adaptation scheme. The prediction model is applied to multi-task prediction in the target community scenario; The spatiotemporal indicator data includes spatial indicator data and temporal indicator data. The process of acquiring observation data of the target interest within the target community scenario and its associated spatiotemporal indicator data, and obtaining the first input feature through preprocessing, includes the following steps: The observation data of the target of interest with various attributes are collected by multiple sensors preset in the target community scene; The targets of attention include traffic flow, speed, pedestrian flow, and risk level; Based on the location information of the sensor that collects the observation data, the coordinate information of the target of interest is located to obtain the spatial index data; The time index data is obtained based on the time point when the sensor collects the observation data; Based on the observation data, the spatial index data, and the temporal index data, the observation features, the spatial features, and the temporal features are obtained through a multilayer perceptron. The process of constructing task prompts based on the known observation data for each task includes the following steps: Based on the observation data for each task, the initial task features for each task are learned through an autoencoder. The initial task features are aligned with the first input features by feature dimension using a fully connected model to obtain target task features as task prompts. When the interaction feature is the first interaction feature, the step of constructing the interaction feature through a multi-head cross-attention model includes the following steps: Extract a first slice of the spatial features and a second slice of the observed features from the second input features; Based on the first slice, a first query matrix is constructed by combining the preset first query weight; Based on the second slice, a first key matrix is constructed by combining the preset first key weights, and a first value matrix is constructed by combining the second slice with the preset first value weights. Based on the first query matrix, the first key matrix, and the first value matrix, the spatial and observational first feature representations are fused using a multi-head cross-attention structure; Based on the result of the fusion of the first feature representation, the first interaction feature is obtained by sequentially passing through a fully connected network and layer normalization processing. When the interaction feature is the second interaction feature, the step of constructing the interaction feature through a multi-head cross-attention model includes the following steps: Based on the time features and observation features in the second input features, a time-series observation feature vector is obtained; A location code is constructed based on the feature dimensions and time sequence of the aforementioned time features; The location code is added to the time-series observation feature vector to obtain the coded feature representation; Extract the third slice of the time feature and the fourth slice of the observation feature from the encoded feature representation; Based on the third slice, a second query matrix is constructed by combining the preset second query weights; Based on the fourth slice, a second key matrix is constructed by combining the preset second key weights; based on the fourth slice, a second value matrix is constructed by combining the preset second value weights. Based on the second query matrix, the second key matrix, and the second value matrix, the second feature representation of time and observation is fused through a multi-head cross-attention structure; Based on the result of the second feature representation fusion, the second interaction feature is obtained by sequentially passing through a fully connected network and layer normalization processing; The step of superimposing the interaction feature onto the second input feature to perform spatiotemporal self-interaction to obtain the third input feature includes the following steps: The first interaction feature and the second interaction feature are superimposed onto the second input feature according to the corresponding dimensions, and then input into the multi-head self-attention module. Based on the output of the multi-head self-attention module, the third input feature is obtained by sequentially passing through a fully connected network, a non-linear activation function, and layer normalization. The step of extracting and modeling the commonalities among different tasks through a rolling adaptation scheme to obtain a prediction model includes the following steps: Based on the preset initial weights, the preset model is independently trained using the training dataset of the first task, and the first weights are obtained in response to model convergence. Use the first weight as the initial weight for training and the second task as the training task; Based on the initial training weights, the preset model is trained for several rounds using the training dataset of the training task, and a weight set is obtained by organizing the updated weights of each round before the model converges. Based on the elements at the same position in the updated weights of different rounds in the weight set, construct the variance of each element in the weight, and mark the set of elements whose variance is less than the variance threshold as stable weights; The stable weights in the updated weights of the last round are frozen as the initial weights for training, and the next task of the training task is taken as the training task. Return to the step of training the preset model for several rounds based on the initial training weights and the training dataset of the training task, until all tasks have been traversed; The updated weight of the last task in the last round is used as the target weight, and the target weight is applied to the preset model to obtain the prediction model.
2. A community multi-task prediction device based on spatiotemporal characteristics, characterized in that, The apparatus for implementing the method of claim 1 includes: The first module is used to acquire observation data and associated spatiotemporal indicator data of the target of interest in the target community scenario, and obtain the first input feature through preprocessing; wherein, the first input feature includes observation features, spatial features and temporal features; The second module is used to construct task prompts based on the known observation data of each task, and to concatenate the task prompts with the first input features of the corresponding task to obtain the second input features of each task. The third module is used to construct interaction features based on the second input features through a multi-head cross-attention model, and to superimpose the interaction features onto the second input features to perform spatiotemporal self-interaction to obtain a third input feature to determine the training dataset for each task; wherein, the interaction features include a first interaction feature between the spatial features and the observation features and a second interaction feature between the temporal features and the observation features; The fourth module is used to extract and model the commonalities between different tasks based on the training dataset for each task, and obtain a prediction model by means of a rolling adaptation scheme. The fifth module is used to apply the prediction model to multi-task prediction in the target community scenario.
3. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method of claim 1.
4. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of claim 1.