Model training methods and prediction methods for spatiotemporal data
By adopting hierarchical structure and time transformation processing methods in the spatiotemporal data prediction model, learning multi-scale representation and sharing parameters, the problem of poor multi-scale prediction effect in the existing technology is solved, and the training efficiency and prediction accuracy of the model are improved. .
Patent Information
- Application Number
- CN202410537585.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-04-30
AI Technical Summary
Existing spatiotemporal supply and demand forecasting methods do not fully utilize the hierarchical relationship of multi-scale representation, resulting in high model training overhead and low prediction accuracy.
The hierarchical structure method is used to represent multiple types of spatio-temporal data through different time intervals, and the multi-type spatio-temporal data is time transformed and spliced. Multi-scale spatio-temporal representation is learned from the bottom up, and the hierarchical structure is used to share parameters and reduce Reduce the cost of model training and improve prediction accuracy.
It realizes the full utilization of the hierarchical relationship of multi-scale representation in spatiotemporal data prediction model training, reduces the cost of model training and improves the prediction accuracy.
Smart Images

Figure CN118134054B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a model training method and a spatiotemporal data prediction method. Background Art
[0002] Spatiotemporal supply and demand forecasting is a key technology in smart cities and has a wide range of application scenarios, such as demand forecasting for shared bicycles and taxis. In existing spatiotemporal supply and demand forecasting methods, spatial division is usually the basis and prerequisite for spatiotemporal supply and demand forecasting. For example, the city is divided into grids of equal size, and supply and demand forecasting is performed on these grids. The supply and demand forecasting system has multi-scale requirements for the forecast area. For example, in order to balance the supply and demand relationship, the supply and demand forecasting area required for resource scheduling tasks is usually larger (for example, 5km*5km), while the hotspot area in the demand forecasting task in the city hotspot (such as commercial district) is usually smaller (for example, 500m*500m) to facilitate refined management.
[0003] Most related designs focus on single-scale prediction problems. Even though there are dual-scale spatiotemporal prediction methods, their multi-scale prediction effects are poor and the computational cost is high.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a model training method and a spatiotemporal data prediction method to at least solve the technical problem that the hierarchical relationship represented by multi-scale is not fully utilized during the training process of the relevant spatiotemporal data prediction model, resulting in high overhead in the model training process and low model prediction accuracy.
[0006] According to one aspect of an embodiment of the present application, a model training method is provided, including: determining multiple types of spatiotemporal data represented by different time intervals in a first-layer grid, and performing time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first-layer grid, wherein the first-layer grid belongs to a hierarchical structure, and the hierarchical structure includes: n-layer grids, the n-layer grids are obtained by segmenting the target area according to different segmentation granularities, the first-layer grid is the grid with the smallest segmentation granularity in the n-layer grids, the i-th layer grid corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; from 1 to n-1, according to the i-th spatiotemporal representation, determining the i+1th spatiotemporal representation corresponding to the i+1th layer grid to obtain n-1 spatiotemporal representations; according to the i-th spatiotemporal representation, determining the loss function corresponding to the i-th layer grid to obtain n loss functions, and using the n loss functions to train a preset neural network model to obtain a target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at a future moment.
[0007] Optionally, the first layer of grids includes: h×w atomic grids, where h and w are both positive integers greater than 1; the i-th spatiotemporal representation is used to represent the spatiotemporal data corresponding to each grid in the target grid in the i-th layer of grids, where the target grid is any k×k grid in the i-th layer of grids, and the moving step of the target grid in the i-th layer of grids is k, and k is a positive integer not greater than h and w.
[0008] Optionally, from 1 to n-1, based on the i-th space-time representation, determine the i+1th space-time representation corresponding to the i+1th layer of grid, including: from 1 to n-1, merging k×k i-th space-time representations corresponding to the i-th layer of grid to obtain the i+1th space-time representation corresponding to the i+1th layer of grid.
[0009] Optionally, the k×k i-th spatiotemporal representations corresponding to the i-th layer of grid are merged to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid, including: inputting the k×k i-th spatiotemporal representations into a two-dimensional convolutional layer, and using the two-dimensional convolutional layer to process the k×k i-th spatiotemporal representations to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid, wherein the two-dimensional convolutional layer includes: a convolution kernel with a size and a step size of k.
[0010] Optionally, from 1 to n-1, based on the i-th spatiotemporal representation, the i+1th spatiotemporal representation corresponding to the i+1th layer of grid is determined to obtain n-1 spatiotemporal representations, the method also includes: merging the i+1th spatiotemporal representation with the i+1th target spatiotemporal representation corresponding to the i+1th layer of grid, wherein the i+1th target spatiotemporal representation is the spatiotemporal representation with the greatest degree of correlation with the i+1th spatiotemporal representation in the i+1th layer of grid.
[0011] Optionally, based on the i-th spatiotemporal representation, determining the loss function corresponding to the i-th grid layer includes: mapping the i-th spatiotemporal representation to the prediction result of the i-th spatiotemporal data corresponding to the i-th grid layer; performing mathematical processing on the historical spatiotemporal data corresponding to the i-th grid layer to determine the i-th spatiotemporal data corresponding to the i-th grid layer; determining the loss function corresponding to the i-th grid layer based on the prediction result of the i-th spatiotemporal data and the i-th spatiotemporal data.
[0012] Optionally, mathematically processing the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids includes: processing the historical spatiotemporal data corresponding to the i-th layer of grids based on digital features of the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids.
[0013] Optionally, the historical spatiotemporal data corresponding to the i-th layer of grids are processed according to digital features of the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids, including: processing the historical spatiotemporal data according to the expected value and variance of the historical spatiotemporal data corresponding to the i-th layer of grids to obtain the i-th spatiotemporal data corresponding to the i-th layer of grids.
[0014] Optionally, before respectively mapping the first space-time representation and n-1 space-time representations to space-time data prediction results to obtain n space-time data prediction results, the method also includes: processing the i-th space-time representation to obtain n processed space-time representations, including: performing nearest neighbor upsampling processing on the i+1-th space-time representation to obtain the i+1-th first feature map; performing convolution processing on the i-th space-time representation to obtain the i-th second feature map; merging the i+1-th first feature map and the i-th second feature map to obtain the processed i-th space-time representation; and determining the n processed space-time representations based on the processed i-th space-time representation.
[0015] Optionally, a preset neural network model is trained using n loss functions to obtain a target neural network model, including: determining a neural network model that minimizes a target loss function as the target neural network model, wherein the target loss function is the sum of the n loss functions.
[0016] Optionally, multiple categories of spatiotemporal data represented by different time intervals within the first layer of grid are determined, including: determining a first category of spatiotemporal data with a first preset time unit as a time interval, wherein the first preset time unit includes at least: hours; determining a second category of spatiotemporal data with a second preset time unit as a time interval, wherein the second preset time unit includes at least: days; determining a third category of spatiotemporal data with a third preset time unit as a time interval, wherein the third preset time unit includes at least: weeks.
[0017] Optionally, time conversion and splicing are performed on multiple categories of spatiotemporal data to obtain a first spatiotemporal representation corresponding to a first layer of grids, including: performing convolution processing on each category of spatiotemporal data in the multiple categories of spatiotemporal data to extract feature information of each category of spatiotemporal data at different time points; using the feature information of each category of spatiotemporal data at different time points as a time representation to obtain multiple time representations corresponding to the multiple categories of spatiotemporal data; converting multiple time representations into multiple feature vectors, and splicing the multiple feature vectors to obtain a first spatiotemporal representation corresponding to the first layer of grids.
[0018] According to another aspect of the embodiment of the present application, a method for predicting spatiotemporal data is also provided, including: obtaining first historical spatiotemporal data in a first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the first historical spatiotemporal data includes at least: historical spatiotemporal supply and demand data based on the target object; inputting the first historical spatiotemporal data into a target neural network model, and using the target neural network model to determine future spatiotemporal supply and demand data based on the target object, wherein the target neural network model is trained according to the above model training method.
[0019] According to another aspect of the embodiment of the present application, a model training device is also provided, including: a first determination module, used to determine multiple types of spatiotemporal data represented by different time intervals in a first layer of grids, and perform time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; a second determination module, used to determine the i+1th spatiotemporal representation corresponding to the i+1th layer of grids from 1 to n-1 according to the i-th spatiotemporal representation, so as to obtain n-1 spatiotemporal representations; a third determination module, used to determine the loss function corresponding to the i-th layer of grids according to the i-th spatiotemporal representation, so as to obtain n loss functions, and use the n loss functions to train a preset neural network model to obtain a target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at future moments.
[0020] According to another aspect of the embodiments of the present application, a non-volatile storage medium is also provided, the storage medium includes a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the above model training method.
[0021] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above model training method is executed when the program is run.
[0022] According to another aspect of the embodiments of the present application, a computer program is also provided, wherein when the computer program is executed by a processor, the above model training method is implemented.
[0023] According to another aspect of the embodiments of the present application, a computer program product is also provided, which includes a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above model training method is implemented.
[0024] In an embodiment of the present application, multiple types of spatiotemporal data represented by different time intervals in a first-layer grid are determined, and time conversion and splicing processing are performed on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first-layer grid, wherein the first-layer grid belongs to a hierarchical structure, and the hierarchical structure includes: n-layer grids, the n-layer grids are obtained by segmenting the target area according to different segmentation granularities, the first-layer grid is the grid with the smallest segmentation granularity in the n-layer grids, the i-th layer grid corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; from 1 to n-1, according to the i-th spatiotemporal representation, the i+1-th spatiotemporal representation corresponding to the i+1-th layer grid is determined to obtain n -1 spatiotemporal representation; according to the ith spatiotemporal representation, the loss function corresponding to the ith layer of grid is determined to obtain n, and the multi-scale spatiotemporal representation is learned in a hierarchical and bottom-up manner. Different scales share parameters through a hierarchical structure, so as to achieve the purpose of making full use of the hierarchical relationship represented by multi-scale in the training process of the spatiotemporal data prediction model, thereby achieving the technical effect of reducing the overhead in the model training process and improving the prediction accuracy of the model, and further solving the technical problem that the hierarchical relationship represented by multi-scale is not fully utilized in the training process of the relevant spatiotemporal data prediction model, resulting in high overhead in the model training process and low prediction accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0026] Figure 1a It is a schematic diagram of a multi-layer grid;
[0027] Figure 1b is a schematic diagram of a spatiotemporal data prediction method according to the related art;
[0028] Figure 1c is a schematic diagram of another spatiotemporal data prediction method according to the related art;
[0029] Figure 2 is a flow chart of a model training method according to an embodiment of the present application;
[0030] Figure 3is a schematic diagram of a model training according to an embodiment of the present application;
[0031] Figure 4 is a schematic diagram of cross-scale modeling according to an embodiment of the present application;
[0032] Figure 5 is a flow chart of a model training method according to an embodiment of the present application;
[0033] Figure 6 is a structural diagram of a training device of a model according to an embodiment of the present application;
[0034] Figure 7 It is a hardware structure block diagram of a computer terminal according to a model training method of an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0038] Hierarchical structure, the hierarchical structure includes multiple layers of grids, Figure 1aIt is a schematic diagram of a multi-layer grid, where the multi-layer grid is obtained by segmenting a certain area according to different scales (segmentation granularity). The smallest-scale grid layer includes h×w atomic grids, which have the highest resolution and are the finest-grained grids. The grids of other scales in the multi-layer grid, except the smallest-scale grid layer, are obtained by adding adjacent high-resolution grids through a sliding window containing k×k grids. The stride of the sliding window can be set to k, which ensures that each fine-grained grid belongs to only one coarse-grained grid in the hierarchical structure.
[0039] There are two strategies for related spatiotemporal data prediction methods: Related technology 1 is based on fine-grained prediction: a single fine-grained prediction model is trained, and the prediction of the coarse-grained area can be obtained by merging the fine-grained prediction results, such as Figure 1b Related technology 2 is based on multi-scale prediction: training multiple prediction models of different scales, or using one model to predict multiple scales at the same time, and the predictions of different scales are obtained from the prediction results of the corresponding scales, such as Figure 1c shown.
[0040] In summary, since only a single model needs to be trained, the strategy based on fine-grained prediction has the benefit of low computational cost. However, when providing coarse-grained prediction, merging fine-grained prediction results will accumulate fine-grained prediction errors, resulting in low accuracy of coarse-grained prediction results. Since the strategy based on multi-scale prediction provides prediction results at multiple scales, there is no problem of error accumulation, and the prediction accuracy is usually higher than that based on fine-grained prediction model. However, since multiple models / network layers of different scales need to be trained, its computational cost is higher than that based on fine-grained prediction.
[0041] Based on the improvement of related technology 1 and related technology 2, related technology 3 has determined a method that can simultaneously perform dual-scale prediction. Based on a single neural network, it simultaneously predicts the traffic at two scales. However, related technology 3 has the following defects: 1. It does not fully utilize the hierarchical relationship of multi-scale representation, resulting in a large computational overhead. Specifically, the representation learning of different scales is implemented based on completely different modules (that is, these modules do not share parameters). In related technology 3, as the number of scales increases, its computational cost will increase significantly accordingly. 2. It does not balance the multi-scale tasks, resulting in the prediction biased towards the scale with a larger artificial weight. Specifically, related technology 3 uses multi-task learning to simultaneously optimize network parameters of different scales, but due to the difference in the magnitude of prediction tasks of different scales (for example, the loss of coarse-grained may be 1000 times that of fine-grained), related technology 3 balances tasks of different scales by manually weighting different tasks. Since it is difficult to determine the optimal weights of multiple scales, this method is difficult to completely balance the learning tasks of each scale.
[0042] In summary, in order to solve the above problems, relevant solutions are provided in the embodiments of the present application, which are described in detail below.
[0043] According to an embodiment of the present application, a method embodiment of a model training method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0044] Figure 2 is a flow chart of a model training method according to an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:
[0045] Step S202, determining multiple types of spatiotemporal data represented by different time intervals in the first layer of grids, and performing time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n.
[0046] Preferably, the target area is a preset specific target or target range. This area can be a specific geographical area or other field. For example, the target area can be a city or a business district.
[0047] For example, spatiotemporal data includes spatiotemporal supply and demand data, where spatiotemporal supply and demand data refers to data on the supply and demand of resources, products or services within a specific time and space. These data can include information on population size, economic activities, traffic flow, energy consumption, etc., aiming to help people understand and analyze resource allocation and utilization under specific spatiotemporal conditions. For example, spatiotemporal supply and demand data in the field of urban planning may include information such as population density, traffic congestion, and housing demand; spatiotemporal supply and demand data in the economic field may include information such as commodity sales, labor demand, and capacity utilization; spatiotemporal supply and demand data in the energy field may include information such as electricity consumption, fuel demand, and distribution of renewable energy resources.
[0048] It can be understood that the first layer of grids is the grid with the smallest segmentation granularity among the n layers of grids included in the hierarchical structure. In other words, the first layer of grids is the grid with the smallest scale among the n layers of grids. The smaller the segmentation granularity of the grid, that is, the smaller the scale of the grid, the finer the grid is divided, and thus the characteristics of the space can be described more finely. The larger the segmentation granularity of the grid, that is, the larger the scale of the grid, the coarser the grid is divided, and the faster the calculation and analysis can be performed. In practical applications, the segmentation granularity of the grid needs to be determined based on the complexity of the specific problem, the limitation of computing resources, and the accuracy requirements.
[0049] Preferably, the i-th grid is the grid with the i-th smallest segmentation granularity among the n-layer grids. For example, the hierarchical structure includes: 4 layers of grids, namely the 1st layer of grids, the 2nd layer of grids, the 3rd layer of grids, the 4th layer of grids and the 5th layer of grids, wherein the 1st layer of grids is the grid with the smallest segmentation granularity among the 4 layers of grids, the 2nd layer of grids is the grid with the second smallest segmentation granularity among the 4 layers of grids, the 3rd layer of grids is the grid with the third smallest (second largest) segmentation granularity among the 4 layers of grids, and the 4th layer of grids is the grid with the fourth smallest (first largest) segmentation granularity among the 4 layers of grids. In addition, the spatiotemporal representation of the 1st layer of grids is the 1st spatiotemporal representation, the spatiotemporal representation of the 2nd layer of grids is the 2nd spatiotemporal representation, the spatiotemporal representation of the 3rd layer of grids is the 3rd spatiotemporal representation, and the spatiotemporal representation of the 4th layer of grids is the 4th spatiotemporal representation.
[0050] It is understood that the space-time representation is to express or display (space-time data) mathematical concepts, relations and operations in symbols, graphics or other ways. The space-time representation can be in the form of algebraic expressions, equations, inequalities, graphics, tables, etc.
[0051] Step S204, from 1 to n-1, according to the i-th spatiotemporal representation, determine the i+1-th spatiotemporal representation corresponding to the i+1-th layer grid to obtain n-1 spatiotemporal representations.
[0052] Exemplarily, when n=4, determining the i+1th space-time representation corresponding to the i+1th layer of grid based on the i-th space-time representation can be achieved by the following method: determining the second space-time representation corresponding to the second layer of grid based on the first space-time representation; determining the third space-time representation corresponding to the third layer of grid based on the second space-time representation; determining the fourth space-time representation corresponding to the fourth layer of grid based on the third space-time representation.
[0053] Step S206, based on the i-th spatiotemporal representation, determine the loss function corresponding to the i-th layer of grid to obtain n loss functions, and use the n loss functions to train the preset neural network model to obtain the target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at future times.
[0054] According to some preferred embodiments, the preset neural network model is trained using n loss functions to obtain the target neural network model, including the following steps: 1. Select an appropriate loss function according to the data type of the data to be predicted. Common loss functions include mean squared error (MSE), cross entropy loss function (CrossEntropy Loss), etc. 2. Select a suitable optimization algorithm to minimize the loss function. Common optimization algorithms include gradient descent (GD), stochastic gradient descent (SGD), etc. 3. Use the selected optimization algorithm to train the neural network model. In each training round, the training data is input into the model, the value of the loss function is calculated, and the model parameters are updated using the optimization algorithm. 4. During the training process, monitor the change of the loss function and the performance of the model on the validation set. According to the change of the loss function, adjust the learning rate, optimization algorithm or model structure to improve the performance of the model. 5. After the training is completed, the model is verified and tested using the validation set and the test set to evaluate the performance of the model.
[0055] Figure 3 This is a schematic diagram of a model training according to an embodiment of the present application. Figure 2 and Figure 3 , describe the technical solutions in the embodiments of the present application.
[0056] According to some optional embodiments of the present application, the first layer of grids includes: h×w atomic grids, wherein h and w are both positive integers greater than 1; the i-th spatiotemporal representation is used to represent the spatiotemporal data corresponding to each grid in the target grid in the i-th layer of grids, wherein the target grid is any k×k grid in the i-th layer of grids, and the moving step of the target grid in the i-th layer of grids is k, and k is a positive integer not greater than h and w.
[0057] It can be understood that the atomic grid has the highest resolution (e.g., 150m×150m) in the multi-layer grid and is the finest-grained grid. The target grid can also be called a sliding window. Assuming that the target grid includes 2 rows and 2 columns (2×2) of atomic grids, that is, the target grid is a 2×2 grid, then the first spatiotemporal representation is used to represent: in the first layer of grids, the spatiotemporal data corresponding to each of the 4 atomic grids in the target grid. That is, the first grid corresponds to k×k (2×2) first spatiotemporal representations.
[0058] According to some preferred embodiments of the present application, determining multiple types of spatiotemporal data represented by different time intervals within the first layer of grid can be achieved by the following method: determining a first type of spatiotemporal data with a first preset time unit as a time interval, wherein the first preset time unit includes at least: hours; determining a second type of spatiotemporal data with a second preset time unit as a time interval, wherein the second preset time unit includes at least: days; determining a third type of spatiotemporal data with a third preset time unit as a time interval, wherein the third preset time unit includes at least: weeks.
[0059] It is understandable that in order to capture different time dependencies, one can use Figure 3 The illustrated time series modeling module determines multiple types of spatiotemporal data represented by different time intervals within a first-level grid.
[0060] Specifically, for a preset time t, multiple types of spatiotemporal data represented by different time intervals in the first layer of grids can be determined along a preset number of time slots on the time axis (for example, adjacent time, daily periodicity, and weekly periodicity), where the first type of spatiotemporal data , the second type of spatiotemporal data And the third type of spatiotemporal data , the above process can be expressed by the following formula:
[0061]
[0062] where d and w denote the daily and weekly intervals, respectively (e.g., in a one-hour forecasting task, d and w are 24 and 144, respectively).
[0063] In some preferred embodiments, for the first type of spatiotemporal data , the second type of spatiotemporal data And the third type of spatiotemporal data Time conversion and splicing are performed to obtain a first space-time representation corresponding to the first layer of grids. This can be achieved by the following method: performing convolution processing on each type of space-time data in the multiple types of space-time data to extract feature information of each type of space-time data at different time points; using the feature information of each type of space-time data at different time points as time representation to obtain multiple time representations corresponding to the multiple types of space-time data; converting multiple time representations into multiple feature vectors, splicing the multiple feature vectors to obtain the first space-time representation corresponding to the first layer of grids.
[0064] In other words, using three unshared convolutional layers (i.e. Figure 3 Conv) of the time series modeling module in the first category of spatiotemporal data , the second type of spatiotemporal data And the third type of spatiotemporal data Converted to time representation, respectively Conv( )、Conv( ) and Conv( ), where the dimension of each time representation is D. Then, concatenating the above three time representations, we can get the first spatiotemporal representation corresponding to the first layer of grid: .
[0065] The above process can be expressed by the following formula:
[0066]
[0067] In addition, the first spatiotemporal representation corresponding to the first layer of grid can be determined by the following method: First, the spatiotemporal data needs to be converted into a format suitable for input into CNN. For spatiotemporal data, it can be represented as a three-dimensional tensor, where the first dimension represents time, the second dimension represents space, and the third dimension represents the features of the data. For example, for video data, it can be represented as a four-dimensional tensor, where the first dimension represents time, the second and third dimensions represent the height and width of the video, and the fourth dimension represents the number of channels of the video. Then, the features in the spatiotemporal data are extracted through the convolution layer. The convolution layer can extract local features by sliding the convolution kernel and combine these features to obtain a higher-level representation. The spatiotemporal data can be converted into a temporal representation, that is, the temporal features are extracted through the convolution layer. Finally, the extracted features are reduced and abstracted through the pooling layer to obtain a more efficient temporal representation. The pooling layer can achieve dimensionality reduction of features by taking the maximum or average value in the local area while retaining the most important information.
[0068] According to some other optional embodiments of the present application, from 1 to n-1, according to the i-th spatiotemporal representation, determining the i+1th spatiotemporal representation corresponding to the i+1th grid layer is achieved by the following method: from 1 to n-1, merging the k×k i-th spatiotemporal representations corresponding to the i-th grid layer to obtain the i+1th spatiotemporal representation corresponding to the i+1th grid layer. The above steps are implemented by the hierarchical spatial modeling unit.
[0069] It can be understood that for each scale, there is a scale merging layer and a spatial modeling unit. The scale merging layer aggregates adjacent grids and reduces the width and height of the feature map, thereby mapping the representation of the fine-grained grid to the coarse-grained representation. The subsequent spatial modeling unit further captures the spatial dependencies under the coarse granularity and learns the coarse-grained (large-scale) spatial representation.
[0070] For example, by represents the i+1th spatiotemporal representation corresponding to the i+1th grid layer, through Represents the i-th spatiotemporal representation corresponding to the i-th grid layer, which can be represented by the following formula: Based on the i-th spatiotemporal representation, determine the i+1-th spatiotemporal representation corresponding to the i+1-th grid layer:
[0071]
[0072] Assuming n=4, k=2, we can take the following steps to obtain three space-time representations (the second space-time representation, the third space-time representation, and the fourth space-time representation):
[0073] The 2×2 first spatiotemporal representations corresponding to the first grid are merged to obtain the second spatiotemporal representation corresponding to the second grid;
[0074] The 2×2 second spatiotemporal representations corresponding to the second grid are merged to obtain the third spatiotemporal representation corresponding to the third grid;
[0075] The 2×2 third-time space representations corresponding to the third grid are merged to obtain the fourth-time space representation corresponding to the fourth-layer grid.
[0076] In some optional embodiments of the present application, the k×k i-th spatiotemporal representations corresponding to the i-th layer of grid are merged to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid. This can be achieved by the following method: input the k×k i-th spatiotemporal representations into a two-dimensional convolutional layer, and use the two-dimensional convolutional layer to process the k×k i-th spatiotemporal representations to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid, wherein the two-dimensional convolutional layer includes: a convolution kernel with a size and a step size of k.
[0077] Preferably, k×k ith spatiotemporal representations are input into a two-dimensional convolutional layer, and the k×k ith spatiotemporal representations are processed by the two-dimensional convolutional layer, which can be achieved by the following steps: 1. Define the size and number of convolution kernels to determine the mode of convolution operation and the number of features extracted. In this embodiment, the size and step size of the convolution kernel are both k, wherein the convolution kernel is a filter used to extract input features, and the convolution kernel with a size and step size of k means that each of its movements is in units of k, and it will also slide in units of k during the convolution operation. The convolution kernel with a size and step size of k can extract coarser features because it can skip some detailed information, but can process the input faster. 2. Input the k×k ith spatiotemporal representation into the two-dimensional convolutional layer, perform the convolution operation using the defined convolution kernel, and obtain the output feature map. 3. After obtaining the output feature map, an activation function can be added to introduce nonlinearity, such as the ReLU activation function, to enhance the expressive power of the model. 4. After the convolution operation, a pooling layer can be added to downsample the feature map and reduce the size of the feature map, thereby reducing the number of parameters and enhancing the robustness of the model.
[0078] Preferably, when the hierarchical structure P has n scales, the spatiotemporal table calculated at time t+1 is for:
[0079]
[0080] Among them, SM and Merge are the spatial building block and scale merging layer respectively. is a natural number representing the scale, for example, Always equal to 1. From the finest granularity to the coarsest granularity, by adding more scale merging layers and spatial building blocks, the network continuously learns coarser-grained (larger-scale) spatial representations.
[0081] The scale merging layer obtains a coarser spatial representation by merging the representations of adjacent positions. The spatial modeling unit is intended to model the correlation between adjacent positions. The scale merging layer and the spatial modeling unit are replaceable in the present invention.
[0082] For example, the following methods can be used to determine the degree of association between spatiotemporal representations: 1. Calculate similarity: Evaluate the degree of association between two spatiotemporal representations by calculating the similarity between them. Common similarity calculation methods include cosine similarity, Euclidean distance, Pearson correlation coefficient, etc. 2. Feature matching: Match the features in the spatiotemporal representations and evaluate the degree of association between them based on the matching results. 3. Model prediction: Predict the degree of association between two spatiotemporal representations by training a model. For example, a classifier or regression model can be used to predict the probability of whether two spatiotemporal representations are related or similar.
[0083] As some optional embodiments of the present application, after determining the i+1th spatiotemporal representation corresponding to the i+1th layer of grid based on the i-th spatiotemporal representation to obtain n-1 spatiotemporal representations, it is also necessary to: merge the i+1th spatiotemporal representation with the i+1th target spatiotemporal representation corresponding to the i+1th layer of grid, wherein the i+1th target spatiotemporal representation is the spatiotemporal representation with the greatest degree of correlation with the i+1th spatiotemporal representation in the i+1th layer of grid. The above degree of correlation can be determined by ConvBlock, ResBlock or SEBlock, wherein ConvBlock is a neural network module including a convolutional layer for constructing a deep convolutional neural network, ResBlock is a residual module, which can help solve the gradient vanishing and gradient exploding problems in deep neural network training by directly adding the input to the convolutional layer output inside the module, and SEBlock is an attention mechanism module, which dynamically adjusts the importance of each channel by learning the channel relationship of the input feature, thereby improving the model's attention to the input feature.
[0084] For example, if n is 4 and k is 2, then after determining three spatiotemporal representations (the second spatiotemporal representation, the third spatiotemporal representation, and the fourth spatiotemporal representation), it is also necessary to: merge the second spatiotemporal representation with the second target spatiotemporal representation, merge the third spatiotemporal representation with the third target spatiotemporal representation, and merge the fourth spatiotemporal representation with the fourth target spatiotemporal representation. Through this step, the correlation between adjacent positions can be modeled, thereby improving the accuracy of the spatiotemporal representation.
[0085] In some optional embodiments of the present application, the first spatiotemporal representation and n-1 spatiotemporal representations are respectively mapped to spatiotemporal data prediction results, and before obtaining n spatiotemporal data prediction results, the i-th spatiotemporal representation needs to be processed to obtain the processed n spatiotemporal representations. The above processing can be implemented by a cross-scale modeling module.
[0086] Specifically, the processing of the i-th spatiotemporal representation can be implemented by the following steps:
[0087] Step S1, perform nearest neighbor upsampling on the i+1th spatiotemporal representation to obtain the i+1th first feature map. The specific implementation of step S1 is as follows:
[0088] 1. Determine the target upsampling frequency. For example, if the original data has 10 features per frame and the target upsampling frequency is 20, then every two original features will be merged into a new feature. 2. For each time step in the i+1th spatiotemporal representation, find the most recent observation. This can be done by calculating the time difference. 3. Copy the most recent observation found to the time step of the target upsampling frequency. 4. Repeat steps 2 and 3 until all time steps have been processed. The resulting feature map is the i+1th first feature map.
[0089] Step S2, performing convolution processing on the i-th spatiotemporal representation to obtain the i-th second feature map.
[0090] Step S3: merge the (i+1)th first feature map and the (i)th second feature map to obtain the processed (i)th spatiotemporal representation.
[0091] Step S4, determining n processed space-time representations based on the processed i-th space-time representation.
[0092] Figure 4 is a schematic diagram of cross-scale modeling according to an embodiment of the present application, such as Figure 4 As shown, considering that the grid in this embodiment has a regular hierarchical structure, that is, the number of fine-grained grids is always an integer multiple of the coarse-grained grids, a top-down lateral connection is used to enhance the spatiotemporal representation of each scale. This structure is similar to the feature pyramid network in computer vision. The following is the calculation method of the cross-scale modeling module:
[0093]
[0094] in, is the i-th spatiotemporal representation among the processed n spatiotemporal representations, is the i-th spatiotemporal representation corresponding to the i-th layer of grid, It is the i+1th spatiotemporal representation corresponding to the i+1th layer grid.
[0095] Figure 4 An example of cross-scale representation enhancement is given. The function UpSample improves the spatial resolution by nearest neighbor upsampling, so that feature maps from coarse scales and more detailed ones can be aligned. Subsequently, the lateral connection merges the bottom-up and top-down feature maps with the same resolution by element-by-element addition. The entire iterative process starts from the coarsest granularity and ends at the finest granularity.
[0096] In summary, the cross-scale modeling module is used to strengthen the information interaction between scales and can continuously use coarse-grained information to enhance fine-grained information.
[0097] It should be explained that related multi-scale data prediction schemes usually use multi-task learning technology to simultaneously learn the spatiotemporal representation of multiple scales and obtain the final prediction results. A major difficulty in multi-task learning is to balance the learning weights of each task. Related technology 3 achieves traffic prediction at two scales by manually setting weights.
[0098] This application designs a scale normalization mechanism to automatically balance learning tasks of different scales and ensure that each scale is balanced. The above mechanism is reflected in the process of determining n first spatiotemporal data through a multi-task learning module and determining the target neural network model. The relevant process is explained in detail below.
[0099] First, multiple fully connected layers are used to map the first spatiotemporal representation and n-1 spatiotemporal representations into spatiotemporal data prediction results, and n spatiotemporal data prediction results are obtained. This process can be represented by the following formula:
[0100]
[0101] in, is the spatiotemporal data prediction result corresponding to the s-th layer grid, is the spatiotemporal representation corresponding to the s-th layer grid, where s∈P and P is the hierarchical structure. It is worth noting that the above fully connected layers are scale-specific and do not share parameters between different scales.
[0102] In addition, multiple fully connected layers can be used to map the processed n spatiotemporal representations into spatiotemporal data prediction results to obtain n spatiotemporal data prediction results. This process can be represented by the following formula:
[0103]
[0104] in, It is the processed spatiotemporal representation corresponding to the s-th layer grid.
[0105] Furthermore, in the training of multi-scale networks, there are significant differences in the prediction targets of various scales. For example, the flow rate at the coarsest scale may be more than 1,000 times larger than the flow rate at the finest scale. These differences will cause multi-task optimization to be biased towards the coarse-grained scale, resulting in poor prediction of the fine-grained scale. In order to solve the above problems, the scale normalization mechanism proposed in this application performs a normalization transformation at the input level. Specifically, the loss function corresponding to the i-th grid layer is determined according to the i-th spatiotemporal representation by the following method: mapping the i-th spatiotemporal representation to the i-th spatiotemporal data prediction result corresponding to the i-th grid layer; performing mathematical processing on the historical spatiotemporal data corresponding to the i-th grid layer to determine the i-th spatiotemporal data corresponding to the i-th grid layer; determining the loss function corresponding to the i-th grid layer based on the i-th spatiotemporal data prediction result and the i-th spatiotemporal data.
[0106] Among them, mathematical processing is performed on the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids, which is achieved by the following method: based on the digital characteristics of the historical spatiotemporal data corresponding to the i-th layer of grids, the historical spatiotemporal data corresponding to the i-th layer of grids are processed to determine the i-th spatiotemporal data corresponding to the i-th layer of grids.
[0107] In addition, based on the digital characteristics of the historical spatiotemporal data corresponding to the i-th layer of grids, the historical spatiotemporal data corresponding to the i-th layer of grids are processed to determine the i-th spatiotemporal data corresponding to the i-th layer of grids, which is achieved by the following method: based on the expected value and variance of the historical spatiotemporal data corresponding to the i-th layer of grids, the historical spatiotemporal data are processed to obtain the i-th spatiotemporal data corresponding to the i-th layer of grids.
[0108] The expected value and variance of the historical spatiotemporal data corresponding to the s-th grid layer can be expressed by the following formula: Processing is performed to obtain the s-th spatiotemporal data corresponding to the s-th grid layer The process:
[0109]
[0110] In this way, all scales and their corresponding loss functions are rescaled to a consistent level. This method can adaptively give equal attention to learning tasks of different scales.
[0111] Therefore, the multi-task loss function can be directly calculated as the sum of the loss functions of each scale without manually setting weights. Specifically, the preset neural network model is trained using n loss functions to obtain the target neural network model, which is achieved by the following method: the neural network model that minimizes the target loss function is determined as the target neural network model, where the target loss function is the sum of the n loss functions. This method can be expressed by the following formula:
[0112]
[0113] Among them, L and Θ are the loss function and network parameters respectively.
[0114] The above approach ensures that each scale is given equal consideration. Equal consideration of each scale can lead to more comprehensive information and understanding, because factors at different scales may influence each other, and ignoring a certain scale may lead to one-sided conclusions.
[0115] Preferably, the target neural network can also be determined by the following method. The target neural network model can be obtained by setting the maximum number of iterations and satisfying the maximum number of iterations, for example, stopping training after 100 iterations of the data set. The target neural network model can also be obtained by observing the confirmation check value. Specifically, during the model training process, when the error curve of the confirmed sample no longer decreases for several consecutive iterations, the training can be stopped. The prediction accuracy of the training set on the network can also be calculated: when the prediction accuracy reaches a certain threshold value, the target neural network model is obtained.
[0116] In summary, according to the above steps, multiple types of spatiotemporal data represented by different time intervals in the first layer of grids are determined, and time conversion and splicing processing are performed on the multiple types of spatiotemporal data to obtain the first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; from 1 to n-1, according to the i-th spatiotemporal representation , determine the i+1th spatiotemporal representation corresponding to the i+1th layer of grid to obtain n-1 spatiotemporal representations; according to the i-th spatiotemporal representation, determine the loss function corresponding to the i-th layer of grid to obtain n, through a hierarchical, bottom-up (from the grid with the smallest segmentation granularity to the grid with the largest segmentation granularity) approach, learn multi-scale spatiotemporal representations, and share parameters at different scales through a hierarchical structure, so as to achieve the purpose of making full use of the hierarchical relationship represented by multi-scales in the training process of the spatiotemporal data prediction model, thereby achieving the technical effect of reducing the overhead in the model training process and improving the prediction accuracy of the model.
[0117] It is understandable that according to Figure 3 The model shown uses a hierarchical spatial modeling module to hierarchically learn spatial representations by stacking spatial building blocks layer by layer, instead of using completely different spatial building blocks for each scale as in previous studies. This method has higher representation learning efficiency, and the more scales that need to be predicted, the higher the efficiency compared to existing solutions, because it extracts the spatial representation of the next coarse-grained scale grid from the previous finer-grained scale instead of extracting from the finest granularity. Moreover, the hierarchical spatial modeling module also implicitly considers the structural constraints of different scales (for example, the spatiotemporal flow data of the coarse-grained scale should be equal to the sum of the spatiotemporal flow data of the fine-grained scale), making the multi-scale representation learning effect better. In addition, the multi-task learning module designs a scale normalization mechanism to balance the learning tasks of different scales and ensure that each scale is considered equally. Compared with the method of manually assigning task weights in previous studies, this embodiment is an adaptive method with low computational overhead. It only needs to normalize the original input elements and has no additional learning parameters. It promotes multi-scale learning while ensuring efficient training.
[0118] Figure 5 is a flow chart of a model training method according to an embodiment of the present application, such as Figure 5 As shown, the method comprises the following steps:
[0119] Step S502, obtaining the first historical spatiotemporal data in the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, and the first historical spatiotemporal data includes at least: historical spatiotemporal supply and demand data based on the target object.
[0120] Step S504: input the first historical spatiotemporal data into the target neural network model, and use the target neural network model to determine the future spatiotemporal supply and demand data based on the target object, wherein the target neural network model is based on Figure 2 The training method shown is effective for example Figure 3 The model shown is trained.
[0121] It should be noted that Figure 5 The preferred implementation of the illustrated embodiment can be found in Figure 2 The relevant description of the illustrated embodiment will not be repeated here.
[0122] Figure 6 is a structural diagram of a training device of a model according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:
[0123] The first determination module 60 is used to determine multiple types of spatiotemporal data represented by different time intervals in the first layer of grids, and perform time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n.
[0124] The second determination module 62 is used to determine the i+1th spatiotemporal representation corresponding to the i+1th layer grid from 1 to n-1 according to the i-th spatiotemporal representation, so as to obtain n-1 spatiotemporal representations.
[0125] The third determination module 64 is used to determine the loss function corresponding to the i-th layer of grid based on the i-th spatiotemporal representation to obtain n loss functions, and use the n loss functions to train the preset neural network model to obtain the target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at future times.
[0126] Furthermore, the first layer of grids includes: h×w atomic grids, wherein h and w are both positive integers greater than 1; the i-th spatiotemporal representation is used to represent the spatiotemporal data corresponding to each grid in the target grid in the i-th layer of grids, wherein the target grid is any k×k grid in the i-th layer of grids, and the moving step of the target grid in the i-th layer of grids is k, and k is a positive integer not greater than h and w.
[0127] Further, from 1 to n-1, based on the i-th spatiotemporal representation, the i+1th spatiotemporal representation corresponding to the i+1th layer of grid is determined, including: from 1 to n-1, k×k i-th spatiotemporal representations corresponding to the i-th layer of grid are merged to obtain the i+1th spatiotemporal representation corresponding to the i+1th layer of grid.
[0128] Furthermore, the k×k i-th spatiotemporal representations corresponding to the i-th layer of grid are merged to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid, including: inputting the k×k i-th spatiotemporal representations into a two-dimensional convolutional layer, and using the two-dimensional convolutional layer to process the k×k i-th spatiotemporal representations to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer of grid, wherein the two-dimensional convolutional layer includes: a convolution kernel with a size and a step size of k.
[0129] Furthermore, from 1 to n-1, according to the i-th spatiotemporal representation, the i+1th spatiotemporal representation corresponding to the i+1th layer of grid is determined to obtain n-1 spatiotemporal representations, and the method also includes: merging the i+1th spatiotemporal representation with the i+1th target spatiotemporal representation corresponding to the i+1th layer of grid, wherein the i+1th target spatiotemporal representation is the spatiotemporal representation with the greatest degree of correlation with the i+1th spatiotemporal representation in the i+1th layer of grid.
[0130] Furthermore, based on the i-th spatiotemporal representation, the loss function corresponding to the i-th grid layer is determined, including: mapping the i-th spatiotemporal representation to the prediction result of the i-th spatiotemporal data corresponding to the i-th grid layer; performing mathematical processing on the historical spatiotemporal data corresponding to the i-th grid layer to determine the i-th spatiotemporal data corresponding to the i-th grid layer; and determining the loss function corresponding to the i-th grid layer based on the prediction result of the i-th spatiotemporal data and the i-th spatiotemporal data.
[0131] Furthermore, mathematical processing is performed on the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids, including: processing the historical spatiotemporal data corresponding to the i-th layer of grids based on digital features of the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids.
[0132] Furthermore, based on the digital features of the historical spatiotemporal data corresponding to the i-th grid layer, the historical spatiotemporal data corresponding to the i-th grid layer is processed to determine the i-th spatiotemporal data corresponding to the i-th grid layer, including: based on the expected value and variance of the historical spatiotemporal data corresponding to the i-th grid layer, the historical spatiotemporal data is processed to obtain the i-th spatiotemporal data corresponding to the i-th grid layer.
[0133] Furthermore, before respectively mapping the first spatiotemporal representation and the n-1 spatiotemporal representations to spatiotemporal data prediction results to obtain n spatiotemporal data prediction results, the method also includes: processing the i-th spatiotemporal representation to obtain n processed spatiotemporal representations, including: performing nearest neighbor upsampling processing on the i+1-th spatiotemporal representation to obtain the i+1-th first feature map; performing convolution processing on the i-th spatiotemporal representation to obtain the i-th second feature map; merging the i+1-th first feature map and the i-th second feature map to obtain the processed i-th spatiotemporal representation; and determining the n processed spatiotemporal representations based on the processed i-th spatiotemporal representation.
[0134] Furthermore, the preset neural network model is trained using n loss functions to obtain a target neural network model, including: determining the neural network model that minimizes the target loss function as the target neural network model, wherein the target loss function is the sum of the n loss functions.
[0135] Furthermore, multiple types of spatiotemporal data represented by different time intervals within the first layer of grid are determined, including: determining a first type of spatiotemporal data with a first preset time unit as a time interval, wherein the first preset time unit includes at least: hours; determining a second type of spatiotemporal data with a second preset time unit as a time interval, wherein the second preset time unit includes at least: days; determining a third type of spatiotemporal data with a third preset time unit as a time interval, wherein the third preset time unit includes at least: weeks.
[0136] Furthermore, the multiple categories of spatiotemporal data are subjected to time transformation and splicing processing to obtain a first spatiotemporal representation corresponding to the first layer of grids, including: performing convolution processing on each category of spatiotemporal data in the multiple categories of spatiotemporal data to extract feature information of each category of spatiotemporal data at different time points; using the feature information of each category of spatiotemporal data at different time points as time representation to obtain multiple time representations corresponding to the multiple categories of spatiotemporal data; converting multiple time representations into multiple feature vectors, splicing the multiple feature vectors to obtain the first spatiotemporal representation corresponding to the first layer of grids.
[0137] It should be noted that the above Figure 6Each module in the can be a program module (for example, a set of program instructions that implement a specific function) or a hardware module. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above modules is a processor, or the functions of each of the above modules are implemented by a processor.
[0138] It should be noted that Figure 6 The preferred implementation of the illustrated embodiment can be found in Figure 2 The relevant description of the illustrated embodiment will not be repeated here.
[0139] Figure 7 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a model training method. Figure 7 As shown, the computer terminal 70 may include one or more (shown as 702a, 702b, ..., 702n in the figure) processors 702 (the processor 702 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 704 for storing data, and a transmission module 706 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown.
[0140] It should be noted that the one or more processors 702 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 70. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0141] The memory 704 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the training method of the model in the embodiment of the present application. The processor 702 executes various functional applications and data processing by running the software programs and modules stored in the memory 704, that is, realizing the training method of the above-mentioned model. The memory 704 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 704 may further include a memory remotely arranged relative to the processor 702, and these remote memories may be connected to the computer terminal 70 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0142] The transmission module 706 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 70. In one example, the transmission module 706 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 706 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0143] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 70 .
[0144] It should be noted that, in some optional embodiments, the above Figure 7 The computer terminal shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 7 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computer terminal described above.
[0145] It should be noted that Figure 7 The computer terminal shown is used to execute Figure 2 The training method of the model shown, therefore the relevant explanations in the execution method of the above commands are also applicable to the electronic device and will not be repeated here.
[0146] An embodiment of the present application also provides a non-volatile storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above model training method.
[0147] A program for a non-volatile storage medium to perform the following functions: determining multiple types of spatiotemporal data represented by different time intervals in a first-layer grid, and performing time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first-layer grid, wherein the first-layer grid belongs to a hierarchical structure, and the hierarchical structure includes: n-layer grids, the n-layer grids are obtained by segmenting the target area according to different segmentation granularities, the first-layer grid is a grid with the smallest segmentation granularity among the n-layer grids, the i-th layer grid corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; from 1 to n-1, according to the i-th spatiotemporal representation, determining the i+1th spatiotemporal representation corresponding to the i+1th layer grid to obtain n-1 spatiotemporal representations; according to the i-th spatiotemporal representation, determining the loss function corresponding to the i-th layer grid to obtain n.
[0148] An embodiment of the present application also provides an electronic device, including: a memory and a processor, the processor is used to run a program stored in the memory, wherein the above model training method is executed when the program is running.
[0149] The processor is used to run a program that performs the following functions: determining multiple types of spatiotemporal data represented by different time intervals in the first layer of grids, and performing time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n; from 1 to n-1, according to the i-th spatiotemporal representation, determine the i+1th spatiotemporal representation corresponding to the i+1th layer of grids to obtain n-1 spatiotemporal representations; according to the i-th spatiotemporal representation, determine the loss function corresponding to the i-th layer of grids to obtain n.
[0150] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0151] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0152] In the above-mentioned embodiments of the present application, the collected information is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary protection measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0153] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0155] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0156] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0157] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A model training method, characterized in that: include: Determine multiple types of spatiotemporal data represented by different time intervals in the first layer of grids, and perform time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n layers of grids, the n layers of grids are obtained by segmenting the target area according to different segmentation granularities, the first layer of grids is the grid with the smallest segmentation granularity in the n layers of grids, the i-th layer of grids corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n, wherein the first layer of grids includes: h×w atomic grids, wherein h and w are both positive integers greater than 1, and the i-th spatiotemporal representation is used to represent the spatiotemporal data corresponding to each grid in the target grid in the i-th layer of grids, wherein the target grid is any k×k grid in the i-th layer of grids, and the moving step of the target grid in the i-th layer of grids is k, and k is a positive integer not greater than h and w; From 1 to n-1, according to the i-th spatiotemporal representation, determine the i+1th spatiotemporal representation corresponding to the i+1th layer grid to obtain n-1 spatiotemporal representations; According to the i-th spatiotemporal representation, determine the loss function corresponding to the i-th layer of grid to obtain n loss functions, and use the n loss functions to train a preset neural network model to obtain a target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at a future time; Before determining the loss function corresponding to the i-th layer of grid based on the i-th spatiotemporal representation, the method also includes: processing the i-th spatiotemporal representation to obtain n processed spatiotemporal representations, including: performing nearest neighbor upsampling processing on the i+1-th spatiotemporal representation to obtain the i+1-th first feature map; performing convolution processing on the i-th spatiotemporal representation to obtain the i-th second feature map; merging the i+1-th first feature map and the i-th second feature map to obtain the processed i-th spatiotemporal representation; and determining the n processed spatiotemporal representations based on the processed i-th spatiotemporal representation.
2. The method according to claim 1, characterized in that From 1 to n-1, according to the i-th spatiotemporal representation, determine the i+1th spatiotemporal representation corresponding to the i+1th layer grid, including: From 1 to n-1, the k×k i-th spatiotemporal representations corresponding to the i-th grid layer are merged to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th grid layer.
3. The method according to claim 2, characterized in that Merging k×k i-th spatiotemporal representations corresponding to the i-th grid layer to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th grid layer includes: Input the k×k i-th spatiotemporal representations into a two-dimensional convolutional layer, and use the two-dimensional convolutional layer to process the k×k i-th spatiotemporal representations to obtain the i+1-th spatiotemporal representation corresponding to the i+1-th layer grid, wherein the two-dimensional convolutional layer includes: a convolution kernel with a size and a step size both of which are k.
4. The method according to claim 1, characterized in that: From 1 to n-1, after determining the i+1th spatiotemporal representation corresponding to the i+1th grid layer according to the i-th spatiotemporal representation to obtain n-1 spatiotemporal representations, the method further includes: The i+1th spatiotemporal representation is merged with the i+1th target spatiotemporal representation corresponding to the i+1th layer of grid, wherein the i+1th target spatiotemporal representation is the spatiotemporal representation with the greatest degree of correlation with the i+1th spatiotemporal representation in the i+1th layer of grid.
5. The method according to claim 1, characterized in that Determining a loss function corresponding to the i-th layer of grid according to the i-th spatiotemporal representation includes: Mapping the i-th spatiotemporal representation to the i-th spatiotemporal data prediction result corresponding to the i-th layer of grid; Performing mathematical processing on the historical spatiotemporal data corresponding to the i-th grid layer to determine the i-th spatiotemporal data corresponding to the i-th grid layer; Determine the loss function corresponding to the i-th layer of grid according to the prediction result of the i-th spatiotemporal data and the i-th spatiotemporal data.
6. The method according to claim 5, characterized in that Performing mathematical processing on the historical spatiotemporal data corresponding to the i-th grid layer to determine the i-th spatiotemporal data corresponding to the i-th grid layer, including: The historical spatiotemporal data corresponding to the i-th layer of grids are processed according to digital features of the historical spatiotemporal data corresponding to the i-th layer of grids to determine the i-th spatiotemporal data corresponding to the i-th layer of grids.
7. The method according to claim 6, characterized in that According to the digital features of the historical spatiotemporal data corresponding to the i-th grid layer, the historical spatiotemporal data corresponding to the i-th grid layer is processed to determine the i-th spatiotemporal data corresponding to the i-th grid layer, including: The historical spatiotemporal data are processed according to the expected value and variance of the historical spatiotemporal data corresponding to the i-th grid layer to obtain the i-th spatiotemporal data corresponding to the i-th grid layer.
8. The method according to claim 1, characterized in that The preset neural network model is trained using the n loss functions to obtain a target neural network model, including: Determine the neural network model that minimizes the target loss function as the target neural network model, wherein the target loss function is the sum of the n loss functions.
9. The method according to claim 1, characterized in that: Determine multiple types of spatiotemporal data represented by different time intervals in the first layer of grid, including: Determine a first type of spatiotemporal data with a first preset time unit as a time interval, wherein the first preset time unit at least includes: hours; Determine a second type of spatiotemporal data with a second preset time unit as the time interval, wherein the second preset time unit at least includes: day; Determine a third type of spatiotemporal data with a third preset time unit as the time interval, wherein the third preset time unit at least includes: week.
10. The method according to claim 1, characterized in that The multiple types of spatiotemporal data are subjected to time conversion and splicing processing to obtain a first spatiotemporal representation corresponding to the first layer of grids, including: Performing convolution processing on each type of spatiotemporal data in the multiple types of spatiotemporal data to extract feature information of each type of spatiotemporal data at different time points; Taking the characteristic information of each type of spatiotemporal data at different time points as time representation, obtaining multiple time representations corresponding to the multiple types of spatiotemporal data; The multiple time representations are converted into multiple feature vectors, and the multiple feature vectors are concatenated to obtain the first spatiotemporal representation corresponding to the first layer of grids.
11. A method for predicting spatiotemporal data, characterized in that: include: Acquire first historical spatiotemporal data in a first-layer grid, wherein the first-layer grid belongs to a hierarchical structure, and the hierarchical structure includes: n-layer grids, the n-layer grids are obtained by segmenting the target area according to different segmentation granularities, the first-layer grid is a grid with the smallest segmentation granularity in the n-layer grids, and the first historical spatiotemporal data at least includes: historical spatiotemporal supply and demand data based on the target object; The first historical spatiotemporal data is input into a target neural network model, and the target neural network model is used to determine future spatiotemporal supply and demand data based on the target object, wherein the target neural network model is trained according to the model training method according to any one of claims 1 to 10.
12. A model training device, characterized in that: include: The first determination module is used to determine multiple types of spatiotemporal data represented by different time intervals in the first layer of grids, and perform time conversion and splicing processing on the multiple types of spatiotemporal data to obtain a first spatiotemporal representation corresponding to the first layer of grids, wherein the first layer of grids belongs to a hierarchical structure, and the hierarchical structure includes: n-layer grids, wherein the n-layer grids are obtained by segmenting the target area according to different segmentation granularities, the first-layer grid is the grid with the smallest segmentation granularity in the n-layer grids, the i-th layer grid corresponds to the i-th spatiotemporal representation, n is a positive integer greater than 1, and i is a positive integer not greater than n, wherein the first-layer grid includes: h×w atomic grids, wherein h and w are both positive integers greater than 1, and the i-th spatiotemporal representation is used to represent the spatiotemporal data corresponding to each grid in the target grid in the i-layer grid, wherein the target grid is any k×k grid in the i-layer grid, and the moving step of the target grid in the i-layer grid is k, and k is a positive integer not greater than h and w; The second determination module is used to determine the i+1th spatiotemporal representation corresponding to the i+1th layer grid from 1 to n-1 according to the i-th spatiotemporal representation, so as to obtain n-1 spatiotemporal representations; A third determination module is used to determine the loss function corresponding to the i-th layer grid according to the i-th spatiotemporal representation to obtain n loss functions, and use the n loss functions to train a preset neural network model to obtain a target neural network model, wherein the target neural network model is used to predict the spatiotemporal data of the target area at a future time; The training device of the model is also used to perform the following steps before determining the loss function corresponding to the i-th layer of grid based on the i-th spatiotemporal representation: processing the i-th spatiotemporal representation to obtain n processed spatiotemporal representations, including: performing nearest neighbor upsampling processing on the i+1-th spatiotemporal representation to obtain the i+1-th first feature map; performing convolution processing on the i-th spatiotemporal representation to obtain the i-th second feature map; merging the i+1-th first feature map and the i-th second feature map to obtain the processed i-th spatiotemporal representation; and determining the processed n spatiotemporal representations based on the processed i-th spatiotemporal representation.
13. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the model training method described in any one of claims 1 to 10 or the spatiotemporal data prediction method described in claim 11.
14. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein when the program is run, the model training method described in any one of claims 1 to 10 or the spatiotemporal data prediction method described in claim 11 is executed.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the model training method described in any one of claims 1 to 10 or the spatiotemporal data prediction method described in claim 11.
