An Image Classification Method and System Based on Autoencoder and Decision Tree
By combining the autoencoder and the decision tree, the low-dimensional features of the image samples are extracted and the decision tree is constructed, the problems of high computational complexity and poor interpretability under high-dimensional complex data are solved, and efficient and interpretable image classification is achieved.
Patent Information
- Application Number
- CN202310070830.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-07
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-02-07
AI Technical Summary
Existing machine learning algorithms have high computational complexity, time-consuming and lack interpretability when processing high-dimensional complex data. Although deep learning networks have good classification effects, they are not interpretable, and it is difficult to improve accuracy and interpretability at the same time in image classification.
Combining the autoencoder and the decision tree, the low-dimensional structural features of the image samples are extracted through the autoencoder, and characterization learning is performed using the encoder and decoder. Combining sparseness and correlation constraints, a decision tree is built to improve the interpretability and generalization ability of classification.
It realizes improving the interpretability and classification accuracy of the algorithm in image classification, extracting low-dimensional features through the autoencoder and building a decision tree to obtain interpretable efficient classification results.
Smart Images

Figure CN116246102B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an image classification method and system based on an autoencoder and a decision tree, belonging to the technical fields of machine learning and deep learning. Background Art
[0002] A large number of image samples obtained in research have no label information and need to be manually labeled. However, manually labeling a large amount of data is time-consuming and laborious. Therefore, the goal of traditional machine learning methods and deep learning methods is to classify or identify unlabeled samples through a sample data set with label information. Among them, the classification task, as a basic task of traditional machine learning methods, needs to use the sample label information of the training set to classify samples with unknown label information. And the image classification task, as a popular field of current research, has derived many corresponding classic methods of traditional machine learning and their improved algorithms.
[0003] Current classic machine learning algorithms include decision trees, Bayesian classifiers, support vector machines, and K-nearest neighbor classifiers, etc. These methods have good classification effects when dealing with small-scale structured data. When facing the input of complex data, such as high-dimensional data, most machine learning algorithms will face the curse of dimensionality and reduce the classification effect of the algorithms. In large sample data sets, deep learning networks can greatly improve the speed of the algorithms and the classification accuracy. ]>
[0004] The difference between traditional machine learning algorithms and deep learning algorithms is that deep learning networks do not need to be given features and do not need to analyze features. When the data volume increases, the number of network layers can be deepened to obtain better learning performance, while the performance of machine learning algorithms does not adjust after exceeding a certain limit. However, a common feature of machine learning algorithms is that they are interpretable, and the process of generating a specific output can be intuitively seen. Although the current deep network methods have good classification effects, they are not interpretable, and the classification process of the network is unknown.
[0005] With the diversified development of data collection channels, high-dimensional complex data challenges are often faced in image classification. For the problems of large computational complexity and long time consumption of basic machine learning methods for image classification when facing high-dimensional complex data, neural networks are used to process sample information. By using the interpretability of the decision tree model, while improving the classification accuracy of the algorithm, the algorithm results are made to have a certain degree of interpretability, combining the autoencoder network with the decision tree to improve the interpretability of classification and the generalization ability of the model. Summary of the Invention
[0006] The purpose of the present invention is to provide an image classification method based on an autoencoder and a decision tree in order to solve the above problems existing in image classification.
[0007] The technical solution implemented by the present invention is as follows. An image classification method based on an autoencoder and a decision tree includes the following steps:
[0008] (1) Collect data, obtain the original RGB image data, and convert the image samples into a pixel information matrix / vector;
[0009] (2) Input the collected image data into the autoencoder, use a feedforward neural network, perform autoencoder-based representation learning on the image samples through the encoder and decoder, and use the encoder part to extract the low-dimensional structural feature information of the image samples; construct a network based on the sample image data, add sparsity constraints and correlation constraints to the loss function of the network, and update the weight parameters of the autoencoder network in an iterative manner;
[0010] (3) During the iterative process of solving the optimal weight parameters of the network, calculate the distance between the image samples based on the low-dimensional sample vectors obtained by the encoder, and update the nearest neighbor value corresponding to each image sample under the constraint of the nearest neighbor distance;
[0011] (4) Based on the encoder in the trained autoencoder network model, extract the low-dimensional feature information of the samples, combine the obtained sample nearest neighbor values through iteration as the corresponding sample labels, use the CART method to construct a decision tree with the nearest neighbor values as the leaf nodes, and at the same time adjust the parameters of the autoencoder network;
[0012] (5) Use the autoencoder to obtain the low-dimensional feature information of the new samples and input them into the decision tree to obtain the nearest neighbor values, search for the nearest neighbor neighborhood of the training samples through KNN, and take the category with the largest number in the nearest neighbor neighborhood as the prediction result.
[0013] The representation learning steps of the autoencoder include:
[0014] Construct a network based on the sample image data, add sparsity constraints and correlation constraints to the loss function of the network. The loss function of the autoencoder network without constraints is:
[0015] X = (x1, x2,..., x n )
[0016]
[0017]
[0018] Among them, X is the input sample vector; x i is the i-th feature of the input sample vector X; n is the dimension of the input vector. In the image samples of 28 pixels × 28 pixels in size, the dimension n of the corresponding input sample vector is 784; is the output reconstructed sample vector; is the reconstructed sample vector The i-th feature of; J ave (W, b) is the unconstrained loss function of the autoencoder network, used to measure the average difference between the reconstructed samples and the original sample X; W and b are the weights and biases of the autoencoder network respectively;
[0019] The loss function of the autoencoder network after adding a sparsity constraint to the output of the hidden layer of the autoencoder network is:
[0020]
[0021]
[0022]
[0023] Wherein, is the average activation degree of the neurons in the hidden layer of the autoencoder network; n is the dimension of the input vector; x j is the j-th feature of the input sample vector; a i (x j ) is the activation value of the i-th neuron under the input x j ; is the relative entropy, used as a penalty factor to measure the difference between two distributions; h is the number of neurons in the hidden layer; ρ is the sparsity parameter; γ is the KL divergence constraint parameter; J sparse (W, b) is the sparse loss function of the autoencoder network; is the average activation degree of the neurons in the hidden layer;
[0024] The loss function of the autoencoder network after adding a similarity constraint to the sparse autoencoder neural network:
[0025]
[0026] Wherein, J re (W, b) is the loss function of the autoencoder network with sparsity constraint and similarity constraint added, μ is the similarity parameter, n is the dimension of the input vector, is the i-th feature of the reconstructed sample vector, used as a restriction to increase the difference between samples as much as possible;
[0027] The weight parameters of the autoencoder network are updated in an iterative manner, and the quasi-Newton method L-BFGS is used for the iteration of the autoencoder neural network, and the maximum number of iterations is set to 300.
[0028] Calculating the distance between image samples includes:
[0029] (1) The autoencoder network updates the nearest neighbor value of the sample at each iteration. The distance parameter between samples and the maximum and minimum nearest neighbor value limits are preset before training. Under this limit, the minimum nearest neighbor value of the sample is 1, and the maximum nearest neighbor value is 10. That is, if the nearest neighbor value of the sample is 0, it is corrected to 1; if the nearest neighbor value of the sample is greater than 10, it is corrected to 10.
[0030] During the iterative calculation process, from the updated weights W and bias term b, a new sample vector after extracting low-dimensional features can be obtained. The distance calculation of the compressed feature vector of the sample after passing through the autoencoder neural network with two hidden layers is as follows:
[0031] X i ′ = h1(X i ) = σ1(W1X i + b1)
[0032] X i ″ = h2(X i ′) = σ2(W2X i ′ + b2)
[0033]
[0034] Among them, W1 and W2 are the weights of the first hidden layer h1 and the second hidden layer h2 in the encoder network respectively; b1 and b2 are the corresponding bias terms; σ1 and σ2 are the output functions corresponding to the hidden layers h1 and h2 of the network; X i ′ represents the vector of the i-th input sample X i after passing through the hidden layer h1; X i ″ represents the vector of X i ′ after passing through the hidden layer h2; D(X i ″, X j ″) is the Euclidean distance between the extracted low-dimensional sample vectors X i ″ and X j ″; m is the dimension of the low-dimensional feature vector X″; x i ′ s ′ is the s-th feature of the sample vector X i ″; x′ j ′ s is the s-th feature of the sample vector X j ″; the distance parameter α between samples determines the farthest nearest neighbor distance of other samples from the sample. When the distance from this sample is greater than α, that is, D(X i ″, X j ″) > α, it cannot be a nearest neighbor of this sample; based on this distance parameter, the nearest neighbor value of the i-th sample is expressed as the number of samples with a distance less than α between all samples.
[0035] (2) The autoencoder neural network is set with two hidden layers. For the sample data with an input of 784×1, the size of the first hidden layer d1 is set to 196×1, and the size of the second hidden layer d2 is set to 20×1;
[0036] (3) Initialize the parameters of the network. The initial value of the weight parameter of the autoencoder network is set to 0, the sparsity parameter ρ is set to 0.05, the coefficient γ of the sparsity penalty factor is set to 0.5, and the parameter μ of the similarity constraint is set to 3×10 -3 .
[0037] The construction of the decision tree with the nearest neighbor value as the leaf node is as follows:
[0038] Use the final output X″ after the iteration of the autoencoder as the sample vector for constructing the decision tree, and use the nearest neighbor number of each sample obtained by the iteration as the new label of the sample;
[0039] The generation of the decision tree uses the CART algorithm, and a full binary tree is generated. The calculation method of the Gini index is as follows;
[0040]
[0041]
[0042] Among them, Gini(B) represents the purity of the sample set B in the decision tree; v i represents the proportion of the i-th (i = 1,..., C) class of samples in the sample set B; Gini(B, q) represents the Gini index of the attribute q; T represents the number of values of the attribute q = {q 1 , q 2 ,..., q T}; B t represents all the samples in the t-th branch node with the value of q t .
[0043] Adjust the parameters of the autoencoder network, including:
[0044] Test sample X z First, generate a new verification sample vector X z ″ through the generated autoencoder neural network, and then obtain the corresponding nearest neighbor value K through the constructed CART decision tree z ;
[0045] Calculate the distance between samples:
[0046]
[0047] Among them, D(X z ″, X i″) represents the Euclidean distance between two samples, m is the dimension of the low-dimensional feature vector X″, and x′ z ′ s represents the s-th feature of the sample vector X z ″; x i ′ s ′ represents the s-th feature of the sample vector X i ″;
[0048] Then, the corresponding nearest neighbor sample set in the training set is searched through the KNN algorithm, and the samples are classified using the labels of the nearest neighbor sample set; if the classification effect is excellent, that is, the classification accuracy reaches 85% or above, the generated network model and decision tree are retained; otherwise, the parameters of the autoencoder neural network are adjusted to achieve a better classification effect.
[0049] The search for the nearest neighbor domain of the training samples is as follows:
[0050] Z = (z1, z2,..., z n )
[0051]
[0052]
[0053]
[0054] where Z is the training sample; z i is the i-th feature of Z; Z″ is the low-dimensional feature vector extracted by the autoencoder; z i ″ is the i-th feature of the low-dimensional feature vector Z″; D(Z″, X i ″) is the Euclidean distance metric; m is the dimension of the low-dimensional feature vectors X″ and Z″; K z is the optimal nearest neighbor value corresponding to the training sample output by the decision tree; is the set of nearest neighbor samples of the training sample; α is the distance parameter; is the i-th nearest neighbor sample corresponding to; p i is the probability that the label corresponding to appears in the set of nearest neighbor samples ; P z is the predicted label of the training sample Z; C is the number of label categories of the sample.
[0055] A system for an image classification method based on an autoencoder and a decision tree according to the present invention includes an image input conversion module, a training module, a feature extraction module, a nearest neighbor module, a decision tree module, and a classification module.
[0056] The image input conversion module is used to collect image sample data, obtain the original RGB image data, and obtain the matrix / vector of the pixel information of the image sample.
[0057] The training module inputs the collected image data into the autoencoder, uses a feedforward neural network, and solves the weight parameters of the autoencoder network through the backpropagation algorithm.
[0058] The feature extraction module uses the autoencoder network model to learn the representation information of the image sample, and extracts the typical feature information of the image sample based on the encoder.
[0059] The nearest neighbor module calculates the distance between image samples based on the output result of the corresponding encoder during the iterative process of solving the optimal weight parameters of the network, and updates the nearest neighbor value corresponding to each image sample under the constraint of the nearest neighbor distance.
[0060] The decision tree module extracts the compressed feature information of the sample based on the encoder in the trained autoencoder network model, constructs a decision tree by combining the optimal nearest neighbor numbers of each sample as labels, and constructs it based on the CART method.
[0061] The classification module compresses the sample feature information using the autoencoder and inputs it into the decision tree, obtains its corresponding optimal nearest neighbor value, finds its corresponding nearest neighbor domain, and uses the category with the largest number in the nearest neighbor domain in KNN as the prediction result.
[0062] In the system of an image classification method based on an autoencoder and a decision tree, first, the image input conversion module is used to process the data, then the training module is used to train the data, the feature extraction module is generated based on the training module to extract the data features and input them into the decision tree module to obtain the nearest neighbor value, the nearest neighbor module is used to find the nearest neighbor domain, and finally, the classification module outputs the prediction result.
[0063] The beneficial effects of the present invention are as follows. The present invention uses an autoencoder network to process image samples, compress the features of the samples, and extract the low-dimensional features and structures of the samples as much as possible; during the training process of the autoencoder network, continuously find the nearest neighbor numbers of samples that satisfy a given distance according to the distance between the extracted low-dimensional feature vectors; use the nearest neighbor values of the samples and the extracted low-dimensional sample features to construct a decision tree, use the decision tree to obtain the nearest neighbor value of a new image sample with an unknown label, and use the nearest neighbor algorithm to determine the category to which the image belongs.
[0064] The method proposed by the present invention can obtain the low-dimensional feature information of the target and predict the category of the sample, and the prediction result has interpretability. Description of the Drawings
[0065] Figure 1Flowchart of an image classification method using an autoencoder and a decision tree according to the present invention;
[0066] Figure 2 Schematic diagram generated by the decision tree. Detailed implementation
[0067] As Figure 1 shown, an image classification method based on an autoencoder and a decision tree in this embodiment includes:
[0068] S101. Collect data, obtain the original RGB image data, and convert the image samples into a pixel information matrix / vector.
[0069] S102. Input the collected image data into the autoencoder, use a feedforward neural network, perform representation learning on the image samples through the encoder and decoder, and extract the low-dimensional structural feature information of the image samples using the encoder part.
[0070] The loss function of the corresponding autoencoder network without constraints is:
[0071] X = (x1, x2,..., x n )
[0072]
[0073]
[0074] where X is the input sample vector, x i is the i-th feature of the input sample vector X, n is the dimension of the input vector (in an image sample of size 28 pixels × 28 pixels, the dimension n of the corresponding input sample vector = 784), is the output reconstructed sample vector, is the i-th feature of the reconstructed sample vector J ave (W, b) is the loss function of the autoencoder network without constraints, used to measure the average difference between the reconstructed sample and the original sample X, and W, b are the weights and biases of the autoencoder network respectively.
[0075] The loss function of the autoencoder network with the hidden layer output plus the sparse constraint is:
[0076]
[0077]
[0078]
[0079] where is the average activation of the hidden layer neurons in the autoencoder network, n is the dimension of the input vector, x j is the jth feature of the input sample vector, a i (x j ) is the input of the i-th neuron x j The activation value under is the relative entropy, which is a penalty factor to measure the difference between the two distributions, h is the number of neurons in the hidden layer, ρ is the sparsity parameter, γ is the KL divergence constraint parameter, and J sparse (W,b) is the sparse loss function of the autoencoder network;
[0080] Add similarity constraints to the sparse autoencoder neural network:
[0081]
[0082] Among them, J re (W, b) is the loss function of the autoencoder network with sparsity constraints and similarity constraints, μ is the similarity parameter, n is the dimension of the input vector, To reconstruct the i-th feature of the sample vector, it is used as a restriction to increase the difference between samples as much as possible.
[0083] S103, in the iterative process of solving the optimal weight parameters of the network, calculating the distance between image samples based on the low-dimensional sample vector obtained by the encoder, and updating the nearest neighbor value corresponding to each image sample under the constraint of the nearest neighbor distance;
[0084] The corresponding distance calculation formula is expressed as:
[0085] X i ′=h1(X i )=σ1(W1X i +b1)
[0086] X i ″=h2(X i ′)=σ2(W2X i ′+b2)
[0087]
[0088] Among them, W1 and W2 are the weights of the first hidden layer h1 and the second hidden layer h2 in the encoder network, b1 and b2 are the corresponding bias terms, σ1 and σ2 are the output functions corresponding to the network hidden layers h1 and h2, and X i ′ represents the i-th input sample X i The vector after the hidden layer h1, X i ″ is represented by X i ′The vector after the hidden layer h2, D(Xi ″, X j ″) is the extracted low-dimensional sample vector X i ″ and X j ″ is the Euclidean distance between them, m is the dimension of the low-dimensional feature vector X″, x i ′ s ′ is the s-th feature of the sample vector X i ″, x′ j ′ s is the s-th feature of the sample vector X j ″. The distance parameter α between samples determines the nearest neighbor distance of other samples from the farthest sample. When the distance from this sample is greater than α, that is, D(X i ″, X j ″) > α, it cannot be a nearest neighbor of this sample. Based on this distance parameter, the nearest neighbor value of the i-th sample is represented as the number of samples with a distance less than α between all samples.
[0089] S104. Based on the encoder in the trained autoencoder network model, extract the low-dimensional feature information of the samples, combine the obtained nearest neighbor values of the samples through iteration as the corresponding sample labels, and use the CART method to construct a decision tree model;
[0090] The calculation method of the corresponding Gini index is expressed as;
[0091]
[0092]
[0093] Among them, Gini(B) represents the purity of the sample set B in the decision tree, v i represents the proportion of the i-th (i = 1,..., C) class samples in the sample set B, Gini(B, q) represents the Gini index of the attribute q, T represents the number of values of the attribute q = {q 1 , q 2 ,..., q T}, and B t represents the sample set of all values of q t at the t-th branch node.
[0094] The corresponding mode fine-tuning includes:
[0095] For the test sample X z First, generate a new verification sample X z ″ through the generated autoencoder neural network, and then obtain the corresponding nearest neighbor value K z .
[0096] Calculate the distance between samples:
[0097]
[0098] Among them, D(X z ″, X i ″) represents the Euclidean distance between two samples, m is the dimension of the low-dimensional feature vector X″, and x′ z ′ s represents the s-th feature of the sample vector X z ″; x i ′ s ′ is the s-th feature of the sample vector X i ″.
[0099] Then, the corresponding nearest neighbor sample set in the training set is searched through the KNN algorithm, and the samples are classified using the labels of the nearest neighbor sample set. If the classification effect is excellent, that is, the classification accuracy reaches 85% or above, the generated network model and decision tree are retained; otherwise, the parameters of the autoencoder neural network are adjusted to achieve a better classification effect.
[0100] S105. Obtain the low-dimensional feature information of the new sample using the autoencoder and input it into the decision tree to obtain the nearest neighbor value. Search for the corresponding nearest neighbor through KNN, and use the category with the largest number in the nearest neighbor neighborhood as the prediction result;
[0101] The corresponding search for the nearest neighbor neighborhood of the training sample is expressed as:
[0102] Z = (z1, z2,..., z n )
[0103]
[0104] N Kz = {X K1 , X K2 ,..., X Kz | D(Z″, X i ″) < α, K z = 1,..., 10}
[0105]
[0106] Among them, Z is the training sample, z i is the i-th feature of Z, Z″ is the low-dimensional feature vector extracted by the autoencoder, z i ″ is the i-th feature of the low-dimensional feature vector Z″, D(Z″, X i ″) is the Euclidean distance metric, m is the dimension of the low-dimensional feature vectors X″ and Z″, K z is the optimal nearest neighbor value corresponding to the training sample output by the decision tree, is the set of nearest neighbor samples of the training sample, α is the distance parameter, is The corresponding i-th nearest neighbor sample, p i is the set of nearest neighbor samples The probability that the corresponding label in appears, P z is the predicted label of the training sample Z, and C is the number of label categories of the sample.
[0107] A system for implementing an image classification method based on an autoencoder and a decision tree in this embodiment includes an image input conversion module, a training module, a feature extraction module, a nearest neighbor module, a decision tree module, and a classification module; the image input conversion module is connected to the training module, the training module is connected to the feature extraction module, the feature extraction module is connected to the decision tree module, the decision tree module is connected to the nearest neighbor module, and the nearest neighbor module is connected to the classification module.
[0108] The image input conversion module of this system is used to collect image sample data, obtain the original RGB image data, and obtain the matrix / vector of the pixel information of the image sample.
[0109] The training module of this system inputs the collected image data into the autoencoder, uses a feedforward neural network, and solves the weight parameters of the autoencoder network through the backpropagation algorithm.
[0110] The feature extraction module of this system uses the autoencoder network model to learn the characterization information of the image sample, and extracts the typical feature information of the image sample based on the encoder.
[0111] The nearest neighbor module of this system, during the iterative process of solving the optimal weight parameters of the network, calculates the distance between image samples based on the corresponding encoder output results, and simultaneously updates the corresponding nearest neighbor values of each image sample under the constraint of the nearest neighbor distance.
[0112] The decision tree module of this system extracts the compressed feature information of the sample based on the encoder in the trained autoencoder network model, constructs a decision tree by combining the optimal nearest neighbor number of each sample as the label, and constructs based on the CART method.
[0113] The classification module of this system compresses the sample feature information using the autoencoder and inputs it into the decision tree, obtains its corresponding optimal nearest neighbor value, finds its corresponding nearest neighbor domain, and uses the category with the largest number in the nearest neighbor domain in KNN as the prediction result.
[0114] This embodiment uses an autoencoder network to process image samples, compress the features of the samples, and extract the low-dimensional features and structure of the samples as much as possible; during the training process of the autoencoder network, the number of neighbors of the samples that meet a given distance is continuously searched based on the distance between the extracted low-dimensional feature vectors; the nearest neighbor values of the samples and the extracted low-dimensional sample features are used to construct a decision tree, the decision tree is used to obtain the nearest neighbor values of new image samples with unknown labels, and the nearest neighbor algorithm is used to determine the category to which the image should belong.
[0115] The technical principles of the present invention have been described above in conjunction with specific embodiments. These descriptions are intended solely to illustrate the principles of the present invention and are not to be construed in any way as limiting the scope of protection of the present invention. Based on the explanations herein, those skilled in the art will be able to devise other specific embodiments of the present invention without inventive effort, and such embodiments will fall within the scope of protection of the present invention.
Claims
1. An image classification method based on an autoencoder and a decision tree, characterized in that, The method includes the following steps: (1) Collect data, obtain the original RGB image data, and convert the image samples into a pixel information matrix / vector; (2) Input the collected image data into the autoencoder, use the feedforward neural network, perform the representation learning of the autoencoder on the image samples through the encoder and decoder, and use the encoder part to extract the low-dimensional structural feature information of the image samples; construct a network according to the sample image data, add sparsity constraints and correlation constraints to the loss function of the network, and update the weight parameters of the autoencoder network in an iterative manner; (3) In the iterative process of solving the optimal weight parameters of the network, calculate the distance between image samples based on the low-dimensional sample vectors obtained by the encoder, and update the nearest neighbor value corresponding to each image sample under the constraint of the nearest neighbor distance; (4) Based on the encoder in the trained autoencoder network model, extract the low-dimensional feature information of the samples, combine the obtained nearest neighbor values of the samples through iteration as the corresponding sample labels, use the CART method to construct a decision tree with the nearest neighbor values as leaf nodes, and at the same time adjust the parameters of the autoencoder network; (5) Use the autoencoder to obtain the low-dimensional feature information of the new samples and input them into the decision tree to obtain the nearest neighbor values, search for the nearest neighbor neighborhood of the training samples through KNN, and take the category with the largest number in the nearest neighbor neighborhood as the prediction result.
2. The image classification method based on an autoencoder and a decision tree according to claim 1, wherein The representation learning steps of the autoencoder include: Construct a network according to the sample image data, add sparsity constraints and correlation constraints to the loss function of the network. The loss function of the autoencoder network without constraints is: X = (x1, x2,..., x n ) Among them, X is the input sample vector; x i is the i-th feature of the input sample vector X; n is the dimension of the input vector. In an image sample of size 28 pixels × 28 pixels, the dimension n of the corresponding input sample vector is 784; is the output reconstructed sample vector; is the i-th feature of the reconstructed sample vector ; J ave (W, b) is the unconstrained loss function of the autoencoder network, used to measure the average difference between the reconstructed sample and the original sample X; W and b are the weights and biases of the autoencoder network respectively; The loss function of the autoencoder network after adding a sparsity constraint to the output of the hidden layer of the autoencoder network is: Among them, is the average activation degree of neurons in the hidden layer of the autoencoder network; n is the dimension of the input vector; x j is the j-th feature of the input sample vector; a i (x j ) is the activation value of the i-th neuron for the input x j ; is the relative entropy, used as a penalty factor for measuring the difference between two distributions; h is the number of neurons in the hidden layer; ρ is the sparsity parameter; γ is the KL divergence constraint parameter; J sparse (W, b) is the sparse loss function of the autoencoder network; is the average activation degree of neurons in the hidden layer; The loss function of the autoencoder network after adding a similarity constraint to the sparse autoencoder neural network: Among them, J re (W, b) is the loss function of the autoencoder network with sparsity constraint and similarity constraint added. μ is the similarity parameter, and n is the dimension of the input vector. is the i-th feature of the reconstructed sample vector, which is used as a constraint to increase the differences between samples as much as possible. The weight parameters of the autoencoder network are updated in an iterative manner. The iteration of the autoencoder neural network uses the quasi-Newton method L-BFGS, and the maximum number of iterations is set to 300.
3. A method for image classification based on an autoencoder and a decision tree according to claim 1, characterized in that, The calculation of the distance between image samples includes: (1) Update the nearest neighbor value of the sample at each step of the iteration of the autoencoder network. Preset the distance parameter between samples and the maximum and minimum nearest neighbor value limits before training; under this limit, the minimum nearest neighbor value of the sample is 1, and the maximum nearest neighbor value is 10. That is, if the nearest neighbor value of the sample is 0, it is corrected to 1, and if the nearest neighbor value of the sample is greater than 10, it is corrected to 10; In the iterative calculation process, from the updated weight W and bias term b, a new sample vector after extracting the low-dimensional features can be obtained; the distance calculation of the compressed feature vector of the sample after passing through the autoencoder neural network with two hidden layers is as follows: X i ′ = h1(X i ) = σ1(W1X i + b1) X i ″ = h2(X i ′) = σ2(W2X i ′ + b2) Among them, W1 and W2 are the weights of the first hidden layer h1 and the second hidden layer h2 in the encoder network respectively; b1 and b2 are the corresponding bias terms; σ1 and σ2 are the output functions corresponding to the hidden layers h1 and h2 of the network; X i ′ represents the vector of the i-th input sample X i after passing through the hidden layer h1; X i ″ represents the vector of X i ′ after passing through the hidden layer h2; D(X i ″, X j ″) is the extracted low-dimensional sample vector X i ″ and X j ″ The Euclidean distance between them; m is the dimension of the low-dimensional feature vector X″; x i ′ s ′ is the s-th feature of the sample vector X i ″; x′ j ′ s is the s-th feature of the sample vector X j ″; The distance parameter α between samples determines the distance of the nearest neighbor of other samples from the farthest sample. When the distance from this sample is greater than α, that is, D(X i ″, X j ″) > α, then it cannot be the nearest neighbor of this sample; Based on this distance parameter, the nearest neighbor value of the i-th sample is expressed as the number of samples with a distance less than α between all samples; (2) The autoencoder neural network is set with two hidden layers. For the sample data with an input of 784×1, the size of the first hidden layer d1 is set to 196×1, and the size of the second hidden layer d2 is set to 20×1; (3) Initialize the parameters of the network. The initial value of the weight parameters of the autoencoder network is set to 0, the sparsity parameter ρ is set to 0.05, the coefficient γ of the sparsity penalty factor is set to 0.5, and the parameter μ of the similarity constraint is set to 3e^-3.
4. A method for image classification based on an autoencoder and a decision tree according to claim 1, characterized in that, The construction of a decision tree with the nearest neighbor value as the leaf node is as follows: Use the final output X″ after the iteration of the autoencoder as the sample vector for constructing the decision tree, and use the nearest neighbor number of each sample obtained by iteration as the new label of the sample; The generation of the decision tree adopts the CART algorithm, and a full binary tree is generated. The calculation method of the Gini index is as follows; Among them, Gini(B) represents the purity of the sample set B in the decision tree; v i represents the proportion of samples of the i-th (i = 1,..., C) class in the sample set B; Gini(B, q) represents the Gini index of the attribute q; T represents the number of values that the attribute q = {q 1 , q 2 ,..., q T} can take; B t represents the sample set with all values being q t at the t-th branch node.
5. A method for image classification based on an autoencoder and a decision tree according to claim 1, characterized in that, Adjust the parameters of the autoencoder network, including: Test sample X z First, generate a new verification sample vector X through the generated autoencoder neural network z ″, and then obtain the corresponding nearest neighbor value K through the constructed CART decision tree z ; Calculate the distance between samples: where D(X z ″, X i ″) represents the Euclidean distance between two samples, m is the dimension of the low-dimensional feature vector X″, x′ z ′ s represents the s-th feature of the sample vector X z ″; x i ′ s ′ represents the s-th feature of the sample vector X i ″. Then search for the corresponding nearest neighbor sample set in the training set through the KNN algorithm, and classify the samples using the labels of the nearest neighbor sample set; if the classification effect is excellent, that is, the classification accuracy reaches 85% or above, then retain the generated network model and decision tree.
6. The image classification method based on an autoencoder and a decision tree according to claim 1, characterized in that, Search for the nearest neighbor domain of the training samples as follows: Z = (z1, z2,..., z n ) Among them, Z is the training sample; z i is the i-th feature of Z; Z″ is the low-dimensional feature vector extracted by the autoencoder; z i ″ is the i-th feature of the low-dimensional feature vector Z″; D(Z″, X i ″) is the Euclidean distance metric; m is the dimension of the low-dimensional feature vectors X″ and Z″; K z is the optimal nearest neighbor value corresponding to the training sample output by the decision tree; is the set of nearest neighbor samples of the training sample; α is the distance parameter; is the i-th nearest neighbor sample corresponding to; p i is the probability that the corresponding label appears in the set of nearest neighbor samples ; P z is the predicted label of the training sample Z; C is the number of label categories of the sample.
7. A system for implementing an image classification method based on an autoencoder and a decision tree according to any one of claims 1-6, characterized in that, The system includes an image input conversion module, a training module, a feature extraction module, a nearest neighbor module, a decision tree module, and a classification module: The image input conversion module is used to collect image sample data, obtain the original RGB image data, and obtain the matrix / vector of the pixel information of the image sample; The training module inputs the collected image data into the autoencoder, uses a feedforward neural network, and solves the weight parameters of the autoencoder network through the backpropagation algorithm; The feature extraction module uses the autoencoder network model to learn the representation information of the image samples, and extracts the typical feature information of the image samples based on the encoder; The nearest neighbor module calculates the distance between image samples based on the output result of the corresponding encoder during the iteration of solving the optimal weight parameters of the network, and updates the nearest neighbor value corresponding to each image sample under the constraint of the nearest neighbor distance; The decision tree module extracts the compressed feature information of the samples based on the encoder in the trained autoencoder network model, constructs a decision tree by combining the optimal nearest neighbor numbers of each sample as labels, and constructs it based on the CART method; The classification module compresses the sample feature information using the autoencoder and inputs it into the decision tree, obtains its corresponding optimal nearest neighbor value, searches for its corresponding nearest neighbor domain, and uses the category with the largest number in the nearest neighbor domain in KNN as the prediction result; In the system of an image classification method based on an autoencoder and a decision tree, first use the image input conversion module to process the data, then use the training module to train the data, generate the feature extraction module based on the training module to extract the data features and input them into the decision tree module to obtain the nearest neighbor value, use the nearest neighbor module to search for the nearest neighbor domain, and finally use the classification module to output the prediction result.
Citation Information
Patent Citations
Method and system for finger vein anti-counterfeiting discriminating based on autoencoder
CN107832718A
Small sample photovoltaic hot spot identification method based on deep stack type hybrid self-encoding network
CN113610159A