Fast image classification method based on multi-level approximation dictionary learning
By introducing multi -level approximation dictionary learning methods in the image classification task, combining label constraints, local invariability constraints, and internal differences inhibitory constraints, and introduce classification error constraints during the training phase, solve the slow convergence speed in existing technologies. The problem of long classification time achieves faster training and classification time and higher classification accuracy.
Patent Information
- Application Number
- CN202411315504.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-09-20
AI Technical Summary
The prior art has problems of slow convergence speed and long classification time in image classification tasks, especially in scenarios with complex backgrounds, diverse categories and variable feature representations.
Put forward a fast image classification method based on multi -level approximation dictionary learning. By adding label constraints, local invariability constraints, and internal differences in inhibitory constraints, and introduce classification error constraints during the training stage, it uses multiple parameters to optimize iterative iterations. , Improve the convergence of dictionary model learning process. At the same time, a linear classifier is used instead of the KNN classifier during the classification stage, and the dictionary and linear classification model parameters are combined to learn together.
Effectively shorten the training time and classification time, and improve the accuracy of image classification, which can better meet the application requirements in the actual scenario.
Smart Images

Figure CN119380072A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image classification technology, and specifically relates to a fast image classification method based on multi-level approximate dictionary learning. The present invention has the advantages of faster convergence speed and running time, and higher image classification accuracy. Background Art
[0002] With the climax of digitalization, automation and intelligent transformation, major factories and enterprises continue to introduce computer vision models and apply them to classification problems to replace the traditional manual classification process. Then high-precision and high-efficiency classification models will become one of the core competitiveness of factories or enterprises. With the rapid development of computer vision, excellent models for image classification emerge in an endless stream. However, there are still many factors that hinder the development of image classification models. For example, the size of the image set, the complexity of the image background, the degree of difference in image features, and the adaptive ability of the model.
[0003] Over the years, dictionary learning algorithms have been widely used in various fields such as visual tracking, computer vision, and image processing. The core idea of dictionary learning algorithms is to learn from raw data to obtain a more compact dictionary that provides a concise and effective representation for the data. Nowadays, dictionary learning is not only applicable to signal representation, but also to image representation, audio representation, video representation, etc. Therefore, designing a suitable dictionary is crucial to the performance of various sparse representation-based algorithms.
[0004] With the advancement of computer vision, image classification has become increasingly popular among researchers in fields such as deep learning and sparse representation. The impressive classification performance achieved by deep learning methods has prompted more scholars to explore these techniques. However, deep learning algorithms have a large hypothesis space, which often leads to time-consuming and unstable training due to overfitting. On the other hand, sparse representation techniques can handle small-scale datasets, saving a lot of time not only during training but also during testing, while still achieving satisfactory performance.
[0005] In recent years, many dictionary learning models for image classification have emerged, which focus on better representing the original image. However, these dictionary models often lack discriminative ability when applied to classification tasks. Many discriminative dictionary learning (DDL) methods enhance the discriminative ability of dictionaries by adding various types of constraints. These DDL methods add discriminative constraints to the objective function of dictionary learning, continuously optimize the reconstruction error and discriminative constraint regularization terms, and obtain the optimal discriminative dictionary. Common discriminative constraints include category label information constraints, softmax loss constraints, linear prediction classification error constraints, Fisher discriminant criterion constraints, logical loss constraints, hinge loss constraints, etc. These discriminative constraints have proved that dictionary learning models have good classification accuracy. However, for classification problems in real scenes with complex backgrounds, diverse categories, and variable feature representations, the convergence speed and classification time of these DDL methods will be greatly affected. Based on this, the present invention proposes a fast image classification method based on multi-level approximate dictionary learning, called MA-DL method, which can effectively improve the convergence speed and shorten the classification time. Summary of the invention
[0006] In view of the problems existing in the above-mentioned prior art, the present invention proposes a fast image classification method based on multi-level approximate dictionary learning.
[0007] First, the present invention adds three constraints to the dictionary learning model for construction, namely, label constraint, local invariance constraint and intra-class difference inhibition constraint. Secondly, the present invention constructs a classification label matrix and introduces a classification error constraint in the training stage, and adopts optimization iteration of multiple parameters to achieve multi-level rapid approximation, thereby improving the convergence speed of the dictionary model learning process. Finally, in the classification stage, the present invention adopts a linear classifier instead of the kNN classifier with higher computational complexity, and jointly learns the dictionary and linear classification model parameters for image classification. Compared with the existing image classification technology, the technical solution of the present invention can effectively shorten the training time and classification time, and can obtain a better classification accuracy, which can well meet the application requirements in actual scenarios.
[0008] The present invention adopts the following technical scheme:
[0009] A fast image classification method based on multi-level approximate dictionary learning includes the following steps:
[0010] S1, select image dataset;
[0011] S2, preprocessing the image using feature extraction method to generate an image sample set;
[0012] S3, build a supervised dictionary learning model;
[0013] S4, using Laplace eigenmap to constrain the local invariance of sparse coefficients;
[0014] S5, introduce intra-class difference suppression items to constrain the dictionary learning model;
[0015] S6, construct a classification label matrix;
[0016] S7, construct classification error constraint items;
[0017] S8, solving the objective function using an analytical method, and iteratively updating the sparse coefficients, linear classification model parameters and dictionary;
[0018] S9, calculating the error based on the updated sparse coefficient and dictionary;
[0019] S10, determine whether the judgment dictionary and the linear classification model parameters meet the iterative convergence conditions. If they do, output the optimal judgment dictionary D len and the optimal linear classification model parameters R len , otherwise return to step S5;
[0020] S11. Use the classification error constraint term as a linear classifier for image classification.
[0021] Preferably, in step S2, different feature extraction methods are used to pre-process four types of data sets, namely, objects, faces, scenes and textures, to generate image sample sets.
[0022] This step describes different feature extraction methods, such as:
[0023] 1) For the Caltech101 image dataset (objects) and the Scene15 dataset (scenes), the 3000-dimensional feature extraction method of scale-invariant feature transform (SIFT) is used to preprocess the images of the above two datasets.
[0024] 2) For the Extended YaleB face image dataset, a random face feature extraction method is used to preprocess the face images and generate a 504-dimensional feature vector.
[0025] 3) For the Alibaba Cloud Tianchi fabric image dataset, the histogram of oriented gradients (HOG), gray-level co-occurrence matrix (GLCM) and local binary pattern (LBP) are combined to extract features of fabric images, and principal component analysis (PCA) is used for dimensionality reduction.
[0026] Preferably, step S3, constructing a supervised dictionary learning model:
[0027] Set the sample data to: The dictionary matrix is:
[0028] in, represents a real number set, n represents the data dimension, and N represents the sample y i The number of, i = 1, 2, ..., N; K represents the dictionary atom d j The number of , j = 1, 2,…, K.
[0029] The L2 norm is used to constrain the dictionary model, that is:
[0030] in, represents the sparse coefficient, and λ is a non-negative positive parameter. In order to make the objective function as convex as possible and to facilitate the solution, the objective function of dictionary learning can be further rewritten as:
[0031]
[0032] in, represents the sparse coefficient matrix, F represents the F norm, D * and S * Represent the updated dictionary matrix and sparse coefficient matrix respectively. Therefore, the following form of supervised dictionary learning model can be constructed:
[0033] Assume that the data sample is represented as: Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9], when samples y1, y2 and y3 are from the first category, y4, y5 and y6 are from the second category, y7, y8 and y9 are from the third category, the label matrix can be defined as:
[0034]
[0035] Among them, each diagonal block in the matrix A represents a subspace of each class, expanded to N samples, and the matrix A is defined as: a i Represents the elements in matrix A, i=1,2,…,N.
[0036] In order to realize that the sparse coefficient belongs to the subspace spanned by the association coefficient of the category to which it belongs, the label matrix is used as the association coefficient to constrain the sparse coefficient. Let K = N, so the objective function of the supervised dictionary learning model can be re-expressed as:
[0037] Among them, the dictionary matrix Sparse coefficient matrix α (α>0) is the regularization parameter of the label constraint term.
[0038] Preferably, in step S4, Laplacian eigenmaps are used to impose local invariance constraints on the sparse coefficients.
[0039] Regarding each sample y i as a point, the k (k < N) points with the closest distances are calculated through the kNN algorithm. An edge <yi, yj> is constructed between y i and these k points, that is, an undirected graph G. Based on the undirected graph, a Laplacian matrix is constructed: L = M - W.
[0040] Where is the Laplacian matrix, represents the weight matrix of the undirected graph G, represents the degree matrix of the undirected graph G, and M is a diagonal matrix. The element w in the weight matrix W ij generally has two solution methods: the simple method and the Gaussian kernel function method. The present invention uses the Gaussian kernel function method to calculate the weight value w ij :
[0041]
[0042] Where σ (σ > 0) is the bandwidth parameter of the Gaussian kernel function, and the diagonal element M of the degree matrix M ii is expressed as:
[0043] Since there is a linear relationship Y = DS between the training samples Y and the sparse coefficients S, according to the principle of Laplacian eigenmaps, the local feature relationship between the training samples is forced to be the local feature relationship between the sparse coefficients S. Therefore, the objective function optimized by Laplacian eigenmaps is obtained as:
[0044]
[0045] Where tr(·) is to find the trace of the · matrix. Adding the Laplacian eigenmap constraint as a regularization term to the objective function of the dictionary, the constructed dictionary learning model with local invariance is as follows:
[0046]
[0047] Where β (β > 0) is the regularization parameter of the Laplacian eigenmap constraint term.
[0048] Preferably, in step S5, an intra-class difference suppression term is introduced to constrain the dictionary model.
[0049] Assume that the training sample Y contains N samples and C different classes, and the number of samples in each class is x c =(1, 2,..., C), then Let the sub-matrix of sparse coefficients corresponding to each class of training samples be
[0050] The sparse coefficient matrix S is updated column by column, and different sparse coefficients s in the same category i With different intra-class sparse mean vector μ i ,Right now:
[0051]
[0052] Here, t represents the number of iterations.
[0053] In order to suppress the intra-class differences in the feature space, the sparse mean square error of the sparse representation is minimized so that the targets from the same category are aggregated to the intra-class sparse mean vector. Therefore, we get:
[0054]
[0055] Among them, γ (γ>0) is the regularization parameter of the intra-class difference suppression constraint term.
[0056] Preferably, in step S6, a classification label matrix is constructed.
[0057] Assume that the sample is: Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to the first category, y3 and y4 belong to the second category, y5, y6 and y7 belong to the third category, the classification label matrix H can be defined as:
[0058]
[0059] Expanded to N samples, the matrix H is defined as: C is the sample category.
[0060] Preferably, in step S7, a classification error constraint term is constructed.
[0061] By minimizing the error between the classification label vector and the sparse coefficient linear mapping vector, the similar optimal value is solved. The classification error constraint can be expressed as:
[0062]
[0063] in, represents the linear classification model parameter matrix. Therefore, the objective function of the dictionary model can be expressed as:
[0064]
[0065] Among them, τ (τ>0) is the regularization parameter of the classification error constraint term.
[0066] Preferably, in step S8, an analytical method is used to solve the objective function, and the sparse coefficient S, the linear classification model parameter R and the dictionary D are iteratively updated, that is, the partial derivatives of the sparse coefficient, the linear classification model parameter and the dictionary are respectively obtained to obtain:
[0067]
[0068] Where I is the identity matrix; ω (ω>0) is a small constant that ensures that the update formula of the linear classification model parameter R is a non-singular function.
[0069]
[0070] Among them, θ (θ>0) is a small constant, which ensures that the update formula of the dictionary D is a non-singular function.
[0071] Preferably, step S9, according to the updated sparse coefficient S (t) and dictionary D (t) Calculation error ε (t) :
[0072]
[0073] Preferably, step S10, determining the dictionary D (t) and the linear classification model parameters R (t) Whether the iterative convergence condition is met, if so, the optimal discriminant dictionary D is output len =D (t) and the optimal linear classification model parameters R len =R (t) ; If not, execute step S5. The iterative convergence condition is expressed as:
[0074] |ε (t) -ε (t-1) |<ε0 or or
[0075] Among them, ε0 represents the iteration termination parameter.
[0076] Preferably, in step S11, the classification error constraint term is used as a linear classifier to perform image classification. The linear classifier can be expressed as:
[0077]
[0078] Among them, r i is the i-th row of the linear classification model parameter matrix R. The linear classifier is constructed by the linear classification model parameters R len and the sparse coefficient The product of obtains a prediction vector, so the sample to be tested The sparse coefficient The updates are as follows:
[0079]
[0080] Among them, λ R (λ R >0) is the classification sparsity parameter.
[0081] The classification error constraint term is used as a linear classifier, and the optimal linear classification model parameter R len As a training model for the classifier, the sample to be tested The sparse coefficient Perform linear classification, resulting in faster image classification.
[0082] The beneficial effects of the present invention are:
[0083] (1) The present invention adds three constraints to the dictionary learning model, namely, label constraint, local invariance constraint and intra-class difference suppression constraint, which enhances the discriminability of the dictionary model. A classification label matrix is constructed and a classification error constraint is introduced in the training phase. Multiple parameters are optimized and iterated to achieve multi-level rapid approximation, thereby improving the convergence speed of the dictionary model learning process. The linear classification of the multi-level approximation dictionary is realized by using a linear classifier combined with the dictionary and the linear classification model parameters.
[0084] (2) Compared with the image classification method in the prior art, the present invention can effectively shorten the training time and classification time, and can achieve a higher classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] Figure 1 It is a model structure diagram of a fast image classification method based on multi-level approximate dictionary learning in a preferred embodiment of the present invention;
[0086] Figure 2 It is an algorithm flow chart of a fast image classification method based on multi-level approximation dictionary learning according to a preferred embodiment of the present invention;
[0087] Figure 3 It is a curve diagram showing the influence of different parameter values used in the Caltech101 data set on the classification performance of the present invention. DETAILED DESCRIPTION
[0088] The following describes the implementation of the present invention through specific embodiments, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific implementations, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.
[0089] The preferred embodiment of the present invention discloses a fast image classification method based on multi-level approximate dictionary learning, referring to Figure 1 As shown in the figure, it is the model structure diagram of this method. Figure 2 , which is an algorithm flow chart involved in the method. All images are processed according to the process of the method of this embodiment below to illustrate in detail the effect of the method of the present invention on improving the classification accuracy.
[0090] The present embodiment provides a fast image classification method based on multi-level approximate dictionary learning, comprising the following steps:
[0091] S1. Select image dataset.
[0092] S2. Use different feature extraction methods to preprocess four types of data sets: objects, faces, scenes, and textures to generate image sample sets.
[0093] S3. Build a supervised dictionary learning model. Set the sample data as: The dictionary matrix is:
[0094] in, represents a real number set, n represents the data dimension, and N represents the sample y i The number of, i = 1, 2, ..., N; K represents the dictionary atom d j The number of , j = 1, 2,…, K.
[0095] The L2 norm is used to constrain the dictionary model, that is:
[0096] in, represents the sparse coefficient, and λ is a non-negative positive parameter. In order to make the objective function as convex as possible and to facilitate the solution, the objective function of dictionary learning can be further rewritten as:
[0097]
[0098] in, represents the sparse coefficient matrix, F represents the F norm, D * and S * Represent the updated dictionary matrix and sparse coefficient matrix respectively.
[0099] The expression of sparse coefficients can maintain the attributes of category labels, and to a certain extent, the sparse coefficients belong to the subspace spanned by the association coefficients. Therefore, based on the category label information of the training samples, a supervised dictionary learning model can be constructed in the following form:
[0100] Suppose the sample is represented as Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9]. When the samples y1, y2, and y3 come from the first class, y4, y5, and y6 come from the second class, and y7, y8, and y9 come from the third class, the label matrix can be defined as:
[0101]
[0102] Among them, each diagonal block in matrix A represents a subspace of each class, extended to N samples. Matrix A is defined as: a i represents the element in matrix A, i = 1, 2, …, N. The definition of matrix A depends on the order of each sample (y i represents a sample), and it is not necessarily a consistent block diagonal matrix.
[0103] To make the sparse coefficients belong to the subspace spanned by the correlation coefficients of their respective categories, the label matrix is used as the correlation coefficient to constrain the sparse coefficients. Set the number of atoms K in the dictionary to be equal to the number of samples N. Therefore, the objective function of the supervised dictionary learning model can be re-expressed as:
[0104]
[0105] Among them, the dictionary matrix sparse coefficient matrix α (α > 0) is the regularization parameter of the label constraint term.
[0106] S4. Use Laplacian eigenmaps to perform local invariance constraints on the sparse coefficients.
[0107] Regard each sample y i as a point, calculate the k (k < N) points with the closest distance through the kNN algorithm, and construct an edge <yi, yj> between y i and these k points, that is, the undirected graph G. The constructed Laplacian matrix is: L = M - W.
[0108] Among them, is the Laplacian matrix, represents the weight matrix of the undirected graph G, represents the degree matrix of the undirected graph G, and M is a diagonal matrix. The element w ij in the weight matrix W has two solution methods: the simple method and the Gaussian kernel function method. The present invention uses the Gaussian kernel function method to calculate the weight w ij :
[0109]
[0110] Among them, σ (σ > 0) is the bandwidth parameter of the Gaussian kernel function, and the diagonal element M of the degree matrix Mii It is expressed as:
[0111] Since there is a linear relationship Y=DS between the training sample Y and the sparse coefficient S, according to the principle of Laplace eigenmap, the local feature relationship between the training samples is forced to be the local feature relationship between the sparse coefficients S. Therefore, the objective function of the Laplace eigenmap optimization is:
[0112]
[0113] Among them, tr(·) is the trace of the · matrix. The Laplace eigenmap constraint is added as a regular term to the objective function of the dictionary, and the dictionary learning model of local invariance is constructed as follows:
[0114]
[0115] Among them, β (β>0) is the regularization parameter of the Laplace eigenmap constraint term.
[0116] S5. Introduce intra-class difference suppression items to constrain the dictionary model.
[0117] Assume that the training sample Y contains N samples, C different categories, and the number of samples in each category is x c =(1,2,…,C), then Let the sparse coefficient submatrix corresponding to each type of training sample be
[0118] The sparse coefficient matrix S is updated column by column, and different sparse coefficients s in the same category i With different intra-class sparse mean vector μ i ,Right now:
[0119]
[0120] Here, t represents the number of iterations.
[0121] In order to suppress intra-class differences in the feature space, the sparse mean square error of the sparse representation is minimized so that the targets from the same category are clustered towards the intra-class sparse mean vector. Therefore, we get:
[0122]
[0123] Among them, γ (γ>0) is the regularization parameter of the intra-class difference suppression constraint term.
[0124] S6. Construct a classification label matrix.
[0125] Assume that the sample is: Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to the first category, y3 and y4 belong to the second category, y5, y6 and y7 belong to the third category, the classification label matrix H can be defined as:
[0126]
[0127] Expanded to N samples, the matrix H is defined as: C is the sample category. The classification label matrix H is different from the label matrix A in step S3. The label matrix A is related to the number of samples in each category, while the classification label matrix H is related to the number of classification categories.
[0128] S7. Construct classification error constraints.
[0129] By minimizing the error between the classification label vector and the sparse coefficient linear mapping vector, the similar optimal value is solved. The classification error constraint can be expressed as:
[0130]
[0131] in, represents the linear classification model parameter matrix. Therefore, the objective function of the dictionary model can be expressed as:
[0132]
[0133] Among them, τ (τ>0) is the regularization parameter of the classification error constraint term.
[0134] S8. Use analytical method to iteratively update the sparse coefficient S, linear classification model parameters R and dictionary D, that is, calculate partial derivatives of the sparse coefficient, linear classification model parameters and dictionary respectively, and obtain:
[0135]
[0136] Where I is the identity matrix; ω (ω>0) is a small constant that ensures that the update formula of the linear classification model parameter R is a non-singular function.
[0137]
[0138] Among them, θ (θ>0) is a small constant, which ensures that the update formula of the dictionary D is a non-singular function.
[0139] S9, according to the updated sparse coefficient S (t) and dictionary D (t) Calculation error ε (t) :
[0140] S10, judgment dictionary D(t) and the linear classification model parameters R (t) Whether the iterative convergence condition is met, if so, the optimal discriminant dictionary D is output len =D (t) and the optimal linear classification model parameters R len =R (t) ; If not, execute step S5. The iterative convergence condition is:
[0141] |ε (t) -ε (t-1) |<ε0 or or
[0142] S11. Use the classification error constraint term as a linear classifier for image classification. The linear classifier can be expressed as:
[0143]
[0144] Among them, r i is the i-th row of the linear classification model parameter matrix R. The linear classifier is constructed by the linear classification model parameters R len and the sparse coefficient The product of obtains a prediction vector, so the sample to be tested The sparse coefficient The updates are as follows:
[0145]
[0146] Among them, λ R (λ R >0) is the classification sparsity parameter.
[0147] The classification error constraint term is used as a linear classifier, and the optimal linear classification model parameter R len As a training model for the classifier, the sample to be tested The sparse coefficient Perform linear classification, resulting in faster image classification.
[0148] The following describes in detail each step of the above embodiment in conjunction with specific data.
[0149] In step S1, the remote sensing datasets obtained are specifically: Caltech101 image dataset, Extended YaleB face image dataset, Scene 15 natural scene image dataset and Alibaba Cloud Tianchi fabric image dataset.
[0150] In step S2, different feature extraction methods are used to preprocess the four types of data sets, namely, objects, faces, scenes and textures, to generate image sample sets.
[0151] For the Caltech101 image dataset, the six categories with the largest number of samples were selected for multiple experiments, including airplanes, motorcycles, leopards, faces, watches, and faces with simple backgrounds. 32, 64, and 80 samples were randomly selected from each category as training samples for training, and the remaining samples were tested. Depending on the number of training samples, the dictionary size was set to 192, 384, and 480 atoms, respectively. For the Scene15 dataset, multiple experiments were randomly selected from 15 categories of scene images. 100 samples were randomly selected from each category as training samples for training, and the remaining samples were tested, and the dictionary size was set to 1500 atoms. The images of the above two datasets were preprocessed using the 3000-dimensional feature extraction method of Scale-Invariant Feature Transform (SIFT).
[0152] For the Extended YaleB face image dataset, 38 people's face images are randomly selected for classification, 32 samples are randomly selected from each category as training samples for training, and the remaining samples are used for testing. The dictionary size is set to 1216 atoms. The random face feature extraction method is used to preprocess the face images to generate a 504-dimensional feature vector.
[0153] Alibaba Cloud Tianchi fabric image dataset is divided into two categories: normal and defective. Multiple experiments are conducted by randomly selecting fabric images from the two categories. 100 and 200 samples are randomly selected from each category as training samples for training, and the remaining samples are tested. Depending on the number of training samples, the dictionary size is set to 200 and 400 atoms, respectively. The Histogram of Gradient (HOG), Gray-Level Co-occurrence Matrix (GLCM) and Local Binary Patterns (LBP) are combined to extract features from fabric images, and Principal Components Analysis (PCA) is used for dimensionality reduction.
[0154] Step S3, construct a supervised dictionary learning model. Set the sample data to The dictionary matrix is Since the L2 norm is differentiable at all points, it usually provides a smoother solution when there is noise in the data. And the L2 norm minimization problem is guaranteed to have a unique solution. Therefore, the L2 norm can be used to constrain the dictionary model:
[0155] in, is the sparse coefficient. λ is a non-negative positive parameter used to weigh the weight of reconstruction error and sparsity. In order to make the objective function as convex as possible and easy to solve, the objective function of dictionary learning can be further rewritten as:
[0156]
[0157] in, represents the sparse coefficient matrix, F represents the F norm, D * and S * Represent the updated dictionary matrix and sparse coefficient matrix respectively.
[0158] The expression of sparse coefficients can maintain the attributes of the category labels, and to a certain extent make the sparse coefficients belong to the subspace spanned by the association coefficients, thereby improving the classification performance. Therefore, based on the category label information of the training samples, a supervised dictionary learning model can be constructed in the following form:
[0159] Assume that the data sample is represented as Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9], when samples y1, y2 and y3 are from the first category, samples y4, y5 and y6 are from the second category, and samples y7, y8 and y9 are from the third category, the label matrix A can be defined as:
[0160]
[0161] Among them, each diagonal block in the matrix A represents a subspace of each class, expanded to N samples, and the matrix A is defined as: a i represents the elements in matrix A, i = 1, 2, ..., N. The definition of matrix A depends on each sample (y i represents a sample), which is not necessarily a consistent block diagonal matrix.
[0162] In order to ensure that the sparse coefficients belong to the subspace spanned by the association coefficients of the corresponding categories, the label matrix is used as the association coefficient to constrain the sparse coefficients. The number of atoms K in the dictionary is set equal to the number of samples N, so the objective function of the supervised dictionary learning model can be re-expressed as:
[0163]
[0164] Among them, the dictionary Sparse coefficient α (α>0) is the regularization parameter of the label constraint term, which is used to weigh the weight of the label matrix in the entire model.
[0165] Step S4. According to the supervised dictionary learning model constructed in step S3, use Laplacian eigenmaps to impose local invariance constraints on the sparse coefficients.
[0166] Use the kNN algorithm on the training samples Y to construct an undirected graph G. Consider each sample y i as a point, and calculate the k (k < N) points with the closest distance through the kNN algorithm. Build an edge between y i and these k points, that is, <yi, yj>. The constructed Laplacian matrix is: L = M - W.
[0167] Among them, is the Laplacian matrix, represents the weight matrix of the undirected graph G, represents the degree matrix of the undirected graph G, and M is a diagonal matrix. The elements w in the weight matrix W ij generally have two solution methods: the simple method and the Gaussian kernel function method. The present invention uses the Gaussian kernel function method to calculate the weight w ij :
[0168]
[0169] Among them, σ (σ > 0) is the bandwidth parameter of the Gaussian kernel function, and the diagonal element M of the degree matrix M ii is expressed as:
[0170] Since there is a linear relationship Y = DS between the training samples Y and the sparse coefficients S, according to the principle of Laplacian eigenmaps, use the Laplacian matrix L to enforce the local feature relationship between the training samples as the local feature relationship between the sparse coefficients S. The optimization objective function of Laplacian eigenmaps is as follows:
[0171]
[0172] Among them, tr(·) is to find the trace of the · matrix. Add the Laplacian eigenmap constraint as a regularization term to the objective function of the dictionary, and the constructed dictionary learning model with local invariance is as follows:
[0173]
[0174] Among them, β (β > 0) is the regularization parameter of the Laplacian eigenmap constraint term, which is used to balance the weight of local invariance in the entire model.
[0175] Step S5. Introduce an intra-class difference suppression term to constrain the dictionary model. First, calculate the intra-class sparse mean vector:
[0176] Assume that the training samples Y contain N samples and C different categories, and the number of samples in each category is xc =(1,2,…,C), then Let the sparse coefficient submatrix corresponding to each type of training sample be
[0177] The sparse coefficient matrix S is updated column by column. In order to better approximate the sparse class center, the sparse mean vector within the class is calculated in a "real-time" update manner. i With different intra-class sparse mean vectors μ i ,Right now:
[0178]
[0179] Here, t represents the number of iterations.
[0180] In order to suppress intra-class differences in the feature space, the sparse mean square error of the sparse representation is minimized so that the targets from the same category are clustered towards the intra-class sparse mean vector. Therefore, we get:
[0181]
[0182] Among them, γ (γ>0) is the regularization parameter of the intra-class difference suppression constraint, which is used to weigh the weight of intra-class difference suppression in the entire model.
[0183] Step S6, constructing a classification label matrix.
[0184] Assume that the sample is: Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to the first category, y3 and y4 belong to the second category, y5, y6 and y7 belong to the third category, the classification label matrix H can be defined as:
[0185]
[0186] Expanded to N samples, the matrix H is defined as: C is the sample category. The classification label matrix H is different from the label matrix A in step S3. The label matrix A is related to the number of samples in each category, while the classification label matrix H is related to the number of classification categories.
[0187] Step S7, constructing classification error constraint items.
[0188] By minimizing the error between the classification label vector and the sparse coefficient linear mapping vector, the similar optimal value is solved. The classification error constraint can be expressed as:
[0189]
[0190] in, represents the linear classification model parameter matrix. Therefore, the objective function of the dictionary model can be expressed as:
[0191]
[0192] Among them, τ (τ>0) is the regularization parameter of the classification error constraint term.
[0193] Step S8, using analytical method to solve the objective function, iteratively update the sparse coefficient S, linear classification model parameter r and dictionary D. The analytical method obtains the optimal solution by taking the derivative to zero, or by using Lagrange multiplier method. That is, when optimizing the sparse coefficient S, the linear classification model parameter R and dictionary D are regarded as constants, and when optimizing the dictionary D, the linear classification model parameter R and sparse coefficient S are regarded as constants. Vice versa, the sparse coefficient S, linear classification model parameter R and dictionary D are obtained as follows:
[0194]
[0195] The specific solution process of sparse coefficient S, linear classification model parameter R and dictionary D is as follows:
[0196] 1) Initialization: Use a Gaussian random matrix to initialize the dictionary matrix D (0) , the initial value S of the sparse coefficient matrix S (0) The extreme value of S can be obtained by using the supervised dictionary learning model in step S3, namely:
[0197] 2) Update the linear classification model parameters: Solve the MA-DL model and use the formula The first-order and second-order derivatives of the linear classification model parameter R are obtained:
[0198] First-order derivative:
[0199] Second order derivative:
[0200] It can be seen that The second-order derivative of is non-negative, so the first-order derivative formula is 2τ(RS-H)S T is a convex function. Let The first-order derivative of is zero, and the update formula of the linear classification model parameter R is:
[0201] R * =HS T (SS T +ωI) -1
[0202] Where I is the identity matrix; ω (ω>0) is a small constant that ensures that the update formula of the linear classification model parameter R is a non-singular function.
[0203] 3) Update sparse coefficients: Solve the MA-DL model and let The sum of is F(s i ), respectively F(s i )
[0204] To find the first and second derivatives, we get:
[0205] First-order derivative:
[0206] 2γ(s i -μ i )+2τR T (Rs i -h i )
[0207] Second order derivative:
[0208] It can be seen that F(s i ) is non-negative, so the first-order derivative is a convex function. Let F(s i ) is zero, we can get the sparse coefficient s i The update formula is:
[0209]
[0210] 4) Update dictionary: Solve the MA-DL model using the formula Find the first-order and second-order derivatives of the dictionary respectively, and we get:
[0211] First-order derivative:
[0212] Second order derivative:
[0213] It can be seen that The second derivative of is non-negative, then the first derivative is a convex function. The first-order derivative of is zero, and the update formula of the dictionary D is:
[0214] D (t) =YS T (SS T +θI) -1
[0215] Among them, θ (θ>0) is a small constant, which ensures that the update formula of the dictionary D is a non-singular function.
[0216] Step S9, based on the updated sparse coefficient S (t) and dictionary D (t) Calculation error ε (t) :
[0217] Step S10, according to the four-layer loop iterative approximation in step S8, the optimal dictionary D is obtained len and the optimal linear classification model parameters R len . Determine whether the iterative convergence condition is met. If so, output the optimal discriminant dictionary D len =D (t) and the optimal linear classification model parameters R len =R (t) ; If not, execute step S5. The iterative convergence condition is expressed as:
[0218] |ε (t) -ε (t-1) |<ε0 or or
[0219] Step S11, using the classification error constraint term as a linear classifier to classify the image, the linear classifier can be expressed as:
[0220]
[0221] Among them, r i is the i-th row of the linear classification model parameter matrix R. The linear classifier is constructed by the linear classification model parameters R len and the sparse coefficient The product of obtains a prediction vector, so the sample to be tested The sparse coefficient The updates are as follows:
[0222]
[0223] Among them, λ R (λ R >0) is the classification sparsity parameter.
[0224] The classification error constraint term is used as a linear classifier, and the optimal linear classification model parameter R len As a training model for the classifier, the sample to be tested The sparse coefficient Perform linear classification, resulting in faster image classification.
[0225] Table 1 is the common parameter table;
[0226] Table 1
[0227]
[0228] Table 2 is the independent parameter table of each data set;
[0229] Table 2
[0230]
[0231] According to Table 1, Table 2 and Figure 3 It can be seen that in the training with 32 samples, the classification accuracy of parameters α, β, and γ is stable at more than 98% for any value in the interval; while the classification accuracy of parameters λ and τ is stable in the range of [1×10 -6 ,0.1] is more sensitive, and the values in the range of [1,10] are more stable. In the training with 64 samples, the parameters λ, α, and γ are in the range of [1×10 -6 ,10] range, the classification accuracy is stable at more than 99%; the parameter β is more sensitive to the value in the range of [1,10], and -6 ,0.1] interval is relatively stable; parameter τ has a good classification accuracy in the interval other than 0.001. This is because in some special cases, the parameter update in the model may approach a singular value, resulting in abnormal results. In the training with 80 samples, any value of parameters α and γ in the interval makes the model stable with a classification accuracy of more than 99%; parameter λ has a good classification accuracy of more than 99% in the interval [1×10 -6 ,0.1] is more sensitive, and the value in the interval [1,10] is more stable; the parameter τ is in the range [1×10 -6 ,0.01] interval is more sensitive, and the value in the interval [0.1,10] is relatively stable; the value of parameter β is relatively sensitive in the interval [1,10], and is relatively stable in the interval [1×10 -6 ,0.1] interval is relatively stable. Therefore, it can be seen that the selection of parameter values is very important for the classification performance of the model.
[0232] Table 3 is a comparison table of classification accuracy of different methods on four data sets;
[0233] Table 3
[0234]
[0235] As can be seen from Table 3, the MA-DL method achieved the highest classification accuracy in the experiments on Caltech101, Scene15, and the fabric dataset of Alibaba Cloud Tianchi (Tianchi), which were 98.44%, 99.01%, 99.38%; 98.57%; 71.05% and 77.25% respectively. However, the MA-DL method did not obtain good classification accuracy on the Extended YaleB face dataset, and the classification accuracy decreased by 2.76% compared with the FDDL method on the Extended YaleB face dataset. The main reasons for the decline in the classification performance of the MA-DL method mainly include: 1) There are many images with poor lighting in the Extended YaleB face dataset, and the image categories are numerous, and the linear classifier cannot provide a good classification environment; 2) When balancing the weights of the classification error constraint and the within-class difference suppression constraint, the MA-DL method is more inclined to the classification error constraint, resulting in a still large within-class scatter generated by the MA-DL method in the training of similar face images. However, as the number of training samples increases, the classification effect of the MA-DL method is better. Thus, it can be seen that the MA-DL method is more suitable for some special classification scenarios with high timeliness.
[0236] Table 4 is a comparison table of the computational complexities of different classifiers;
[0237] Table 4
[0238]
[0239] As can be seen from Table 4, the kNN classifier requires a computational complexity of O(N 2 ) to classify a sample, where one N represents the total number of training samples, and the other N represents the dimension of the sparse coefficient. The linear classifier requires a computational complexity of O(CN) to classify a sample, where C represents the number of training sample categories, and N represents the dimension of the sparse coefficient. Since C << N, using a linear classifier in the classification stage can greatly reduce the computational complexity and shorten the classification time.
[0240] Table 5 is a comparison table of the classification times of different methods on four datasets;
[0241] Table 5
[0242]
[0243] As can be seen from Table 5, the classification time performance of the MA-DL method on the four data sets is significantly improved, and the classification time is the shortest. Moreover, the classification time of the MA-DL method will also increase with the increase in the number of samples. The experimental results in Table 5 show the classification time performance advantage brought by the MA-DL method using a linear classifier. The difference between the MA-DL method and other methods is that the dictionary does not have a fixed size, and the difference in classification time performance between different numbers of samples in the same data set stems from the sparsity of model training. Therefore, the classification time performance may be affected by the size and sparsity of the dictionary during the classification process. The MA-DL method effectively shortens the training time and classification time of the model by introducing classification error constraints and linear classifiers to realize linear classification of multi-level approximation dictionaries.
[0244] The results of the above embodiments well demonstrate the rationality and effectiveness of the supervised dictionary learning model, Laplace eigenmap, intra-class difference suppression term, and classification error constraint term constructed in steps S3-S8 of the present invention. By using multiple parameter optimization iterations in the training phase, multi-level rapid approximation is achieved, the convergence speed of the model learning process is improved, and the training time and classification time of the model are effectively shortened. In the classification phase, a linear classifier is used instead of a kNN classifier with a higher computational complexity, and the dictionary and linear classification model parameters are jointly learned to obtain a higher classification accuracy.
[0245] In summary, the present invention discloses a fast image classification method of multi-level approximation dictionary learning. The present invention selects the public Caltech101 data set, Extended YaleB face data set, Scene15 data set and Alibaba Cloud Tianchi fabric data set, and uses different feature extraction methods to pre-process these four types of data sets. The present invention first adds three constraints to the dictionary learning model for image classification tasks, namely label constraints, local invariance constraints and intra-class difference inhibition constraints. Secondly, a classification label matrix is constructed and a classification error constraint is introduced in the training stage. The optimization iteration of multiple parameters is adopted to achieve multi-level fast approximation, thereby improving the convergence speed of the dictionary model learning process. Finally, a linear classifier is used in the classification stage to replace the kNN classifier with higher computational complexity, and the dictionary and linear classification model parameters are jointly learned for image classification. Compared with the existing image classification technology, the use of the present invention for image classification can effectively shorten the training time and classification time, and obtain a better classification accuracy.
[0246] Compared with the image classification method in the prior art, the fast image classification method of the multi-level approximate dictionary learning of the present invention has a shorter classification time and a higher classification accuracy.
[0247] The embodiments described above are merely descriptions of preferred implementations of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope of the present invention.
Claims
1. A fast image classification method based on multi-level approximate dictionary learning, characterized by The steps include: S1, select image dataset; S2, preprocessing the image using feature extraction method to generate an image sample set; S3, build a supervised dictionary learning model; S4, using Laplace eigenmap to constrain the local invariance of sparse coefficients; S5, introduce intra-class difference suppression items to constrain the dictionary learning model; S6, construct a classification label matrix; S7, construct classification error constraint items; S8, solving the objective function using an analytical method, and iteratively updating the sparse coefficients, linear classification model parameters, and dictionary; S9, calculating the error based on the updated sparse coefficient and dictionary; S10, determine whether the judgment dictionary and the linear classification model parameters meet the iterative convergence conditions. If they do, output the optimal judgment dictionary D len and the optimal linear classification model parameters R len , otherwise return to step S5; S11. Use the classification error constraint term as a linear classifier for image classification.
2. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 1, characterized in that: In step S3, the sample data is assumed to be: The dictionary matrix is: in, represents a real number set, n represents the data dimension, and N represents the sample y i The number of, i = 1, 2, ..., N; K represents the dictionary atom d j The number of , j = 1, 2, ..., K; The L2 norm is used to constrain the dictionary model, that is: in, represents the sparse coefficient, λ is a non-negative regular parameter; the objective function of dictionary learning is rewritten as: in, represents the sparse coefficient matrix, F represents the F norm, D * and S * Represent the updated dictionary matrix and sparse coefficient matrix respectively; According to the category label information of the training samples, the following supervised dictionary learning model is constructed: Assume that the data sample is represented as: Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9]. When samples y1, y2 and y3 are from the first category, y4, y5 and y6 are from the second category, and y7, y8 and y9 are from the third category, the label matrix is defined as: Among them, each diagonal block in the matrix A represents a subspace of each class, expanded to N samples, and the matrix A is defined as: a i represents the elements in the matrix A, i = 1, 2, ..., N; The number of atoms K in the dictionary is set equal to the number of samples N, so the objective function of the supervised dictionary learning model is re-expressed as: Among them, the dictionary matrix Sparse coefficient matrix α is the regularization parameter of the label constraint term, α>
0.
3. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 2, characterized in that: In step S4, the kNN algorithm is used on the training sample Y to construct an undirected graph G; each sample y i is regarded as a point, and the k points with the closest distance are calculated through the kNN algorithm, where k < N. Between the sample y i and these k points, an edge is constructed for each, that is, <yi, yj>; the constructed Laplacian matrix is: L = M - W; in, is the Laplace matrix, represents the weight matrix of the undirected graph G, Represents the degree matrix of the undirected graph G, and M is a diagonal matrix; the Gaussian kernel function method is used to calculate the weight w ij : Where σ is the bandwidth parameter of the Gaussian kernel function, σ>0, and the diagonal elements M of the degree matrix M ii It is expressed as: The objective function of Laplace eigenmap optimization is as follows: Among them, tr(·) is the trace of the · matrix; the Laplace eigenmap constraint is added as a regular term to the objective function of the dictionary, and the dictionary learning model of local invariance is constructed as follows: Where β is the regularization parameter of the Laplace eigenmap constraint term, β>0.
4. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 3, characterized in that: In step S5, assume that the training sample Y contains N samples, C different categories, and the number of samples in each category is x c =(1,2,…,C), then Let the sparse coefficient submatrix corresponding to each type of training sample be The sparse coefficient matrix S is updated column by column; different sparse coefficients s in the same category i With different intra-class sparse mean vectors μ i ,Right now: Where t represents the number of iterations; By minimizing the intra-class sparse mean square error of the sparse representation, the targets from the same category are aggregated to the intra-class sparse mean vector; thus, we get: Among them, γ is the regularization parameter of the intra-class difference suppression constraint term, γ>0.
5. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 4, characterized in that: In step S6, let the sample be: Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to the first category, y3 and y4 belong to the second category, y5, y6 and y7 belong to the third category, and the classification label matrix H is defined as: Expanded to N samples, the matrix H is defined as: C is the sample category.
6. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 5, characterized in that: In step S7, the similarity optimal value is solved by minimizing the error between the classification label vector and the sparse coefficient linear mapping vector; the classification error constraint term is expressed as: in, represents the linear classification model parameter matrix; therefore, the objective function of the dictionary model is expressed as: Among them, τ is the regularization parameter of the classification error constraint term, τ>0.
7. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 6, characterized in that: In step S8, the objective function is solved by an analytical method, and the sparse coefficient S, the linear classification model parameter R and the dictionary D are iteratively updated, that is, the partial derivatives of the sparse coefficient, the linear classification model parameter and the dictionary are respectively obtained to obtain: Where I is the identity matrix; ω is a constant, ω>0; Among them, θ is a constant, θ>0.
8. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 7, characterized in that: In S9, according to the updated sparse coefficient S (t) and dictionary D (t) Calculation error ε (t) :
9. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 8, characterized in that: In step S10, the iterative convergence condition is: |e (t) -e (t-1) |<ε0 or Or Among them, ε0 represents the iteration termination parameter; judge whether the iteration convergence condition is met, if it is met, output the optimal discriminant dictionary D len =D (t) and the optimal linear classification model parameters R len =R (t) ; If not satisfied, execute step S5.
10. The fast image classification method based on multi-level approximate dictionary learning as claimed in claim 9, characterized in that: In step S11, the linear classifier is expressed as: Among them, r i is the i-th row of the linear classification model parameter matrix R; the linear classifier is obtained by len and the sparse coefficient The product of obtains a prediction vector, so the sample to be tested The sparse coefficient The updates are as follows: Among them, λ R is the classification sparsity parameter, λ R >0.
Citation Information
Patent Citations
Fabric image defect detection method and system based on category constraint dictionary learning model
CN113793319A
Textile defect image classification method based on intra-class difference suppression discrimination dictionary learning
CN115018814A
Image classification method based on intra-class difference suppression dictionary learning
CN119251542A