Deep learning-based picture classification model training method and device

By combining transformer networks and generative adversarial networks, and utilizing attention mechanisms and loss function optimization, the problems of global feature extraction and adversarial example defense in existing image classification models are solved, achieving more efficient and accurate image classification.

CN119295807APending Publication Date: 2025-01-10SHIYOU UNIVERSE (CHENGDU) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411318677.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

Existing image classification models have shortcomings in global feature extraction, training efficiency, and adversarial example defense, resulting in inaccurate and unstable classification results.

Method used

By combining an attention-based transformer network and an adversarial generative network, and through feature extraction, mapping function and loss function optimization, an image classification model is constructed to achieve global feature capture and adversarial example defense.

Benefits of technology

It improves the accuracy and stability of image classification, enhances the model's generalization ability and defense against adversarial examples, and improves the model's performance in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119295807A_ABST
    Figure CN119295807A_ABST
Patent Text Reader

Abstract

The invention discloses a picture classification model training method and device based on deep learning. The method comprises the following steps: fusing a transformer network combined with an attention mechanism and an adversarial generative network to construct a picture classification model; inputting the training samples into a transformer network, and performing feature extraction on two sample pictures forming similar samples or dissimilar samples in the training samples by using the transformer network to obtain two feature vectors; comparing the feature difference between the two feature vectors by using a mapping function, and predicting the similarity of the two sample pictures based on the feature difference; and comparing the predicted similarity with the actual similarity by using a loss function to obtain loss between the predicted similarity and the actual similarity, and updating network parameters of the transformer network and the generative adversarial network based on the loss to obtain a trained picture classification model. The technical problem of inaccurate picture classification is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a training method and device for a picture classification model based on deep learning. Background Art

[0002] In the prior art, image classification models mainly rely on convolutional neural networks (CNNs) for feature extraction and classification. CNN processes images through local receptive fields and is good at extracting local features, especially when processing images with obvious edge and texture features, showing good classification results. However, this method has certain limitations in capturing global features. Since CNN focuses on information in local areas, it cannot fully utilize the global contextual relationship in the image, resulting in inaccurate classification results when processing complex scenes or when there are multiple objects in the image.

[0003] In addition, existing deep learning models also have efficiency issues during the training process. As the size of the data set continues to expand, the computing resources and time required for model training have also increased significantly. Especially when faced with uneven data distribution or imbalanced categories, the generalization ability of the model is limited, and overfitting problems are prone to occur, resulting in unstable performance of the model in practical applications. In these cases, although the model shows high accuracy on the training data set, the classification effect is poor when processing new data and cannot meet actual needs.

[0004] Another technical challenge is the vulnerability of image classification models to adversarial sample attacks. Adversarial samples are those that add subtle, imperceptible noise to images, causing significant changes in the output of the classification model. This type of attack reveals security issues with existing image classification models, causing the models to show greater uncertainty when facing maliciously modified input data, seriously affecting their reliability and robustness in practical applications.

[0005] In summary, the image classification methods in the existing technology have significant deficiencies in global feature extraction, training efficiency, and adversarial sample defense. These problems urgently need to be solved through new model architectures and training methods.

[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0007] The embodiments of the present invention provide a method and device for training an image classification model based on deep learning, so as to at least solve the technical problem of inaccurate image classification.

[0008] According to one aspect of an embodiment of the present invention, a training method for a deep learning-based image classification model is provided, comprising: fusing a transformer network combined with an attention mechanism and a generative adversarial network to construct the image classification model; inputting a training sample into the transformer network, and using the transformer network to extract features of two sample images that form similar samples or dissimilar samples in the training sample to obtain two feature vectors; using a mapping function to compare the feature difference between the two feature vectors, and predicting the similarity of the two sample images based on the feature difference; using a loss function to compare the predicted similarity with the actual similarity to obtain the loss between the predicted similarity and the actual similarity, and updating the network parameters of the transformer network and the generative adversarial network based on the loss to obtain the trained image classification model.

[0009] According to another aspect of an embodiment of the present invention, a training device for a deep learning-based image classification model is provided, comprising: a construction module, configured to fuse a transformer network combined with an attention mechanism and a generative adversarial network to construct the image classification model; a feature extraction module, configured to input a training sample into the transformer network, and use the transformer network to perform feature extraction on two sample images that form similar samples or dissimilar samples in the training sample to obtain two feature vectors; a similarity comparison module, configured to use a mapping function to compare the feature difference between the two feature vectors, and predict the similarity of the two sample images based on the feature difference; a training module, configured to use a loss function to compare the predicted similarity with the actual similarity, obtain the loss between the predicted similarity and the actual similarity, and update the network parameters of the transformer network and the generative adversarial network based on the loss to obtain the trained image classification model.

[0010] According to another aspect of an embodiment of the present invention, a method for image classification detection is provided, which uses the image classification model as described above to classify images.

[0011] Through the above solution, the technical problem of inaccurate image classification is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0013] Figure 1 is a flowchart of a training method for a picture classification model based on deep learning according to an embodiment of the present invention;

[0014] Figure 2is a flowchart of another method for training a picture classification model based on deep learning according to an embodiment of the present invention;

[0015] Figure 3 is a flow chart of a method for training an image classification model using a mapping function according to an embodiment of the present invention;

[0016] Figure 4 is an architecture diagram of a transformer network according to an embodiment of the present invention;

[0017] Figure 5 is an architecture diagram of a generative adversarial network according to an embodiment of the present invention;

[0018] Figure 6 is a flowchart of a method for image classification according to an embodiment of the present invention.

[0019] Figure 7 It is a structural diagram of a training device for a deep learning-based image classification model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0021] It should be noted that the terms "", "", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] According to an embodiment of the present invention, a method embodiment of a training method for a deep learning-based image classification model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0023] This application provides a training method for an image classification model based on deep learning, such as Figure 1 As shown, the following steps are included:

[0024] Step S102, fusing the transformer network combined with the attention mechanism and the adversarial generative network to construct the image classification model;

[0025] The attention mechanism is introduced into the transformer network, wherein the attention mechanism can adaptively assign different weights to image features in different regions; two sub-networks, a generator and a discriminator, are set in the generative adversarial network, wherein the generator generates image features similar to real samples by receiving noise data, and the discriminator distinguishes between real samples and generated samples; the transformer network optimized by the attention mechanism is fused with the features generated by the generative adversarial network to construct the image classification model.

[0026] Step S104, inputting the training samples into the transformer network, and using the transformer network to extract features from two sample images that form similar samples or dissimilar samples in the training samples to obtain two feature vectors;

[0027] First, the training samples are preprocessed. Image data is collected and divided into a training sample set, a validation data set, and a test data set; the training sample set is preprocessed, wherein the preprocessing includes at least one of the following: image normalization, size adjustment, and data enhancement.

[0028] Then, the training samples are input into the transformer network, and the transformer network is used to extract features of two sample images that form similar samples or dissimilar samples in the training samples to obtain two feature vectors.

[0029] Step S106, comparing the feature difference between the two feature vectors using a mapping function, and predicting the similarity between the two sample images based on the feature difference;

[0030] The two feature vectors are respectively mapped to a new feature space through a preset mapping function, wherein the mapping function is composed of a multi-layer neural network, a fully connected layer, a convolutional layer or other nonlinear transformation function, and is used to perform dimensional transformation or enhancement on the feature vector; in the new feature space, the two mapped feature vectors are difference calculated using a difference measurement method to obtain the feature difference between the two sample images in the feature space, wherein the difference measurement method includes Euclidean distance, cosine similarity, Mahalanobis distance, or Manhattan distance; according to the correlation of different dimensions of the feature vectors, the feature difference is weighted by a weighting function, and the similarity of the two sample images is predicted based on the feature difference after the weight adjustment.

[0031] Step S108, using a loss function to compare the predicted similarity and the actual similarity, obtain the loss between the predicted similarity and the actual similarity, and update the network parameters of the transformer network and the adversarial generation network based on the loss to obtain the trained image classification model.

[0032] First, select a loss function based on the characteristics of the image classification task, such as mean square error (MSE), cross entropy loss, or other loss functions suitable for similarity measurement. This loss function is used to quantify the difference between the predicted similarity and the actual similarity. By calculating the error between the predicted similarity and the actual similarity, the performance of the model can be measured and the optimization of the network parameters can be guided.

[0033] During model training, the predicted similarity and actual similarity are input into the loss function for calculation. The loss function calculates a loss value based on the difference between the predicted result and the true label. This loss value reflects the performance of the model in the current training iteration. The size of the loss value directly affects the update direction and magnitude of the network parameters.

[0034] The back-propagation algorithm is used to calculate the gradient of the loss function. By calculating and propagating the gradient of the loss function, the sensitivity of the model parameters to the loss can be obtained. According to the gradient information, the parameters in the transformer network and the adversarial generation network are adjusted to reduce the difference between the predicted similarity and the actual similarity.

[0035] Select a suitable optimization algorithm (such as stochastic gradient descent (SGD), Adam optimizer, or RMSprop, etc.) to minimize the value of the loss function by updating the network parameters. The optimization algorithm adjusts the weights and biases of the transformer network and the adversarial generation network based on the gradient information of the loss to optimize the performance of the model.

[0036] Repeat the steps of loss calculation, gradient calculation, and parameter update to continuously optimize the model parameters through multiple iterations. After each iteration, the model will be evaluated on the training data to check whether the loss value is gradually decreasing to ensure that the accuracy of the model in feature extraction and classification tasks is gradually improving.

[0037] After the training is completed, the optimized parameters of the transformer network and the adversarial generative network are saved to obtain a trained image classification model. This model can be applied to actual image classification tasks to perform accurate image recognition and classification, providing an effective solution for related applications.

[0038] Figure 2 is another training method of a picture classification model based on deep learning according to an embodiment of the present invention, such as Figure 2 As shown, the method includes:

[0039] Step S202: data preprocessing.

[0040] Collect image data and divide it into training sample set, validation data set and test data set. First, collect diverse image data from different sources, which can come from public image data sets, professional image libraries, or self-collection through web crawlers and cameras. Next, divide the collected image data into three parts: training sample set, validation data set and test data set. The training sample set usually occupies 70%-80% of the entire data set and is used for adjusting and optimizing model parameters; the validation data set occupies 10%-15% and is used to monitor model performance during training, help adjust hyperparameters and prevent overfitting; the test data set also occupies 10%-15%, which is mainly used to evaluate the performance of the model on unknown data and ensure that the model has good generalization ability.

[0041] After the data is divided, the training sample set needs to be preprocessed. Preprocessing includes image normalization, resizing, and data augmentation. Normalization is to uniformly scale the pixel values ​​of the image to a specific range to eliminate the lighting differences and uneven pixel value distribution between different images; resizing is to adjust the image size to the fixed size required by the model so that the image data can be processed in batches; data augmentation is a method to increase data diversity through random rotation, translation, flipping, noise addition, etc., which can effectively enhance the robustness of the model and reduce the risk of overfitting. Preprocessing can be automatically completed through built-in functions or custom scripts in the deep learning framework to ensure efficient and consistent processing of large-scale image data during the training process. In addition, the validation dataset and the test dataset also need to undergo the same preprocessing operations during the training and evaluation stages to ensure the consistency of the model processing throughout the training and testing process, thereby ensuring the final classification effect.

[0042] Step S204: model training.

[0043] like Figure 3 As shown, the model training method includes the following steps:

[0044] Step S2042, extracting global features.

[0045] First, the preprocessed training sample set is input into the transformer network. Figure 4 As shown in the figure, the transformer network combines the self-attention mechanism to effectively process the local and global information of the image. Specifically, each image in the training sample set is decomposed into multiple image blocks, which are input into the transformer network as independent input units. Through the self-attention mechanism, the transformer network can capture the relationship between image blocks and identify the dependencies between different regions, thereby realizing the extraction of global features of the image.

[0046] The attention mechanism is used to adaptively assign weights to different regions based on the content of the input image. Different image regions have different importance for classification tasks, some regions contain key information, while other regions are redundant information. The attention mechanism can dynamically assign higher weights to regions that contain important features and lower weights to unimportant regions.

[0047] The transformer network uses multiple layers of self-attention mechanisms to analyze the similarities and dependencies between image blocks layer by layer. Each layer calculates the weighted feature values ​​of each image block to form a global feature representation. Through layer-by-layer processing, the network can capture the hierarchical features of the image, including not only local details but also global structures.

[0048] Finally, the transformer network generates feature vectors of the two input images. These feature vectors are high-dimensional representations. Each feature vector contains the fusion information of multiple image blocks in the image and represents the global features of the image. These high-dimensional features can not only describe the appearance of the image, but also capture deep semantic information. Through the feature capture ability of the transformer network, the model can not only handle simple classification tasks, but also cope with complex image data sets.

[0049] Step S2044, calculating feature differences.

[0050] The two feature vectors are mapped to the new feature space using a mapping function. The mapping function processes and transforms the feature vectors to improve their separability in the new feature space, which can more effectively calculate similarity.

[0051] Specifically, mapping using a mapping function includes: first, processing the eigenvector through a universal basis function to generate a corresponding feature matrix. Then, the feature matrix is ​​transformed using a single variable continuous function. The specific steps are as follows: First, the linear combination result of each element in the feature matrix and the corresponding basis function parameter is calculated. Then, the linear combination result is transformed using a single variable continuous function to obtain the output matrix of the basis function. Finally, the basis function output matrix is ​​linearly mapped and weighted by a weight matrix. The present application processes the eigenvector through a universal basis function, which can effectively capture the core features of the input data and construct a more expressive feature matrix. Then, by transforming the feature matrix through a single variable continuous function, the nonlinear expression ability of the feature is further improved, so that the model can fit complex data more accurately. Finally, the basis function output matrix is ​​linearly mapped and weighted by using a weight matrix, which not only improves the computational efficiency of the model, but also enhances the model's generalization ability to different data patterns, thereby showing better performance and robustness in a variety of application scenarios.

[0052] In some embodiments, the mapping may be achieved by the following formula:

[0053]

[0054] Among them, φ is the universal basis function that receives the eigenvector xp and its parameters θq,p in the feature matrix. The eigenvectors in the feature matrix share the same universal basis function φ at different q and p. Here, the parameters θq,p of the universal basis function will vary according to q and p. φq represents a continuous function of a single variable, which is used to linearly transform the result of the inner layer summation. q represents the outer layer summation index, and p represents the component index of the input element. The present application uses the universal basis function φ to map the eigenvectors in the feature matrix, so that the eigenvectors share the same basis function at different q and p, thereby improving the parameter sharing and computational efficiency of the model. In addition, by linearly transforming the inner layer summation result, the expressive power of the mapping is further enhanced, and the complex relationship between the input features can be effectively captured, thereby improving the accuracy and robustness of the model. In addition, this mapping method can also flexibly adapt to different parameter configurations to achieve accurate feature extraction and conversion of input data.

[0055] In other embodiments, the feature matrix can also be transformed by a piecewise polynomial interpolation function to better capture the nonlinear features in the input data. Specifically, a piecewise polynomial function for interpolation is determined, and each element of the feature matrix is ​​interpolated to generate an interpolation matrix. Then, the interpolation matrix is ​​linearly combined with the weight matrix, multiplied by the corresponding weights one by one and weighted summation is performed. The interpolation transformation matrix finally obtained contains the feature information after the piecewise polynomial interpolation and linear transformation processing, and can more effectively characterize the nonlinear features of the input data. The present application performs a fine interpolation calculation on each element of the feature matrix by a piecewise polynomial interpolation function, and the generated interpolation matrix can more accurately reflect the complex change trend of the data. Then, the linear combination of the interpolation matrix and the weight matrix is ​​used to fully integrate the feature information after interpolation. The interpolation transformation matrix finally obtained not only contains the feature information of the original data, but also undergoes the dual processing of nonlinear interpolation and linear transformation, which can more effectively characterize the diversity and complexity of the input data, and improve the model's ability to capture nonlinear relationships and prediction accuracy.

[0056] In the mapping process, the original feature vector is transformed or enhanced. Through this dimensional transformation, the mapping function can not only improve the separation ability of the feature vector, but also effectively reduce the redundant information between different samples in the new feature space and enhance the ability to capture feature differences.

[0057] In order to ensure the accuracy of difference calculation, a variety of difference measurement methods can be used. For example, Euclidean distance, cosine similarity and Mahalanobis distance. Euclidean distance is a classic distance measurement method that calculates the geometric distance between two vectors in space and is used to measure the absolute difference between samples. Cosine similarity focuses on the directional similarity of vectors and is particularly suitable for comparing the similarity of two samples in high-dimensional space. Mahalanobis distance takes into account the covariance structure between samples and is suitable for situations where there is a significant correlation between features.

[0058] The difference measurement method can accurately calculate the difference between two sample images in the feature space. The result of the difference measurement will be directly used to predict the similarity between the two sample images. Specifically, if the difference between the two feature vectors is small, it means that the two sample images have a high similarity; conversely, a large difference means that the similarity between the samples is low. In this way, the model can accurately predict the similarity between different sample images based on the mapped feature vectors.

[0059] At the same time, in the adversarial generation network, such as Figure 5As shown in the figure, the generator generates samples similar to the training data by inputting noise data, and the discriminator judges the similarity between the generated samples and the real samples. The discriminator and the generator continuously improve their capabilities in an adversarial manner, making the generated samples closer to the real pictures. Combining the generated features with the features extracted by the transformer network can further optimize the classification effect of the model.

[0060] Step S2046, calculate the loss.

[0061] The loss function is used to compare the predicted similarity and the actual similarity and calculate the loss between the two. The loss function includes cross entropy loss. Cross entropy loss is mainly used to deal with classification problems. Its calculation method is to quantify the difference between the predicted category probability distribution and the actual label, which is suitable for the training of models in multi-classification tasks.

[0062] When calculating the loss, the loss function converts the difference between the predicted similarity and the actual similarity into a scalar value, which represents the prediction performance of the current model. A larger loss value indicates that the difference between the predicted result and the actual value is large, and the performance of the model is poor; while a smaller loss value indicates that the model's prediction result is close to the actual situation and the classification accuracy is high.

[0063] Specifically, the cross entropy loss of each sample in the training sample set is calculated, and these loss values ​​are accumulated. Then, the accumulated cross entropy losses are weighted averaged using the weight parameters to obtain the average cross entropy loss, where the weight parameters are used to adjust the influence of different samples. Next, based on the network parameters and regularization parameters of the image classification model, the regularization term is calculated to control the complexity of the model and prevent overfitting. Finally, the weighted average cross entropy loss is combined with the regularization term to calculate the final loss. At this point, the final loss function includes the weighted sum of the cross entropy loss and the regularization term, and uses additional weight parameters to balance the classification error and the regularization effect, thereby improving the training stability and generalization ability of the model.

[0064] Among them, the calculation of the regularization term includes a specific form of constraint on the model parameters, such as determining the size or sparsity of the weights through L1 regularization or L2 regularization methods. Specifically, the L2 regularization term (also known as weight decay) can be calculated by multiplying the sum of the squares of all weight parameters by the regularization coefficient, while the L1 regularization term promotes the sparsity of the weights by calculating the sum of the absolute values ​​of all weight parameters. In this way, by selecting appropriate regularization methods and parameters, the complexity of the model can be effectively controlled and the generalization ability of the model can be improved, thereby reducing overfitting.

[0065] Step S2048, update network parameters.

[0066] The calculated loss value will be used to optimize the weight parameters of the transformer network and the adversarial generative network. The gradient backpropagation algorithm calculates the gradient of the loss function for each weight in the network and uses these gradients to adjust the weight value to minimize the value of the loss function. This process usually includes two main steps: forward propagation and backpropagation. In the forward propagation stage, the input data is processed by the network to generate prediction results and calculate the loss; in the backpropagation stage, the gradient information of the loss function will be backpropagated along the layers of the network, updating the weight parameters of each layer and gradually reducing the prediction error.

[0067] As the model training progresses, the parameters of the network will be continuously adjusted and optimized through multiple rounds of iterative training. Each round of iteration will update the weights based on the current loss value, thereby gradually reducing the error and improving the classification accuracy. In each iteration, the model will adjust its internal feature extraction mechanism so that the transformer network and the adversarial generative network can better adapt to the characteristics of the training data and improve their generalization ability to new data. This iterative training not only helps to optimize the performance of the model, but also enables the model to have stronger feature extraction capabilities and classification accuracy when facing complex and diverse data.

[0068] Through this systematic training process, the resulting image classification model will have higher classification performance and robustness. The model can more accurately identify and classify different images, improving the effect and stability in practical applications.

[0069] The present application embodiment provides a method for classifying pictures. Figure 6 As shown, the method comprises the following steps:

[0070] Step S602, input the image to the image classification model.

[0071] Step S604: Use the pre-trained image classification model to predict the similarity of the two images and output a similarity score.

[0072] The training method of the image classification model is shown above and will not be repeated here.

[0073] The present application also provides a training device for an image classification model based on deep learning, such as Figure 7As shown, it includes: a construction module 72, which is configured to fuse the transformer network combined with the attention mechanism and the adversarial generation network to construct the image classification model; a feature extraction module 74, which is configured to input the training sample into the transformer network, and use the transformer network to extract features of two sample images that form similar samples or dissimilar samples in the training sample to obtain two feature vectors; a similarity comparison module 76, which is configured to use a mapping function to compare the feature difference between the two feature vectors, and predict the similarity of the two sample images based on the feature difference; a training module, which is configured to use a loss function to compare the predicted similarity with the actual similarity, obtain the loss between the predicted similarity and the actual similarity, and update the network parameters of the transformer network and the adversarial generation network based on the loss to obtain the trained image classification model.

[0074] It should be noted that the training device provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the training device provided in the above embodiment belongs to the same concept as the training method embodiment. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0075] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A training method for an image classification model based on deep learning, characterized in that: include: The transformer network combined with the attention mechanism and the adversarial generative network are fused to construct the image classification model; Inputting the training samples into the transformer network, and using the transformer network to extract features from two sample images that form similar samples or dissimilar samples in the training samples to obtain two feature vectors; Comparing the feature difference between the two feature vectors using a mapping function, and predicting the similarity between the two sample images based on the feature difference; The predicted similarity and the actual similarity are compared using a loss function to obtain a loss between the predicted similarity and the actual similarity, and network parameters of the transformer network and the generative adversarial network are updated based on the loss to obtain the trained image classification model.

2. The method according to claim 1, characterized in that Comparing the feature difference between the two feature vectors using a mapping function, and predicting the similarity of the two sample images based on the feature difference, including: The two feature vectors are respectively mapped to a new feature space by a preset mapping function, wherein the mapping function is composed of a multi-layer neural network, a fully connected layer, a convolutional layer or other nonlinear transformation function, and is used to perform dimensional transformation or enhancement on the feature vector; In the new feature space, the two mapped feature vectors are calculated using a difference measurement method to obtain a feature difference between the two sample images in the feature space, wherein the difference measurement method includes Euclidean distance, cosine similarity, Mahalanobis distance, or Manhattan distance; According to the correlation of different dimensions of the feature vector, the feature difference is weighted by using a weighting function, and the similarity of the two sample images is predicted based on the feature difference after the weight adjustment.

3. The method according to claim 1, characterized in that The transformer network combined with the attention mechanism and the adversarial generation network are fused to build the image classification model, including: Introducing the attention mechanism into the transformer network, wherein the attention mechanism can adaptively assign different weights to image features in different regions; Two sub-networks, a generator and a discriminator, are set in the adversarial generative network, wherein the generator generates image features similar to real samples by receiving noise data, and the discriminator distinguishes between real samples and generated samples; The transformer network optimized by the attention mechanism is fused with the features generated by the generative adversarial network to construct the image classification model.

4. The method according to claim 3, characterized in that After constructing the picture classification model, the method further includes: migrating the pre-trained weights to the picture classification model through a transfer learning method.

5. The method according to claim 1, characterized in that Before inputting the training samples into the transformer network, the method further comprises: Collecting image data and dividing the image data into a training sample set, a verification data set, and a test data set; The training sample set is preprocessed, wherein the preprocessing includes at least one of the following: image normalization, size adjustment, and data enhancement.

6. A method for image classification, characterized in that: The picture classification model according to any one of claims 1 to 5 is used to classify the picture.

7. A training device for an image classification model based on deep learning, characterized in that: include: A building module configured to fuse the transformer network combined with the attention mechanism and the adversarial generation network to build the image classification model; A feature extraction module is configured to input the training sample into the transformer network, and use the transformer network to extract features from two sample images that form similar samples or dissimilar samples in the training sample to obtain two feature vectors; A similarity comparison module is configured to compare the feature difference between the two feature vectors using a mapping function, and predict the similarity of the two sample images based on the feature difference; The training module is configured to compare the predicted similarity with the actual similarity using a loss function to obtain a loss between the predicted similarity and the actual similarity, and update network parameters of the transformer network and the adversarial generation network based on the loss to obtain the trained image classification model.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.

9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.