An image data compression method based on improved sparrow search algorithm to optimize CAEN
By improving the sparrow search algorithm to optimize the hyperparameters of the CAEN network, the problem of time-consuming and labor-intensive hyperparameter tuning in traditional methods is solved, and the image data compression recognition accuracy and data reconstruction degree are achieved.
Patent Information
- Application Number
- CN202211100719.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-09-09
AI Technical Summary
When optimizing the hyperparameters of the convolutional autoencoding network (CAEN), the prior art requires a lot of manpower to tune and it is difficult to find the optimal solution, resulting in limited model performance.
The improved sparrow search algorithm (CMASSA) is used to combine the chaotic mutation adaptive sparrow search algorithm to optimize the hyperparameters of the CAEN network through real-number coding and adaptive population adjustment strategies.
It improves the recognition accuracy and data reconstruction of the CAEN network in image data compression, balances the global search capability and local optimization capability, and significantly improves the model performance.
Smart Images

Figure CN115880380B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image data compression in edge computing, and in particular to an image data compression method based on optimizing CAEN with an improved sparrow search algorithm. Background Art
[0002] While realizing the Internet of Everything, sensor nodes will collect massive amounts of image data, which not only has a lot of redundancy, but also takes up a lot of communication bandwidth resources during transmission. If the data is compressed in advance on the edge server close to the data source, it can not only improve the data transmission efficiency, but also enable more flexible data processing in the cloud service center.
[0003] Deep learning has achieved good results in the field of data compression, especially when the amount of data is large, it is better than traditional machine learning methods. Convolutional Auto-Encoder Network (CAEN) is a deep neural network that learns in an unsupervised manner and performs effective data encoding. The hyperparameters of the network have a huge impact on the quality of the final model. The setting of traditional hyperparameters usually takes a lot of manpower to tune, and it is difficult to find the optimal solution. In recent years, many researchers have been looking for suitable methods to obtain the optimal network hyperparameters in order to improve model performance. Summary of the invention
[0004] The object of the present invention is to provide an image data compression method, which is implemented based on a chaotic mutation adaptive sparrow search algorithm (CMASSA), real-number encoding of hyperparameters, and image data compression in an optimal CAEN network.
[0005] To achieve the above objectives, the present application proposes an image data compression method based on an improved sparrow search algorithm to optimize CAEN, comprising:
[0006] Step 1: Build the basic CAEN network structure, determine the range of parameters such as the size and number of convolution kernels in the network, and set the initial upper and lower limits of the space where the sparrow population is located, the number of sparrow populations N, the maximum ratio coefficient r between discoverers and followers, and the maximum number of iterations T according to the parameter range. max , position dimension and other basic parameters, and input the training set and test set of the image data to be compressed into the basic CAEN network;
[0007] Step 2: Use real number coding to encode the hyperparameters of the basic CAEN network, such as the kernel size of the convolution layer, the kernel size of the pooling layer, and the ratio of loss neurons in the Dropout layer;
[0008] Step 3: Using the code as the sparrow individual of the CMASA algorithm, the hyperparameters of the basic CAEN network are initialized chaotically;
[0009] Step 4: The initialized hyperparameters are input into the basic CAEN network for compression and reconstruction. According to the error rate Loss and data reconstruction rate of the CAEN network classification task, the initial fitness of each sparrow individual is obtained by using the initialized hyperparameters, and the hyperparameters corresponding to the current best and worst sparrow individuals are recorded.
[0010] Step 5: Get the number of discoverers and followers, and adjust the optimal hyperparameters and the remaining hyperparameter ratios in the sparrow population Where t is the current iteration number, k is a random number in [0,1); pNum = r·N discoverers, sNum = (1-r)·N followers, the population size is adjusted adaptively, and the pNum sparrow individuals with the best fitness value in the current iteration cycle are selected as discoverers, and the remaining sNum sparrow individuals are selected as followers; according to the network hyperparameter X corresponding to the discoverer i The network hyperparameters X corresponding to the position and followers i Update the individual position of the sparrow and obtain the fitness values of the discoverer and the follower;
[0011] Step 6: Randomly select 20% of the hyperparameters in the current sparrow population as alerters, update the sparrow position, and obtain the fitness value of the sparrow;
[0012] Step 7: After an iteration cycle is completed, the hyperparameters corresponding to the optimal sparrow individual in this cycle are stored;
[0013] Step 8: Repeat steps 4-7. After reaching the maximum number of iterations, output and store the optimal hyperparameters.
[0014] Step 9: Input the optimal hyperparameters into the reconstructed CAEN network to obtain the optimal CAEN network structure, and perform image data compression using the optimal CAEN network structure.
[0015] Furthermore, the hyperparameters of the basic CAEN network are initialized chaotically, specifically:
[0016]
[0017] in, is the jth parameter of the i-th sparrow of the CAEN network hyperparameter at the t-th iteration after encoding;
[0018] Furthermore, the error rate is Among them, TP, FP, TN, and FN represent the number of true positive, false positive, true negative, and false negative samples, respectively.
[0019] Furthermore, the data reconstruction degree where x i ,y i They are the image data vectors before and after compression respectively.
[0020] Furthermore, the initial fitness of the individual sparrow is Fitness=a·Loss+b·Rate, wherein a and b are constants, and a+b=1.
[0021] Furthermore, the corresponding network hyperparameter X i The location is:
[0022]
[0023] The network hyperparameters X corresponding to the followers i The location is:
[0024]
[0025] Among them, α is a random number that obeys uniform distribution in (0,1); Q is a random number that obeys normal distribution in [0,1); L is a one-dimensional vector with a length of d and all elements are 1; AT and ST represent the safety value and warning value respectively, where AT is a random number in [0,1), and ST is the warning value. Once AT is greater than ST, the sparrow individual will update its individual position to other safer places according to the pace of normal distribution; Indicates the global worst position in the current iteration; X P The best position currently occupied by the discoverer; A + =A T (AA T ) -1 , A is a one-dimensional vector with a length of d and all elements are 1 or -1.
[0026] Furthermore, the method for updating the sparrow position in step 6 is:
[0027]
[0028] Among them, f i is the fitness value of the current sparrow individual; f g is the optimal individual fitness value of the sparrow in this iteration; f w is the worst individual sparrow fitness value in this iteration; is the global optimal position in this iteration; β is a set of random numbers with a length of d, a mean of 0, a variance of 1, and a normal distribution in the range [0,1); K is a random number in the interval [-1,1]; ε is a very small constant to prevent the current individual's fitness from being the worst global fitness value, resulting in the denominator being 0.
[0029] Compared with the prior art, the above technical scheme adopted by the present invention has the following advantages: the present invention adopts improved Circle chaotic mapping to initialize the individual population of sparrows to enhance the population diversity; introduces sine and cosine mutation operators into the sentinel formula to improve the search capability; and proposes an adaptive population adjustment strategy to balance the global search capability and local optimization capability of CMASASA; combines the CMASA algorithm with CAEN, proposes a new fitness function, and encodes the hyperparameters by real numbers, and finally obtains the optimal CAEN network, which has higher average recognition accuracy and data reconstruction degree under the same compression ratio. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 Schematic diagram of the CAEN structure;
[0031] Figure 2 A flow chart of the image data compression method based on the improved sparrow search algorithm to optimize CAEN;
[0032] Figure 3 This is a comparison chart of the original image and the compressed and reconstructed image;
[0033] Figure 4 It is a comparison chart of optimization results in the embodiments. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application, that is, the embodiments described are only part of the embodiments of the present application, not all of the embodiments.
[0035] like Figure 1 As shown in the figure, in order to prove the effectiveness of the present invention, the CAEN network structure is built using the Python deep learning library Kears framework, and the Multi-class Weather Dataset (MWD) of Shenzhen University is selected to test the network model performance output by CMASA-CAEN. MWD contains 65,000 images of 6 common categories, including sunny, cloudy, rainy, snowy, haze and thunderstorm weather. Each time the model is trained, 70% is randomly selected as the training set, and the remaining 30% is used as the training set.
[0036] like Figure 2 As shown, an image data compression method based on an improved sparrow search algorithm to optimize CAEN specifically includes:
[0037] Step 1: Use Python's deep learning library Kears framework to build the basic CAEN network structure, and determine the parameter ranges of the convolution kernel size and number in the network. According to the parameter range, set the initial upper and lower limits of the space where the sparrow population is located, the number of sparrow populations N, the maximum ratio coefficient r between discoverers and followers, and the maximum number of iterations T max , position dimension and other basic parameters, and input the training set and test set of the image data to be compressed into the basic CAEN network;
[0038] Step 2: Use real number coding to encode the hyperparameters of the basic CAEN network, such as the kernel size of the convolution layer, the kernel size of the pooling layer, and the ratio of loss neurons in the Dropout layer;
[0039] Step 3: Use the code obtained in step 2 as the sparrow individual of the CMASA algorithm to perform chaos initialization on the hyperparameters of the basic CAEN network:
[0040]
[0041] in, is the jth parameter of the i-th sparrow of the CAEN network hyperparameter at the t-th iteration after encoding;
[0042] Step 4: The initialized hyperparameters are input into the basic CAEN network for compression and reconstruction. According to the error rate Loss and data reconstruction rate of the CAEN network classification task, the initial fitness of each sparrow individual is obtained by using the initialized hyperparameters, and the hyperparameters corresponding to the current best and worst sparrow individuals are recorded.
[0043] Specifically, the error rate is Among them, TP, FP, TN, and FN represent the number of true positive, false positive, true negative, and false negative samples, respectively;
[0044] The data reconstruction where x i ,y i They are the image data vectors before and after compression respectively.
[0045] The initial fitness of the individual sparrow is Fitness=a·Loss+b·Rate, wherein a and b are constants, and a+b=1.
[0046] Step 5: Get the number of discoverers and followers, and adjust the optimal hyperparameters and the remaining hyperparameter ratios in the sparrow population Where t is the current iteration number, k is a random number in [0,1); pNum = r·N discoverers, sNum = (1-r)·N followers, the population size is adjusted adaptively, and the pNum sparrow individuals with the best fitness value in the current iteration cycle are selected as discoverers, and the remaining sNum sparrow individuals are selected as followers; according to the network hyperparameter X corresponding to the discoverer i The network hyperparameters X corresponding to the position and followers i Update the individual position of the sparrow and obtain the fitness values of the discoverer and the follower;
[0047] Specifically, the corresponding network hyperparameter X i The location is:
[0048]
[0049] The network hyperparameters X corresponding to the followers i The location is:
[0050]
[0051] Step 6: Randomly select 20% of the hyperparameters in the current sparrow population as alerters, update the sparrow position, and obtain the fitness value of the sparrow;
[0052] Specifically, the method for updating the sparrow position is:
[0053]
[0054] Step 7: After an iteration cycle is completed, the hyperparameters corresponding to the optimal sparrow individual in this cycle are stored;
[0055] Step 8: Repeat steps 4-7. After reaching the maximum number of iterations, output and store the optimal hyperparameters.
[0056] Step 9: Input the optimal hyperparameters into the reconstructed CAEN network to obtain the optimal CAEN network structure, and perform image data compression using the optimal CAEN network structure.
[0057] In this embodiment, the parameters can be: The initial parameters of the CMASA algorithm are shown in Table 1: The optimized CAEN network hyperparameter range is shown in Table 2:
[0058] Table 1 Initial parameters of CMASSA algorithm
[0059]
[0060] Table 2 Optimization range of some relevant parameters of CAEN network
[0061]
[0062] In the above CAEN network, since CCN and CDN are inverse processes, the parameters of the convolution layer of CCN and the deconvolution layer of CDN need to be set to be the same; the parameters of the pooling layer of CCN and the upsampling layer of CDN need to be set to be the same. The compression ratio can be controlled between 1 / 4 and 1 / 64 by setting the pooling layer hyperparameters.
[0063] The optimal network structure output by CMASSA-CAEN is shown in Table 3.
[0064] Table 3 The optimal hyperparameters of CMASSA-CAEN on the MWD dataset
[0065]
[0066] from Figure 3 It can be seen that the compressed and reconstructed image is well restored compared to the original image.
[0067] Table 4 shows the highest accuracy of each algorithm in optimizing the CAEN network on the MWD test set. Compared with other algorithms, the optimization effect of the CMASA-CAEN algorithm is significant, and the pooling kernel size of the pooling layer reflects the compression multiple. This shows that when the original data is compressed to 1 / 32 of the original, the proposed algorithm can still maintain a high accuracy.
[0068] Table 4 The highest classification accuracy of the optimized algorithm on the MWD dataset
[0069] Table 7 The highest classification accuracy of the optimization algorithm on the MWD dataset
[0070]
[0071] Figure 4 The trend chart of the classification accuracy of CAEN optimized by each algorithm under 20 epochs. It shows that the network model obtained by the CMASASA-CAEN training algorithm has a higher accuracy on the test set than other algorithms, so the performance of the CMASASA-CAEN algorithm is better than other algorithms. It can also be seen that at the beginning of training, the CAEN accuracy obtained by the CMASASA algorithm is significantly higher than that obtained by other algorithms, which proves that the network established by CMASASA-CAEN has stronger optimization ability and more stable performance.
[0072] In addition to classification accuracy, data reconstruction is also an important indicator to characterize the quality of CAEN network. The data reconstruction degree is obtained. As shown in Table 5, the data reconstruction degree of the CMASA-CAEN algorithm is significantly higher than that of other algorithms, reaching 99.41%, indicating that after being compressed to 1 / 32 of the data size, the data can still retain most of the information after recovery.
[0073] Table 5 Data reconstruction degree of the optimization algorithm in the MWD dataset
[0074]
[0075] The foregoing description of specific exemplary embodiments of the present invention is for the purpose of illustration and demonstration. These descriptions are not intended to limit the present invention to the precise form disclosed, and it is clear that many changes and variations can be made based on the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the present invention and its practical application, so that those skilled in the art can realize and utilize various different exemplary embodiments of the present invention and various different selections and changes. The scope of the present invention is intended to be limited by the claims and their equivalents.
Claims
1. An image data compression method based on an improved sparrow search algorithm to optimize CAEN, characterized in that: include: Step 1: Build the basic CAEN network structure, determine the parameter range of the size and number of convolution kernels in the network, and set the initial upper and lower limits of the space where the sparrow population is located, the number of sparrow populations N, the maximum ratio coefficient r between discoverers and followers, and the maximum number of iterations T according to the parameter range. max , position dimension, input the training set and test set of the image data to be compressed into the basic CAEN network; Step 2: Use real number coding to encode the hyperparameters of the convolutional layer kernel size, pooling layer kernel size, and Dropout layer loss neuron ratio of the basic CAEN network; Step 3: Using the code as the sparrow individual of the CMASA algorithm, the hyperparameters of the basic CAEN network are initialized chaotically; Step 4: The initialized hyperparameters are input into the basic CAEN network for compression and reconstruction. According to the error rate Loss and data reconstruction rate of the CAEN network classification task, the initial fitness of each sparrow individual is obtained by using the initialized hyperparameters, and the hyperparameters corresponding to the current best and worst sparrow individuals are recorded. Step 5: Get the number of discoverers and followers, and adjust the optimal hyperparameters and the remaining hyperparameter ratios in the sparrow population Where t is the current iteration number, k is a random number in [0,1); pNum = r·N discoverers, sNum = (1-r)·N followers, the population size is adjusted adaptively, and the pNum sparrow individuals with the best fitness value in the current iteration cycle are selected as discoverers, and the remaining sNum sparrow individuals are selected as followers; according to the network hyperparameter X corresponding to the discoverer i The network hyperparameters X corresponding to the position and followers i Update the individual position of the sparrow and obtain the fitness values of the discoverer and the follower; Step 6: Randomly select 20% of the hyperparameters in the current sparrow population as alerters, update the sparrow position, and obtain the fitness value of the sparrow; Step 7: After an iteration cycle is completed, the hyperparameters corresponding to the optimal sparrow individual in this cycle are stored; Step 8: Repeat steps 4-7. After reaching the maximum number of iterations, output and store the optimal hyperparameters. Step 9: Input the optimal hyperparameters into the reconstructed CAEN network to obtain the optimal CAEN network structure, and perform image data compression using the optimal CAEN network structure.
2. According to claim 1, the image data compression method based on the improved sparrow search algorithm to optimize CAEN is characterized in that: The hyperparameters of the basic CAEN network are initialized chaotically, specifically: in, is the jth parameter of the i-th sparrow in the t-th iteration of the CAEN network hyperparameter after encoding.
3. According to claim 1, the image data compression method based on the improved sparrow search algorithm to optimize CAEN is characterized in that: The error rate is Among them, TP, FP, TN, and FN represent the number of true positive, false positive, true negative, and false negative samples, respectively.
4. According to claim 1, the image data compression method based on the improved sparrow search algorithm to optimize CAEN is characterized in that: The data reconstruction where x i ,y i They are the image data vectors before and after compression respectively.
5. The image data compression method based on the improved sparrow search algorithm and CAEN optimization according to claim 3 or 4, characterized in that: The initial fitness of the individual sparrow is Fitness=a·Loss+b·Rate, wherein a and b are constants, and a+b=1.
6. According to claim 1, the image data compression method based on the improved sparrow search algorithm to optimize CAEN is characterized in that: The corresponding network hyperparameter X i The location is: The network hyperparameters X corresponding to the followers i The location is: Among them, α is a random number that obeys uniform distribution in (0,1); Q is a random number that obeys normal distribution in [0,1); L is a one-dimensional vector with a length of d and all elements are 1; AT and ST represent the safety value and warning value respectively, where AT is a random number in [0,1), and ST is the warning value. Once AT is greater than ST, the sparrow individual will update its individual position to other safer places according to the pace of normal distribution; Indicates the global worst position in the current iteration; X P The best position currently occupied by the discoverer; A + =A T (AA T ) -1 , A is a one-dimensional vector with a length of d and all elements are 1 or -1.
7. According to claim 1, the image data compression method based on the improved sparrow search algorithm to optimize CAEN is characterized in that: The way to update the sparrow position in step 6 is: Among them, f i is the fitness value of the current sparrow individual; f g is the optimal individual fitness value of the sparrow in this iteration; f w is the worst individual sparrow fitness value in this iteration; is the global optimal position in this iteration; β is a set of random numbers with a length of d, a mean of 0, a variance of 1, and a normal distribution in the range [0,1); K is a random number in the interval [-1,1]; ε is a very small constant.
Citation Information
Patent Citations
Vulnerability detection method and system based on deep learning model compression, and mobile device
CN113076544A
Stainless steel weld defect detection method based on multi-domain expression data enhancement and model self-optimization
CN113129266A