WO2023005287A1 - 模型预训练方法、装置、电子设备和存储介质 - Google Patents
模型预训练方法、装置、电子设备和存储介质 Download PDFInfo
- Publication number
- WO2023005287A1 WO2023005287A1 PCT/CN2022/088612 CN2022088612W WO2023005287A1 WO 2023005287 A1 WO2023005287 A1 WO 2023005287A1 CN 2022088612 W CN2022088612 W CN 2022088612W WO 2023005287 A1 WO2023005287 A1 WO 2023005287A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- image processing
- processing model
- model
- task
- feature
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
Definitions
- the present disclosure relates to the field of artificial intelligence, specifically to the fields of deep learning and computer vision, and can be applied to scenarios such as image processing and image recognition, and more specifically relates to a model pre-training method and device, electronic equipment, non-transitory computer-readable storage media, Computer Program Products and Computer Programs.
- the pre-training model is widely used to improve the effect of upper-level artificial intelligence tasks.
- pre-training the pre-training model with a large amount of training data can realize the training of the model with a small amount of training data in the downstream task. In this case, better prediction results can be obtained. Therefore, how to pre-train the pre-trained model is very important.
- the present disclosure provides a method, device, electronic device, non-transitory computer-readable storage medium, computer program product and computer program for model pre-training.
- a model pre-training method including:
- sample pair includes the same or similar first image and second image
- a model pre-training device including:
- An acquisition module configured to acquire a pair of samples; wherein, the pair of samples includes the same or similar first image and second image;
- a first extraction module configured to extract features from the first image using a first image processing model to obtain first features
- a second extraction module configured to extract features from the second image using a second image processing model to obtain second features
- An update module configured to update the historical output feature set of the second image processing model according to the second feature
- a pre-training module configured to perform pre-training on the first image processing model and the second image processing model according to the difference between the first feature and the updated historical output feature set.
- an electronic device including:
- the memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the model pre-training method proposed in the above aspect of the present disclosure .
- a non-transitory computer-readable storage medium of computer instructions the computer instructions are used to enable the computer to execute the model pre-training method proposed in the above aspect of the present disclosure.
- a computer program product including a computer program, and when the computer program is executed by a processor, the model pre-training method proposed in the above aspect of the present disclosure is implemented.
- a computer program including computer program code.
- the computer program code When the computer program code is run on a computer, the computer executes the model pre-training method proposed in the above aspect of the present disclosure.
- FIG. 1 is a schematic flow chart of the model pre-training method provided by Embodiment 1 of the present disclosure
- FIG. 2 is a schematic flow chart of the model pre-training method provided by Embodiment 2 of the present disclosure
- FIG. 3 is a schematic diagram of a large-scale pre-training architecture based on multiple queues in an embodiment of the disclosure
- FIG. 4 is a schematic flow chart of the model pre-training method provided by Embodiment 3 of the present disclosure.
- FIG. 5 is a schematic flowchart of a model pre-training method provided in Embodiment 4 of the present disclosure
- FIG. 6 is a schematic structural diagram of a model pre-training device provided in Embodiment 5 of the present disclosure.
- FIG. 7 shows a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure.
- the existing pre-training models are mainly pre-trained on a single task, or migrated on similar tasks, such as cifar10, cifar100, imagenet (the above three are data sets designed to solve classification recognition problems) and other classification tasks.
- cifar10, cifar100, imagenet the above three are data sets designed to solve classification recognition problems
- imagenet the above three are data sets designed to solve classification recognition problems
- pre-training methods have great limitations in application scenarios sex.
- the present disclosure proposes a model pre-training method, device, electronic equipment, non-transitory computer-readable storage medium, computer program product and computer program.
- FIG. 1 is a schematic flowchart of a model pre-training method provided by Embodiment 1 of the present disclosure.
- Embodiments of the present disclosure are illustrated by taking the model pre-training method configured in a model pre-training device as an example, and the model pre-training device can be applied to any electronic device, so that the electronic device can perform a model pre-training function.
- the electronic device can be any device with computing capabilities, such as a personal computer (Personal Computer, referred to as PC), a mobile terminal, a server, etc., and a mobile terminal can be a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc. and other hardware devices with various operating systems, touch screens and/or displays.
- PC Personal Computer
- a mobile terminal can be a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc. and other hardware devices with various operating systems, touch screens and/or displays.
- model pre-training method may include the following steps:
- Step 101 acquire a sample pair; wherein, the sample pair includes the same or similar first image and second image.
- the sample pair can be obtained from the existing data set, test set or training set, or it can also be collected online, or it can also be collected offline, for example, it can be captured by a user-held image acquisition device , or, one of the images in the sample pair can also be obtained, and image processing is performed on one of the above images through image processing technology to obtain the other image in the sample pair, etc., and this disclosure is not limited thereto.
- Step 102 using the first image processing model to perform feature extraction on the first image to obtain first features.
- the structure of the first image processing model is not limited.
- the first image processing model can be a model with Transformer as the basic structure, or it can also be a model of other structures, such as Transformer A model of the variant structure.
- the first image processing model may be used to perform feature extraction on the first image, and the extracted feature of the first image may be used as the first feature.
- Step 103 using the second image processing model to perform feature extraction on the second image to obtain second features.
- the structure of the second image processing model is not limited.
- the second image processing model can be a model with Transformer as the basic structure, or it can also be a model of other structures, such as Transformer A model of the variant structure.
- the second image processing model may be used to perform feature extraction on the second image, and the extracted features of the second image may be used as the second features.
- Step 104 updating the historical output feature set of the second image processing model according to the second feature.
- the historical output feature set of the second image processing model may be updated according to the second feature.
- an upper limit (such as 106 ) of the number of historical output features included in the historical output feature set can be preset, and when the number of historical output features in the historical output feature set is lower than the upper limit
- the second feature can be directly added to the historical output feature set, and when the number of historical output features in the historical output feature set is equal to the upper limit, the second feature can be added to the historical output feature set , and delete the historical output features in the historical output feature set, for example, the earliest added historical output feature in the historical output feature set can be deleted.
- the upper limit of the number of historical output features contained in the historical output feature set is 4 for illustration. It is assumed that the historical output feature set includes historical output feature 1 and historical output feature 2 added sequentially in chronological order. , historical output feature 3, and historical output feature 4, then the second feature can be added to the historical feature set, and historical output feature 1 can be deleted.
- Step 105 pre-training the first image processing model and the second image processing model according to the difference between the first feature and the updated historical output feature set.
- the difference between the first feature and the updated historical output feature set may be determined according to the difference between the first feature and each historical output feature in the updated historical output feature set. Wherein, the difference between the first feature and the updated historical output feature set has a positive relationship with the difference between the first feature and each historical output feature.
- the first image processing model and the second image processing model can be pre-trained according to the difference between the first feature and the updated historical output feature set, so as to maximize the above difference.
- model pre-training method of the embodiment of the present disclosure by obtaining the sample pair, and using the first image processing model to extract the features of the first image in the sample pair to obtain the first feature, and using the second image processing model to extract the features of the sample pair Feature extraction is performed on the second image in to obtain the second feature, and the historical output feature set of the second image processing model is updated according to the second feature, so that according to the difference between the first feature and the updated historical output feature set, the The first image processing model and the second image processing model are pre-trained. In this way, joint pre-training of different models can be realized to improve the prediction effect of the model.
- the present disclosure provides another model pre-training method.
- FIG. 2 is a schematic flowchart of a model pre-training method provided in Embodiment 2 of the present disclosure.
- model pre-training method may include the following steps:
- Step 201 acquire a sample pair; wherein, the sample pair includes the same or similar first image and second image.
- step 201 For the execution process of step 201, reference may be made to the execution process of the foregoing embodiments, and details are not described here.
- Step 202 using the first conversion layer corresponding to the task to be performed to convert the first image into a first input sequence.
- the tasks to be performed may include coarse-grained classification tasks, and/or include fine-grained tasks such as face recognition.
- the conversion layer is used to perform serialized representation on the image.
- the sequence lengths corresponding to different tasks may be different, and the first image may be converted through the first conversion layer corresponding to the task to be executed to obtain the first input sequence corresponding to the first image.
- the first image can be divided into blocks to obtain 9 blocks, and the 9 blocks can be transformed through the linear projection of the flat block (Linear Projection of Flattened Patches) to obtain the first An input sequence.
- the flat block Linear Projection of Flattened Patches
- Step 203 adding the first input sequence to the first target queue of the first image processing model.
- the first target queue is a queue corresponding to the task to be executed among the multiple queues of the first image processing model.
- sequence lengths corresponding to different tasks can be different.
- different queues can be used to temporarily store the input sequences corresponding to different tasks.
- the first target queue corresponding to the task to be executed may be determined from the multiple queues of the first image processing model, and the first input sequence may be added to the first target queue.
- Step 204 when the first input sequence is polled by the first target queue, input the first input sequence to the first image processing model for feature extraction to obtain the first feature.
- the first image processing model can be used to sequentially perform feature extraction on each input sequence in each first target queue, and when the first target queue polls the first input sequence, the first The input sequence is input into the first image processing model for feature extraction to obtain the first feature corresponding to the first image.
- Step 205 using the second conversion layer corresponding to the task to convert the second image into a second input sequence.
- the second image may be converted through the second conversion layer corresponding to the task to be executed to obtain a second input sequence corresponding to the second image.
- the second image can be divided into blocks to obtain 9 blocks, and the 9 blocks can be transformed through the linear projection of the flat block (Linear Projection of Flattened Patches) to obtain the first Two input sequences.
- the flat block Linear Projection of Flattened Patches
- Step 206 adding the second input sequence to the second target queue corresponding to the second image processing module.
- sequence lengths corresponding to different tasks can be different, in order to facilitate the processing of the input sequences corresponding to the same task, different queues can be used to temporarily store the input sequences corresponding to different tasks.
- the second target queue corresponding to the task to be executed may be determined from the multiple queues of the second image processing model, and the second input sequence may be added to the second target queue.
- Step 207 when the first target queue inputs the first input sequence to the first image processing model, synchronously input the second input sequence belonging to the same sample pair to the second image processing model to obtain the second feature.
- the second input sequence can be synchronized with the first input sequence for feature extraction, that is, when the first target queue inputs the first input sequence to the first image processing model for feature extraction, it can synchronize the The second input sequence belonging to the same sample pair (for example, the sample pair with the same ID) is input to the second image processing model for feature extraction to obtain the second feature of the second image.
- Step 208 updating the historical output feature set of the second image processing model according to the second feature.
- Step 209 perform pre-training on the first image processing model and the second image processing model according to the difference between the first feature and the updated historical output feature set.
- the first image is converted into the first input sequence by using the first conversion layer corresponding to the task to be executed, and the first input sequence is added to the first target queue of the first image processing model
- the first input sequence is input to the first image processing model for feature extraction to obtain the first feature. Therefore, by adding the input sequences corresponding to different tasks to different queues, each task maintains a separate queue, so that the first image processing model can distinguish or target each task and improve the accuracy of feature extraction .
- the present disclosure further provides a model pre-training method.
- FIG. 4 is a schematic flowchart of a model pre-training method provided by Embodiment 3 of the present disclosure.
- model pre-training method may include the following steps:
- Step 401 acquire a sample pair; wherein, the sample pair includes the same or similar first image and second image.
- step 401 For the execution process of step 401, reference may be made to the execution process of the foregoing embodiments, and details are not repeated here.
- Step 402 for each task to be performed, using the first conversion layer corresponding to the task to convert the first image into a first input sequence, wherein there are multiple tasks.
- sequence lengths corresponding to different tasks may be different, and for each task, the first conversion layer corresponding to the task may be used to convert the first image into the first input sequence.
- Step 403 adding the first input sequence to the first target queue of the first image processing model.
- the first target queue is the queue corresponding to the task among the multiple queues of the first image processing model.
- sequence lengths corresponding to different tasks can be different.
- different queues can be used to temporarily store the input sequences corresponding to different tasks.
- the first target queue corresponding to the task can be determined from the multiple queues of the first image processing model, and the first input sequence can be added to the first target queue corresponding to the task .
- Step 404 when the first input sequence is polled by the first target queue, input the first input sequence to the first image processing model for feature extraction to obtain the first feature.
- the first image processing model may be used to perform feature extraction on the first input sequence corresponding to the task to obtain the first feature corresponding to the task.
- Step 405 for each task to be performed, use the second conversion layer corresponding to the task to convert the second image into a second input sequence.
- sequence lengths corresponding to different tasks may be different, and for each task, the second conversion layer corresponding to the task may be used to convert the second image into the second input sequence.
- Step 406 adding the second input sequence to the second target queue corresponding to the second image processing model.
- sequence lengths corresponding to different tasks can be different, in order to facilitate the processing of the input sequences corresponding to the same task, different queues can be used to temporarily store the input sequences corresponding to different tasks.
- the second target queue corresponding to the task can be determined from multiple queues of the second image processing model, and the second input sequence can be added to the second target queue corresponding to the task .
- Step 407 when the first target queue inputs the first input sequence to the first image processing model, synchronously input the second input sequence belonging to the same sample pair to the second image processing model to obtain the second feature.
- each task has a corresponding first input sequence and a second input sequence
- the first image processing model can perform feature extraction on the first input sequence corresponding to each task to obtain the first input sequence corresponding to each task.
- the second image processing model can simultaneously perform feature extraction on the second input sequence corresponding to each task to obtain the second feature corresponding to each task.
- Step 408 updating the historical output feature set of the second image processing model according to the second feature.
- each task may have a corresponding historical output feature set, and for each task, the second feature corresponding to the task may be added to the historical output feature set corresponding to the task.
- the upper limit value (such as 106 ) of the number of historical output features included in the historical output feature set corresponding to the task can be preset, and the historical output feature in the historical output feature set
- the second feature can be directly added to the historical output feature set, and when the number of historical output features in the historical output feature set is equal to the upper limit, the second feature can be added to the historical output feature set
- the second feature is added to the historical output feature set, and the historical output feature in the historical output feature set is deleted, for example, the earliest added historical output feature in the historical output feature set can be deleted.
- Step 409 for each task, the difference between the first feature obtained by performing feature extraction on the first input sequence corresponding to each task according to the first image processing model and the updated historical output feature set of the corresponding task, to obtain each The contrastive loss function value for the task.
- the difference between the first feature corresponding to the task and the updated historical output feature set corresponding to the task can be calculated (for example, the difference is marked as the first difference), for example,
- the difference between the first feature corresponding to the task and each feature in the updated historical output feature set corresponding to the task can be calculated (for example, the difference is marked as the second difference), according to the difference between the first feature and each feature
- the second difference between determines the first difference.
- the first difference has a positive relationship with the second difference, that is, the larger the second difference is, the larger the first difference is, and conversely, the smaller the second difference is, the smaller the first difference is.
- the contrastive loss function value corresponding to the task can be determined according to the above-mentioned first difference, wherein the contrastive loss function value is inversely related to the first difference, that is, the larger the first difference, the smaller the contrastive loss function value , conversely, the smaller the first difference, the larger the value of the loss function.
- Step 410 weighted and summed the comparison loss function values of each task to obtain the target comparison loss function value.
- the comparison loss function values corresponding to each task may be weighted and summed to obtain the target comparison loss function value Loss.
- the comparison loss function values corresponding to each task can be weighted and summed to obtain the target comparison loss function value.
- the weights corresponding to different tasks may be fixed to a specific ratio, or may be an end-to-end learning ratio, which is not limited in the present disclosure.
- Step 411 adjust the model parameters of the first image processing model and the second image processing model according to the target comparison loss function value.
- model parameters may be adjusted for the first image processing model and the second image processing model according to the target contrastive loss function value, so as to minimize the value of the target contrastive loss function value.
- different tasks may have different sequence lengths, that is, different encoding methods, and the attention weights corresponding to each task may also be different, in order for the model to know which task the input sequence is used to perform , to improve the prediction effect of the model, the position code corresponding to the task can be added to the input sequence.
- the first position code corresponding to the task can also be added to the first input sequence corresponding to the task, wherein the first position code is used to instruct the first image processing model to adopt the corresponding attention weight.
- the first image processing model as an example based on the Transformer structure.
- different tasks have corresponding position encodings (position embedding), which are used to indicate
- the self attention mechanism (self attention) part of the Transformer model can add attention weights corresponding to position embedding.
- the second position code corresponding to the task can also be added to the second input sequence corresponding to the task, wherein the second position code is used to instruct the second image processing model to adopt the corresponding attention Weights.
- the structure of the second image processing model is the same as that of the first image processing model.
- different tasks have corresponding position embeddings.
- the position embedding It is used to indicate that the self attention part of the Transformer model can add the attention weight corresponding to the position embedding.
- pre-training the model on multi-task can solve the technical problem of the limitation of application scenarios in the way of pre-training the model on a single task in the related art.
- large-scale pre-training of the model can improve the prediction accuracy and speed of the small model, making the model more accurate at the same speed, or, at the same accuracy, faster, which can improve the model in a specific The speed at which images or audio and video are processed on hardware or chips.
- the first feature obtained by performing feature extraction on the first input sequence corresponding to each task according to the first image processing model, and the updated historical output feature of the corresponding task The difference between the sets can be used to obtain the comparison loss function value of each task, and the weighted sum of the comparison loss function values of each task is obtained to obtain the target comparison loss function value, which can improve the reliability and rationality of the determination result of the target comparison loss function value, thus According to the target comparison loss function value, adjusting the model parameters of the first image processing model and the second image processing model can improve the pre-training effect of the model.
- the present disclosure further provides a model pre-training method.
- FIG. 5 is a schematic flowchart of a model pre-training method provided by Embodiment 4 of the present disclosure.
- model pre-training method may include the following steps:
- Step 501 acquire a sample pair; wherein, the sample pair includes the same or similar first image and second image.
- Step 502 using the first image processing model to perform feature extraction on the first image to obtain first features.
- Step 503 using the second image processing model to perform feature extraction on the second image to obtain second features.
- Step 504 updating the historical output feature set of the second image processing model according to the second feature.
- Step 505 according to the difference between the first feature and the updated historical output feature set, determine the target comparison loss function value.
- the difference between the first feature and the updated historical output feature set can be calculated (for example, the difference is marked as the first difference), for example, the first feature and the updated historical output feature set can be calculated
- the difference between each feature in for example, the difference is marked as the second difference
- the difference according to the second difference between the first feature and each feature, determine the first difference, where the first difference can be compared with the second difference into a positive relationship.
- the target contrastive loss function value can be determined according to the above-mentioned first difference, wherein the target contrastive loss function value has an inverse relationship with the first difference, that is, the larger the first difference, the smaller the target contrastive loss function value, Conversely, the smaller the first difference, the larger the value of the target contrastive loss function.
- Step 506 Adjust the model parameters of the second image processing model according to the target comparison loss function value.
- model parameter adjustment may be performed on the second image processing model according to the target contrastive loss function value, so as to minimize the value of the target contrastive loss function value.
- Step 507 Adjust the model parameters of the first image processing model according to the variation of the model parameters before and after the adjustment of the parameters of the second image processing model.
- the model parameters in the two models can be updated using the momentum update method, that is, the model parameters in the second image processing model can be updated online, and after the second image processing model is updated, use The model parameter variation of the second image processing model before and after adjustment is used to adjust the model parameters of the first image processing model offline. That is to say, the model parameters in the first image processing model can be adjusted according to the variation trend of the model parameters in the second image processing model.
- the first feature is the feature corresponding to the first image in the current sample pair
- each feature in the updated historical output feature set includes not only the feature corresponding to the second image in the current sample pair, but also the historical input
- the first feature currently extracted by the first image processing model is compared with each feature in the historical output feature set of the second image processing model, which will cause the two models to be unequal in the time dimension .
- the second image processing model in order to make the two models as equal as possible in the time dimension during feature extraction, so as to improve the model pre-training effect, can be processed according to the change trend of the model parameters in the second image processing model.
- the model parameters in an image processing model are adjusted so that the model parameters in the first image processing model lag behind in time dimension.
- model parameter variation of the second image processing model before and after adjustment may be weighted and fused with the model parameters of the first image processing model to obtain the adjusted model parameters of the first image processing model.
- the above model parameter variation may be superimposed on the model parameters of the first image processing model to obtain the adjusted model parameters of the first image processing model.
- the adjusted model weight may be 0.9.
- task 1 is an object recognition task
- task 2 is a face recognition task for exemplary description, wherein the structures of the first image processing model and the second image processing model may be the same.
- both tasks 1 and 2 input positive sample pairs, that is, the positive sample pairs can include different images with the same ID, or include the original image and a new image obtained by processing the original image.
- the pre-training architecture diagram can support multiple tasks at the same time, each task maintains a separate queue, and different tasks have corresponding conversion layers for converting images into sequences.
- the sequence lengths corresponding to different tasks can be different.
- the position codes corresponding to the corresponding tasks need to be added to the sequences corresponding to different tasks, and the self-attention mechanism of the model can be added to the corresponding Attention weights for positional encoding.
- the first image processing model and the second image processing model can update model parameters through momentum, that is, the second image processing model can be updated online, and the first image processing model can be updated offline.
- the target comparison loss function value is determined according to the difference between the first feature and the updated historical output feature set; and the second image processing model is modeled according to the target comparison loss function value.
- Parameter adjustment adjust the model parameters of the first image processing model according to the variation of the model parameters before and after the adjustment of the parameters of the second image processing model. In this way, the joint pre-training of the first image processing model and the second image processing model can be implemented, and the prediction effect of the model can be improved.
- the present disclosure also provides a model pre-training device. Therefore, the implementation of the model pre-training method is also applicable to the model pre-training device provided in the embodiments of the present disclosure, and will not be described in detail in the embodiments of the present disclosure.
- FIG. 6 is a schematic structural diagram of a model pre-training device provided by Embodiment 5 of the present disclosure.
- the model pre-training device 600 may include: an acquisition module 610 , a first extraction module 620 , a second extraction module 630 , an update module 640 and a pre-training module 650 .
- the acquiring module 610 is configured to acquire a sample pair; wherein, the sample pair includes the same or similar first image and second image.
- the first extraction module 620 is configured to perform feature extraction on the first image by using the first image processing model to obtain the first feature.
- the second extraction module 630 is configured to perform feature extraction on the second image by using a second image processing model to obtain a second feature.
- An update module 640 configured to update the historical output feature set of the second image processing model according to the second feature.
- the pre-training module 650 is configured to perform pre-training on the first image processing model and the second image processing model according to the difference between the first feature and the updated historical output feature set.
- the first extraction module 620 is specifically configured to: use the first conversion layer corresponding to the task to be executed to convert the first image into the first input sequence; The sequence is added to the first target queue of the first image processing model; when the first target queue polls the first input sequence, the first input sequence is input to the first image processing model for feature extraction; wherein, the first A target queue is a queue corresponding to tasks in the multiple queues of the first image processing model.
- the second extraction module 630 is specifically configured to: use the second conversion layer corresponding to the task to convert the second image into the second input sequence; add the second input sequence to In the second target queue corresponding to the second image processing model; when the first target queue inputs the first input sequence to the first image processing model, synchronously input the second input sequence belonging to the same sample pair to the second image processing Model.
- each task has a corresponding second input sequence, and each task has a corresponding historical output feature set;
- the update module 640 is specifically used to : adding the second feature extracted by the second image processing model to the second input sequence corresponding to each task to the historical output feature set of the corresponding task, and deleting the historical output feature in the historical output feature set of the corresponding task.
- the pre-training module 650 is specifically configured to: for each task, perform feature extraction on the first input sequence corresponding to each task according to the first image processing model. The difference between a feature and the updated historical output feature set of the corresponding task is used to obtain the comparison loss function value of each task; the weighted sum of the comparison loss function values of each task is obtained to obtain the target comparison loss function value; according to the target comparison loss function value, adjust the model parameters of the first image processing model and the second image processing model.
- model pre-training device 600 may also include:
- the adding module is used to add the first position code corresponding to the task to the first input sequence, wherein the first position code is used to instruct the first image processing model to adopt the corresponding attention weight; the second position code corresponding to the task added to the second input sequence, wherein the second position code is used to instruct the second image processing model to adopt the corresponding attention weight.
- the pre-training module 650 is specifically configured to: determine the target comparison loss function value according to the difference between the first feature and the updated historical output feature set; The loss function value is used to adjust the model parameters of the second image processing model; and to adjust the model parameters of the first image processing model according to the variation of the model parameters before and after the adjustment of the parameters of the second image processing model.
- the pre-training module 650 is specifically configured to: compare the variation of the model parameters of the second image processing model before and after adjustment with the model parameters of the first image processing model Weighted fusion is performed to obtain adjusted model parameters of the first image processing model.
- the model pre-training device in the embodiment of the present disclosure obtains the sample pair, and uses the first image processing model to perform feature extraction on the first image in the sample pair to obtain the first feature, and uses the second image processing model to extract the features of the sample pair Feature extraction is performed on the second image in to obtain the second feature, and the historical output feature set of the second image processing model is updated according to the second feature, so that according to the difference between the first feature and the updated historical output feature set, the The first image processing model and the second image processing model are pre-trained. In this way, joint pre-training of different models can be realized to improve the prediction effect of the model.
- the present disclosure also provides an electronic device, the electronic device may include the host client or server in the above embodiments, the electronic device may include at least one processor; and the at least one processor is communicatively connected Memory; wherein, the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor, so that at least one processor can execute the model pre-training method proposed by any of the above-mentioned embodiments of the present disclosure.
- the present disclosure also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to make a computer execute the model pre-training method proposed in any of the above-mentioned embodiments of the present disclosure.
- the present disclosure further provides a computer program product, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the model pre-training method proposed in any of the above embodiments of the present disclosure.
- the present disclosure also provides a computer program, the computer program includes computer program code, when the computer program code is run on the computer, the computer is made to execute the model pre-training proposed by any of the above-mentioned embodiments of the present disclosure method.
- the present disclosure also provides an electronic device, a non-transitory computer-readable storage medium, a computer program product, and a computer program.
- FIG. 7 shows a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure.
- Electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers.
- Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices.
- the components shown herein, their connections and relationships, and their functions, are by way of example only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
- the device 700 includes a computing unit 701, which can be loaded into a RAM (Random Access Memory, Random Access/ accesses the computer program in the memory) 703 to execute various appropriate actions and processes.
- RAM Random Access Memory
- various programs and data necessary for the operation of the device 700 can also be stored.
- the computing unit 701, ROM 702, and RAM 703 are connected to each other through a bus 704.
- An I/O (Input/Output, input/output) interface 705 is also connected to the bus 704 .
- the I/O interface 705 includes: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disk, etc. ; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, and the like.
- the communication unit 709 allows the device 700 to exchange information/data with other devices over a computer network such as the Internet and/or various telecommunication networks.
- the computing unit 701 may be various general-purpose and/or special-purpose processing components having processing and computing capabilities. Some examples of computing unit 701 include but are not limited to CPU (Central Processing Unit, central processing unit), GPU (Graphic Processing Units, graphics processing unit), various dedicated AI (Artificial Intelligence, artificial intelligence) computing chips, various operating The computing unit of the machine learning model algorithm, DSP (Digital Signal Processor, digital signal processor), and any appropriate processor, controller, microcontroller, etc.
- the calculation unit 701 executes various methods and processes described above, such as the above-mentioned model pre-training method.
- the above-mentioned model pre-training method can be implemented as a computer software program, which is tangibly embodied in a machine-readable medium, such as the storage unit 708 .
- part or all of the computer program may be loaded and/or installed on the device 700 via the ROM 702 and/or the communication unit 709.
- the computing unit 701 may be configured in any other appropriate way (for example, by means of firmware) to execute the above-mentioned model pre-training method.
- programmable processor can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
- Program codes for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special purpose computer, or other programmable data processing devices, so that the program codes, when executed by the processor or controller, make the functions/functions specified in the flow diagrams and/or block diagrams Action is implemented.
- the program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
- a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device.
- a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
- a machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing.
- machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory, Erasable Programmable Read-Only Memory) Or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory, portable compact disk read-only memory), optical storage device, magnetic storage device, or any suitable combination of the above.
- the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (Cathode-Ray Tube) or LCD ( Liquid Crystal Display (LCD) monitor); and a keyboard and pointing device (such as a mouse or trackball) through which a user can provide input to a computer.
- a display device e.g., a CRT (Cathode-Ray Tube) or LCD ( Liquid Crystal Display (LCD) monitor
- a keyboard and pointing device such as a mouse or trackball
- Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
- the systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system.
- the components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: LAN (Local Area Network, local area network), WAN (Wide Area Network, wide area network), the Internet, and blockchain networks.
- a computer system may include clients and servers.
- Clients and servers are generally remote from each other and typically interact through a communication network.
- the relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other.
- the server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the problems existing in traditional physical hosts and VPS services (Virtual Private Server, virtual private server). The defects of difficult management and weak business expansion.
- the server can also be a server of a distributed system, or a server combined with a blockchain.
- artificial intelligence is a discipline that studies the use of computers to simulate certain human thinking processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), including both hardware-level technology and software-level technology.
- Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, and machine learning/depth Learning, big data processing technology, knowledge map technology and other major directions.
- the technical solution of the embodiment of the present disclosure by acquiring the sample pair, and using the first image processing model to perform feature extraction on the first image in the sample pair to obtain the first feature, and using the second image processing model to extract the features of the sample pair Feature extraction is performed on the second image of the second image to obtain the second feature, and the historical output feature set of the second image processing model is updated according to the second feature, so that the first feature is calculated based on the difference between the first feature and the updated historical output feature set.
- An image processing model and a second image processing model are pre-trained. In this way, joint pre-training of different models can be realized to improve the prediction effect of the model.
- steps may be reordered, added or deleted using the various forms of flow shown above.
- each step described in the present disclosure may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present disclosure can be achieved, no limitation is imposed herein.
Landscapes
- Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Image Analysis (AREA)
Abstract
提供了模型预训练方法和装置、电子设备、非瞬时计算机可读存储介质、计算机程序产品和计算机程序。该模型预训练方法包括:获取样本对;采用第一图像处理模型对样本对中的第一图像进行特征提取,以得到第一特征;采用第二图像处理模型对样本对中的第二图像进行特征提取,以得到第二特征;根据第二特征更新第二图像处理模型的历史输出特征集合;和根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。
Description
相关申请的交叉引用
本申请要求在2021年07月29日在中国提交的中国专利申请号202110866809.2的优先权,其全部内容通过引用并入本文。
本公开涉及人工智能领域,具体涉及深度学习和计算机视觉等领域,可应用于图像处理、图像识别等场景,更具体地涉及模型预训练方法和装置、电子设备、非瞬时计算机可读存储介质、计算机程序产品和计算机程序。
预训练模型被广泛应用于改进上层人工智能任务的效果,在上游任务中,通过大量的训练数据对预训练模型进行预训练,即可实现在下游任务中,利用少量训练数据对模型进行训练的情况下,就可以取得较好的预测结果。因此,如何对预训练模型进行预训练是非常重要的。
发明内容
本公开提供了一种用于模型预训练方法、装置、电子设备、非瞬时计算机可读存储介质、计算机程序产品和计算机程序。
根据本公开一方面的实施例,提供了一种模型预训练方法,包括:
获取样本对;其中,所述样本对中包括相同或相似的第一图像和第二图像;
采用第一图像处理模型对所述第一图像进行特征提取,以得到第一特征;
采用第二图像处理模型对所述第二图像进行特征提取,以得到第二特征;
根据所述第二特征更新所述第二图像处理模型的历史输出特征集合;
根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练。
根据本公开另一方面的的实施例,提供了一种模型预训练装置,包括:
获取模块,用于获取样本对;其中,所述样本对中包括相同或相似的第一图像和第二图像;
第一提取模块,用于采用第一图像处理模型对所述第一图像进行特征提取,以得到第一特征;
第二提取模块,用于采用第二图像处理模型对所述第二图像进行特征提取,以得到第二特征;
更新模块,用于根据所述第二特征更新所述第二图像处理模型的历史输出特征集合;
预训练模块,用于根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练。
根据本公开又一方面的实施例,提供了一种电子设备,包括:
至少一个处理器;以及
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行本公开上述一方面提出的模型预训练方法。
根据本公开再一方面的实施例,提供了一种计算机指令的非瞬时计算机可读存储介质,所述计算机指令用于使所述计算机执行本公开上述一方面提出的模型预训练方法。
根据本公开还一方面的实施例,提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现本公开上述一方面提出的模型预训练方法。
根据本公开还一方面的实施例,提供了一种计算机程序,包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行本公开上述一方面提出的模型预训练方法。
应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。
附图用于更好地理解本方案,不构成对本公开的限定。其中:
图1是本公开实施例一所提供的模型预训练方法的流程示意图;
图2为本公开实施例二所提供的模型预训练方法的流程示意图;
图3为本公开实施例中基于多队列的大规模预训练架构示意图;
图4为本公开实施例三所提供的模型预训练方法的流程示意图;
图5为本公开实施例四所提供的模型预训练方法的流程示意图;
图6为本公开实施例五所提供的模型预训练装置的结构示意图;
图7示出了可以用来实施本公开的实施例的示例电子设备的示意性框图。
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。
现有的预训练模型主要在单任务上进行预训练,或者在类似的任务上进行迁移,比如cifar10、cifar100、imagenet(上述三个是为了解决分类识别问题而设计的数据集)等分类任务。然而很少有工作研究对预训练模型进行跨任务的预训练,比如跨粗粒度的分类任务和细粒度的人脸识别任务的预训练,因此上述预训练方式在应用场景中具有很大的局限性。
针对上述存在的问题,本公开提出一种模型预训练方法、装置、电子设备、非瞬时计算机可读存储介质、计算机程序产品和计算机程序。
下面参考附图描述本公开实施例的模型预训练方法、装置、电子设备、非瞬时计算机可读存储介质、计算机程序产品和计算机程序。
图1为本公开实施例一所提供的模型预训练方法的流程示意图。
本公开实施例以该模型预训练方法被配置于模型预训练装置中来举例说明,该模型预训练装置可以应用于任一电子设备中,以使该电子设备可以执行模型预训练功能。
其中,电子设备可以为任一具有计算能力的设备,例如可以为个人电脑(Personal Computer,简称PC)、移动终端、服务器等,移动终端例如可以为手机、平板电脑、个人数字助理、穿戴式设备等具有各种操作系统、触摸屏和/或显示屏的硬件设备。
如图1所示,该模型预训练方法可以包括以下步骤:
步骤101,获取样本对;其中,样本对中包括相同或相似的第一图像和第二图像。
在本公开实施例中,样本对,可以从现有的数据集、测试集或训练集中获取,或者,也可以在线采集,或者,也可以线下采集,比如可以通过用户手持图像采集设备拍摄得到,或者,也可以获取样本对中的其中一个图像,通过图像处理技术,对上述其中一个图像进行图像处理,以得到样本对中的另一个图像,等等,本公开对此并不做限制。
步骤102,采用第一图像处理模型对第一图像进行特征提取,以得到第一特征。
在本公开实施例中,对第一图像处理模型的结构不作限制,比如,该第一图像处理模型可以为以Transformer为基本结构的模型,或者,也可以为其他结构的模型,比如为Transformer的变种结构的模型。
在本公开实施例中,可以通过第一图像处理模型对第一图像进行特征提取,将提取到的第一图像的特征,作为第一特征。
步骤103,采用第二图像处理模型对第二图像进行特征提取,以得到第二特征。
在本公开实施例中,对第二图像处理模型的结构不作限制,比如,该第二图像处理模型可以为以Transformer为基本结构的模型,或者,也可以为其他结构的模型,比如为Transformer的变种结构的模型。
在本公开实施例中,可以通过第二图像处理模型对第二图像进行特征提取,将提取到的第二图像的特征,作为第二特征。
步骤104,根据第二特征更新第二图像处理模型的历史输出特征集合。
在本公开实施例中,可以根据第二特征更新第二图像处理模型的历史输出特征集合。
作为一种示例,可以预先设置历史输出特征集合中包括的历史输出特征数量的上限值(比如10
6个),在历史输出特征集合中的历史输出特征的个数低于上限值的情况下,可以将第二特征直接添加至历史输出特征集合中,而在历史输出特征集合中的历史输出特征的个数等于上限值的情况下,可以将第二特征添加至历史输出特征集合中,并删除历史输出特征集合中的历史输出特征,比如可以删除历史输出特征集合中最早添加的历史输出特征。
举例而言,以历史输出特征集合包含的历史输出特征数量的上限值为4进行示例性说明,假设历史输出特征集合中包括按照时间先后顺序,依次添加的历史输出特征1、历史输出特征2、历史输出特征3以及历史输出特征4,则可以将第二特征添加至历史特征集合,并删除历史输出特征1。
步骤105,根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。
在本公开实施例中,第一特征与更新后的历史输出特征集合之间的差异,可以根据第一特征与更新后的历史输出特征集合中的每个历史输出特征之间的差异确定。其中,第一特征与更新后的历史输出特征集合之间的差异,与第一特征与各历史输出特征之间的差异成正向关系。
应当理解的是,更新后的历史输出特征集合中各个特征中只有第二特征是与第一特征相似的,而其他特征可能与第一特征并不相似,为了使得模型能够正确对各图像进行识别,在对模型进行预训练时,可以根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练,以使上述差异最大化。
本公开实施例的模型预训练方法,通过获取样本对,并采用第一图像处理模型对样本对中的第一图像进行特征提取,以得到第一特征,以及采用第二图像处理模型对样本对中的第二图像进行特征提取,以得到第二特征,根据第二特征更新第二图像处理模型的历史输出特征集合,以根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。由此,可以实现对不同的模型进行联合预训练,以提升模型预测效果。
为了清楚说明上述实施例中是如何提取第一特征和第二特征的,本公开提供了另一种模型预训练方法。
图2为本公开实施例二所提供的模型预训练方法的流程示意图。
如图2所示,该模型预训练方法可以包括以下步骤:
步骤201,获取样本对;其中,样本对中包括相同或相似的第一图像和第二图像。
步骤201的执行过程可以参见上述实施例的执行过程,在此不做赘述。
步骤202,采用待执行的任务对应的第一转换层将第一图像转化为第一输入序列。
在本公开实施例中,待执行的任务可以包括粗粒度的分类任务,和/或,包括细粒度的人脸识别等任务。
在本公开实施例中,转换层用于对图像进行序列化表示。
在本公开实施例中,不同任务对应的序列长度可以不同,可以通过待执行的任务对应的第一转换层将第一图像进行转化,得到该第一图像对应的第一输入序列。
作为一种示例,如图3所示,可以将第一图像进行分块,得到9个图块,通过平坦图块的线性投影(Linear Projection of Flattened Patches)将9个图块进行转化,得到第一输入序列。
步骤203,将第一输入序列添加到第一图像处理模型的第一目标队列中。
其中,第一目标队列是第一图像处理模型的多个队列中上述待执行的任务所对应的队列。
需要说明的是,不同任务对应的序列长度可以不同,为了便于对同一任务对应的输入序列进行处理,可以通过不同队列,来暂存不同任务对应的输入序列。
即,本公开中,可以从第一图像处理模型的多个队列中,确定待执行的任务对应的第一目标队列,将第一输入序列添加到第一目标队列中。
步骤204,在第一目标队列轮询到第一输入序列的情况下,将第一输入序列输入到第一图像处理模型进行特征提取,得到第一特征。
在本公开实施例中,可以利用第一图像处理模型依次对各第一目标队列中的各输 入序列进行特征提取,在第一目标队列轮询到第一输入序列的情况下,可以将第一输入序列输入到第一图像处理模型中进行特征提取,得到该第一图像对应的第一特征。
步骤205,采用任务对应的第二转化层将第二图像转化为第二输入序列。
同理,由于不同任务对应的序列长度可以不同,可以通过待执行的任务对应的第二转换层将第二图像进行转化,得到该第二图像对应的第二输入序列。
作为一种示例,如图3所示,可以将第二图像进行分块,得到9个图块,通过平坦图块的线性投影(Linear Projection of Flattened Patches)将9个图块进行转化,得到第二输入序列。
步骤206,将第二输入序列添加到第二图像处理模块对应的第二目标队列中。
同理,由于不同任务对应的序列长度可以不同,为了便于对同一任务对应的输入序列进行处理,可以通过不同队列,来暂存不同任务对应的输入序列。
即,本公开中,可以从第二图像处理模型的多个队列中,确定待执行的任务对应的第二目标队列,将第二输入序列添加到第二目标队列中。
步骤207,在第一目标队列将第一输入序列输入第一图像处理模型的情况下,同步将属于相同样本对的第二输入序列输入到第二图像处理模型,得到第二特征。
在本公开实施例中,第二输入序列可以与第一输入序列同步进行特征提取,即在第一目标队列将第一输入序列输入到第一图像处理模型进行特征提取的情况下,可以同步将属于相同样本对(比如同一ID的样本对)的第二输入序列输入到第二图像处理模型进行特征提取,得到第二图像的第二特征。
步骤208,根据第二特征更新第二图像处理模型的历史输出特征集合。
步骤209,根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。
步骤208至209的执行过程可以参见上述实施例的执行过程,在此不做赘述。
本公开实施例的模型预训练方法,通过采用待执行的任务对应的第一转换层将第一图像转化为第一输入序列,将第一输入序列添加到第一图像处理模型的第一目标队列中,在第一目标队列轮询到第一输入序列的情况下,将第一输入序列输入到第一图像处理模型进行特征提取,得到第一特征。由此,通过将不同任务对应的输入序列,添加至不同的队列中,每个任务维护单独的队列,从而第一图像处理模型可以对各任务进行区分或针对性处理,提升特征提取的准确性。
同理,通过采用任务对应的第二转化层将第二图像转化为第二输入序列,将第二输入序列添加到第二图像处理模块对应的第二目标队列中,在第一目标队列将第一输入序列输入第一图像处理模型的情况下,同步将属于相同样本对的第二输入序列输入 到第二图像处理模型,得到第二特征。由此,通过将不同任务对应的输入序列,添加至不同的队列中,每个任务维护单独的队列,从而第二图像处理模型可以对各任务进行区分或针对性处理,提升特征提取的准确性。
为了清楚说明上述实施例中是如何对第一图像处理模型和第二图像处理模型进行预训练的,本公开还提供一种模型预训练方法。
图4为本公开实施例三所提供的模型预训练方法的流程示意图。
如图4所示,该模型预训练方法可以包括以下步骤:
步骤401,获取样本对;其中,样本对中包括相同或相似的第一图像和第二图像。
步骤401的执行过程可以参见上述实施例的执行过程,在此不做赘述。
步骤402,针对每个待执行的任务,采用该任务对应的第一转换层将第一图像转化为第一输入序列,其中,任务为多个。
在本公开实施例中,不同任务对应的序列长度可以不同,针对每个任务,可以采用该任务对应的第一转换层将第一图像转化为第一输入序列。
步骤403,将第一输入序列添加到第一图像处理模型的第一目标队列中。
其中,第一目标队列是第一图像处理模型的多个队列中该任务所对应的队列。
需要说明的是,不同任务对应的序列长度可以不同,为了便于对同一任务对应的输入序列进行处理,可以通过不同队列,来暂存不同任务对应的输入序列。
即,本公开中,针对每个任务,可以从第一图像处理模型的多个队列中,确定该任务对应的第一目标队列,将第一输入序列添加到该任务对应的第一目标队列中。
步骤404,在第一目标队列轮询到第一输入序列的情况下,将第一输入序列输入到第一图像处理模型进行特征提取,得到第一特征。
在本公开实施例中,针对每个任务,可以采用第一图像处理模型对该任务对应的第一输入序列进行特征提取,得到该任务对应的第一特征。
步骤405,针对每个待执行的任务,采用该任务对应的第二转化层将第二图像转化为第二输入序列。
在本公开实施例中,不同任务对应的序列长度可以不同,针对每个任务,可以采用该任务对应的第二转化层将第二图像转化为第二输入序列。
步骤406,将第二输入序列添加到第二图像处理模型对应的第二目标队列中。
同理,由于不同任务对应的序列长度可以不同,为了便于对同一任务对应的输入序列进行处理,可以通过不同队列,来暂存不同任务对应的输入序列。
即,本公开中,针对每个任务,可以从第二图像处理模型的多个队列中,确定该 任务对应的第二目标队列,将第二输入序列添加到该任务对应的第二目标队列中。
步骤407,在第一目标队列将第一输入序列输入第一图像处理模型的情况下,同步将属于相同样本对的第二输入序列输入到第二图像处理模型,以得到第二特征。
在本公开实施例中,每个任务均具有对应的第一输入序列和第二输入序列,第一图像处理模型可以对各任务对应的第一输入序列进行特征提取,得到各任务对应的第一特征,相应的,第二图像处理模型可以同步对各任务对应的第二输入序列进行特征提取,得到各任务对应的第二特征。
步骤408,根据第二特征更新第二图像处理模型的历史输出特征集合。
在公开实施例中,每个任务均可以具有对应的历史输出特征集合,针对每个任务,可以将该任务对应的第二特征添加到该任务对应的历史输出特征集合中。
作为一种示例,针对每个任务,可以预先设置该任务对应的历史输出特征集合中包括的历史输出特征数量的上限值(比如10
6个),在历史输出特征集合中的历史输出特征的个数低于上限值的情况下,可以将第二特征直接添加至历史输出特征集合中,而在历史输出特征集合中的历史输出特征的个数等于上限值的情况下,可以将第二特征添加至历史输出特征集合中,并删除历史输出特征集合中的历史输出特征,比如可以删除历史输出特征集合中最早添加的历史输出特征。由此,可以实现对各历史输出特征集合进行动态维护和更新。
步骤409,针对每个任务,根据第一图像处理模型对各任务对应的第一输入序列进行特征提取所得到的第一特征,与对应任务更新后的历史输出特征集合之间的差异,得到各任务的对比损失函数值。
在本公开实施例中,针对每个任务,可以计算该任务对应的第一特征与该任务对应的更新后的历史输出特征集合之间的差异(比如该差异标记为第一差异),例如,可以计算该任务对应的第一特征与该任务对应的更新后的历史输出特征集合中的每个特征之间的差异(比如该差异标记为第二差异),根据第一特征与每个特征之间的第二差异,确定第一差异。其中,第一差异与第二差异成正向关系,即第二差异越大,第一差异越大,反之,第二差异越小,第一差异越小。
从而本公开中,可以根据上述第一差异,确定该任务对应的对比损失函数值,其中,对比损失函数值与第一差异成反向关系,即第一差异越大,对比损失函数值越小,反之,第一差异越小,损失函数值越大。
步骤410,对各任务的对比损失函数值加权求和得到目标对比损失函数值。
在本公开实施例中,可以对各任务对应的对比损失函数值进行加权求和,得到目标对比损失函数值Loss。例如,可以根据各任务对应的权重,对各任务对应的对比损 失函数值进行加权求和,得到目标对比损失函数值。
其中,不同任务对应的权重可以固定为特定的比例,或者,也可以为端到端学习比例,本公开对此并不做限制。
步骤411,根据目标对比损失函数值,对第一图像处理模型和第二图像处理模型进行模型参数调整。
在本公开实施例中,可以根据目标对比损失函数值,对第一图像处理模型和第二图像处理模型进行模型参数调整,以使目标对比损失函数值的取值最小化。
在本公开的任意一个实施例之中,不同任务可以具有不同的序列长度,即编码方式不同,各个任务对应的注意力权重也可以不同,为了使得模型获知输入序列是用于执行哪种任务的,以提升模型的预测效果,可以在输入序列中添加任务对应的位置编码。
即,本公开中,针对每个任务,还可以将该任务对应的第一位置编码添加到该任务对应的第一输入序列中,其中,第一位置编码用于指示第一图像处理模型采用对应的注意力权重。
作为一种示例,以第一图像处理模型为基于Transformer结构的模型进行示例,在不同任务对应的序列长度不同的情况下,不同任务具有对应的位置编码(position embedding),该位置编码用于指示Transformer模型的自注意力机制(self attention)部分可以加入对应position embedding的注意力权重。
同理,针对每个任务,还可以将该任务对应的第二位置编码添加到该任务对应的第二输入序列中,其中,第二位置编码用于指示第二图像处理模型采用对应的注意力权重。
作为一种示例,以第二图像处理模型与第一图像处理模型的结构相同进行示例,在不同任务对应的序列长度不同的情况下,不同任务具有对应的位置编码(position embedding),该位置编码用于指示Transformer模型的self attention部分可以加入对应position embedding的注意力权重。
由此,在多任务上对模型进行预训练,可以解决相关技术中在单任务上对模型进行预训练的方式,存在应用场景的局限性的技术问题。并且,对模型进行大规模预训练,可以提升小模型的预测精度和速度,使得模型在同样的速度情况下精度更高,或者,在同样精度的情况下,速度更快,可以提升模型在特定硬件或芯片上处理图像或者音视频的速度。
本公开实施例的模型预训练方法,通过针对每个任务,根据第一图像处理模型对各任务对应的第一输入序列进行特征提取所得到的第一特征,与对应任务更新后的历 史输出特征集合之间的差异,得到各任务的对比损失函数值,对各任务的对比损失函数值加权求和得到目标对比损失函数值,可以提升目标对比损失函数值确定结果的可靠性和合理性,从而根据该目标对比损失函数值,对第一图像处理模型和第二图像处理模型进行模型参数调整,可以提升模型的预训练效果。
为了清楚说明上述实施例中是如何对第一图像处理模型和第二图像处理模型进行预训练的,本公开还提供一种模型预训练方法。
图5为本公开实施例四所提供的模型预训练方法的流程示意图。
如图5所示,该模型预训练方法可以包括以下步骤:
步骤501,获取样本对;其中,样本对中包括相同或相似的第一图像和第二图像。
步骤502,采用第一图像处理模型对第一图像进行特征提取,以得到第一特征。
步骤503,采用第二图像处理模型对第二图像进行特征提取,以得到第二特征。
步骤504,根据第二特征更新第二图像处理模型的历史输出特征集合。
步骤501至504的执行过程可以参见上述任一实施例的执行过程,在此不做赘述。
步骤505,根据第一特征与更新后的历史输出特征集合之间的差异,确定目标对比损失函数值。
在本公开实施例中,可以计算第一特征与更新后的历史输出特征集合之间的差异(比如该差异标记为第一差异),例如,可以计算第一特征与更新后的历史输出特征集合中的每个特征之间的差异(比如该差异标记为第二差异),根据第一特征与每个特征之间的第二差异,确定第一差异,其中,第一差异可以与第二差异成正向关系。从而本公开中,可以根据上述第一差异,确定目标对比损失函数值,其中,目标对比损失函数值与第一差异成反向关系,即第一差异越大,目标对比损失函数值越小,反之,第一差异越小,目标对比损失函数值越大。
步骤506,根据目标对比损失函数值,对第二图像处理模型进行模型参数调整。
在本公开实施例中,可以根据目标对比损失函数值,对第二图像处理模型进行模型参数调整,以使目标对比损失函数值的取值最小化。
步骤507,根据第二图像处理模型参数调整前和调整后的模型参数变化量,对第一图像处理模型进行模型参数调整。
在本公开实施例中,可以采用动量更新方式,对两个模型中的模型参数进行更新,即可以在线对第二图像处理模型中的模型参数进行更新,在第二图像处理模型更新后,利用第二图像处理模型参数调整前和调整后的模型参数变化量,离线对第一图像处理模型进行模型参数调整。也就是说,可以根据第二图像处理模型中模型参数的变化趋 势,对第一图像处理模型中的模型参数进行调整。
需要说明的是,第一特征是当前样本对中第一图像对应的特征,而更新后的历史输出特征集合中的各特征不仅包含当前样本对中第二图像对应的特征,还包含历史输入的各样本对中图像对应的特征,将第一图像处理模型当前提取得到的第一特征与第二图像处理模型的历史输出特征集合中各特征进行比对,将导致两个模型在时间维度不对等。
因此,在本公开实施例中,为了使得两个模型在特征提取时,在时间维度上尽量对等,从而提升模型预训练效果,可以根据第二图像处理模型中模型参数的变化趋势,对第一图像处理模型中的模型参数进行调整,以使第一图像处理模型中的模型参数在时间维度上滞后些。
作为一种示例,可以将第二图像处理模型参数调整前和调整后的模型参数变化量,与第一图像处理模型的模型参数进行加权融合,以得到第一图像处理模型调整后的模型参数。比如,可以将上述模型参数变化量与第一图像处理模型的模型参数进行叠加,得到第一图像处理模型调整后的模型参数。
举例而言,第一图像处理模型的模型权重为1,第二图像处理模型对应的模型参数变化量为0.1,则调整后的模型权重可以为0.9。
作为一种示例,如图3所示,以任务1为物体识别任务,任务2为人脸识别任务进行示例性说明,其中,第一图像处理模型和第二图像处理模型的结构可以相同。
图3中,任务1和任务2输入的都是正样本对,即该正样本对中可以包括采用同一ID的不同图像,或者包括原始图像以及对原始图像进行处理后得到的新的图像。
图3中,预训练架构图中可以同时支持多任务,每个任务维护单独的队列,不同任务具有对应的转换层,用于将图像转换成序列。其中,不同任务对应的序列长度可以不同,在不同任务对应的序列长度不同的情况下,不同任务对应的序列中,需要加入对应任务所对应的位置编码,模型的自注意力机制部分可以加入对应位置编码的注意力权重。
图3中,第一图像处理模型和第二图像处理模型可以通过动量的方式更新模型参数,即第二图像处理模型可以在线更新,第一图像处理模型可以离线更新。
本公开实施例的模型预训练方法,通过根据第一特征与更新后的历史输出特征集合之间的差异,确定目标对比损失函数值;根据目标对比损失函数值,对第二图像处理模型进行模型参数调整;根据第二图像处理模型参数调整前和调整后的模型参数变化量,对第一图像处理模型进行模型参数调整。由此,可以实现对第一图像处理模型和第二图像处理模型进行联合预训练,可以提升模型的预测效果。
与上述图1至图5实施例提供的模型预训练方法相对应,本公开还提供一种模型预训练装置,由于本公开实施例提供的模型预训练装置与上述图1至图5实施例提供的模型预训练方法相对应,因此在模型预训练方法的实施方式也适用于本公开实施例提供的模型预训练装置,在本公开实施例中不再详细描述。
图6为本公开实施例五所提供的模型预训练装置的结构示意图。
如图6所示,该模型预训练装置600可以包括:获取模块610、第一提取模块620、第二提取模块630、更新模块640以及预训练模块650。
其中,获取模块610,用于获取样本对;其中,样本对中包括相同或相似的第一图像和第二图像。
第一提取模块620,用于采用第一图像处理模型对第一图像进行特征提取,以得到第一特征。
第二提取模块630,用于采用第二图像处理模型对第二图像进行特征提取,以得到第二特征。
更新模块640,用于根据第二特征更新第二图像处理模型的历史输出特征集合。
预训练模块650,用于根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。
在本公开实施例的一种可能的实现方式中,第一提取模块620,具体用于:采用待执行的任务对应的第一转换层将第一图像转化为第一输入序列;将第一输入序列添加到第一图像处理模型的第一目标队列中;在第一目标队列轮询到第一输入序列的情况下,将第一输入序列输入到第一图像处理模型进行特征提取;其中,第一目标队列是第一图像处理模型的多个队列中任务所对应的队列。
在本公开实施例的一种可能的实现方式中,第二提取模块630,具体用于:采用任务对应的第二转化层将第二图像转化为第二输入序列;将第二输入序列添加到第二图像处理模型对应的第二目标队列中;在第一目标队列将第一输入序列输入第一图像处理模型的情况下,同步将属于相同样本对的第二输入序列输入到第二图像处理模型。
在本公开实施例的一种可能的实现方式中,任务为多个,对应地,各任务具有对应的第二输入序列,且各任务具有对应的历史输出特征集合;更新模块640,具体用于:将第二图像处理模型对各任务对应的第二输入序列所提取的第二特征,添加到对应任务的历史输出特征集合,并删除对应任务的历史输出特征集合中的历史输出特征。
在本公开实施例的一种可能的实现方式中,预训练模块650,具体用于:针对每个任务,根据第一图像处理模型对各任务对应的第一输入序列进行特征提取所得到的第 一特征,与对应任务更新后的历史输出特征集合之间的差异,得到各任务的对比损失函数值;对各任务的对比损失函数值加权求和得到目标对比损失函数值;根据目标对比损失函数值,对第一图像处理模型和第二图像处理模型进行模型参数调整。
在本公开实施例的一种可能的实现方式中,该模型预训练装置600还可以包括:
添加模块,用于将任务对应的第一位置编码添加到第一输入序列中,其中,第一位置编码用于指示第一图像处理模型采用对应的注意力权重;将任务对应的第二位置编码添加到第二输入序列中,其中,第二位置编码用于指示第二图像处理模型采用对应的注意力权重。
在本公开实施例的一种可能的实现方式中,预训练模块650,具体用于:根据第一特征与更新后的历史输出特征集合之间的差异,确定目标对比损失函数值;根据目标对比损失函数值,对第二图像处理模型进行模型参数调整;根据第二图像处理模型参数调整前和调整后的模型参数变化量,对第一图像处理模型进行模型参数调整。
在本公开实施例的一种可能的实现方式中,预训练模块650,具体用于:将第二图像处理模型参数调整前和调整后的模型参数变化量,与第一图像处理模型的模型参数进行加权融合,以得到第一图像处理模型调整后的模型参数。
本公开实施例的模型预训练装置,通过获取样本对,并采用第一图像处理模型对样本对中的第一图像进行特征提取,以得到第一特征,以及采用第二图像处理模型对样本对中的第二图像进行特征提取,以得到第二特征,根据第二特征更新第二图像处理模型的历史输出特征集合,以根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。由此,可以实现对不同的模型进行联合预训练,以提升模型预测效果。
为了实现上述实施例,本公开还提供一种电子设备,电子设备可以包括上述实施例中的主播客户端或服务端,该电子设备可以包括至少一个处理器;以及与至少一个处理器通信连接的存储器;其中,存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行本公开上述任一实施例提出的模型预训练方法。
为了实现上述实施例,本公开还提供一种存储有计算机指令的非瞬时计算机可读存储介质,其中,计算机指令用于使计算机执行本公开上述任一实施例提出的模型预训练方法。
为了实现上述实施例,本公开还提供一种计算机程序产品,该计算机程序产品包括计算机程序,计算机程序在被处理器执行时实现本公开上述任一实施例提出的模型 预训练方法。
为了实现上述实施例,本公开还提供一种计算机程序,该计算机程序包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行本公开上述任一实施例提出的模型预训练方法。
根据本公开的实施例,本公开还提供了一种电子设备、一种非瞬时计算机可读存储介质、一种计算机程序产品和一种计算机程序。
图7示出了可以用来实施本公开的实施例的示例电子设备的示意性框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。
如图7所示,设备700包括计算单元701,其可以根据存储在ROM(Read-Only Memory,只读存储器)702中的计算机程序或者从存储单元707加载到RAM(Random Access Memory,随机访问/存取存储器)703中的计算机程序,来执行各种适当的动作和处理。在RAM 703中,还可存储设备700操作所需的各种程序和数据。计算单元701、ROM 702以及RAM 703通过总线704彼此相连。I/O(Input/Output,输入/输出)接口705也连接至总线704。
设备700中的多个部件连接至I/O接口705,包括:输入单元706,例如键盘、鼠标等;输出单元707,例如各种类型的显示器、扬声器等;存储单元708,例如磁盘、光盘等;以及通信单元709,例如网卡、调制解调器、无线通信收发机等。通信单元709允许设备700通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。
计算单元701可以是各种具有处理和计算能力的通用和/或专用处理组件。计算单元701的一些示例包括但不限于CPU(Central Processing Unit,中央处理单元)、GPU(Graphic Processing Units,图形处理单元)、各种专用的AI(Artificial Intelligence,人工智能)计算芯片、各种运行机器学习模型算法的计算单元、DSP(Digital Signal Processor,数字信号处理器)、以及任何适当的处理器、控制器、微控制器等。计算单元701执行上文所描述的各个方法和处理,例如上述模型预训练方法。例如,在一些实施例中,上述模型预训练方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元708。在一些实施例中,计算机程序的部分或者全部可以经由ROM 702和/或通信单元709而被载入和/或安装到设备700上。当计算机程序加载 到RAM 703并由计算单元701执行时,可以执行上文描述的模型预训练方法的一个或多个步骤。备选地,在其他实施例中,计算单元701可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行上述模型预训练方法。
本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、FPGA(Field Programmable Gate Array,现场可编程门阵列)、ASIC(Application-Specific Integrated Circuit,专用集成电路)、ASSP(Application Specific Standard Product,专用标准产品)、SOC(System On Chip,芯片上系统的系统)、CPLD(Complex Programmable Logic Device,复杂可编程逻辑设备)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。
用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码当由处理器或控制器执行时使流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、RAM、ROM、EPROM(Electrically Programmable Read-Only-Memory,可擦除可编程只读存储器)或快闪存储器、光纤、CD-ROM(Compact Disc Read-Only Memory,便捷式紧凑盘只读存储器)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(Cathode-Ray Tube,阴极射线管)或者LCD(Liquid Crystal Display,液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。 其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:LAN(Local Area Network,局域网)、WAN(Wide Area Network,广域网)、互联网和区块链网络。
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与VPS服务(Virtual Private Server,虚拟专用服务器)中,存在的管理难度大,业务扩展性弱的缺陷。服务器也可以为分布式系统的服务器,或者是结合了区块链的服务器。
其中,需要说明的是,人工智能是研究使计算机来模拟人的某些思维过程和智能行为(如学习、推理、思考、规划等)的学科,既有硬件层面的技术也有软件层面的技术。人工智能硬件技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理等技术;人工智能软件技术主要包括计算机视觉技术、语音识别技术、自然语言处理技术以及机器学习/深度学习、大数据处理技术、知识图谱技术等几大方向。
根据本公开实施例的技术方案,通过获取样本对,并采用第一图像处理模型对样本对中的第一图像进行特征提取,以得到第一特征,以及采用第二图像处理模型对样本对中的第二图像进行特征提取,以得到第二特征,根据第二特征更新第二图像处理模型的历史输出特征集合,以根据第一特征与更新后的历史输出特征集合之间的差异,对第一图像处理模型和第二图像处理模型进行预训练。由此,可以实现对不同的模型进行联合预训练,以提升模型预测效果。
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本公开中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。
上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。
Claims (20)
- 一种模型预训练方法,包括:获取样本对;其中,所述样本对中包括相同或相似的第一图像和第二图像;采用第一图像处理模型对所述第一图像进行特征提取,以得到第一特征;采用第二图像处理模型对所述第二图像进行特征提取,以得到第二特征;根据所述第二特征更新所述第二图像处理模型的历史输出特征集合;根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练。
- 根据权利要求1所述的方法,其中,所述采用第一图像处理模型对所述第一图像进行特征提取,以得到第一特征,包括:采用待执行的任务对应的第一转换层将所述第一图像转化为第一输入序列;将所述第一输入序列添加到所述第一图像处理模型的第一目标队列中;在所述第一目标队列轮询到所述第一输入序列的情况下,将所述第一输入序列输入到所述第一图像处理模型进行特征提取;其中,所述第一目标队列是所述第一图像处理模型的多个队列中所述任务所对应的队列。
- 根据权利要求1或2所述的方法,其中,所述采用第二图像处理模型对所述第二图像进行特征提取,以得到第二特征,包括:采用所述任务对应的第二转化层将所述第二图像转化为第二输入序列;将所述第二输入序列添加到所述第二图像处理模型对应的第二目标队列中;在所述第一目标队列将所述第一输入序列输入所述第一图像处理模型的情况下,同步将属于相同样本对的所述第二输入序列输入到所述第二图像处理模型。
- 根据权利要求3所述的方法,其中,所述任务为多个,对应地,各所述任务具有对应的所述第二输入序列,且各所述任务具有对应的所述历史输出特征集合;所述根据所述第二特征更新所述第二图像处理模型的历史输出特征集合,包括:将所述第二图像处理模型对各任务对应的第二输入序列所提取的第二特征,添加到对应任务的所述历史输出特征集合,并删除对应任务的所述历史输出特征集合中的历史输出特征。
- 根据权利要求1-4中任一项所述的方法,其中,所述根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练,包括:针对每个所述任务,根据所述第一图像处理模型对各所述任务对应的第一输入序列进行特征提取所得到的第一特征,与对应任务更新后的所述历史输出特征集合之间的差异,得到各任务的对比损失函数值;对各所述任务的对比损失函数值加权求和得到目标对比损失函数值;根据所述目标对比损失函数值,对所述第一图像处理模型和所述第二图像处理模型进行模型参数调整。
- 根据权利要求3所述的方法,还包括:将所述任务对应的第一位置编码添加到所述第一输入序列中,其中,所述第一位置编码用于指示所述第一图像处理模型采用对应的注意力权重;将所述任务对应的第二位置编码添加到所述第二输入序列中,其中,所述第二位置编码用于指示所述第二图像处理模型采用对应的注意力权重。
- 根据权利要求1-6中任一项所述的方法,其中,所述根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练,包括:根据所述第一特征与更新后的所述历史输出特征集合之间的差异,确定目标对比损失函数值;根据所述目标对比损失函数值,对所述第二图像处理模型进行模型参数调整;根据所述第二图像处理模型参数调整前和调整后的模型参数变化量,对所述第一图像处理模型进行模型参数调整。
- 根据权利要求7所述的方法,其中,所述根据所述第二图像处理模型参数调整前和调整后的模型参数变化量,对所述第一图像处理模型进行模型参数调整,包括:将所述第二图像处理模型参数调整前和调整后的模型参数变化量,与所述第一图像处理模型的模型参数进行加权融合,以得到所述第一图像处理模型调整后的模型参数。
- 一种模型预训练装置,包括:获取模块,用于获取样本对;其中,所述样本对中包括相同或相似的第一图像和第二 图像;第一提取模块,用于采用第一图像处理模型对所述第一图像进行特征提取,以得到第一特征;第二提取模块,用于采用第二图像处理模型对所述第二图像进行特征提取,以得到第二特征;更新模块,用于根据所述第二特征更新所述第二图像处理模型的历史输出特征集合;预训练模块,用于根据所述第一特征与更新后的所述历史输出特征集合之间的差异,对所述第一图像处理模型和所述第二图像处理模型进行预训练。
- 根据权利要求9所述的装置,其中,所述第一提取模块,具体用于:采用待执行的任务对应的第一转换层将所述第一图像转化为第一输入序列;将所述第一输入序列添加到所述第一图像处理模型的第一目标队列中;在所述第一目标队列轮询到所述第一输入序列的情况下,将所述第一输入序列输入到所述第一图像处理模型进行特征提取;其中,所述第一目标队列是所述第一图像处理模型的多个队列中所述任务所对应的队列。
- 根据权利要求9或10所述的装置,其中,所述第二提取模块,具体用于:采用所述任务对应的第二转化层将所述第二图像转化为第二输入序列;将所述第二输入序列添加到所述第二图像处理模型对应的第二目标队列中;在所述第一目标队列将所述第一输入序列输入所述第一图像处理模型的情况下,同步将属于相同样本对的所述第二输入序列输入到所述第二图像处理模型。
- 根据权利要求11所述的装置,其中,所述任务为多个,对应地,各所述任务具有对应的所述第二输入序列,且各所述任务具有对应的所述历史输出特征集合;所述更新模块,具体用于:将所述第二图像处理模型对各任务对应的第二输入序列所提取的第二特征,添加到对应任务的所述历史输出特征集合,并删除对应任务的所述历史输出特征集合中的历史输出特征。
- 根据权利要求9-12中任一项所述的装置,其中,所述预训练模块,具体用于:针对每个所述任务,根据所述第一图像处理模型对各所述任务对应的第一输入序列进行特征提取所得到的第一特征,与对应任务更新后的所述历史输出特征集合之间的差异, 得到各任务的对比损失函数值;对各所述任务的对比损失函数值加权求和得到目标对比损失函数值;根据所述目标对比损失函数值,对所述第一图像处理模型和所述第二图像处理模型进行模型参数调整。
- 根据权利要求11所述的装置,还包括:添加模块,用于将所述任务对应的第一位置编码添加到所述第一输入序列中,其中,所述第一位置编码用于指示所述第一图像处理模型采用对应的注意力权重;将所述任务对应的第二位置编码添加到所述第二输入序列中,其中,所述第二位置编码用于指示所述第二图像处理模型采用对应的注意力权重。
- 根据权利要求9-14中任一项所述的装置,其中,所述预训练模块,具体用于:根据所述第一特征与更新后的所述历史输出特征集合之间的差异,确定目标对比损失函数值;根据所述目标对比损失函数值,对所述第二图像处理模型进行模型参数调整;根据所述第二图像处理模型参数调整前和调整后的模型参数变化量,对所述第一图像处理模型进行模型参数调整。
- 根据权利要求15所述的装置,其中,所述预训练模块,具体用于:将所述第二图像处理模型参数调整前和调整后的模型参数变化量,与所述第一图像处理模型的模型参数进行加权融合,以得到所述第一图像处理模型调整后的模型参数。
- 一种电子设备,包括:至少一个处理器;以及与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-8中任一项所述的模型预训练方法。
- 一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-8中任一项所述的模型预训练方法。
- 一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-8中任一项所述的模型预训练方法。
- 一种计算机程序,包括计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行根据权利要求1-8中任一项所述的模型预训练方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110866809.2A CN113657467B (zh) | 2021-07-29 | 2021-07-29 | 模型预训练方法、装置、电子设备和存储介质 |
| CN202110866809.2 | 2021-07-29 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2023005287A1 true WO2023005287A1 (zh) | 2023-02-02 |
Family
ID=78479018
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/088612 Ceased WO2023005287A1 (zh) | 2021-07-29 | 2022-04-22 | 模型预训练方法、装置、电子设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN113657467B (zh) |
| WO (1) | WO2023005287A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117116048A (zh) * | 2023-08-28 | 2023-11-24 | 河南大学 | 基于知识表示模型和图神经网络的知识驱动交通预测方法 |
| CN117523665A (zh) * | 2023-11-13 | 2024-02-06 | 书行科技(北京)有限公司 | 人体动作预测模型的训练方法、相关方法及相关产品 |
| CN117744732A (zh) * | 2023-12-20 | 2024-03-22 | 北京百度网讯科技有限公司 | 深度学习模型的训练方法、推理方法、装置、设备和介质 |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113657467B (zh) * | 2021-07-29 | 2023-04-07 | 北京百度网讯科技有限公司 | 模型预训练方法、装置、电子设备和存储介质 |
| CN114119989B (zh) * | 2021-11-29 | 2023-08-11 | 北京百度网讯科技有限公司 | 图像特征提取模型的训练方法、装置及电子设备 |
| CN115620749B (zh) * | 2022-09-06 | 2026-04-03 | 平安科技(深圳)有限公司 | 基于人工智能的预训练优化方法、装置、设备及介质 |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113657467A (zh) * | 2021-07-29 | 2021-11-16 | 北京百度网讯科技有限公司 | 模型预训练方法、装置、电子设备和存储介质 |
Family Cites Families (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110147547A (zh) * | 2019-04-09 | 2019-08-20 | 苏宁易购集团股份有限公司 | 一种基于迭代式学习的智能辅助标注方法及系统 |
| CN111623881A (zh) * | 2020-05-21 | 2020-09-04 | 平安国际智慧城市科技股份有限公司 | 基于图像处理的双光摄像机测温方法及相关设备 |
| CN111950596B (zh) * | 2020-07-15 | 2024-09-20 | 华为技术有限公司 | 一种用于神经网络的训练方法以及相关设备 |
| CN111814755A (zh) * | 2020-08-18 | 2020-10-23 | 深延科技(北京)有限公司 | 面向夜间运动场景的多帧图像行人检测方法和装置 |
| CN112269719B (zh) * | 2020-09-16 | 2022-12-02 | 苏州浪潮智能科技有限公司 | 基于ai训练平台的文件操作队列控制方法、装置及介质 |
| CN112633074B (zh) * | 2020-11-30 | 2024-01-30 | 浙江华锐捷技术有限公司 | 行人信息的检测方法和装置、存储介质及电子设备 |
| CN112529162B (zh) * | 2020-12-15 | 2024-02-27 | 北京百度网讯科技有限公司 | 神经网络模型的更新方法、装置、设备和存储介质 |
| CN112949855B (zh) * | 2021-02-26 | 2023-08-25 | 平安科技(深圳)有限公司 | 人脸识别模型训练方法、识别方法、装置、设备及介质 |
| CN113034516A (zh) * | 2021-03-24 | 2021-06-25 | 联通(上海)产业互联网有限公司 | 一种分割图像中异常区域的深度学习算法 |
| CN113033408B (zh) * | 2021-03-26 | 2023-10-20 | 北京百度网讯科技有限公司 | 数据队列动态更新方法、装置、电子设备及存储介质 |
| CN112907589A (zh) * | 2021-04-02 | 2021-06-04 | 联通(上海)产业互联网有限公司 | 一种检测异常并且分割图像中异常区域的深度学习算法 |
| CN113033468A (zh) * | 2021-04-13 | 2021-06-25 | 中国计量大学 | 一种基于多源图像信息的特定人员重识别方法 |
-
2021
- 2021-07-29 CN CN202110866809.2A patent/CN113657467B/zh active Active
-
2022
- 2022-04-22 WO PCT/CN2022/088612 patent/WO2023005287A1/zh not_active Ceased
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113657467A (zh) * | 2021-07-29 | 2021-11-16 | 北京百度网讯科技有限公司 | 模型预训练方法、装置、电子设备和存储介质 |
Non-Patent Citations (2)
| Title |
|---|
| ALEXEY DOSOVITSKIY; LUCAS BEYER; ALEXANDER KOLESNIKOV; DIRK WEISSENBORN; XIAOHUA ZHAI; THOMAS UNTERTHINER; MOSTAFA DEHGHANI; MATTH: "An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale", ARXIV.ORG, CORNELL UNIVERSITY LIBRARY, 201 OLIN LIBRARY CORNELL UNIVERSITY ITHACA, NY 14853, 3 June 2021 (2021-06-03), 201 Olin Library Cornell University Ithaca, NY 14853 , XP081976531 * |
| BI LI; TENG XI; GANG ZHANG; HAOCHENG FENG; JUNYU HAN; JINGTUO LIU; ERRUI DING; WENYU LIU: "Dynamic Class Queue for Large Scale Face Recognition In the Wild", ARXIV.ORG, CORNELL UNIVERSITY LIBRARY, 201 OLIN LIBRARY CORNELL UNIVERSITY ITHACA, NY 14853, 24 May 2021 (2021-05-24), 201 Olin Library Cornell University Ithaca, NY 14853 , XP081968183 * |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117116048A (zh) * | 2023-08-28 | 2023-11-24 | 河南大学 | 基于知识表示模型和图神经网络的知识驱动交通预测方法 |
| CN117523665A (zh) * | 2023-11-13 | 2024-02-06 | 书行科技(北京)有限公司 | 人体动作预测模型的训练方法、相关方法及相关产品 |
| CN117744732A (zh) * | 2023-12-20 | 2024-03-22 | 北京百度网讯科技有限公司 | 深度学习模型的训练方法、推理方法、装置、设备和介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN113657467B (zh) | 2023-04-07 |
| CN113657467A (zh) | 2021-11-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN113657467B (zh) | 模型预训练方法、装置、电子设备和存储介质 | |
| CN112857268B (zh) | 对象面积测量方法、装置、电子设备和存储介质 | |
| CN115631418B (zh) | 图像处理方法及装置、神经辐射场的训练方法 | |
| CN115063875B (zh) | 模型训练方法、图像处理方法、装置和电子设备 | |
| CN115147687A (zh) | 学生模型训练方法、装置、设备及存储介质 | |
| CN111582477B (zh) | 神经网络模型的训练方法和装置 | |
| WO2022227768A1 (zh) | 动态手势识别方法、装置、设备以及存储介质 | |
| CN115578515B (zh) | 三维重建模型的训练方法、三维场景渲染方法及装置 | |
| CN116580212B (zh) | 图像生成方法、图像生成模型的训练方法、装置和设备 | |
| CN114187459A (zh) | 目标检测模型的训练方法、装置、电子设备以及存储介质 | |
| JP2023539934A (ja) | 物体検出モデルのトレーニング方法、画像検出方法及び装置 | |
| EP4156124A1 (en) | Dynamic gesture recognition method and apparatus, and device and storage medium | |
| KR20220116395A (ko) | 사전 훈련 모델의 결정 방법, 장치, 전자 기기 및 저장 매체 | |
| CN115358411A (zh) | 一种数据处理方法、装置、设备及介质 | |
| CN111241838A (zh) | 文本实体的语义关系处理方法、装置及设备 | |
| CN113657466A (zh) | 预训练模型的生成方法、装置、电子设备和存储介质 | |
| JP2022091919A (ja) | バックボーンネットワーク生成方法、装置、電子機器、記憶媒体およびコンピュータプログラム | |
| JP2023078411A (ja) | 情報処理方法、モデルトレーニング方法、装置、機器、媒体及びプログラム製品 | |
| CN115511779A (zh) | 图像检测方法、装置、电子设备和存储介质 | |
| CN114723949A (zh) | 三维场景分割方法和用于训练分割模型的方法 | |
| CN114266937A (zh) | 模型训练、图像处理方法,装置,设备以及存储介质 | |
| CN117710504A (zh) | 图像生成方法、图像生成模型的训练方法、装置和设备 | |
| CN116597454A (zh) | 图像处理方法、图像处理模型的训练方法和装置 | |
| CN116432522A (zh) | 一种用于电力走廊的导线模型的结构化建模方法和装置 | |
| CN115601555A (zh) | 图像处理方法及装置、设备和介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 22847905 Country of ref document: EP Kind code of ref document: A1 |