Rail transit construction safety identification model dynamic adaptation method and system
By constructing a scenario parameter memory library and a dynamic expert hybrid mechanism, the problems of poor cross-scenario adaptability and insufficient sustainable learning ability in existing technologies are solved, and efficient identification and adaptive enhancement of safety hazards in urban rail transit engineering are achieved.
Patent Information
- Application Number
- CN202510705139.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-05-29
AI Technical Summary
Existing safety hazard identification models for urban rail transit projects are insufficient in terms of cross-scenario adaptability and sustainable learning ability, making it difficult to effectively identify safety hazards in complex and ever-changing construction scenarios.
A dynamic adaptation method for the safety identification model of rail transit construction is adopted. By constructing a scene parameter memory library, using a dynamic expert hybrid mechanism and low-rank adaptation technology, the optimal expert module is adaptively selected for parameter updates. Combined with multi-task optimization objective function, incremental learning is achieved while maintaining old scene knowledge.
It improves the model's adaptability and sustainable learning ability in new scenarios, reduces computational costs, alleviates the problem of catastrophic forgetting, enhances the model's robustness and recognition ability in noisy environments, and improves the safety and reliability of urban rail transit engineering.
Smart Images

Figure CN120635839B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of rail transit safety control, and more particularly relates to a rail transit construction safety identification model dynamic adaptation method and system. BACKGROUND
[0002] The continuous learning strategies of the urban rail transit engineering safety hazard identification model mainly include methods based on regularization, replay, optimization and architecture. The method based on regularization restricts the change of model parameters by introducing regularization constraints to prevent new task learning from covering the key parameters of old tasks; the method based on replay alleviates forgetting by storing or generating old task samples and mixing them with new task data for training; the method based on optimization adjusts the optimization process to make the gradient update direction compatible with the old task; and the method based on architecture dynamically extends or isolates model parameters to allocate dedicated sub-networks for different tasks.
[0003] However, the existing continuous learning methods have many problems. The method based on regularization has the defects of inaccurate parameter importance estimation, dependence on task boundaries, inapplicability to online or fuzzy task boundary scenarios, and excessive regularization that may hinder the learning ability of new tasks; the method based on replay has problems such as the need for additional memory for original data playback, possible privacy issues, and the possibility of uneven representation of old tasks due to the buffer sample selection strategy; and the method based on optimization has defects such as high computational cost, the need to store the gradient or feature space of old tasks, increased memory and computational burden, and sensitivity to task similarity.
[0004] Therefore, there is an urgent need for a new method and system that can effectively solve the problems of poor cross-scene adaptability and insufficient sustainable learning ability of existing continuous learning methods in urban rail transit engineering safety hazard identification. SUMMARY
[0005] In view of the above defects or improvement needs of the prior art, the present application provides a rail transit construction safety identification model dynamic adaptation method and system, which can efficiently learn new tasks without forgetting old knowledge, and has the ability to process multi-scale visual features and dynamic scene context to meet the safety hazard identification needs in complex and variable urban rail transit engineering construction scenarios.
[0006] To achieve the above purpose, one aspect of the present application provides a rail transit construction safety identification model dynamic adaptation method, comprising the following steps:
[0007] S1, initializing an urban rail transit engineering construction safety hazard identification model and new scene training parameters;
[0008] S2, read in the image of the safety hidden danger identification of urban rail transit engineering construction in the new scene and the corresponding label, perform data enhancement operation on the image to obtain enhanced image data;
[0009] S3, select the historical scene similar in features to the current new scene from the pre-constructed scene parameter memory bank through image feature comparison method; use the encoder weight corresponding to the similar scene as the initial value to set the weight parameter of the new scene model;
[0010] S4, input the enhanced image data into the image encoder to obtain the feature vector, input the feature vector into the discriminator, map the feature vector to the probability distribution of the category to which the image belongs through the discriminator, and obtain the category prediction result of the image;
[0011] S5, construct a multi-task optimization objective function including classification loss and regularization loss; calculate the total loss value considering classification accuracy and model parameter stability through the multi-task optimization objective function;
[0012] S6, according to the features of the current task and the total loss value considering classification accuracy and model parameter stability calculated in step S5, select specific parameters in the image encoder for updating through the dynamic expert mixing mechanism and the adaptive method of dynamic low rank adaptation, so that the model can adapt to the new scene while not forgetting the old scene;
[0013] S7, check whether the model has completed the predetermined number of training rounds or reached other stopping conditions; if the training is not completed, return to step S2 to continue training; if the training is completed, proceed to the next step;
[0014] S8, update the scene parameter memory bank, store the parameters of the new scene and the updated information of the model in the scene parameter memory bank for use in future training.
[0015] Further, step 1 includes model structure initialization, optimizer setting, image encoder parameter setting, discriminator parameter setting and other initialization settings;
[0016] The model structure initialization includes determining the model architecture for urban rail transit engineering construction safety hidden danger identification, randomly initializing all parameters of the model or using pre-trained weights for initialization, setting the structure of the discriminator for discriminator initialization;
[0017] The optimizer setting includes selecting an optimizer, setting the initial learning rate of the optimizer, and gradually reducing the learning rate using the cosine annealing strategy; setting the batch size and the total number of training rounds;
[0018] The image encoder parameter setting includes setting the number of visual coding layers and setting the multi-head attention parameter;
[0019] The discriminator parameter setting includes setting the total number of output categories;
[0020] Other initialization settings include setting a random seed, initializing a log, and a save path.
[0021] Further, step S2 includes the following steps:
[0022] S21: reading new scene images and labels;
[0023] S22: data cleaning on the read new scene images and labels;
[0024] S23: data enhancement operation on the cleaned data;
[0025] S24: standardization processing on the data after the data enhancement operation;
[0026] S25: batch and loading of the standardized data.
[0027] Further, step S3 includes:
[0028] S31: reading new scene images and checking the image format to ensure that the format and size of the input images meet the model requirements;
[0029] S32: feature extraction on the read new scene images to obtain a feature vector for each image;
[0030] S33: saving the image features of the historical scenes and the corresponding model parameters in the scene training process to construct a scene parameter memory bank; after each new scene training is completed, the features of the new scene and the updated model parameters are stored in the scene parameter memory bank;
[0031] S34: comparing the feature vector of the new scene image obtained in step S32 with the historical scene image feature vectors stored in the scene parameter memory bank to calculate the feature distance therebetween; selecting the most similar historical scene to the new scene according to the feature distance;
[0032] S35: initializing the encoder weight parameters of the new scene model according to the most similar historical scene to the new scene; including obtaining the encoder weights corresponding to the most similar historical scene to the new scene from the scene parameter memory bank; using the encoder weights corresponding to the similar scenes as initial values to set the weight parameters of the new scene model.
[0033] Further, step S4 includes:
[0034] S41: inputting the image after the enhancement processing in step S2 into an image encoder to perform feature coding on the input image to obtain a feature vector;
[0035] S42: input the feature vector output by the image encoder into the discriminator; perform linear transformation on the input feature vector through a linear layer in the discriminator to obtain the score of each category; normalize the output of the linear layer through a softmax layer to obtain the probability distribution of each category; and select the category with the highest probability as the prediction result according to the output of the softmax layer.
[0036] Further, step S5 comprises:
[0037] S51: define a classification loss function, and use a cross-entropy loss function as the classification loss function; calculate the classification loss of the model predicted sample according to the model predicted category probability obtained in step S4 and the real label read in step S2;
[0038] S52: define a regularization loss function, and use elastic weight consolidation as the regularization method; according to the elastic weight consolidation method, perform parameter regularization on the current new scene parameter using the model parameter of the old scene, and calculate the regularization loss;
[0039] S53: combine the classification loss and the regularization loss into a comprehensive multi-task optimization objective function, and calculate the total loss value of the model in the new task considering the classification accuracy and the retention ability of the old task.
[0040] Further, in step S51, the classification loss L is represented by formula (1):
[0041]
[0042] Wherein, y i,c is the real label of the i-th sample in the category C; p i,c is the probability of the i-th sample predicted by the model to belong to the category C; and N is the number of samples.
[0043] In step S52, the regularization loss L EWC is represented by formula (2):
[0044]
[0045] Wherein, θ i represents the parameter of the current task; F i is the diagonal element of the Fisher information matrix, which represents the importance of the parameter θ i . represents the optimal parameter on the old scene;
[0046] In step S53, the multi-task optimization objective function L 总 is represented by formula (3):
[0047] L总 = L + λL EWC (3)
[0048] Wherein, λ is a regularization coefficient, used to balance the weight of classification loss and regularization loss.
[0049] Further, the step S6 comprises:
[0050] S61: calculating the gradient of the total loss value in step S5 with respect to the model parameters by the back propagation algorithm
[0051] S62: initializing a plurality of expert modules in the dynamic expert mixing mechanism, and adaptively selecting the optimal expert module for parameter updating according to the characteristics of the current task and the gradient of the total loss value with respect to the model parameters;
[0052] S63: performing low-rank decomposition on the parameter weight matrix to be updated into the product of two low-rank matrices;
[0053] S64: verifying the model after updating the parameters to ensure that the performance of the model is improved in the new scene while the knowledge of the old scene is not forgotten; according to the verification result, adjusting the learning rate and the regularization coefficient to optimize the training process of the model.
[0054] Further, in step S62, the optimal expert module is adaptively selected for parameter updating according to the characteristics of the current task and the gradient of the total loss value with respect to the model parameters, comprising:
[0055] S621: using the ReLU function as the activation function; for each expert module, the input feature vector of the model is linearly transformed through the parameters of the expert module, and then the activation score is calculated through the activation function;
[0056] S622: normalizing the activation scores of all expert modules through the softmax function so that their sum is 1;
[0057] S623: selecting the expert module with the highest activation score for parameter updating according to the normalized activation score.
[0058] The second aspect of the application provides a rail transit construction safety recognition model dynamic adaptation system for realizing the rail transit construction safety recognition model dynamic adaptation method, comprising:
[0059] An initialization module is used to set the initial state and training parameters of the model;
[0060] A data preprocessing module is used to read the urban rail transit engineering construction safety hidden danger recognition image and the corresponding label in the new scene, and perform data enhancement operation on the image;
[0061] a scene parameter memory bank module for storing image features and corresponding model parameters of historical scenes;
[0062] a model initialization module for selecting the most similar historical scene from the scene parameter memory bank according to the features of the new scene image, and initializing the weights of the new scene model with the corresponding encoder weights of the historical scene;
[0063] a feature extraction module for extracting a feature vector of the new scene image using a pre-trained feature extraction network;
[0064] an image encoding and discrimination module for inputting the enhanced image data into an image encoder to obtain a feature vector, and predicting the category to which the image belongs through a discriminator;
[0065] a loss function calculation module for constructing a multi-task optimization objective function including a classification loss and a regularization loss, and calculating a total loss value;
[0066] a training control module for checking whether the model has completed a predetermined number of training rounds or reached other stopping conditions, controlling the iteration and termination of the training process;
[0067] a model parameter update module for dynamically and adaptively selecting and updating specific parameters in the image encoder through a dynamic expert mixing mechanism and a low-rank adaptation according to the gradient of the total loss value;
[0068] a model verification and adjustment module for verifying the performance of the updated model, and adjusting the learning rate and the regularization coefficient;
[0069] a log recording and model saving module for recording key information during the training process, and saving the trained model weights.
[0070] Overall, compared with the prior art, the above technical solutions conceived by the present application can achieve the following beneficial effects:
[0071] (1) The track traffic construction safety recognition model dynamic adaptation method and system of the present application effectively solves the problems of poor cross-scene adaptability and insufficient sustainable learning ability of existing continuous learning methods in urban rail transit engineering safety hazard identification by introducing a mixed expert low-rank adaptive sustainable learning strategy and constructing a scene memory bank. The method uses a dynamic expert hybrid mechanism to adaptively select the optimal expert module for parameter updating, and combines a low-rank adaptation technology to significantly reduce the number of parameters that need to be trained, thereby adapting to new scenes while avoiding forgetting old scene knowledge. In addition, by selecting similar scenes from the scene parameter memory bank to initialize the encoder weights, incremental learning is achieved, further alleviating the problem of catastrophic forgetting. Compared with existing technologies, the method of the present application has stronger adaptability in new scenes and better sustainable learning ability, and can more effectively identify safety hazards in urban rail transit engineering construction, improving the safety and reliability of urban rail transit engineering.
[0072] (2) The track traffic construction safety recognition model dynamic adaptation method and system of the present application addresses the problem of poor cross-scene adaptability of traditional continuous learning methods, which makes it difficult to maintain recognition ability for old scenes in new scenes. Through a dynamic expert hybrid mechanism and a low-rank adaptation technology, the model can adaptively select the optimal expert module for parameter updating, thereby quickly adapting to new scenes while maintaining performance for old scenes. This cross-scene adaptive feature extraction capability significantly improves the adaptability of the model.
[0073] (3) The track traffic construction safety recognition model dynamic adaptation method and system of the present application addresses the problem of existing methods easily forgetting old task knowledge during the continuous learning process, leading to a decline in model performance. By constructing a scene parameter memory bank, the model can initialize using historical scene knowledge during new scene training, avoiding catastrophic forgetting. This incremental learning approach enhances the model's sustainable learning ability, allowing it to learn new knowledge without forgetting old knowledge while continuously receiving new task data. To address the privacy concerns associated with storing raw data using a replay-based method, the method reduces dependence on raw data by selecting similar scenes from the scene parameter memory bank to initialize the encoder weights, thereby alleviating privacy concerns to some extent.
[0074] (4) The track traffic construction safety recognition model dynamic adaptation method and system of the present application addresses the problem of optimization-based methods requiring storage of old task gradients or feature spaces, increasing memory and computational burden. The low-rank adaptation technology significantly reduces the number of parameters that need to be trained by decomposing the weight matrix into the product of two low-rank matrices, thereby reducing computational cost. This makes model training more efficient and suitable for resource-constrained environments.
[0075] (5) The track traffic construction safety recognition model dynamic adaptation method and system of the present application can adapt to different light environments and noise interference by adding random noise and other operations through the data preprocessing module, so as to improve the robustness of the model in actual application.
[0076] (6) The track traffic construction safety recognition model dynamic adaptation method and system of the present application can automatically adjust the learning rate and regularization coefficient according to the verification result through the model verification and adjustment module, so as to optimize the model training process and improve the training efficiency and model performance. BRIEF DESCRIPTION OF DRAWINGS
[0077] Figure 1 FIG. 1 is a flowchart of a track traffic construction safety recognition model dynamic adaptation method according to an embodiment of the present application;
[0078] Figure 2 FIG. 1 is a flowchart of a track traffic construction safety recognition model dynamic adaptation method according to an embodiment of the present application;
[0079] Figure 3 FIG. 1 is a flowchart of a track traffic construction safety recognition model dynamic adaptation method according to an embodiment of the present application;
[0080] Figure 4 FIG. 1 is a flowchart of a track traffic construction safety recognition model dynamic adaptation method according to an embodiment of the present application; DETAILED DESCRIPTION
[0081] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application. In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as they do not conflict with each other.
[0082] As shown in Figure 1 and Figure 2 An aspect of the present application provides a track traffic construction safety recognition model dynamic adaptation method, comprising the following steps:
[0083] S1, initializing a city track traffic engineering construction safety hidden danger recognition model and new scene training parameters;
[0084] S2, new scene training data preprocessing: reading in city track traffic engineering construction safety hidden danger recognition images and corresponding labels under a new scene, and performing data enhancement operations on these images to obtain enhanced image data;
[0085] S3, selecting similar scenes from the scene parameter memory bank to initialize the encoder weight: selecting similar historical scenes to the current new scene in terms of features from the pre-constructed scene parameter memory bank through image feature comparison method; the encoder weight corresponding to these similar scenes is used as the initial value to set the weight parameter of the new scene model;
[0086] S4, image feature encoding and discriminator prediction: input the enhanced image data into the image encoder to obtain the feature vector, input the feature vector into the discriminator, map the feature vector to the probability distribution of the image category through the discriminator, and obtain the category prediction result of the enhanced image;
[0087] S5, calculating the loss function: constructing a multi-task optimization objective function containing classification loss and regularization loss; calculating the total loss value considering classification accuracy and model parameter stability (retention ability for old tasks) through the multi-task optimization objective function;
[0088] S6, according to the features of the current task and the total loss value considering classification accuracy and model parameter stability calculated in step S5, through the dynamic expert mixing mechanism and the low-rank adaptive dynamic LoRA (Low-Rank Adaptation) adaptive selection of specific parameters in the image encoder for updating, so that the model can adapt to the new scene while not forgetting the old scene;
[0089] S7, checking whether the model has completed the predetermined number of training rounds or reached other stopping conditions; if the training is not completed, return to step S2 to continue training; if the training is completed, proceed to the next step;
[0090] S8, updating the scene parameter memory bank, storing the parameters of the new scene and the updated information of the model in the scene parameter memory bank for future use.
[0091] Further, step 1 includes: model structure initialization, optimizer setting, image encoder parameter setting, discriminator parameter setting and other initialization settings; wherein,
[0092] The model structure initialization includes: selecting a model architecture, determining a model architecture for urban rail transit engineering construction safety hazard identification, for example, using Siwn-Transformer-Large as the image encoder, which can effectively extract image features; initializing the model parameters, randomly initializing or using pre-trained weights to initialize all parameters of the model, to ensure that the model has a reasonable initial state at the beginning of training; initializing the discriminator, setting the structure of the discriminator, for example, using a linear layer plus a softmax layer, to predict the safety hazard category to which the image belongs according to the feature vector output by the encoder;
[0093] The optimizer settings include: selecting an optimizer, selecting a suitable optimizer, such as the AdamW optimizer, which combines the adaptive learning rate adjustment and weight decay strategy of the Adam optimizer, and helps to stabilize the training process; setting the initial learning rate of the optimizer, setting the initial learning rate of the optimizer to 1e-4, and gradually reducing the learning rate to 1e-6 using the cosine annealing strategy to ensure that the learning rate can be adaptively adjusted during the training process to avoid premature convergence or insufficient training; setting the batch size, setting the batch size to 32, which determines the amount of data input into the model each time, affecting the training speed and stability of the model; setting the total training rounds, setting the total training rounds to 300, which determines the total number of iterations of model training, ensuring that the model has enough time to learn the features in the data;
[0094] The image encoder parameter settings include: setting the number of visual encoding layers, setting the number of visual encoding layers of the image encoder to [2, 2, 4, 2], which determines the number of layers at different stages in the encoder, affecting the depth and complexity of feature extraction; setting the multi-head attention parameters, setting the multi-head attention parameters to [4, 8, 26, 32], which determines the number of heads in the multi-head attention mechanism in each encoding layer, helping the model better capture local and global features in the image;
[0095] The discriminator parameter settings include: setting the total number of output categories, setting the total number of output categories of the discriminator to 80, which determines the number of safety hazard categories that the model can recognize, ensuring that the model can cover all possible safety hazard types;
[0096] Other initialization settings include: setting a random seed, setting a random seed to ensure the repeatability of experimental results, making the model initialization and data augmentation operations deterministic; initializing the log and saving path, setting the log recording path and model saving path to record key information during training and save the trained model weights;
[0097] Through step S1, the model structure and training parameters are initialized to obtain a city rail transit engineering construction safety hazard identification model with reasonable initial parameter settings, preparing for the subsequent training and optimization process.
[0098] Further, the new scene training data preprocessing in step S2 is a key link in the dynamic adaptation method of the present application, which ensures that the data input into the model is of high quality and diverse, thereby improving the robustness and generalization ability of the model; step S2 includes:
[0099] S21: reading new scene images and labels; including
[0100] Read Image: Read the image of urban rail transit construction safety hidden danger identification in the new scene from the specified data source. These images may be pictures taken from the construction site, containing various safety hidden danger scenes;
[0101] Read Label: Read the label corresponding to the image at the same time, which identifies the specific category of safety hidden danger in the image. The label can be a category index (such as numbers 0 to 79, corresponding to 80 categories) or a category name (such as "no safety helmet", "equipment failure", etc.);
[0102] Data format check: Ensure that the read image and label format is correct, such as image format is common image file format (such as JPEG, PNG), label format is CSV file, JSON file or directly stored in the database;
[0103] S22: Data cleaning on the read new scene image and label; including:
[0104] Remove invalid data: Check the validity of images and labels, remove damaged image files or samples with missing labels. For example, check if the image file can be opened normally, and the label is complete and conforms to the expected format;
[0105] Handle outliers: For outliers in the label (such as incorrect category label or missing value), correct or delete. For example, if the category index of a label exceeds the pre-defined category range, correct it to a reasonable value or delete the sample;
[0106] S23: Data augmentation operation on the cleaned data; including:
[0107] Random rotation: Randomly rotate the image within a range of -10° to 10°; This helps the model learn the features of the image at different angles and improves the model's robustness to image rotation;
[0108] Random flip: Flip the image horizontally or vertically with a probability of 50%; This can increase the diversity of data, enabling the model to better handle changes in image symmetry;
[0109] Random noise addition: Randomly add Gaussian noise to the image; This helps simulate noise interference in real-world scenarios and improves the model's performance in noisy environments;
[0110] Brightness adjustment: Randomly adjust the brightness of the image to simulate scenes under different lighting conditions; For example, by adjusting the contrast and brightness parameters of the image, the model can adapt to different lighting environments;
[0111] Crop and scale: randomly crop and scale the images to ensure the uniformity of the image size of the input model; for example, crop the image to a fixed size (such as 224x224 pixels) and scale it appropriately to maintain the aspect ratio of the image;
[0112] S24: Standardize the data after data augmentation operation; including:
[0113] Pixel value normalization, normalize the pixel values of the image to the range of 0 to 1; usually by dividing the pixel value by 255 (the maximum pixel value of the image), which helps to speed up the training process of the model;
[0114] Mean and standard deviation normalization, mean and standard deviation normalization of the image. Calculate the mean and standard deviation of the image dataset, and then normalize each pixel value;
[0115] S25: Batch and load the standardized data; including:
[0116] Data batching, organize the preprocessed image and label data in batches so that the model can be trained batch by batch. According to the batch size set in step S1 (such as 32), the data is divided into multiple batches;
[0117] Data loader setting, set up the data loader to efficiently load and deliver data during training; the data loader can realize multi-thread loading, data shuffling and other functions to improve training efficiency;
[0118] Through step S2, the preprocessed enhanced image data and corresponding label data can be obtained, which have higher diversity and quality, and can better support the training process of the model, improve the robustness and generalization ability of the model;
[0119] Further, the selection of similar scene initialization encoder weights from the scene parameter memory library in step S3 is a key link in the method of the present application, which initializes the weights of the new scene model by using the model parameters of the historical scene, thereby avoiding catastrophic forgetting and improving the cross-scene adaptability of the model; the following is the specific content decomposition of step S3, including:
[0120] S31: Read the new scene image and check the image format to ensure that the format and size of the input image meet the model requirements;
[0121] Read the urban rail transit construction safety hazard identification image under the new scene; these images are enhanced image data after step S2 preprocessing; image format check to ensure that the format and size of the input image meet the model requirements, such as image size of 224x224 pixels and format of normalized floating point numbers;
[0122] S32: Feature extraction is performed on the read new scene images to obtain feature vectors of each image; including:
[0123] A feature extraction network is selected, and a pre-trained feature extraction network (such as ResNet) is used to extract the features of the new scene images; ResNet is a commonly used deep convolutional neural network that can effectively extract high-level features of images; it has good generalization ability and feature extraction ability; other pre-trained deep learning models such as VGG, Inception, etc. can also be selected, and the specific selection depends on the actual application scenario and data characteristics;
[0124] Feature vectors are extracted, and the new scene images are input into the ResNet network to obtain the feature vectors of each image. These feature vectors will be used for subsequent similarity comparison;
[0125] S33: Save the image features and corresponding model parameters of the historical scenes during the scene training process, and construct a scene parameter memory library; after each new scene training is completed, store the features of the new scene and the updated model parameters into the scene parameter memory library for future use of new scenes;
[0126] S34: Compare the feature vectors of the new scene images obtained in step S32 with the historical scene image feature vectors stored in the scene parameter memory library, and calculate the feature distance between them; select the most similar historical scene to the new scene according to the feature distance; for example, select the historical scene with the smallest feature distance as the most similar scene;
[0127] The feature distance calculation method in step S34 includes Euclidean distance calculation method and cosine similarity calculation method; Euclidean distance and cosine similarity are two commonly used feature distance calculation methods; Euclidean distance measures the absolute distance between feature vectors, while cosine similarity measures the directional similarity between feature vectors; the specific method can be determined according to the characteristics and needs of the actual data;
[0128] S35: Initialize the encoder weight parameters of the new scene model according to the most similar historical scene to the new scene; including obtaining the encoder weights corresponding to the most similar historical scene to the new scene from the scene parameter memory library; set the encoder weights corresponding to these similar scenes as the initial values of the weight parameters of the new scene model; this step ensures that the new scene model has a similar initial state to the similar historical scene at the beginning of training, thereby improving the convergence speed and performance of the model.
[0129] A city rail transit engineering construction safety hazard identification model initialized based on historical scene model parameters similar to the new scene can be obtained through step S3. This initialization method helps the model quickly adapt to the new scene while avoiding forgetting the knowledge of the old task when learning the new task. The method can effectively utilize the knowledge of the historical scene to initialize the weights of the new scene model, thereby improving the cross-scene adaptability and sustainable learning ability of the model.
[0130] Further, the image feature encoding and discriminator prediction in step S4 are the core links in the rail transit construction safety identification model dynamic adaptation method, which is responsible for converting the preprocessed image data into feature vectors and making class predictions based on these feature vectors. The following is a specific content decomposition of step S4, including:
[0131] S41: input the image processed by step S2 into the image encoder to encode the input image and obtain the feature vector; specifically including:
[0132] In the present application, the image encoder adopts the Siwn-Transformer-Large structure, which can effectively extract high-level features of the image. After inputting the enhanced image data into the image encoder, the feature vector of each image is obtained through the forward propagation of the multi-layer network structure of the encoder. Specifically, the Siwn-Transformer-Large structure gradually extracts local and global features of the image through multi-head self-attention mechanism and feedforward neural network. The feature vector output by the image encoder in this step will be used as the input of the subsequent discriminator. These feature vectors contain key information about safety hazards in the image and can support the discriminator to make accurate class predictions.
[0133] The Siwn-Transformer-Large structure is a deep learning model based on Transformer, which has strong feature extraction capability. It can capture long-distance dependencies in images through multi-head self-attention mechanism, and further process features through feedforward neural network. This structure is particularly suitable for processing complex image data and can extract high-level features that are helpful for safety hazard identification.
[0134] S42: input the feature vector output by the image encoder into the discriminator; linearly transform the input feature vector through the linear layer in the discriminator to obtain the score of each class; normalize the output of the linear layer through the softmax layer to obtain the probability distribution of each class; according to the output of the softmax layer, select the class with the highest probability as the prediction result.
[0135] The discriminator is used to map the feature vector to a category probability distribution. The structure of the discriminator usually includes a linear layer and a softmax layer, which can predict the safety hazard category according to the features output by the encoder. The linear layer is responsible for mapping the feature vector to category scores, and the softmax layer normalizes these scores to a probability distribution. The linear layer in the discriminator performs a linear transformation on the input feature vector to obtain the score of each category. These scores reflect the likelihood of the image belonging to each category. The output of the linear layer is normalized by the softmax layer to obtain the probability distribution of each category. The output of the softmax layer is a probability vector, where each element represents the probability of the image belonging to the corresponding category. According to the output of the softmax layer, the category with the highest probability is selected as the prediction result. Specifically, the predicted category is the category index with the highest probability.
[0136] The entire forward propagation process in step S4 is automated and implemented through a deep learning framework such as PyTorch or TensorFlow. In practical applications, only the input image data needs to be passed to the model, and the model will automatically complete the feature encoding and category prediction process.
[0137] Through step S4, the model's category prediction results for the input image can be obtained. These prediction results will be used for subsequent loss function calculation (step S5) to evaluate the model's performance and guide the update of model parameters.
[0138] Through the detailed operations of step S4 described above, the method of the present application can effectively convert the input image into a feature vector and accurately predict the category based on these feature vectors. This provides a foundation for subsequent loss function calculation and model parameter update, ensuring that the model can quickly adapt to new scenarios and maintain performance in old scenarios.
[0139] Further, the loss function calculation in step S5 is a key step in the dynamic adaptation method of the rail transit construction safety recognition model of the present application. It builds a multi-task optimization objective function to consider classification accuracy and model parameter stability, thereby guiding the training process of the model. The following is a detailed breakdown of step S5, including:
[0140] S51: Define the classification loss function, and use the cross-entropy loss function (Cross-Entropy Loss) as the classification loss function. According to the model prediction category probability obtained in step S4 and the true label read in step S2, calculate the classification loss L of the model prediction sample. It is represented by formula (1):
[0141]
[0142] where y i,cYi is the true label of the ith sample in class C; p i,c Pi is the probability of the ith sample belonging to class C predicted by the model; N is the number of samples;
[0143] S52: Define the regularization loss function, and use Elastic Weight Consolidation (EWC) as the regularization method; according to the EWC method, the model parameters of the old scene are used to regularize the current new scene parameters, and the regularization loss L EWC is calculated; it is represented by formula (2):
[0144]
[0145] where θ i represents the parameters of the current task; F i is the diagonal element of the Fisher information matrix, which represents the importance of the parameter θ i ; represents the optimal parameters on the old scene;
[0146] EWC in step S52 limits the change of model parameters to prevent the key parameters of the old task from being covered by the new task learning;
[0147] S53: Combine the classification loss and the regularization loss into a comprehensive multi-task optimization objective function, and calculate the total loss value which comprehensively considers the classification accuracy of the model on the new task and the retention ability of the old task;
[0148] The multi-task optimization objective function L 总 is represented by formula (3):
[0149] L 总 = L+λL EWC (3)
[0150] where λ is the regularization coefficient, which is used to balance the weights of the classification loss and the regularization loss. By adjusting λ, the influence degree of the regularization loss on the total loss can be controlled;
[0151] The cross-entropy loss function used in step S5 is a commonly used loss function in classification tasks, which can effectively measure the difference between the model's predicted probability distribution and the true distribution; it penalizes the model's prediction error, enabling the model to better learn the classification boundary; elastic weight consolidation (EWC) is an effective regularization method that limits the change of model parameters to prevent new task learning from covering key parameters of old tasks; it measures the importance of parameters through the Fisher information matrix to ensure that important parameters are not modified significantly; the regularization coefficient λ is used to balance the weights of the classification loss and the regularization loss. By adjusting λ, the degree of influence of the regularization loss on the total loss can be controlled. If λ is too large, the model may be too conservative and difficult to learn new tasks; if λ is too small, the model may forget the knowledge of the old task;
[0152] The total loss value considering the classification accuracy and the stability of the model parameters is obtained by step S5. This total loss value will be used for subsequent model parameter updating (step S6) to guide the model training process in the new scenario and ensure that the model can learn new knowledge without forgetting old knowledge and ensure the adaptability and sustainable learning ability of the model in the new scenario.
[0153] Further, the model parameter updating in step S6 is a key link in the dynamic adaptation method of the rail transit construction safety identification model, which selects specific parameters in the image encoder for updating through the dynamic expert mixing mechanism and the self-adaptive method of dynamic low-rank adaptation, thereby ensuring that the model adapts to the new scene while not forgetting the old scene. The following is a specific content decomposition of step S6, including:
[0154] S61: Calculate the gradient of the total loss value with respect to the model parameters in step S5 through the backpropagation algorithm
[0155] S62: Initialize multiple expert modules in the dynamic expert mixing mechanism, and adaptively select the optimal expert module for parameter updating according to the characteristics of the current task and the gradient of the total loss value with respect to the model parameters;
[0156] S63: Perform low-rank decomposition of the parameter weight matrix that needs to be updated into the product of two low-rank matrices, so that the amount of parameters to be trained is greatly reduced; ensure that the model can learn new knowledge without forgetting old knowledge when constantly receiving new task data;
[0157] S64: After updating the parameters, the model is verified to ensure that the performance of the model in the new scenario is improved, and the knowledge of the old scenario is not forgotten; according to the verification result, adjust the learning rate and the regularization coefficient to optimize the training process of the model;
[0158] Further, the gradient of the total loss value with respect to the model parameters in step S61 can reflect the change direction and amplitude of the loss value under the current model parameter setting; the gradient of the total loss value with respect to the model parameters is calculated by formula (4):
[0159]
[0160] wherein, is the gradient of the classification loss; is the gradient of the regularization loss; λ is a regularization coefficient;
[0161] Further, in step S62, the optimal expert module is adaptively selected for parameter updating according to the characteristics of the current task and the gradient of the total loss value with respect to the model parameters, including
[0162] S621: using the ReLU function as the activation function; for each expert module, the input feature vector of the model is linearly transformed through the parameters of the expert module, and then the activation score is calculated through the activation function; wherein,
[0163] The ReLU function has the advantages of nonlinearity, simple calculation and the ability to avoid the problem of gradient disappearance;
[0164] The calculation of the activation score is represented by formula (5):
[0165] S j = RE LU (W j x + b j ) (5)
[0166] wherein, S j is the activation score of the jth expert module; W j x is the weight parameter of the jth expert module, x is the input feature vector of the model, and b j is the bias parameter of the jth expert module;
[0167] S622: normalize all the activation scores of the expert modules through the softmax function, so that their sum is 1;
[0168] S623: according to the normalized activation scores, select the expert module with the highest activation score for parameter updating;
[0169] Further, the parameter updating in step S63 is represented by formula (6):
[0170]
[0171] wherein, θ t is the parameter to be updated, and η is the learning rate;
[0172] A city rail transit engineering construction safety hidden danger identification model updated by parameters is obtained through step S6, and the model has better adaptability in a new scene while maintaining the performance on an old scene.
[0173] Step S6 updates the parameters of the model through multiple expert modules, and the model can adaptively select the optimal expert module according to the characteristics of the current task; this way makes the model adjust specific parameters flexibly instead of updating all parameters globally, thereby improving the adaptability and efficiency of the model; low-rank adaptation decomposes the weight matrix into the product of two low-rank matrices, greatly reducing the number of parameters that need to be trained; this not only improves the training efficiency, but also ensures that the updated parameters will not have a negative impact on the performance of the old task through the constraint of the regularization loss; the regularization loss prevents the new task from learning to cover the key parameters of the old task by limiting the change of the parameters; by adjusting the regularization coefficient λ, the weights of the classification loss and the regularization loss can be balanced, thereby optimizing the training process of the model;
[0174] A city rail transit engineering construction safety hidden danger identification model updated by parameters is obtained through step S6, and the model has better adaptability in a new scene while maintaining the performance on an old scene; thereby realizing better cross-scene adaptability and sustainable learning ability.
[0175] As shown in Figure 3 The second aspect of the present application provides a rail transit construction safety identification model dynamic adaptation system for realizing the above adaptation method, comprising:
[0176] An initialization module is configured to set the initial state and training parameters of the model.
[0177] A data preprocessing module is configured to read the city rail transit engineering construction safety hidden danger identification images and corresponding labels in a new scene, and perform data enhancement operations on the images; the specific tasks include: reading images and labels; data cleaning (removing invalid data and processing outliers); data enhancement (random rotation, flipping, noise addition, brightness adjustment, etc.); data standardization (pixel value normalization, mean and standard deviation normalization); data batching and loading;
[0178] A scene parameter memory bank module is configured to store the image features and corresponding model parameters of historical scenes; the specific tasks include: constructing and maintaining the scene parameter memory bank; storing the features and model parameters of historical scenes; regularly updating the scene parameter memory bank to add the features and parameters of new scenes;
[0179] A model initialization module is configured to initialize the weight of the new scene model according to the feature of the new scene image, select the most similar historical scene from the scene parameter memory bank, and initialize the weight of the new scene model with the corresponding encoder weight of the historical scene; the specific tasks include reading the feature vector of the new scene image, selecting the most similar historical scene from the scene parameter memory bank, obtaining the encoder weight of the most similar historical scene, and initializing the weight parameter of the new scene model;
[0180] A feature extraction module is configured to extract the feature vector of the new scene image using a pre-trained feature extraction network; the specific tasks include selecting a feature extraction network (such as ResNet), inputting the new scene image into the feature extraction network to obtain the feature vector, and calculating the feature distance (such as Euclidean distance, cosine similarity) between the feature vectors;
[0181] An image encoding and discrimination module is configured to input the enhanced image data into an image encoder to obtain a feature vector, and predict the category to which the image belongs through a discriminator; the specific tasks include inputting the enhanced image data into the image encoder (such as Siwn-Transformer-Large), extracting the feature vector by the image encoder, inputting the feature vector into the discriminator (linear layer + softmax layer), and outputting the predicted category probability;
[0182] A loss function calculation module is configured to construct a multi-task optimization objective function including a classification loss and a regularization loss, and calculate a total loss value; the specific tasks include calculating the classification loss (cross-entropy loss), calculating the regularization loss (elastic weight consolidation), and combining the classification loss and the regularization loss to obtain the total loss value;
[0183] A model parameter updating module is configured to dynamically and adaptively select and update specific parameters in the image encoder according to the gradient of the total loss value through a dynamic expert mixing mechanism and a low-rank adaptation; the specific tasks include calculating the gradient of the total loss value through a back propagation algorithm, updating the model parameters using an optimization algorithm (such as gradient descent), initializing the expert module through the dynamic expert mixing mechanism, calculating the activation score of each expert module, and selecting the optimal expert module for parameter updating; the low-rank adaptation update includes low-rank matrix initialization and updating of specific parameter weight matrix;
[0184] A training control module is configured to check whether the model has completed a predetermined number of training rounds or reached other stopping conditions, and control the iteration and termination of the training process;
[0185] A model verification and adjustment module is configured to verify the performance of the updated model, and adjust the learning rate and the regularization coefficient; the specific tasks include verifying the performance of the model in the new scene, adjusting the learning rate and the regularization coefficient, and optimizing the model training process;
[0186] A log recording and model saving module records key information during the training process and saves the trained model weights; specific tasks include: setting the log recording path; recording key information such as loss value, accuracy rate, etc. during the training process; saving the trained model weights;
[0187] The interaction between the various modules includes:
[0188] After the initialization module sets the initial state of the model and the training parameters, it hands over control to the data preprocessing module to begin processing the input data. After the data preprocessing module completes image reading, cleaning, enhancement, standardization, batching, and loading, it sends the preprocessed image data to the feature extraction module for feature vector extraction. After the feature extraction module calculates the feature vectors of the new scene image, it sends these feature vectors to the model initialization module to select similar scenes from the scene parameter memory bank and initialize the encoder weights. Based on the feature vectors provided by the feature extraction module, the model initialization module queries the scene parameter memory bank module to select the most similar historical scene and obtains the corresponding encoder weights. The model initialization module uses the weights obtained from the scene parameter memory bank to initialize the models in the image encoding and discrimination module. After the image encoding and discrimination module outputs the predicted class probability, it sends these probabilities and the true labels to the loss function calculation module for loss value calculation. After the loss function calculation module calculates the total loss value, it sends the loss value and gradient information to the model parameter update module for updating the model parameters. After the model parameter update module updates the parameters, it reports the update to the training control module, which decides whether to continue training or terminate. After each training cycle, the training control module hands over control to the model verification and adjustment module to verify the model performance and adjust the learning rate and regularization coefficient as needed. After the model verification and adjustment module verifies the model performance, it sends the performance indicators and adjusted parameters to the log recording and model saving module for logging and model saving. After saving the model, the log recording and model saving module updates the scene parameter memory bank module, storing the features and model parameters of the new scene in the memory bank.
[0189] The interaction between these modules ensures that the data flow starts from the reading and preprocessing of raw images, goes through feature extraction, model initialization, image encoding and discrimination, loss calculation, parameter updating, and finally to training control, model verification and adjustment, and finally to log recording and model saving. Each module is responsible for a specific task, and their outputs become the inputs of the next module, forming a complete closed-loop system. Through the cooperative work of the above-mentioned modules, the rail transit construction safety recognition model dynamic adaptation system of the present application can effectively realize the dynamic adaptation and continuous learning of the model, improve the adaptability and performance of the model in new scenarios, while maintaining the performance on old scenarios.
[0190] It should be noted that the rail transit construction safety identification model dynamic adaptation system provided in the embodiment can be a computer program (including program code) running in a computer device, for example, the rail transit construction safety identification model dynamic adaptation system is an application software; the rail transit construction safety identification model dynamic adaptation system can be used to execute the corresponding steps in the above method provided by the embodiment of the present application.
[0191] In some possible implementation manners, the rail transit construction safety identification model dynamic adaptation system provided in the embodiment can be implemented in a combination of software and hardware, for example, the rail transit construction safety identification model dynamic adaptation system provided in the embodiment can be a processor in the form of a hardware decoding processor, which is programmed to execute the rail transit construction safety identification model dynamic adaptation method provided by the embodiment of the present application, for example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs) or other electronic elements.
[0192] In some possible implementation manners, the rail transit construction safety identification model dynamic adaptation system provided in the embodiment can be implemented in a software manner, which can be software in the form of a program and a plug-in and the like, and include a series of modules to implement the rail transit construction safety identification model dynamic adaptation method provided by the embodiment of the present application.
[0193] The track traffic construction safety identification model dynamic adaptation system provided by the embodiment effectively solves the problems of poor cross-scene adaptability and insufficient sustainable learning capability of existing continuous learning methods in city track traffic engineering safety hazard identification. The method uses a dynamic expert hybrid mechanism to adaptively select an optimal expert module for parameter updating, and combines a low-rank adaptation technology to greatly reduce the amount of parameters that need to be trained, thereby adapting to new scenes while avoiding forgetting the knowledge of old scenes. In addition, by selecting similar scenes from the scene parameter memory bank to initialize the encoder weight, incremental learning is realized, further alleviating the problem of catastrophic forgetting. Compared with the prior art, the method of the present application has stronger adaptability in new scenes, better sustainable learning capability, can more effectively identify safety hazards in city track traffic engineering construction, and improve the safety and reliability of city track traffic engineering.
[0194] The third aspect of the application also provides an electronic device, Figure 4 is a structural schematic diagram of the electronic device of the embodiment, as Figure 4 indicated, the electronic device 1000 in the embodiment can include a processor 1001, a network interface 1004 and a memory 1005, in addition, the above-mentioned electronic device 1000 can further include a user interface 1003, and at least one communication bus 1002. Wherein, the communication bus 1002 is used to realize the connection communication between these components. Wherein, the user interface 1003 can include a display screen (Display), a keyboard (Keyboard), and the optional user interface 1003 can further include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory, or a non-volatile memory, for example, at least one disk memory. The memory 1005 can optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 4 indicated, the memory 1005 as a computer readable storage medium can include an operating system, a network communication module, a user interface module and a device control application program.
[0195] As Figure 4 indicated in the electronic device 1000, the network interface 1004 can provide network communication function; while the user interface 1003 is mainly used to provide the interface for user input; and the processor 1001 can be used to call the device control application program stored in the memory 1005, to realize each step of the above-mentioned decision method.
[0196] It should be understood that in some possible implementations, the processor 1001 described above can be a central processing unit (CPU), and the processor can also be other general-purpose processors, DSPs, ASICs, FPGAs or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The memory can include read-only memory and random access memory, and provide instructions and data to the processor. Part of the memory can also include non-volatile random access memory. For example, the memory can also store device type information.
[0197] In a specific implementation, the electronic device 1000 described above can perform the implementation manner provided by each step in the above method through each functional module built-in the electronic device 1000, and the specific implementation manner can refer to the implementation manner provided by each step described above, and details are not described herein. Figure 1
[0198] The electronic device provided by the embodiment effectively solves the problems of poor cross-scene adaptability and insufficient sustainable learning ability of existing continuous learning methods in urban rail transit engineering safety hazard identification by introducing a hybrid expert low-rank adaptive sustainable learning strategy and constructing a scene memory library. The method uses a dynamic expert hybrid mechanism to adaptively select the optimal expert module for parameter updating, and combines a low-rank adaptation technology to greatly reduce the amount of parameters that need to be trained, thereby adapting to new scenes while avoiding forgetting the knowledge of old scenes. In addition, by selecting similar scenes from the scene parameter memory library to initialize the encoder weights, incremental learning is achieved, further alleviating the problem of catastrophic forgetting. Compared with the prior art, the method of the present application has stronger adaptability in new scenes and better sustainable learning ability, can more effectively identify safety hazards in urban rail transit engineering construction, and improve the safety and reliability of urban rail transit engineering.
[0199] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method provided by each step in the above method. The specific implementation manner can refer to the implementation manner provided by each step described above, and details are not described herein. Figure 1
[0200] The computer readable storage medium provided by the embodiment effectively solves the problems of poor cross-scene adaptability and insufficient sustainable learning capability of existing continuous learning methods in urban rail transit engineering safety hazard identification by introducing a hybrid expert low-rank adaptive sustainable learning strategy and constructing a scene memory library. The method uses a dynamic expert hybrid mechanism to adaptively select the optimal expert module for parameter updating, and combines a low-rank adaptation technology to greatly reduce the amount of parameters that need to be trained, thereby adapting to new scenes while avoiding forgetting the knowledge of old scenes. In addition, by selecting similar scenes from the scene parameter memory library to initialize the encoder weights, incremental learning is realized, further alleviating the problem of catastrophic forgetting. Compared with the prior art, the method of the present application has stronger adaptability in new scenes, better sustainable learning capability, can more effectively identify safety hazards in urban rail transit engineering construction, and improve the safety and reliability of urban rail transit engineering.
[0201] Any reference to storage, memory, database or other medium used in the various embodiments provided herein can include non-volatile and / or volatile storage. Non-volatile storage can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile storage can include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), Rambus DRAM (RDRAM), direct Rambus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0202] Those skilled in the art will readily understand that the above description is only the preferred embodiment of the present application and is not intended to limit the present application, and any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A dynamic adaptation method for a safety identification model in rail transit construction, characterized in that, Includes the following steps: S1. Initialize the safety hazard identification model for urban rail transit engineering construction and the training parameters for new scenarios; S2. Read in the images and corresponding labels of safety hazards in urban rail transit construction projects under the new scenario, perform data augmentation on these images, and obtain the augmented image data. S3. Select historical scenes that are similar in features to the current new scene from the pre-built scene parameter memory bank by image feature comparison; use the encoder weights corresponding to these similar scenes as initial values to set the weight parameters of the new scene model; S4. Input the enhanced image data into the image encoder to obtain the feature vector. Input the feature vector into the discriminator and map the feature vector to the probability distribution of the image category to obtain the image category prediction result. S5. Construct a multi-task optimization objective function that includes classification loss and regularization loss; calculate the total loss value that comprehensively considers classification accuracy and model parameter stability through the multi-task optimization objective function; S6. Based on the characteristics of the current task and the total loss value calculated in step S5, which comprehensively considers classification accuracy and model parameter stability, specific parameters in the image encoder are selected for updating through the dynamic expert hybrid mechanism and the adaptive method of dynamic low-rank adaptation, so that the model will not forget the old scene while adapting to the new scene. Step S6 includes: S61: Calculate the gradient of the total loss value described in step S5 with respect to the model parameters using the backpropagation algorithm. S62: Initialize multiple expert modules in the dynamic expert hybrid mechanism, and adaptively select the optimal expert module for parameter update based on the characteristics of the current task and the gradient of the total loss value with respect to the model parameters; S63: Perform a low-rank decomposition of the parameter weight matrix that needs to be updated into the product of two low-rank matrices; S64: After updating the parameters, validate the model to ensure that the model's performance improves in the new scenario without forgetting the knowledge of the old scenario; based on the validation results, adjust the learning rate and regularization coefficient to optimize the model's training process. S7. Check if the model has completed the predetermined number of training rounds or reached other stopping conditions; if training is not completed, return to step S2 to continue training; if training is completed, proceed to the next step. S8. Update the scene parameter memory. Store the parameters of the new scene and the updated model information into the scene parameter memory for future training.
2. The dynamic adaptation method for a safety identification model in rail transit construction according to claim 1, characterized in that, Step S1 includes: model structure initialization, optimizer settings, image encoder parameter settings, discriminator parameter settings, and other initialization settings; Model structure initialization includes determining the model architecture for identifying safety hazards in urban rail transit engineering construction, randomly initializing all parameters of the model or using pre-trained weights, and setting the discriminator structure for discriminator initialization; The optimizer settings include selecting an optimizer, setting the initial learning rate of the optimizer, and gradually reducing the learning rate using a cosine annealing strategy; setting the batch size and the total number of training epochs; Image encoder parameter settings include setting the number of visual coding layers and setting multi-head attention parameters; Discriminator parameter settings include setting the total number of output categories; Other initialization settings include setting a random seed, initializing the log, and the save path.
3. The dynamic adaptation method for a safety identification model in rail transit construction according to claim 1, characterized in that, Step S2 includes the following steps: S21: Read the new scene image and labels; S22: Perform data cleaning on the newly read scene images and labels; S23: Perform data augmentation operations on the cleaned data; S24: Standardize the data after data augmentation; S25: Batch and load the standardized data.
4. A dynamic adaptation method for a safety identification model in rail transit construction according to any one of claims 1-3, characterized in that, Step S3 includes: S31: Read the new scene image and check its format to ensure that the format and size of the input image meet the model requirements; S32: Extract features from the newly read scene images to obtain the feature vector of each image; S33: During scene training, save the image features and corresponding model parameters of historical scenes and build a scene parameter memory; after each new scene training is completed, store the features of the new scene and the updated model parameters into the scene parameter memory. S34: Compare the feature vector of the new scene image obtained in step S32 with the feature vector of the historical scene image stored in the scene parameter memory, and calculate the feature distance between them; select the historical scene most similar to the new scene based on the feature distance. S35: Initialize the encoder weight parameters of the new scene model based on the historical scene most similar to the new scene; including obtaining the encoder weights corresponding to the historical scene most similar to the new scene from the scene parameter memory; and using the encoder weights corresponding to these similar scenes as initial values to set the weight parameters of the new scene model.
5. A dynamic adaptation method for a safety identification model in rail transit construction according to any one of claims 1-3, characterized in that, Step S4 includes: S41: Input the image after enhancement processing in step S2 into the image encoder, and perform feature encoding on the input image to obtain the feature vector; S42: Input the feature vector output by the image encoder into the discriminator; perform a linear transformation on the input feature vector through the linear layer in the discriminator to obtain the score for each category; normalize the output of the linear layer through the softmax layer to obtain the probability distribution of each category; select the category with the highest probability as the prediction result based on the output of the softmax layer.
6. A dynamic adaptation method for a safety identification model in rail transit construction according to any one of claims 1-3, characterized in that, Step S5 includes: S51: Define the classification loss function, and use the cross-entropy loss function as the classification loss function; calculate the classification loss of the model's predicted samples based on the model's predicted class probabilities obtained in step S4 and the true labels read in step S2; S52: Define the regularization loss function and use elastic weight consolidation as the regularization method; based on the elastic weight consolidation method, use the model parameters of the old scene to perform parameter regularization on the parameters of the current new scene, and calculate the regularization loss; S53: Combine the classification loss and regularization loss into a comprehensive multi-task optimization objective function, and calculate the total loss value that comprehensively considers the model's classification accuracy on new tasks and its ability to preserve old tasks.
7. The dynamic adaptation method for a safety identification model in rail transit construction according to claim 6, characterized in that, In step S51, the classification loss L is expressed by equation (1): Among them, y i,c p is the true label of the i-th sample in class C; i,c Let N be the probability that the i-th sample belongs to class C as predicted by the model; N is the number of samples. In step S52, the regularization loss L EWC ; expressed by equation (2): Where, θ i The parameter representing the current task; F i The diagonal elements of the Fisher information matrix represent the parameter θ. i The importance of; This represents the optimal parameters in the old scenario; In step S53, the multi-task optimization objective function L 总 This can be expressed by equation (3): THE 总 =L+λL EWC (3) Where λ is the regularization coefficient, used to balance the weights of classification loss and regularization loss.
8. A dynamic adaptation method for a safety identification model in rail transit construction according to any one of claims 1-3, characterized in that, In step S62, based on the features of the current task and the gradient of the total loss value with respect to the model parameters, the optimal expert module is adaptively selected for parameter updates, including: S621: The ReLU function is used as the activation function; for each expert module, the input feature vector of the model is linearly transformed through the parameters of the expert module, and then the activation score is calculated through the activation function; S622: Normalize the activation scores of all expert modules using the softmax function so that their sum is 1; S623: Based on the normalized activation score, select the expert module with the highest activation score for parameter update.
9. A dynamic adaptation system for a safety identification model in rail transit construction, characterized in that, The method for dynamically adapting the rail transit construction safety identification model as described in any one of claims 1-8 includes: The initialization module is used to set the initial state and training parameters of the model; The data preprocessing module is used to read the images and corresponding labels of safety hazards in urban rail transit construction projects under new scenarios, and to perform data augmentation operations on the images; The scene parameter memory module is used to store the image features of historical scenes and the corresponding model parameters; The model initialization module is used to select the most similar historical scene from the scene parameter memory based on the features of the new scene image, and initialize the weights of the new scene model with its corresponding encoder weights. The feature extraction module is used to extract feature vectors from new scene images using a pre-trained feature extraction network; The image encoding and discrimination module is used to input the enhanced image data into the image encoder to obtain feature vectors, and to predict the category to which the image belongs through the discriminator; The loss function calculation module is used to construct a multi-task optimization objective function that includes classification loss and regularization loss, and to calculate the total loss value; The training control module is used to check whether the model has completed the predetermined number of training rounds or reached other stopping conditions, and to control the iteration and termination of the training process. The model parameter update module is used to dynamically and adaptively select specific parameters in the image encoder for updating based on the gradient of the total loss value through a dynamic expert mixture mechanism and low-rank adaptation. The model validation and tuning module is used to validate the performance of the updated model and adjust the learning rate and regularization coefficient. The logging and model saving module records key information during the training process and saves the weights of the trained model.
Citation Information
Patent Citations
Multi-task learning intelligent fault diagnosis method based on two-stage gradient weight adaptive optimization
CN115564038A
Real-time security assessment method and device and computer equipment
CN118194289A