Fast image classification method based on multi-level approximation dictionary learning
By introducing a multi-level approximation dictionary learning method into the image classification model, incorporating label, local invariance, and intra-class difference suppression constraints, and using a linear classifier, the problem of slow convergence speed and long classification time of existing models in complex backgrounds is solved, achieving faster training and higher classification accuracy.
Patent Information
- Application Number
- CN202411315504.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-09-20
AI Technical Summary
Existing image classification models are slow to converge and take a long time to classify in real-world scenarios with complex backgrounds, diverse categories, and varied feature representations, and lack discriminative ability.
A supervised dictionary learning model is constructed by incorporating label constraints, local invariance constraints, and intra-class difference suppression constraints. A classification error constraint term is introduced during the training phase, and an analytical method is used for iterative updates. Finally, a linear classifier is used for image classification.
It improves the convergence speed of the dictionary model, shortens the training and classification time, and improves the accuracy of image classification.
Smart Images

Figure CN119380072B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image classification technology, specifically relating to a fast image classification method based on multi-level approximation dictionary learning. This invention has the advantages of faster convergence speed and running time, and higher image classification accuracy. Background Technology
[0002] With the surge in digital, automated, and intelligent transformation, factories and enterprises are increasingly adopting computer vision models for classification, replacing traditional manual classification processes. High-precision, high-efficiency classification models will become a core competitive advantage for factories and enterprises. While the rapid development of computer vision has led to a proliferation of excellent image classification models, several factors still hinder their advancement. These include the size of the image set, the complexity of the image background, the degree of difference in image features, and the model's adaptability.
[0003] For many 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 the original data to obtain a more compact dictionary, providing a concise and efficient representation of the data. Today, dictionary learning is not only applicable to signal representation but also to image representation, audio representation, and video representation. Therefore, designing a suitable dictionary is crucial to the performance of various sparse representation-based algorithms.
[0004] With advancements in 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 spurred more scholars to explore these techniques. However, deep learning algorithms have large hypothesis spaces, often leading to time-consuming and unstable training due to overfitting. On the other hand, sparse representation techniques can handle small datasets, saving significant 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, focusing 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 the dictionary by incorporating various types of constraints. These DDL methods add discriminative constraints to the objective function of dictionary learning, continuously optimizing the reconstruction error and the discriminative constraint regularization term to obtain the optimal discriminative dictionary. Common discriminative constraints include class label information constraints, softmax loss constraints, linear prediction classification error constraints, Fisher's discriminant criterion constraints, logistic loss constraints, hinge loss constraints, etc. These discriminative constraints have proven that dictionary learning models have good classification accuracy. However, for classification problems in real-world scenarios with complex backgrounds, diverse categories, and varied feature representations, the convergence speed and classification time of these DDL methods are greatly affected. Based on this, this invention proposes a fast image classification method based on multi-level approximation dictionary learning, called the MA-DL method, which can effectively improve the convergence speed and shorten the classification time. Summary of the Invention
[0006] To address the problems existing in the prior art, this invention proposes a fast image classification method based on multi-level approximation dictionary learning.
[0007] First, this invention incorporates three constraints into the dictionary learning model: label constraint, local invariance constraint, and intra-class difference suppression constraint. Second, this invention constructs a classification label matrix and introduces a classification error constraint during the training phase. It employs iterative optimization of multiple parameters to achieve multi-level rapid approximation, thereby improving the convergence speed of the dictionary model learning process. Finally, in the classification phase, this invention uses a linear classifier instead of the computationally complex kNN classifier, and jointly learns image classification using both the dictionary and the linear classification model parameters. Compared to existing image classification techniques, this invention effectively shortens training and classification time while achieving better classification accuracy, thus well meeting the application requirements in real-world scenarios.
[0008] The present invention adopts the following technical solution:
[0009] A fast image classification method based on multi-level approximation dictionary learning includes the following steps:
[0010] S1. Select the image dataset;
[0011] S2. Use feature extraction to preprocess the images and generate an image sample set;
[0012] S3. Construct a supervised dictionary learning model;
[0013] S4. Use the Laplace eigenmap to constrain the local invariance of the sparse coefficients;
[0014] S5. Introduce intra-class difference suppression terms to constrain the dictionary learning model;
[0015] S6. Construct a category label matrix;
[0016] S7. Construct classification error constraint terms;
[0017] S8. The objective function is solved analytically, and the sparse coefficients, linear classification model parameters and dictionary are updated iteratively.
[0018] S9. Calculate the error based on the updated sparsity coefficients and dictionary;
[0019] S10. Determine whether the dictionary and the parameters of the linear classification model satisfy the iterative convergence condition. If they do, output the optimal discriminant 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 preprocess the four types of datasets—objects, faces, scenes, and textures—to generate an image sample set.
[0022] The different feature extraction methods described in this step include, for example:
[0023] 1) For the Caltech101 image dataset (objects) and the Scene15 dataset (scenes), the 3000-dimensional feature extraction method of scale-invariant feature transformation (SIFT) is used to preprocess the images of the two datasets.
[0024] 2) For the Extended YaleB face image dataset, a random face feature extraction method is used to preprocess the face images to generate a 504-dimensional feature vector.
[0025] 3) For the Alibaba Cloud Tianchi fabric image dataset, we used a combination of Histogram of Oriented Gradients (HOG), Gray-Level Co-occurrence Matrix (GLCM), and Local Binary Pattern (LBP) to extract features from the fabric images, and then used Principal Component Analysis (PCA) for dimensionality reduction.
[0026] Preferably, in step S3, a supervised dictionary learning model is constructed:
[0027] The sample data is set as follows: The dictionary matrix is:
[0028] in, Let y represent the set of real numbers, n represent the data dimension, and N represent the number of samples. i The number of elements, i = 1, 2, ..., N; K represents the dictionary atom d. j The number of elements, j = 1, 2, ..., K.
[0029] The dictionary model is constrained using the L2 norm, i.e.:
[0030] in, Let represent the sparsity coefficients, and λ be a non-negative canonical parameter. To make the objective function as convex as possible for easier solution, the objective function for dictionary learning can be further rewritten as:
[0031]
[0032] in, Let D represent the sparse coefficient matrix, F denote the F-norm, and D... * and S * Let represent the updated dictionary matrix and the sparse coefficient matrix, respectively. Therefore, a supervised dictionary learning model of the following form can be constructed:
[0033] Suppose the data samples are represented as: Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9]. When samples y1, y2, and y3 come from class 1, y4, y5, and y6 come from class 2, and y7, y8, and y9 come from class 3, the label matrix can be defined as:
[0034]
[0035] In matrix A, each diagonal block represents a subspace of each class. Extending this to N samples, matrix A is defined as follows: a i Let i represent the elements in matrix A, where i = 1, 2, ..., N.
[0036] To ensure that sparse coefficients belong to a subspace spanned by their respective category association coefficients, the label matrix is used as the association coefficient to constrain the sparse coefficients. Let K = N, then the objective function of the supervised dictionary learning model can be rewritten as:
[0037] Among them, dictionary matrix sparse coefficient matrix α (α>0) is the regularization parameter for the label constraint.
[0038] Preferably, in step S4, Laplacian eigenmaps are used to perform local invariance constraints on the sparse coefficients.
[0039] Regarding each sample y i as a point, calculate the k (k < N) points with the closest distance through the kNN algorithm. Between y i and these k points, construct an edge <yi, yj> respectively, that is, an undirected graph G. Based on the undirected graph, construct a Laplacian matrix: L = M - W.
[0040] 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 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 w ij :
[0041]
[0042] 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:
[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] Among them, 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] Among them, β (β > 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 categories, and the number of samples in each category is x c =(1, 2,..., C), then Let the sparse coefficient sub-matrix corresponding to each class of training samples be
[0050] The sparse coefficient matrix S is updated column-by-column, with different sparse coefficients in the same category being updated sequentially. i Having different intra-class sparse mean vectors μ i ,Right now:
[0051]
[0052] Where t represents the number of iterations.
[0053] To suppress intra-class variance in the feature space, we minimize the intra-class sparse mean square error of the sparse representation, causing targets from the same class to cluster towards the intra-class sparse mean vector. Therefore, we obtain:
[0054]
[0055] Wherein, γ (γ>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] Suppose the sample is Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to class 1, y3 and y4 belong to class 2, and y5, y6, and y7 belong to class 3. The classification label matrix H can be defined as:
[0058]
[0059] Extending to N samples, matrix H is defined as: C represents the sample category.
[0060] Preferably, in step S7, a classification error constraint term is constructed.
[0061] The optimal similarity value is found by minimizing the error between the classification label vector and the linear mapping vector of sparse coefficients. The classification error constraint term can be expressed as:
[0062]
[0063] in, Let represent the parameter matrix of the linear classification model. Therefore, the objective function of the dictionary model can be expressed as:
[0064]
[0065] Where τ (τ>0) is the regularization parameter of the classification error constraint term.
[0066] Preferably, in step S8, the objective function is solved analytically, and the sparse coefficients S, linear classification model parameters R, and dictionary D are iteratively updated. That is, partial derivatives are taken with respect to the sparse coefficients, linear classification model parameters, and dictionary respectively to obtain:
[0067]
[0068] Where I is the identity matrix; ω (ω>0) is a small constant that ensures that the update formula for the parameter R of the linear classification model is a non-singular function.
[0069]
[0070] Here, θ (θ>0) is a small constant, ensuring that the update formula for dictionary D is a non-singular function.
[0071] Preferably, in step S9, based on the updated sparsity coefficient S (t) and dictionary D (t) Calculation error ε (t) :
[0072]
[0073] Preferably, in step S10, the dictionary D is determined. (t) And the parameters R of the linear classification model (t) Check if the iterative convergence condition is met. If it is, output the optimal discriminant dictionary D. len =D (t) And the optimal linear classification model parameters R len =R (t) If not satisfied, proceed to step S5. The iterative convergence condition is expressed as:
[0074] |ε (t) -ε (t-1) |<ε0 or or
[0075] Where ε0 represents the iteration termination parameter.
[0076] Preferably, in step S11, a classification error constraint term is used as a linear classifier for image classification. The linear classifier can be expressed as:
[0077]
[0078] Where, r i Let R be the i-th row of the parameter matrix R of the linear classification model. The linear classifier uses the parameters R of the linear classification model... len With sparsity coefficient The product of these factors yields a prediction vector, thus the sample to be tested... sparsity coefficient The update is as follows:
[0079]
[0080] Where, λ R (λ R >0) is the classification sparsity parameter.
[0081] Using the classification error constraint term as a linear classifier, and setting the optimal linear classification model parameters R... len The training model for the classifier is used as the test sample. sparsity coefficient Linear classification is performed to achieve faster image classification.
[0082] The beneficial effects of this invention are:
[0083] (1) This invention incorporates three constraint terms into the dictionary learning model: label constraint, local invariance constraint, and intra-class difference suppression constraint, thereby enhancing the discriminative power of the dictionary model. A classification label matrix is constructed, and a classification error constraint term is introduced during the training phase. Multiple parameter optimization iterations are employed to achieve multi-level rapid approximation, thus improving the convergence speed of the dictionary model learning process. A linear classifier is used in conjunction with the dictionary and linear classification model parameters to achieve linear classification of the multi-level approximation dictionary.
[0084] (2) Compared with existing image classification methods, the present invention can effectively shorten the training time and classification time, and can obtain a higher classification accuracy. Attached Figure Description
[0085] Figure 1 This is a model structure diagram of a fast image classification method based on multi-level approximation dictionary learning, according to a preferred embodiment of the present invention.
[0086] Figure 2 This is a flowchart of the algorithm involved in a fast image classification method based on multi-level approximation dictionary learning according to a preferred embodiment of the present invention.
[0087] Figure 3 This is a graph showing the impact of different parameter values used in the Caltech101 dataset on the classification performance of this invention. Detailed Implementation
[0088] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention.
[0089] A preferred embodiment of the present invention discloses a fast image classification method based on multi-level approximation dictionary learning, referring to... Figure 1 The diagram shown is a model structure diagram of this method. (Refer to...) Figure 2 This is a flowchart of the algorithm involved in this method. The following describes the processing of all images according to the method of this embodiment to illustrate in detail the effect of the method of this invention on improving classification accuracy.
[0090] This embodiment presents a fast image classification method based on multi-level approximation dictionary learning, comprising the following steps:
[0091] S1. Select the image dataset.
[0092] S2. Different feature extraction methods are used to preprocess the four types of datasets: objects, faces, scenes, and textures, to generate image sample sets.
[0093] S3. Construct a supervised dictionary learning model. The sample data is set as follows: The dictionary matrix is:
[0094] in, Let y represent the set of real numbers, n represent the data dimension, and N represent the number of samples. i The number of elements, i = 1, 2, ..., N; K represents the dictionary atom d. j The number of elements, j = 1, 2, ..., K.
[0095] The dictionary model is constrained using the L2 norm, i.e.:
[0096] in, Let represent the sparsity coefficients, and λ be a non-negative canonical parameter. To make the objective function as convex as possible for easier solution, the objective function for dictionary learning can be further rewritten as:
[0097]
[0098] in, Let D represent the sparse coefficient matrix, F denote the F-norm, and D... * and S * These represent the updated dictionary matrix and the sparse coefficient matrix, respectively.
[0099] The sparse coefficient representation can preserve the attributes of the class labels, making the sparse coefficients, to some extent, belong to the subspace spanned by the correlation coefficients. Therefore, based on the class label information of the training samples, a supervised dictionary learning model of the following form can be constructed:
[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] In order 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 of 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. Build an edge <yi, yj> between y i and these k points, that is, an 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<000004l>:
[0109]
[0110] Among them, σ (σ > 0) is the bandwidth parameter of the Gaussian kernel function, and the diagonal element Mii Represented as:
[0111] Since there is a linear relationship of Y = DS between the training samples Y and the sparse coefficients S, according to the principle of Laplacian eigenmaps, the local feature relationships between the training samples are forced to be local feature relationships between the sparse coefficients S. Therefore, the objective function for optimizing the Laplacian eigenmaps is:
[0112]
[0113] Here, tr(·) is used to find the trace of the · matrix. By incorporating the Laplacian eigenmap constraint as a regularization term into the dictionary's objective function, a locally invariant dictionary learning model is constructed as follows:
[0114]
[0115] Where β (β>0) is the regularization parameter of the Laplacian eigenmap constraint term.
[0116] S5. Introduce intra-class difference suppression terms to constrain the dictionary model.
[0117] Suppose that the training sample Y contains N samples, C distinct classes, and x samples in each class. c = (1,2,…,C), then Let the sparse coefficient submatrix corresponding to each class of training samples be...
[0118] The sparse coefficient matrix S is updated column-by-column, with different sparse coefficients in the same category being updated sequentially. i Having different intra-class sparse mean vectors μ i ,Right now:
[0119]
[0120] Where t represents the number of iterations.
[0121] To suppress intra-class variance in the feature space, we minimize the intra-class sparse mean square error of the sparse representation, causing targets from the same class to cluster towards the intra-class sparse mean vector. Therefore, we obtain:
[0122]
[0123] Wherein, γ (γ>0) is the regularization parameter of the intra-class difference suppression constraint term.
[0124] S6. Construct a category label matrix.
[0125] Suppose the sample is Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to class 1, y3 and y4 belong to class 2, and y5, y6, and y7 belong to class 3. The classification label matrix H can be defined as:
[0126]
[0127] Extending to N samples, matrix H is defined as: C represents 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 categories.
[0128] S7. Construct classification error constraint terms.
[0129] The optimal similarity value is found by minimizing the error between the classification label vector and the linear mapping vector of sparse coefficients. The classification error constraint term can be expressed as:
[0130]
[0131] in, Let represent the parameter matrix of the linear classification model. Therefore, the objective function of the dictionary model can be expressed as:
[0132]
[0133] Where τ (τ>0) is the regularization parameter of the classification error constraint term.
[0134] S8. The sparse coefficients S, linear classification model parameters R, and dictionary D are iteratively updated using an analytical method, that is, partial derivatives are taken with respect to the sparse coefficients, linear classification model parameters, and dictionary respectively, to obtain:
[0135]
[0136] Where I is the identity matrix; ω (ω>0) is a small constant that ensures that the update formula for the parameter R of the linear classification model is a non-singular function.
[0137]
[0138] Here, θ (θ>0) is a small constant, ensuring that the update formula for dictionary D is a non-singular function.
[0139] S9. Based on the updated sparsity coefficient S (t) and dictionary D (t) Calculation error ε (t) :
[0140] S10, Determine if dictionary D(t) And the parameters R of the linear classification model (t) Check if the iterative convergence condition is met. If it is, output the optimal discriminant dictionary D. len =D (t) And the optimal linear classification model parameters R len =R (t) If not satisfied, proceed to step S5. The iterative convergence condition is:
[0141] |ε (t) -ε (t-1) |<ε0 or or
[0142] S11. Image classification is performed using a classification error constraint term as a linear classifier. The linear classifier can be represented as:
[0143]
[0144] Where, r i Let R be the i-th row of the parameter matrix R of the linear classification model. The linear classifier uses the parameters R of the linear classification model... len With sparsity coefficient The product of these factors yields a prediction vector, thus the sample to be tested... sparsity coefficient The update is as follows:
[0145]
[0146] Where, λ R (λ R >0) is the classification sparsity parameter.
[0147] Using the classification error constraint term as a linear classifier, and setting the optimal linear classification model parameters R... len The training model for the classifier is used as the test sample. sparsity coefficient Linear classification is performed to achieve faster image classification.
[0148] The steps of the above embodiments will be described in detail below with reference to specific data.
[0149] In step S1, the obtained remote sensing datasets 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 datasets: objects, faces, scenes, and textures, to generate image sample sets.
[0151] For the Caltech101 image dataset, multiple experiments were conducted on the six most frequent categories: airplane, motorcycle, leopard, face, watch, and face against a simple background. Within each category, 32, 64, and 80 samples were randomly selected as training samples, with the remaining samples used for testing. The dictionary size was set to 192, 384, and 480 atoms, depending on the number of training samples. For the Scene15 dataset, multiple experiments were conducted by randomly selecting images from 15 scene categories. 100 samples were randomly selected from each category as training samples, with the remaining samples used for testing. The dictionary size was set to 1500 atoms. Scale-Invariant Feature Transform (SIFT) with 3000-dimensional feature extraction was used to preprocess the images from both datasets.
[0152] For the Extended YaleB face image dataset, face images of 38 individuals were randomly selected for classification. Within each category, 32 samples were randomly selected as training samples, and the remaining samples were used for testing. The dictionary size was set to 1216 atoms. A random face feature extraction method was used to preprocess the face images, generating 504-dimensional feature vectors.
[0153] The Alibaba Cloud Tianchi fabric image dataset is divided into two categories: normal and defective. Multiple sets of experiments are conducted by randomly selecting fabric images from each category. 100 and 200 samples are randomly selected from each category as training samples, and the remaining samples are used for testing. The dictionary size is set to 200 and 400 atoms respectively, depending on the number of training samples. A combination of Histogram of Gradients (HOG), Gray-Level Co-occurrence Matrix (GLCM), and Local Binary Patterns (LBP) is used to extract features from the 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 as... The dictionary matrix is Since the L2 norm is differentiable at all points, it typically provides a smoother solution when the data is noisy. Furthermore, minimizing the L2 norm guarantees a unique solution. Therefore, the L2 norm can be used to constrain the dictionary model.
[0155] in, λ represents the sparsity coefficients. λ is a non-negative canonical parameter used to weigh the reconstruction error against sparsity. To make the objective function as convex as possible for easier solution, the objective function for dictionary learning can be further rewritten as:
[0156]
[0157] in, Let D represent the sparse coefficient matrix, F denote the F-norm, and D... * and S * These represent the updated dictionary matrix and the sparse coefficient matrix, respectively.
[0158] The sparse coefficient representation can preserve the attributes of the class labels, and to some extent, make the sparse coefficients belong to the subspace spanned by the correlation coefficients, thereby improving classification performance. Therefore, based on the class label information of the training samples, a supervised dictionary learning model of the following form can be constructed:
[0159] Suppose the data samples are represented as Y = [y1, y2, y3, y4, y5, y6, y7, y8, y9]. When samples y1, y2, and y3 come from class 1, samples y4, y5, and y6 come from class 2, and samples y7, y8, and y9 come from class 3, the label matrix A can be defined as:
[0160]
[0161] In matrix A, each diagonal block represents a subspace of each class. Extending this to N samples, matrix A is defined as follows: a i Let represent the elements in matrix A, i = 1, 2, ..., N. The definition of matrix A depends on each sample (y). i The order of (representing a sample) is not necessarily a consistent block diagonal matrix.
[0162] To ensure that sparse coefficients belong to a subspace spanned by their respective category association coefficients, 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; therefore, the objective function of the supervised dictionary learning model can be rewritten as:
[0163]
[0164] Among them, dictionary sparsity coefficient α (α>0) is the regularization parameter of the label constraint term, which is used to weigh the weight of the label matrix in the whole 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. Regard each sample y i as a point, and calculate the k (k < N) points with the closest distance through the kNN algorithm. Construct 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 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 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 [[ID=c = (1,2,…,C), then Let the sparse coefficient submatrix corresponding to each class of training samples be...
[0177] The sparse coefficient matrix S is updated column-by-column. To better approximate the sparse class centers, a "real-time" update method is used to calculate the intra-class sparse mean vector. Different sparse coefficients s within the same class... i Having different intra-class sparse mean vectors μ i ,Right now:
[0178]
[0179] Where t represents the number of iterations.
[0180] To suppress intra-class variance in the feature space, we minimize the intra-class sparse mean square error of the sparse representation, causing targets from the same class to cluster towards the intra-class sparse mean vector. Therefore, we obtain:
[0181]
[0182] Wherein, γ (γ>0) is the regularization parameter of the intra-class difference suppression constraint term, which is used to weigh the weight of intra-class difference suppression in the entire model.
[0183] Step S6: Construct the classification label matrix.
[0184] Suppose the sample is Y = [y1, y2, y3, y4, y5, y6, y7], and y1 and y2 belong to class 1, y3 and y4 belong to class 2, and y5, y6, and y7 belong to class 3. The classification label matrix H can be defined as:
[0185]
[0186] Extending to N samples, matrix H is defined as: C represents 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 categories.
[0187] Step S7: Construct classification error constraint terms.
[0188] The optimal similarity value is found by minimizing the error between the classification label vector and the linear mapping vector of sparse coefficients. The classification error constraint term can be expressed as:
[0189]
[0190] in, Let represent the parameter matrix of the linear classification model. Therefore, the objective function of the dictionary model can be expressed as:
[0191]
[0192] Where τ (τ>0) is the regularization parameter of the classification error constraint term.
[0193] Step S8: The objective function is solved analytically, and the sparse coefficients S, linear classification model parameters r, and dictionary D are iteratively updated. The analytical method obtains the optimal solution by setting the derivative to zero or by using the Lagrange multiplier method. That is, when optimizing the sparse coefficients S, the linear classification model parameters R and dictionary D are treated as constants; when optimizing the dictionary D, the linear classification model parameters R and sparse coefficients S are treated as constants, and vice versa. Therefore, the sparse coefficients S, linear classification model parameters R, and dictionary D are obtained as follows:
[0194]
[0195] The specific solution process for the sparse coefficients S, the linear classification model parameters R, and the dictionary D is as follows:
[0196] 1) Initialization: The dictionary matrix D is initialized using a Gaussian random matrix. (0) The initial value of the sparse coefficient matrix S. (0) The extreme points of S can be obtained by using the supervised dictionary learning model in step S3, that is:
[0197] 2) Update the parameters of the linear classification model: Solve the MA-DL model using the formula Taking the first and second derivatives of the parameters R of the linear classification model, we get:
[0198] First derivative:
[0199] Second derivative:
[0200] It can be seen that, If the second derivative is nonnegative, then the first derivative formula is 2τ(RS-H)S. T Let be a convex function. With the first derivative set to zero, the update formula for the parameters R of the linear classification model can be obtained as follows:
[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 for the parameter R of the linear classification model is a non-singular function.
[0203] 3) Update sparsity coefficients: Solve the MA-DL model and let The sum is F(s) i ), respectively F(s) i )
[0204] To find the first and second derivatives, we get:
[0205] First derivative:
[0206] 2γ(s i -μ i )+2τR T (Rs i -h i )
[0207] Second derivative:
[0208] It can be seen that F(s) i The second derivative of is non-negative, therefore the first derivative is a convex function. Let F(s) i Setting the first derivative of ) to zero yields the sparse coefficients s. i The update formula is:
[0209]
[0210] 4) Update the dictionary: Solve the MA-DL model using the formula Taking the first and second derivatives of the dictionary, we get:
[0211] First derivative:
[0212] Second derivative:
[0213] It can be seen that, If the second derivative is non-negative, then the first derivative is a convex function. Let With the first derivative set to zero, the update formula for dictionary D can be obtained as follows:
[0214] D (t) =YS T (SS T +θI) -1
[0215] Here, θ (θ>0) is a small constant, ensuring that the update formula for dictionary D is a non-singular function.
[0216] Step S9, based on the updated sparsity coefficients S (t) and dictionary D (t) Calculation error ε (t) :
[0217] Step S10: Based on the four-level iterative approximation in step S8, obtain the optimal dictionary D. len And the optimal linear classification model parameters R len Determine if the iterative convergence condition is met. If it is, output the optimal discriminant dictionary D. len =D (t) And the optimal linear classification model parameters R len =R (t) If not satisfied, proceed to step S5. The iterative convergence condition is expressed as:
[0218] |ε (t) -ε (t-1) |<ε0 or or
[0219] Step S11: Use the classification error constraint term as a linear classifier for image classification. The linear classifier can be expressed as:
[0220]
[0221] Where, r i Let R be the i-th row of the parameter matrix R of the linear classification model. The linear classifier uses the parameters R of the linear classification model... len With sparsity coefficient The product of these factors yields a prediction vector, thus the sample to be tested... sparsity coefficient The update is as follows:
[0222]
[0223] Where, λ R (λ R >0) is the classification sparsity parameter.
[0224] Using the classification error constraint term as a linear classifier, and setting the optimal linear classification model parameters R... len The training model for the classifier is used as the test sample. sparsity coefficient Linear classification is performed to achieve faster image classification.
[0225] Table 1 is the common parameter table;
[0226] Table 1
[0227]
[0228] Table 2 is a table of independent parameters for each dataset;
[0229] Table 2
[0230]
[0231] According to Table 1, Table 2 and Figure 3 It can be seen that in training with a sample size of 32, the classification accuracy remains stable above 98% for any value of parameters α, β, and γ within the interval; while the classification accuracy for parameters λ and τ remains stable within [1×10]. -6 The values of λ, α, and γ are relatively sensitive within the interval [0.1], but more stable within the interval [1, 10]. In training with 64 samples, the parameters λ, α, and γ are relatively stable within the interval [1 × 10]. -6 Any value within the interval [1, 10] consistently maintains a classification accuracy of over 99%; the parameter β is more sensitive in the interval [1, 10], and its value within [1×10] is less sensitive. -6 The parameter τ is relatively stable in the range of [0.1]. τ achieves good classification accuracy in ranges outside 0.001. This is because, under certain specific values, parameter updates in the model may approach singular values, leading to abnormal results. In training with 80 samples, any values of parameters α and γ within the range maintain a stable classification accuracy of over 99%. Parameter λ in the range [1×10...]... -6 The parameter τ is sensitive to values within the interval [0, 1], but relatively stable within the interval [1, 10]. -6 The parameter β is more sensitive in the interval [0.01] and more stable in the interval [0.1, 10]. The parameter β is more sensitive in the interval [1, 10] and more stable in the interval [1×10]. -6 The values in the interval [0, 1] are 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 of the classification accuracy of different methods on four datasets;
[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 the Caltech101, Scene15, and Alibaba Cloud Tianchi fabric datasets, which were 98.44%, 99.01%, 99.38%; 98.57%; 71.05% and 77.25% respectively. However, the MA-DL method did not obtain a 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 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. 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 reduce 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 shown in Table 5, the MA-DL method significantly improves classification time performance on all four datasets, achieving the shortest classification time. Furthermore, the classification time of the MA-DL method increases with the number of samples. The experimental results in Table 5 demonstrate the performance advantage of the MA-DL method in terms of classification time due to its use of a linear classifier. The difference between the MA-DL method and other methods lies in the fact that the dictionary does not have a fixed size. The difference in classification time performance between different numbers of samples on the same dataset stems from the sparsity of model training. Therefore, classification time performance may be affected by dictionary size and sparsity during the classification process. The MA-DL method effectively shortens the model's training and classification times by introducing classification error constraints and a linear classifier to achieve linear classification using a multi-level approximation dictionary.
[0244] The results of the above embodiments well demonstrate the rationality and effectiveness of the supervised dictionary learning model, Laplacian feature mapping, intra-class difference suppression term, and classification error constraint term constructed in steps S3-S8 of the present invention. By employing iterative optimization of multiple parameters during the training phase, multi-level fast approximation is achieved, improving the convergence speed of the model learning process and effectively shortening the model's training and classification times. Furthermore, in the classification phase, a linear classifier is used instead of the computationally complex kNN classifier, and the dictionary and linear classification model parameters are jointly learned, resulting in a high classification accuracy.
[0245] In summary, this invention discloses a fast image classification method based on multi-level approximation dictionary learning. This invention selects the publicly available Caltech101 dataset, Extended YaleB face dataset, Scene15 dataset, and Alibaba Cloud Tianchi fabric dataset, and preprocesses these four dataset types using different feature extraction methods. First, for image classification tasks, this invention constructs the dictionary learning model by adding three constraints: label constraint, local invariance constraint, and intra-class difference suppression constraint. Second, a classification label matrix is constructed, and a classification error constraint is introduced during the training phase. Through iterative optimization of multiple parameters, multi-level fast approximation is achieved, thereby improving the convergence speed of the dictionary model learning process. Finally, in the classification phase, a linear classifier is used instead of the computationally complex kNN classifier, and the dictionary and linear classification model parameters are jointly learned for image classification. Using this invention for image classification, compared to existing image classification techniques, can effectively shorten training and classification time and achieve better classification accuracy.
[0246] Compared with existing image classification methods, the fast image classification method based on multi-level approximation dictionary learning proposed in this invention has a shorter classification time and a higher classification accuracy.
[0247] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope of the present invention.
Claims
1. A fast image classification method based on multi-level approximation dictionary learning, characterized by: Includes the following steps: S1. Select the image dataset; S2. Use feature extraction to preprocess the images and generate an image sample set; S3. Construct a supervised dictionary learning model; S4. Use the Laplace eigenmap to constrain the local invariance of the sparse coefficients; S5. Introduce intra-class difference suppression terms to constrain the dictionary learning model; S6. Construct a category label matrix; S7. Construct classification error constraint terms; S8. The objective function is solved analytically, and the sparse coefficients, linear classification model parameters and dictionary are updated iteratively. S9. Calculate the error based on the updated sparsity coefficients and dictionary; S10. Determine whether the dictionary and the parameters of the linear classification model satisfy the iterative convergence condition. If they do, output the optimal discriminant dictionary D. len And the optimal linear classification model parameters R len Otherwise, return to step S5. S11. Use a classification error constraint term as a linear classifier for image classification; In step S3, let the sample data be: The dictionary matrix is: ; in, Represents the set of real numbers. n Indicates data dimension, N Represents sample y i The number of elements, i = 1, 2, ..., N; K Represents dictionary atom d j The number of elements, j=1,2,…,K; use L The 2-norm constrains the dictionary model, namely: ; in, Represents the sparsity coefficient. λ It is a non-negative positive expression parameter; the objective function for dictionary learning is rewritten as: in, Let D represent the sparse coefficient matrix, F denote the F-norm, and D... * and S * These represent the updated dictionary matrix and the sparse coefficient matrix, respectively; Based on the category label information of the training samples, the following supervised dictionary learning model is constructed: Let the data samples be represented as: Y=[y1,y2,y3,y4,y5,y6,y7,y8,y9]. When samples 𝑦1, 𝑦2, and 𝑦3 come from class 1, 𝑦4, 𝑦5, and 𝑦6 come from class 2, and 𝑦7, 𝑦8, and 𝑦9 come from class 3, the label matrix is defined as: In matrix A, each diagonal block represents a subspace of each class. Extending this to N samples, matrix A is defined as follows: , Let i represent the elements in matrix A, i = 1, 2, ..., N; The number of atoms K in the dictionary is set to be equal to the number of samples N. Therefore, the objective function of the supervised dictionary learning model is re-expressed as: Among them, dictionary matrix sparse coefficient matrix α is the regularization parameter for the label constraint term, α > 0; In step S4, the kNN algorithm is used on the training samples Y to construct an undirected graph G; each sample y i Treat it as a single point, and use the kNN algorithm to calculate the k nearest points, where k < N. In sample y i Construct an edge between each of these k points, i.e. <y i ,y j The constructed Laplace matrix is: L=MW; in, For Laplace matrix, The weight matrix represents the weight of an undirected graph G. Let M represent the degree matrix of the undirected graph G, and M be a diagonal matrix; the weights w are calculated using the Gaussian kernel function method. ij : Where is the bandwidth parameter of the Gaussian kernel function, > 0, and M is the diagonal element of the degree matrix . ii Represented as: ; The objective function for Laplacian eigenmap optimization is as follows: Where tr(•) is the trace of the • matrix; by adding the Laplacian eigenmap constraint as a regularization term to the dictionary's objective function, the locally invariant dictionary learning model is constructed as follows: Where 𝛽 is the regularization parameter of the Laplacian eigenmap constraint term, 𝛽 > 0; In step S5, let the training sample Y contain N samples, C different classes, and x samples in each class. c =(1,2,…,C), then Let the sparse coefficient submatrix corresponding to each class of training samples be... ; The sparse coefficient matrix S is updated column-by-column; different sparse coefficients within the same category... Having 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, targets from the same class are clustered towards the intra-class sparse mean vector; therefore, we obtain: Where 𝛾 is the regularization parameter of the intra-class difference suppression constraint term, 𝛾 > 0.
2. The fast image classification method based on multi-level approximation dictionary learning as described in claim 1, characterized in that: In step S6, let the sample be Y = [y1, y2, y3, y4, y5, y6, y7], where y1 and y2 belong to class 1, y3 and y4 belong to class 2, and y5, y6, and y7 belong to class 3. The classification label matrix K is defined as follows: Extending to N samples, matrix H is defined as: C represents the sample category.
3. The fast image classification method based on multi-level approximation dictionary learning as described in claim 2, characterized in that: In step S7, the optimal similarity 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, Let represent the parameter matrix of the linear classification model; therefore, the objective function of the dictionary model is expressed as: in, The regularization parameter for the classification error constraint term. .
4. The fast image classification method based on multi-level approximation dictionary learning as described in claim 3, characterized in that: step S8 In this paper, the objective function is solved analytically, and the sparse coefficients S, linear classification model parameters R, and dictionary D are iteratively updated. Specifically, partial derivatives are taken with respect to the sparse coefficients, linear classification model parameters, and dictionary, yielding the following results: in, I It is the identity matrix; w is a constant, w>0; Where θ is a constant, θ>0.
5. The fast image classification method based on multi-level approximation dictionary learning as described in claim 4, characterized in that: In step S9, based on the updated sparsity coefficients S (t) and dictionary D (t) Calculation error ε (t) : 。 6. The fast image classification method based on multi-level approximation dictionary learning as described in claim 5, characterized in that, In step S10, the convergence condition for the iteration is: Where ε0 represents the iteration termination parameter; determine whether the iteration convergence condition is met, and if so, output the optimal discrimination dictionary D. len =D (t) And the optimal linear classification model parameters R len =R (t) If the condition is not met, proceed to step S5.
7. The fast image classification method based on multi-level approximation dictionary learning as described in claim 6, characterized in that, In step S11, the linear classifier is represented as: Where, r i This represents the nth row of the parameter matrix R of the linear classification model; the linear classifier uses the parameters R of the linear classification model. len With sparsity coefficient The product of these factors yields a prediction vector, thus the sample to be tested... sparsity coefficient The update is as follows: in, λ R For classifying sparsity parameters, λ R >0.
Citation Information
Patent Citations
Image classification method based on intra-class difference suppression dictionary learning
CN119251542A