Fine-grained city flow inference method for adaptively migrating knowledge of multiple cities

Through the urban feature extraction network and adaptive feature fusion module based on Transformer, combined with the upsampling module, the fine-grained urban traffic inference model is trained, and the fine-grained urban traffic inference efficiency, accuracy and generalization ability in the existing technology is solved. The problem has achieved efficient and accurate fine-grained urban traffic inference and effective transfer of knowledge among multiple cities.

CN119416890APending Publication Date: 2025-02-11CENT SOUTH UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411444350.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The prior art has problems with poor inference efficiency, accuracy and generalization capabilities in fine-grained urban traffic inference, especially in terms of sparse data and knowledge transfer between multiple cities.

Method used

The initial spatiotemporal features of coarse-grained urban traffic map are extracted using the urban feature extraction network (UBFormer) based on Transformer, combined with the adaptive feature fusion module and upsampling module, the fine-grained urban traffic inference model is trained through the total loss function to achieve coarseness of the target city. Fine-grained inference of the particle size spatiotemporal flow map.

Benefits of technology

It improves the efficiency, accuracy and generalization ability of fine-grained urban traffic inference, can effectively deal with the problems of sparse data and knowledge transfer between multiple cities, and enhances the model's adaptability in new urban environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119416890A_ABST
    Figure CN119416890A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a fine-grained city flow inference method for adaptively migrating knowledge of multiple cities, and belongs to the technical field of data processing, and the method specifically comprises the steps: extracting an initial spatial-temporal feature corresponding to each source city in a coarse-grained city flow graph through employing a city feature extraction network; inputting all the initial spatio-temporal features into an adaptive feature fusion module to obtain an optimal spatio-temporal feature corresponding to each source city, and calculating a total city specific feature loss and a total city invariant feature loss; respectively inputting the optimal spatial-temporal characteristics and semantic variables of each source city into an up-sampling module to obtain a predicted city flow graph of each source city, and calculating pseudo Huber loss according to the predicted city flow graph; obtaining a total loss function and training a fine-grained urban flow inference model according to the total loss function; and inputting the coarse-grained space-time flow diagram of the target city into the fine-grained city flow inference model to obtain a fine-grained city flow diagram. Through the scheme of the invention, the inference efficiency, accuracy and generalization ability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The disclosed embodiments relate to the field of data processing technology, and in particular to a fine-grained city traffic inference method for adaptively migrating knowledge of multiple cities. Background Art

[0002] Currently, accurate representation of fine-grained urban traffic is of great significance for building smart cities and intelligent transportation systems (ITS), especially in urban planning, urban renewal, and traffic coordination. Deploying a large number of sensors in various areas of a city to observe fine-grained urban traffic will lead to significant expenses in equipment deployment and maintenance. However, in reality, due to limited budgets, only a small number of sensors may be deployed to collect urban traffic data. Therefore, inferring fine-grained urban traffic from coarse-grained observations obtained from a limited number of sensors has become a core research topic and has received increasing research attention in recent years. In many practical applications of smart cities, inferring fine-grained urban traffic flows based on coarse-grained traffic flow observations is of great significance. Most of the existing methods rely on a large amount of high-quality urban flow data, but ignore the data sparsity problem that is common in real-world scenarios. Therefore, the performance of existing methods may not be ideal in cities that lack sufficient traffic flow data. How to design a more generalizable urban flow inference model that can effectively transfer knowledge between multiple cities is a challenging and unsolved open research problem.

[0003] It can be seen that there is an urgent need for a fine-grained urban traffic inference method that has high inference efficiency, accuracy and generalization ability and can adaptively transfer knowledge of multiple cities. Summary of the invention

[0004] In view of this, the embodiments of the present disclosure provide a fine-grained city traffic inference method that adaptively migrates knowledge of multiple cities, which at least partially solves the problems of poor inference efficiency, accuracy and generalization ability in the prior art.

[0005] The embodiment of the present disclosure provides a fine-grained city traffic inference method for adaptively migrating multiple city knowledge, including:

[0006] Step 1: Use the Transformer-based city feature extraction network to extract the initial spatiotemporal features corresponding to each source city in the coarse-grained city flow graph;

[0007] Step 2: Input all initial spatiotemporal features into the adaptive feature fusion module to obtain the optimal spatiotemporal features corresponding to each source city, and calculate the total city-specific feature loss and the total city-invariant feature loss;

[0008] Step 3: Input the optimal spatiotemporal features and semantic variables of each source city into the upsampling module to obtain the predicted urban flow map of each source city and calculate the pseudo-Huber loss based on it;

[0009] Step 4: Combine the total city-specific feature loss, the total city-invariant feature loss, and the pseudo-Huber loss to obtain the total loss function and use it to train a fine-grained urban traffic inference model formed by a Transformer-based urban feature extraction network, an adaptive feature fusion module, and an upsampling module;

[0010] Step 5: Input the coarse-grained spatiotemporal flow map of the target city into the trained fine-grained urban flow inference model to obtain a fine-grained urban flow map.

[0011] According to a specific implementation of an embodiment of the present disclosure, the Transformer-based city feature extraction network includes tokenization, temporal self-attention, block-level self-attention and semantic cross-attention, and the step 1 specifically includes:

[0012] Step 1.1, convert the coarse-grained urban traffic map into a token tensor through tokenization, and then input it into a multi-layer perceptron to generate a token matrix

[0013] Step 1.2, linearly project the token matrix to generate the query vector Q, key vector K and value vector V in the attention mechanism, and transform Q, K, V into {Q i},{K i},{V i}, the expression for generating the query vector Q, key vector K and value vector V is:

[0014] Q=W q (X), K = W k (X), V = W v (X)

[0015] in, W q , W k , W v is a multi-layer perceptron, i = 1, 2, ..., H, i represents the index of the head in the multi-head attention, H and d head are the number of heads and the dimension of the heads respectively;

[0016] Step 1.3, Q i , K i and Split into and in, And t = 1, 2, ..., T, and introduce a hidden dimension attention structure, and then calculate the attention on the token and hidden dimensions separately

[0017]

[0018]

[0019] in, Both represent the calculated attention score matrix, and EMA represents the exponential moving average;

[0020] Step 1.4, get the output of temporal self-attention based on the attention on the token and hidden dimensions

[0021]

[0022] Step 1.5, Q i , K i and Split into blocks and in, Computing spatial attention via block-level self-attention

[0023]

[0024] Where d represents the constant for scaling the attention score;

[0025] Step 1.6, calculate the output of block-level self-attention

[0026]

[0027] Step 1.7, based on the output of temporal self-attention and the output of block-level self-attention, the attention heads are merged in the temporal and block dimensions, and layer normalization and linear projection are applied to further integrate the features, respectively obtaining the temporal features O and t and block-level features O n , and add them together to get the initial spatiotemporal feature O.

[0028] According to a specific implementation of the embodiment of the present disclosure, after step 1, the method further includes:

[0029] Using semantic cross-attention to learn and integrate city semantic features, the continuous factors in city semantic features are directly concatenated, and the categorical factors in city semantic features are input into independent embedding layers;

[0030] Use a 2-layer multi-layer perceptron to fuse the concatenated features and get the semantic variable Semantic cross attention takes O as the query and as key and value.

[0031] According to a specific implementation of the embodiment of the present disclosure, the adaptive feature fusion module includes a city-specific feature learning model and a city-invariant feature learning model, and step 2 specifically includes:

[0032] Step 2.1: Input the initial spatiotemporal features O of each source city into the city classifier of the city-specific feature learning model, obtain the classification results and calculate the city-specific loss based on them

[0033]

[0034] Among them, f e is the shared feature extraction function, f d It uses the features after the city feature extraction network as input for classification, and finally classifies with the label c k Compare and calculate the loss, x represents the original data from the city;

[0035] Step 2.2, get the total city-specific feature loss by averaging the city-specific losses over all source cities

[0036]

[0037] Where K is the number of source cities;

[0038] Step 2.3, input the initial spatiotemporal features O of each source city into the multilayer perceptron of the city-specific feature learning model, input the extracted features into the city-invariant feature learning model, and calculate the maximum mean difference loss between each two source cities

[0039]

[0040] Among them, φ(.) is the feature map, which maps the original sample to the reproducing kernel Hilbert space, and represents a collection of cities;

[0041] Step 2.4, calculate the total city invariant feature loss by averaging all source city pairs

[0042]

[0043] Step 2.5, clustering the spatiotemporal features of each source city extracted by the multi-layer perceptron according to the classification results of the city classifier, and obtaining the optimal spatiotemporal features corresponding to each source city.

[0044] According to a specific implementation of the embodiment of the present disclosure, step 3 specifically includes:

[0045] Step 3.1, in the upsampling module, the optimal spatiotemporal features are upsampled using a preset number of Subpixel blocks to generate hidden features Hf and a convolutional layer is applied to map it into a tensor, and the predicted urban flow map corresponding to each source city is obtained by combining the semantic variables;

[0046] Step 3.2: Calculate the pseudo-Huber loss based on the predicted city flow graph and the real city flow graph

[0047]

[0048] Among them, δ is an adjustable hyperparameter, y i represents the predicted city traffic map, Represents a real city traffic map.

[0049] According to a specific implementation of the embodiment of the present disclosure, the expression of the total loss function is:

[0050]

[0051] in, is the pseudo-Huber loss, is the total city-specific feature loss, is the total city invariant feature loss, and λ and β are trade-off hyperparameters.

[0052] According to a specific implementation of the embodiment of the present disclosure, step 5 specifically includes:

[0053] Step 5.1, input the coarse-grained spatiotemporal flow map of the target city into the city feature extraction network to extract preliminary spatiotemporal features;

[0054] Step 5.2, calculate the similarity between the preliminary spatiotemporal characteristics and the spatiotemporal characteristics of the source city and perform adaptive aggregation based on the similarity to achieve adaptive knowledge transfer and obtain the optimal spatiotemporal characteristics of the target city;

[0055] In step 5.3, the spatiotemporal features of the optimal target city are upsampled to obtain a fine-grained urban flow map.

[0056] The fine-grained urban traffic inference scheme for adaptively migrating multiple city knowledge in the disclosed embodiment includes: step 1, using a Transformer-based urban feature extraction network to extract the initial spatiotemporal features corresponding to each source city in the coarse-grained urban traffic map; step 2, inputting all the initial spatiotemporal features into an adaptive feature fusion module to obtain the optimal spatiotemporal features corresponding to each source city, and calculating the total city-specific feature loss and the total city-invariant feature loss; step 3, respectively inputting the optimal spatiotemporal features and semantic variables of each source city into an upsampling module to obtain a predicted urban traffic map for each source city and calculating the pseudo-Huber loss based on the loss; step 4, combining the total city-specific feature loss, the total city-invariant feature loss and the pseudo-Huber loss to obtain a total loss function and training a fine-grained urban traffic inference model formed by the Transformer-based urban feature extraction network, the adaptive feature fusion module and the upsampling module based on the total loss function; step 5, inputting the coarse-grained spatiotemporal traffic map of the target city into the trained fine-grained urban traffic inference model to obtain a fine-grained urban traffic map.

[0057] The beneficial effects of the embodiments of the present disclosure are as follows: through the scheme of the present disclosure, a transformer-based urban feature extraction network UBFormer is proposed to comprehensively extract the spatiotemporal features of multiple source cities, and then a learnable integrator is introduced to fuse the city-invariant and city-specific feature representations of the sparse traffic flow data of the target city. Finally, the feature representation of the target city is constructed through adaptive feature fusion, and its fine-grained urban flow is inferred through the designed urban flow upsampler, which improves the inference efficiency, accuracy and generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0059] Figure 1 A schematic diagram of a flow chart of a fine-grained urban traffic inference method for adaptively migrating knowledge of multiple cities provided in an embodiment of the present disclosure;

[0060] Figure 2 A system framework diagram of a fine-grained urban traffic inference method for adaptively migrating multiple city knowledge provided in an embodiment of the present disclosure;

[0061] Figure 3 A schematic diagram of an embodiment of the present disclosure for adaptively transferring spatiotemporal knowledge from multiple source cities to infer fine-grained urban flows of a target city. DETAILED DESCRIPTION

[0062] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0063] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0064] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0065] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The illustrations only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0066] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0067] Traditionally, super-resolution methods in computer vision have been used for fine-grained urban traffic inference and have achieved remarkable performance. However, directly borrowing these methods will be insufficient due to ignoring the complex spatiotemporal correlations of traffic data and some external factors such as weather, temperature, and holidays. To address this limitation, methods such as UrbanFM, UrbanPy, and DeepLGR have been proposed, which incorporate specific features of urban traffic flow data into model design. To address the problem that coarse-grained urban traffic collected in real-world scenarios may be incomplete or noisy, MT-CSR and DiffUFlow effectively complete the data completion / denoising and super-resolution tasks.

[0068] Unfortunately, the superior performance of these models is based on large-scale training data, which may be difficult to obtain in real-world applications. For example, a newly constructed city may have limited fine-grained sensor data or even only coarse-grained sensor data. Transfer learning has been studied as an effective solution to the data shortage problem by leveraging the knowledge of cities with rich data. There are many domain adaptation-based models to solve spatiotemporal prediction problems, but there is no research on the fine-grained traffic inference task. They all assume that the target city has a certain amount of fine-grained data, ignoring the possibility of only coarse-grained data. In addition, these methods only transfer knowledge from a single source city, which may lead to unstable results and the risk of negative transfer due to the differences in the underlying data distribution between different cities.

[0069] This paper is the first to focus on transferring knowledge from multiple source cities for fine-grained traffic inference in target cities where no fine-grained data is available. However, this problem faces two key challenges.

[0070] The target city lacks fine-grained data labels. Existing methods usually assume that a certain amount of fine-grained data is available in the target city. However, since the city is newly built, sensor data cannot be obtained, making training and fine-tuning in the target city not directly applicable. How to design a special algorithm for this city-generalized fine-grained urban traffic inference problem to achieve strong generalization ability is a challenge.

[0071] We need to evaluate the helpfulness of regions in source cities in target cities and perform selective transfer. Existing methods for learning regional features focus on inter-region relationships in a single city and are therefore city-specific and may not generalize to another city. It is challenging to extract useful features from source cities and generalize them well in target cities.

[0072] The disclosed embodiment provides a fine-grained urban traffic inference method for adaptively migrating multiple urban knowledge, and the method can be applied to the urban traffic prediction process in urban management scenarios.

[0073] See also Figure 1 , is a flow chart of a fine-grained urban traffic inference method for adaptively migrating multiple city knowledge provided by an embodiment of the present disclosure. Figure 1 As shown, the method mainly comprises the following steps:

[0074] Step 1: Use the Transformer-based city feature extraction network to extract the initial spatiotemporal features corresponding to each source city in the coarse-grained city flow graph;

[0075] Furthermore, the Transformer-based city feature extraction network includes tokenization, temporal self-attention, block-level self-attention and semantic cross-attention, and the step 1 specifically includes:

[0076] Step 1.1, convert the coarse-grained urban traffic map into a token tensor through tokenization, and then input it into a multi-layer perceptron to generate a token matrix

[0077] Step 1.2, linearly project the token matrix to generate the query vector Q, key vector K and value vector V in the attention mechanism, and convert Q, K, V into {Q i},{K i},{V i}, the expression for generating the query vector Q, key vector K and value vector V is:

[0078] Q=W q (X), K = W k (X), V = W v (X)

[0079] in, W q , W k , W v is a multi-layer perceptron, i = 1, 2, ..., H, i represents the index of the head in the multi-head attention, H and d head are the number of heads and the dimensions of the heads respectively:

[0080] Step 1.3, Q i , K i and Split into and in, And t = 1, 2, ..., T, and introduce a hidden dimension attention structure, and then calculate the attention on the token and hidden dimensions separately

[0081]

[0082]

[0083] in, Both represent the calculated attention score matrix, and EMA represents the exponential moving average;

[0084] Step 1.4, get the output of temporal self-attention based on the attention on the token and hidden dimensions

[0085]

[0086] Step 1.5, Q i , K i and Split into blocks and in, Computing spatial attention via block-level self-attention

[0087]

[0088] Where d represents the constant for scaling the attention score;

[0089] Step 1.6, calculate the output of block-level self-attention

[0090]

[0091] Step 1.7, based on the output of temporal self-attention and the output of block-level self-attention, the attention heads are merged in the temporal and block dimensions, and layer normalization and linear projection are applied to further integrate the features, respectively obtaining the temporal features O and t and block-level features O n , and add them together to get the initial spatiotemporal feature O.

[0092] Furthermore, after step 1, the method further comprises:

[0093] Using semantic cross-attention to learn and integrate city semantic features, the continuous factors in city semantic features are directly concatenated, and the categorical factors in city semantic features are input into independent embedding layers;

[0094] Use a 2-layer multi-layer perceptron to fuse the concatenated features and get the semantic variable Semantic cross attention takes O as the query and as key and value.

[0095] In specific implementation, given an upsampling factor N, source data D from K different but related cities s =D 1 ,D 2 ,…,D K, coarse-grained urban traffic map And the target city D te Our goal is to learn a generalized model on K source city datasets so that it can infer fine-grained urban flow graphs from target coarse-grained urban flow spatial graphs.

[0096] like Figure 3 As shown, the method of the present disclosure focuses for the first time on transferring knowledge from multiple source cities for fine-grained traffic inference in target cities where no fine-grained data is available.

[0097] In this regard, the embodiment of the present disclosure provides a fine-grained urban traffic inference framework AdaTM for adaptively migrating knowledge of multiple cities, corresponding to the fine-grained urban traffic inference framework AdaTM for adaptive knowledge transfer across multiple cities. Figure 2 shown.

[0098] AdaTM consists of three components: the Transformer-based city feature extraction network UBFormer module, the adaptive feature fusion module and the upsampling module. UBFormer not only performs self-attention in the patch and time dimensions while considering POI (Point of Interest), but also captures the dependencies of city semantic variables through cross-attention, enabling the framework to fully extract the spatial-temporal features of the source city. After obtaining excellent preliminary features of the source city, the adaptive feature fusion module learns city-invariant and city-specific feature representations. Thus, we can construct the feature representation of the new city and obtain the final fine-grained flow map through the city upsampling module.

[0099] The specific implementation process of AdaTM, a fine-grained urban traffic inference framework with adaptive knowledge transfer across multiple cities, is as follows:

[0100] Step 1: UBFormer network extracts spatial-temporal features

[0101] correspond Figure 2 The blue part in the figure is mainly divided into tokenization, temporal self-attention, block-level self-attention, and semantic cross-attention.

[0102] (1) Tokenization

[0103] We adopt the idea of ​​patching to convert the input spatiotemporal graph into a token tensor. For a city input data of size T×H×W, we first reshape the features by dividing the input into non-overlapping P×P local blocks, where Here, we transform the time series into several paragraphs of length P, each of which retains part of the sequence-level semantic information, which makes the attention mechanism more effective than the ordinary point-by-point correspondence mechanism.

[0104] We then use a deep multi-layer perceptron (MLP) layer F1:P 2 →d, an additional token and position embedding To generate the token matrix Where d is the hidden dimension.

[0105] We consider generating Q (query), K (key), and V (value) by linear projection of the token tensor X as follows:

[0106] Q=W q (X), K = W k (X), V = W v (X) (1)

[0107] in W q , W k , W v is a multi-layer perceptron (MLP) layer.

[0108] Next, to use multi-head attention, we transform Q, K, V into {Q i},{K i},{V i},in i = 1, 2, ..., H. i represents the index of the head in the multi-head attention, H and d head are the number of heads and the dimensions of the heads respectively. We can make full use of cross-channel information through the multi-head attention mechanism.

[0109] (2) We apply the attention mechanism to the time dimension, i , K i and Split into and in and t = 1, 2, ..., T. In addition to the standard attention on the token, we also introduce an additional hidden dimension attention structure, which helps capture local information within each block. The attention on the token and hidden dimensions is calculated as follows:

[0110]

[0111] in And EMA stands for Exponential Moving Average. and Apply EMA. Each query token will be able to get higher attention scores on more key tokens, making the output more robust. The output is calculated as follows:

[0112]

[0113] (3) We then transform Q i , K i and Split into blocks and in And n=1,2,...,N.

[0114] With the help of the attention-based module, we can learn arbitrary spatial dependencies between each grid in the urban flow graph. However, in real-world scenarios, urban flow observations are affected by the geographical surrounding areas. Intuitively, points of interest (POIs) and road network structures (RNs) are crucial for capturing spatial dependencies. Therefore, we incorporate a learnable empty matrix A by embedding PO I and RNs into the attention mechanism. The attention mechanism we designed is formulated as follows:

[0115]

[0116] in And ⊙ represents the element-wise product. Next, the output is calculated as follows:

[0117]

[0118] In the time and patch dimensions, we merge the attention heads and apply LayerNorm and LinearProjection to further integrate the features, obtaining O t and O n . Next, we add these two features together to get O.

[0119] (4) Urban mobility may be affected by various external factors. To further extract these features, we apply cross-attention to learn and integrate urban semantic features and incorporate them into our framework.

[0120] The city semantic features include continuous factors and categorical factors. The continuous factors are directly concatenated, and the categorical factors are input into a separate embedding layer. Next, a 2-layer multi-layer perceptron (MLP) is used to fuse the concatenated features to obtain V sem .

[0121] In UBFormer, the cross-attention layer takes O as the query and V sem As keys and values, to establish the relationship between two variables. The output is generated by applying the query, key and value to formula (1) and formula (4).

[0122] Step 2: Input all initial spatiotemporal features into the adaptive feature fusion module to obtain the optimal spatiotemporal features corresponding to each source city, and calculate the total city-specific feature loss and the total city-invariant feature loss;

[0123] On the basis of the above embodiment, the adaptive feature fusion module includes a city-specific feature learning model and a city-invariant feature learning model, and step 2 specifically includes:

[0124] Step 2.1: Input the initial spatiotemporal features O of each source city into the city classifier of the city-specific feature learning model, obtain the classification results and calculate the city-specific loss based on them

[0125]

[0126] Among them, f e is the shared feature extraction function, f d It uses the features after the city feature extraction network as input for classification, and finally classifies with the label c k Compare and calculate the loss, x represents the original data from the city;

[0127] Step 2.2, get the total city-specific feature loss by averaging the city-specific losses over all source cities

[0128]

[0129] Where K is the number of source cities;

[0130] Step 2.3, input the initial spatiotemporal features O of each source city into the multilayer perceptron of the city-specific feature learning model, input the extracted features into the city-invariant feature learning model, and calculate the maximum mean difference loss between each two source cities

[0131]

[0132] Among them, φ(.) is the feature map, which maps the original sample to the reproducing kernel Hilbert space, and represents a collection of cities;

[0133] Step 2.4, calculate the total city invariant feature loss by averaging all source city pairs

[0134]

[0135] Step 2.5, clustering the spatiotemporal features of each source city extracted by the multi-layer perceptron according to the classification results of the city classifier, and obtaining the optimal spatiotemporal features corresponding to each source city.

[0136] In specific implementation, the specific process of the adaptive feature fusion module fusing spatiotemporal features is as follows:

[0137] The core of AdaTM is to learn the feature representations of city-invariance and city-specificity, and then integrate the obtained features.

[0138] 1) City-specific feature learning model:

[0139] This module aims to learn city-specific features and then aggregate a unified feature representation for the target city by fusing features of multiple source cities. Given a new city x from UBFormer, its city features z are formulated as:

[0140]

[0141] where w k It is City C k The weight on represents the city C k The similarity between the data on the target city and the data on the target city. x is the original data from the city, f k It is City C k The feature learning function, and f e It is the shared feature extraction function UBFormer.

[0142] In order to learn each city C k The weight w k , we build a city classifier It takes the features after UBFormer as input and then uses the softmax function to satisfy formula (7).

[0143] During model training, the city label c of each sample is k ==k is known in advance. Therefore, the city-specific loss can be calculated for each source city k as follows:

[0144]

[0145] c k is the city label used for comparison and loss calculation. By averaging the loss over all source cities, we can get the total city-specific loss, i.e.

[0146] During the evaluation phase of the target city, the fine-grained city flow labels of the new target instance are not available. After the network extracts features, the output of the domain weight branch is used as a weight to fuse the target features extracted by each city-specific branch. It can be understood that the learned city branch network fuses the city-specific features extracted by each source-specific branch to construct the feature representation of the target city. In this way, AdaTM can learn the feature representation of any new city.

[0147] 2) City invariant feature learning module:

[0148] In the domain generalization scenario, we cannot access the target domain data during training, so it is crucial to learn domain-invariant feature representations so that any unseen objects can be represented. Although city-specific feature learning encourages the model to learn domain-specific information for each source city, the feature distribution gap may also widen due to their diverse representations. Therefore, to enhance the generalization ability, we further design a city-invariant representation learning module to seek a balance with city-specific representation learning.

[0149] Existing research on the transfer learning ability of deep networks shows that lower layers tend to learn low-level and general features, while higher layers tend to learn domain-specific features. Therefore, we perform feature adaptation to reduce the distribution differences of source cities between city-specific layers. To achieve feature adaptation, we turn to reducing the number of pairs of cities C i and C j This is done by minimizing the difference dist(C i ,C j ), where dist(.,.) is a distribution distance metric.

[0150] Specifically, we use Maximum Mean Discrepancy (MMD) as the distance metric to help reduce distribution differences. MMD is usually used to measure the similarity of two distributions. i and C j The MMD loss between is formulated as:

[0151]

[0152] where i and j are the indices of the cities, and φ(.) is the feature map that maps the original samples to the reproducing kernel Hilbert space. Then, the total loss of city-invariant learning can be calculated by averaging over all possible city pairs, as

[0153] Step 3: Input the optimal spatiotemporal features and semantic variables of each source city into the upsampling module to obtain the predicted urban flow map of each source city and calculate the pseudo-Huber loss based on it;

[0154] Based on the above embodiment, step 3 specifically includes:

[0155] Step 3.1: In the upsampling module, the optimal spatiotemporal features are upsampled using a preset number of Subpixel blocks to generate hidden features H fA convolutional layer is applied to map it into a tensor, and combined with the semantic variables to obtain the predicted city traffic map corresponding to each source city;

[0156] Step 3.2: Calculate the pseudo-Huber loss based on the predicted city flow graph and the real city flow graph

[0157]

[0158] Among them, δ is an adjustable hyperparameter, y i represents the predicted city traffic map, Represents a real city traffic map.

[0159] In the specific implementation, in the urban flow upsampling module, the extracted features are firstly processed by N Subpixel blocks N = 2 n times upsampling operation to produce a hidden feature The Subpixel block extracts features using a convolutional layer followed by a batch normalization. It then uses a PixelShuffle layer to rearrange and upsample the feature map to a size of 2× and applies a ReLU activation function at the end. After processing each Subpixel block, the output feature map is spatially enlarged by a factor of 2 while the number of channels remains the same. After upsampling, a convolutional layer is applied to convert H f Mapping to a tensor In the embodiment of the present disclosure, for simplicity, F can be set o =1.

[0160] When upsampling, we also consider the semantic features V sem , the city semantic feature fusion module is adopted and combined with H f to integrate.

[0161] When training the fine-grained urban flow inference task, we used the pseudo-Huber loss function, defined as follows:

[0162]

[0163] Here, δ is an adjustable hyperparameter that enables our model to strike a balance between accuracy and robustness. i is the inferred result, is the true value.

[0164] Step 4: Combine the total city-specific feature loss, the total city-invariant feature loss, and the pseudo-Huber loss to obtain the total loss function and use it to train a fine-grained urban traffic inference model formed by a Transformer-based urban feature extraction network, an adaptive feature fusion module, and an upsampling module;

[0165] Furthermore, the expression of the total loss function is:

[0166]

[0167] in, is the pseudo-Huber loss, is the total city-specific feature loss, is the total city invariant feature loss, and λ and β are trade-off hyperparameters.

[0168] In specific implementation, combining the total city-specific feature loss, the total city-invariant feature loss and the pseudo-Huber loss, the total loss function of AdaTM can be formulated as:

[0169]

[0170] in, is the loss of fine-grained urban flow inference, is the loss for city-specific representation learning, is the loss for learning the city-invariant representation. λ and β are trade-off hyperparameters.

[0171] Then the fine-grained urban traffic inference model formed by the Transformer-based urban feature extraction network, the adaptive feature fusion module and the upsampling module can be trained according to the total loss function.

[0172] Step 5: Input the coarse-grained spatiotemporal flow map of the target city into the trained fine-grained urban flow inference model to obtain a fine-grained urban flow map.

[0173] Based on the above embodiment, step 5 specifically includes:

[0174] Step 5.1, input the coarse-grained spatiotemporal flow map of the target city into the city feature extraction network to extract preliminary spatiotemporal features;

[0175] Step 5.2, calculate the similarity between the preliminary spatiotemporal characteristics and the spatiotemporal characteristics of the source city and perform adaptive aggregation based on the similarity to achieve adaptive knowledge transfer and obtain the optimal spatiotemporal characteristics of the target city;

[0176] In step 5.3, the spatiotemporal features of the optimal target city are upsampled to obtain a fine-grained urban flow map.

[0177] In specific implementation, after the fine-grained urban traffic inference model AdaTM is trained, it can be inferred in new cities without labels. A series of coarse-grained spatiotemporal traffic maps of the new city are input. The coarse-grained data is first extracted through UBFormer to extract preliminary spatiotemporal features. Then, this feature is used to calculate the similarity with the spatiotemporal features of the source city and then adaptively aggregated to achieve adaptive knowledge transfer, thereby obtaining excellent spatiotemporal features of the target city and combining them with semantic variables to obtain fine-grained traffic maps through the upsampling module.

[0178] Existing technologies have some shortcomings in fine-grained urban flow inference, mainly including: relying on a large amount of high-quality urban flow data, ignoring the common data sparsity problem in real scenarios; lacking an effective cross-city knowledge transfer mechanism, making it difficult to adapt to target cities with large data distribution differences; usually only focusing on local spatial dependencies, ignoring the influence of global geographic information, and failing to fully consider urban semantic information such as points of interest and road network structure when extracting features, which limits the generalization ability of the model in new urban environments. These limitations lead to poor inference performance of existing methods when faced with insufficient data or significant differences between cities.

[0179] Compared with the prior art, the technical solution adopted by the present invention has the following technical effects:

[0180] 1) Solution to the data sparsity problem: The fine-grained urban traffic inference model AdaTM can handle the problem of lack of fine-grained data in underdeveloped cities and improve the generalization ability of the model through adaptive knowledge transfer.

[0181] 2) Multi-city knowledge transfer: For the first time, we study the transfer of knowledge from multiple source cities to infer the fine-grained traffic of a target city, which enhances the generalization ability of the model in new cities.

[0182] 3) Comprehensive extraction of spatial and temporal features: The UBFormer network in this invention can comprehensively extract the spatial and temporal features of the city and effectively integrate the city semantic information.

[0183] 4) Experimental Verification: Extensive experiments on four large real-world datasets verify the effectiveness of the fine-grained urban traffic inference method of this embodiment that adaptively transfers multiple city knowledge compared with the existing state-of-the-art baselines.

[0184] The fine-grained urban traffic inference method for adaptively transferring knowledge of multiple cities provided in this embodiment performs fine-grained urban traffic inference by adaptively transferring knowledge from multiple cities. Specifically, a Transformer-based urban feature extraction network UBFormer is designed, which not only performs self-attention in the patch and time dimensions while considering points of interest (POI), but also captures the dependencies of urban semantic variables through cross-attention, so that the framework can fully extract the spatial-temporal features of the source city. After obtaining excellent preliminary features of the source city, city-invariant and city-specific feature representations are learned. Specifically, city-invariant representation learning is to capture general and transferable knowledge from the source city, while city-specific representation learning is to selectively learn specific features of each source city to enhance generalization ability. Therefore, the feature representation of the new city is constructed by adaptive feature fusion. Next, a city upsampling module is proposed to obtain the final fine-grained urban traffic, which improves the inference efficiency, accuracy and generalization ability.

[0185] It should be understood that various parts of the present disclosure may be implemented in hardware, software, firmware or a combination thereof.

[0186] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A fine-grained urban traffic inference method that adaptively transfers knowledge of multiple cities, characterized by: include: Step 1: Use the Transformer-based city feature extraction network to extract the initial spatiotemporal features corresponding to each source city in the coarse-grained city flow graph; Step 2: Input all initial spatiotemporal features into the adaptive feature fusion module to obtain the optimal spatiotemporal features corresponding to each source city, and calculate the total city-specific feature loss and the total city-invariant feature loss; Step 3: Input the optimal spatiotemporal features and semantic variables of each source city into the upsampling module to obtain the predicted urban flow map of each source city and calculate the pseudo-Huber loss based on it; Step 4: Combine the total city-specific feature loss, the total city-invariant feature loss, and the pseudo-Huber loss to obtain the total loss function and use it to train a fine-grained urban traffic inference model formed by a Transformer-based urban feature extraction network, an adaptive feature fusion module, and an upsampling module; Step 5: Input the coarse-grained spatiotemporal flow map of the target city into the trained fine-grained urban flow inference model to obtain a fine-grained urban flow map.

2. The method according to claim 1, characterized in that ,The Transformer-based city feature extraction network includes tokenization, temporal self-attention, block-level self-attention and semantic cross-attention. ,The step 1 specifically includes: Step 1.1, convert the coarse-grained urban traffic map into a token tensor through tokenization, and then input it into a multi-layer perceptron to generate a token matrix Step 1.2, linearly project the token matrix to generate the query vector Q, key vector K and value vector V in the attention mechanism, and transform Q, K, V into {Q i },{K i },{V i }, the expression for generating the query vector Q, key vector K and value vector V is: Q=W q (X),K=W k (X),V=W v (X) in, W q ,W k ,W v is a multi-layer perceptron, i represents the index of the head in the multi-head attention, H and d head are the number of heads and the dimension of the heads respectively; Step 1.3, Q i , K i and Split into and in, And t = 1, 2, ..., T, and introduce a hidden dimension attention structure, and then calculate the attention on the token and hidden dimensions separately in, Both represent the calculated attention score matrix, and EMA represents the exponential moving average; Step 1.4, get the output of temporal self-attention based on the attention on the token and hidden dimensions Step 1.5, Q i , K i and Split into blocks and in, Computing spatial attention via block-level self-attention Where d represents the constant for scaling the attention score; Step 1.6, calculate the output of block-level self-attention Step 1.7, based on the output of temporal self-attention and the output of block-level self-attention, the attention heads are merged in the temporal and block dimensions, and layer normalization and linear projection are applied to further integrate the features, respectively obtaining the temporal features O and t and block-level features O n , and add them together to get the initial spatiotemporal feature O.

3. The method according to claim 2, characterized in that After step 1, the method further comprises: Using semantic cross-attention to learn and integrate city semantic features, the continuous factors in city semantic features are directly concatenated, and the categorical factors in city semantic features are input into independent embedding layers; Use a 2-layer multi-layer perceptron to fuse the concatenated features and get the semantic variable Semantic cross attention takes O as the query and as key and value.

4. The method according to claim 3, characterized in that ,The adaptive feature fusion module includes a city specific feature learning model and a city invariant feature learning model. ,The step 2 specifically includes: Step 2.1: Input the initial spatiotemporal features O of each source city into the city classifier of the city-specific feature learning model, obtain the classification results and calculate the city-specific loss based on them Among them, f e is the shared feature extraction function, f d It uses the features after the city feature extraction network as input for classification, and finally classifies with the label c k Compare and calculate the loss, x represents the original data from the city; Step 2.2, get the total city-specific feature loss by averaging the city-specific losses over all source cities Where K is the number of source cities; Step 2.3, input the initial spatiotemporal features O of each source city into the multilayer perceptron of the city-specific feature learning model, input the extracted features into the city-invariant feature learning model, and calculate the maximum mean difference loss between each two source cities Among them, φ(.) is the feature map, which maps the original sample to the reproducing kernel Hilbert space, and represents a collection of cities; Step 2.4, calculate the total city invariant feature loss by averaging all source city pairs Step 2.5, clustering the spatiotemporal features of each source city extracted by the multi-layer perceptron according to the classification results of the city classifier, and obtaining the optimal spatiotemporal features corresponding to each source city.

5. The method according to claim 4, characterized in that , the step 3 specifically includes: Step 3.1: In the upsampling module, the optimal spatiotemporal features are upsampled using a preset number of Subpixel blocks to generate hidden features H f A convolutional layer is applied to map it into a tensor, and combined with the semantic variables to obtain the predicted city traffic map corresponding to each source city; Step 3.2: Calculate the pseudo-Huber loss based on the predicted city flow graph and the real city flow graph Among them, δ is an adjustable hyperparameter, y i represents the predicted city traffic map, Represents a real city traffic map.

6. The method according to claim 5, characterized in that , the expression of the total loss function is in, is the pseudo-Huber loss, is the total city-specific feature loss, is the total city invariant feature loss, and λ and β are trade-off hyperparameters.

7. The method according to claim 6, characterized in that , the step 5 specifically includes: Step 5.1, input the coarse-grained spatiotemporal flow map of the target city into the city feature extraction network to extract preliminary spatiotemporal features; Step 5.2, calculate the similarity between the preliminary spatiotemporal characteristics and the spatiotemporal characteristics of the source city and perform adaptive aggregation based on the similarity to achieve adaptive knowledge transfer and obtain the optimal spatiotemporal characteristics of the target city; In step 5.3, the spatiotemporal features of the optimal target city are upsampled to obtain a fine-grained urban flow map.