Convolutional neural network-based portable electronic nose for beer identification
By adopting a vertical annular gas sensor array and channel attention mechanism in portable electronic nose combined with a cosine annealing thermal restart strategy, the portability and cost problems of traditional beer recognition methods are solved, and efficient and accurate beer recognition is achieved.
Patent Information
- Application Number
- CN202411709071.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-21
AI Technical Summary
Traditional beer recognition methods rely on expensive instruments and complex laboratory equipment, making it difficult to achieve portability and low-cost beer recognition, and fixed-weight convolutional neural networks are easily trapped in local optimal solutions during training.
A portable electronic nose based on a convolutional neural network is designed, using a vertical annular gas sensor array and preprocessing module, a two-dimensional convolutional neural network model CC-2DCNN, which combines the channel attention mechanism and a cosine annealing thermal restart strategy, for rapid and accurate identification of beer.
It realizes portable and low-cost beer recognition, improves the practical application and recognition accuracy of the system, avoids the trap of local optimal solutions, and enhances the robustness and reliability of the model.
Smart Images

Figure CN119667082A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of electronic noses, and in particular to a portable electronic nose based on a convolutional neural network for beer identification. Background Art
[0002] Beer is the most popular alcoholic beverage in the world, and its total production and per capita consumption are increasing every year in European, Asian and North American countries. With the expansion of the market and the diversification of consumer demand, the importance of beer identification has become increasingly prominent. Therefore, a strict beer quality control system has been established to ensure that every bottle of beer purchased by consumers meets the quality standards of the brand, and provides important support for anti-counterfeiting and combating counterfeit products, protecting brand rights and consumer interests.
[0003] Traditional beer identification methods rely on dedicated equipment, and the main current identification methods include gas chromatography, gas chromatography-mass spectrometry, and high-performance liquid chromatography. However, although these methods are able to identify and analyze beer samples, they usually require sample pretreatment and separate qualitative and quantitative analysis of each compound. This limitation limits their ability to fully capture the overall aroma characteristics of beer. In addition, these methods usually rely on expensive instruments, take up a lot of laboratory space, and require specially trained personnel to spend a lot of time to obtain analytical results.
[0004] To address these issues, more and more researchers are committed to developing a variety of portable, low-cost, responsive and easy-to-operate electronic noses (E-noses) combined with pattern recognition algorithms to comprehensively identify beer and other foods. Sun et al. used an E-nose combined with a deep learning method to accurately track the geographical origin of soybeans and improve the quality control of soybean production. Voss et al. used an E-nose and four regression methods to quickly and accurately detect the alcohol content of beer to verify the product quality during beer production. Viejo et al. developed a portable E-nose that combined a machine learning model to predict beer aroma and used two artificial neural network (ANN) models to predict the peak area of volatile compounds and the intensity of sensory descriptions. It is worth mentioning that pattern recognition algorithms play a vital role in the development and application of E-nose, which enables E-nose to classify, identify and analyze various odors by extracting key features from complex odor information. With the rapid development of deep neural networks, two-dimensional convolutional neural networks (2DCNNs) have become one of the most attractive pattern recognition algorithms because they can effectively capture local spatial features through convolutional layers and gradually integrate them into more abstract and distinguishable global representations. For example, Qi et al. used the ability of 2DCNN to automatically perform feature generation and selection, simplify the data processing process and conduct classification experiments on Chinese liquor. Shi et al. combined 2DCNN with support vector machine (SVM) to identify the aroma information of beer, in which an improved particle swarm optimization (PSO) method was applied to optimize the important parameters of SVM.
[0005] Disadvantages of existing technologies: However, the fixed weights of traditional 2DCNNs mean that all channels pay the same attention to features in the task, so it is impossible to distinguish the importance of each channel. In addition, traditional 2DCNNs use a fixed learning rate during training, which can easily lead to slow convergence and tend to fall into local optimal solutions or potential gradient vanishing and explosion problems.
[0006] In addition to effective pattern recognition algorithms, electronic noses are also required to be portable in practical applications. The sensors of traditional electronic noses are usually arranged on the same plane to form a planar sensor array structure, which makes the sensors close to each other and prone to cross-interference. This means that the odor detected by one sensor may affect the measurements of other sensors. In addition, some sensors may be more sensitive to the source of the odor, while other sensors may miss certain components, thus hindering the uniform perception of the odor distribution. In addition, traditional planar electronic noses usually rely on auxiliary equipment such as static chambers, dynamic chambers or air pumps for data collection, which makes them perform poorly in field applications. Summary of the invention
[0007] The invention provides a portable electronic nose based on a convolutional neural network for beer identification, which can quickly and accurately complete the beer identification task.
[0008] To achieve the above-mentioned purpose, the present invention provides a portable electronic nose based on a convolutional neural network for beer identification, the key of which is: a vertical annular gas sensor array is provided, the gas sensor array is connected to a preprocessing module via an ADC analog-to-digital converter, and the preprocessing module is connected to a beer identification module;
[0009] The gas sensor array is used to collect beer gas signals and transmit them to the pre-processing module;
[0010] The preprocessing module is used to perform preprocessing operations on the beer gas signal, and then transmit the preprocessed beer gas data to the beer identification module;
[0011] The beer recognition module is a two-dimensional convolutional neural network model CC-2DCNN based on a channel attention mechanism and a cosine annealing hot restart strategy, which is used to perform beer recognition based on beer gas data and output beer recognition results.
[0012] Through the above design, the gas sensors in the electronic nose are arranged vertically, which overcomes the limitation of the traditional planar electronic nose that relies on large static gas chambers or ventilation dynamic gas chamber equipment, and significantly improves the practical applicability of the system; at the same time, the vertical ring structure design of the gas sensor array reduces the cross-interference between gas sensors, so that the diffused volatiles are evenly distributed on the surface of each gas sensor;
[0013] The two-dimensional convolutional neural network CC-2DCNN based on the channel attention mechanism and cosine annealing hot restart strategy is deployed in the electronic nose as a beer recognition module to identify beer. Among them, the channel attention mechanism enhances the learning and weight differentiation capabilities of key features, while the cosine annealing hot restart strategy dynamically adjusts the learning rate to avoid falling into the local optimum during training, thereby improving the robustness and accuracy of the model.
[0014] Preferably, the gas sensor array is provided with at least 3 gas sensors, each of which is provided on a rectangular circuit board, all rectangular circuit boards are vertically provided on the main circuit board, and are sequentially connected end to end to form a ring structure, and the detection heads of all gas sensors are located in the ring structure;
[0015] A sampling port corresponding to the gas sensor array is provided on the main circuit board, and the sampling port is located in the center of the annular structure. A culture dish for holding beer samples is provided directly below the sampling port, and the culture dish is close to the sampling port.
[0016] An acrylic chamber is also installed on the main circuit board, and the acrylic chamber covers the gas sensor array.
[0017] Through the above design, the gas sensor array is composed of multiple gas sensors of different types, which effectively increases the detection range of the gas sensor array; the rectangular circuit boards of multiple gas sensors of different types are vertically inserted into the main circuit board to form a vertical annular sensor array, which effectively reduces the cross-interference between the sensors and makes the diffused volatiles evenly distributed on the surface of each sensor.
[0018] Preferably, the preprocessing module converts the beer gas signal read by the ADC analog-to-digital converter into a relative response value, and intercepts the relative response value within a set continuous time period as beer gas data and transmits it to the beer identification module;
[0019] The expression for the relative response value conversion is as follows:
[0020]
[0021] Among them, Response represents the relative response value; V Beer represents the current ADC reading of the gas sensor when exposed to the beer sample; V Air Represents the baseline ADC reading of the gas sensor.
[0022] By converting the raw ADC readings into relative response values, the baseline drift of the gas sensor can be eliminated, thereby reducing the stability differences between different gas sensors.
[0023] Preferably, the set continuous time period is within 40 seconds from when the gas sensor is just exposed to the beer sample, that is, when the beer sample is just added.
[0024] The sampling data within 40 seconds from the time the beer sample is added is intercepted as the input data of the beer recognition module. This data not only includes the moment when the sample is added, but also includes the upward trend of the curve and other rich data features.
[0025] Through the above design, each sample only uses 40 seconds of data for training, which not only reduces memory usage and speeds up recognition, but also ensures high accuracy of beer recognition results.
[0026] Preferably, the beer recognition module is provided with an input layer, a first convolution block, a second convolution block, an extension layer, a discard layer, a fully connected layer and an output layer which are connected in sequence, and a SoftMax activation function is built into the output end of the fully connected layer;
[0027] The first convolution block is provided with a first two-dimensional convolution layer, a channel attention module and a first maximum pooling layer connected in sequence;
[0028] The second convolution block is provided with a second two-dimensional convolution layer and a second maximum pooling layer connected in sequence;
[0029] The output ends of the first two-dimensional convolutional layer and the second two-dimensional convolutional layer are both built-in with ReLU activation functions.
[0030] The first convolution block and the second convolution block are used to perform feature extraction operations on the beer gas data.
[0031] The extension layer is used to flatten the three-dimensional convolution data output by the second convolution block into a one-dimensional vector.
[0032] The dropout layer is used to prevent overfitting.
[0033] In the beer recognition module, the beer gas data is first processed by 2D convolution and ReLU activation function in the first convolution block to generate a primary feature map. Subsequently, the model's ability to learn and distinguish key features is enhanced through the channel attention mechanism. Next, a second 2D convolution and ReLU processing is performed in the second convolution block, and a maximum pooling operation is performed to reduce the size of the feature map and reduce the computational complexity. After that, the feature map is flattened through the extension layer and input to the fully connected layer for feature combination. Finally, the output is converted into a probability distribution through the SoftMax activation function, thereby realizing the classification of the input data.
[0034] Preferably: the channel attention module is provided with a channel input layer, the input end of the channel input layer is connected to the first two-dimensional convolutional layer, the output end of the channel input layer is respectively connected to the input ends of the global maximum pooling layer, the global average pooling layer and the multiplication unit, the output ends of the global maximum pooling layer and the global average pooling layer are connected to the input end of the addition unit, the output end of the addition unit is connected to the input end of the multiplication unit, the output end of the addition unit has a built-in Sigmoid activation function, and the output end of the multiplication unit is connected to the first maximum pooling layer via the channel output layer.
[0035] The channel attention mechanism improves recognition accuracy by giving higher weights to important channels, thereby emphasizing key features in the data; at the same time, it reduces noise interference in the data by suppressing less important channels.
[0036] Preferably, the global maximum pooling layer is provided with a maximum pooling unit, a first fully connected unit fc1, and a second fully connected unit fc2 which are connected in sequence, and a ReLU activation function is built into the output end of the second fully connected unit fc2;
[0037] The maximum pooling unit is used to perform a maximum pooling operation on the input feature X of the channel attention module, and the expression is as follows:
[0038]
[0039] Among them, X m(i, j) represents the value of the mth input feature at position (i, j), MaxPool(·) is the maximum pooling function; the size of the input feature X is H×W×C, where H represents the height of the input feature, W represents the width of the input feature, C represents the number of feature channels, and Z m Represents the output data of the maximum pooling unit;
[0040] The output expression of the global maximum pooling layer is as follows:
[0041] M = fc1(fc2(ReLU(Z m )))
[0042] Where M represents the output data of the global maximum pooling layer, the first fully connected unit fcl has 8 neurons, and the second fully connected unit fc2 has 16 neurons;
[0043] The global average pooling layer is provided with an average pooling unit, a third fully connected unit fc3, and a fourth fully connected unit fc4 connected in sequence, and the output end of the fourth fully connected unit fc4 is built-in with a ReLU activation function;
[0044] The average pooling unit is used to perform an average pooling operation on the input feature X of the channel attention module, and the expression is as follows:
[0045]
[0046] Among them, X a (i, j) represents the value of the ath input feature at position (i, j), AvgPool(·) represents the average pooling function, and Z a Represents the output data of the global average pooling unit;
[0047] The output expression of the global average pooling layer is as follows:
[0048] A=fc3(fc4(ReLU(Z a )))
[0049] Among them, A represents the output data of the global average pooling layer, the third fully connected unit fc3 has 8 neurons, and the fourth fully connected unit fc4 has 16 neurons.
[0050] Preferably, the adding unit is used to sum the output data of the global maximum pooling layer and the global average pooling layer, and then map the sum value through the Sigmoid activation function to obtain a channel attention weight V in the range of [0, 1], which is expressed as follows:
[0051] V=Sigmoid(A+M)
[0052] The multiplication unit is used to multiply the input feature x and the channel attention weight V to obtain the output feature of the channel attention module The expression is as follows:
[0053]
[0054] The multiplication unit enables the channel attention mechanism to weight the input feature X, and the weighted result is used as the output feature of the channel attention module. Output.
[0055] Through the above design, the channel attention module is added after the first convolution operation, the input feature X is calculated separately through two branches, and then fused through the activation function sigmoid, and the channel attention weight is output. The addition of the channel attention mechanism can help the model learn the relationship between different channels and automatically select the most important feature channel in the current task, thereby substantially reducing the intra-class distance and increasing the inter-class distance.
[0056] Preferably, the SoftMax activation function is used to output probability distribution values of various beer sample labels to the output layer, and the output layer is used to output the beer sample label corresponding to the maximum value of the probability distribution as the beer recognition result.
[0057] Preferably, the beer recognition module performs network training by means of a cosine annealing hot restart strategy, and at least two learning rate restarts are set during the training process, each restart starts from a high learning rate and then gradually reduces the learning rate, and the training expression of the learning rate is as follows:
[0058]
[0059] in, represents the minimum learning rate for the i-th learning rate restart, It is the lower bound of the learning rate that gradually decreases during the restart process, helping the model to converge stably; represents the maximum learning rate for the i-th learning rate restart, It is the initial value of the learning rate when restarting, providing greater kinetic energy to help the model jump out of the local optimum; η t represents the current learning rate, η t According to the training cycle T cur and formula adjustment, which is expressed as a periodically changing learning rate curve; T i represents the total number of cycles for the i-th learning rate restart, T i Determines the length of the training cycle in the current restart phase. The learning rate will be in T i In a cycle from Gradually decrease to Tcur Indicates the number of training cycles executed since the last restart; when the number of training cycles reaches the set number, the training ends.
[0060] Determining the best learning rate for a neural network is a challenge. Typically, the accuracy can be improved by decreasing the learning rate over time and finding a satisfactory point on the loss curve. However, this also increases the risk of the network falling into a saddle point, making it difficult for the network to reach a global or even local optimum.
[0061] The present invention adopts a simple but effective cosine annealing hot restart strategy to realize network training, and utilizes the non-convexity of the neural network and the ability of the cosine annealing method to get rid of local minima and saddle points. The training process is set to multiple learning rate restarts, each restart starts with a higher learning rate and then gradually decreases to a lower learning rate. The higher learning rate provides enough kinetic energy to enable the model to cross the critical point and saddle point, while the lower learning rate helps the model find the local minimum with lower performance.
[0062] During the training process, the cosine annealing hot restart algorithm is applied to optimize the learning rate, effectively balance the convergence speed and performance stability of the model, and ultimately achieve the global optimal solution.
[0063] Beneficial effects of the present invention:
[0064] 1. The gas sensors in the electronic nose are arranged vertically, which overcomes the limitation of the traditional planar electronic nose that relies on large static gas chambers or ventilation dynamic gas chamber equipment, and significantly improves the practical applicability of the system; at the same time, the vertical ring structure design of the gas sensor array reduces the cross-interference between gas sensors and makes the diffused volatiles evenly distributed on the surface of each gas sensor.
[0065] 2. The two-dimensional convolutional neural network CC-2DCNN based on the channel attention mechanism and the cosine annealing hot restart strategy is deployed in the electronic nose as a beer recognition module to identify beer. Among them, the channel attention mechanism enhances the learning and weight differentiation capabilities of key features, while the cosine annealing hot restart strategy dynamically adjusts the learning rate to avoid falling into the local optimum during training, thereby improving the robustness and accuracy of the model. In addition, each sample only uses 40 seconds of data for training, which reduces memory usage, speeds up recognition, and maintains high accuracy.
[0066] 3. Effectively improve the accuracy and reliability of beer identification, and provide a reliable solution for detecting counterfeit beer and preventing beer deterioration. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 Schematic diagram of the hardware structure of a portable electronic nose based on a convolutional neural network in an embodiment;
[0068] Figure 2 (a) is a top view of the schematic diagram of the sampling module structure in the embodiment, and (b) is a front view;
[0069] Figure 3 This is a schematic diagram of the beer gas signal collection process in the embodiment;
[0070] Figure 4 (a) to (k) are graphs of ADC readings of the gas sensors in the embodiment when exposed to 11 types of beer, and (l) is a graph of steady-state ADC readings of 8 gas sensors;
[0071] Figure 5 (a) is a graph of ADC readings of raw data in the embodiment, and (b) is a graph of relative response values of the sensor;
[0072] Figure 6 The 40S relative response value curve diagram captured in the embodiment;
[0073] Figure 7 This is a schematic diagram of the network structure of the beer identification module in the embodiment;
[0074] Figure 8 This is a structural block diagram of a beer identification module in the embodiment;
[0075] Fig. 9 Schematic diagram of the structure of the attention channel module in the embodiment;
[0076] Fig.10 This is a comparison diagram of SGD optimization using two different learning rate schemes in the embodiment;
[0077] Fig.11 The model accuracy and model loss curves of the training set and the test set in the embodiment;
[0078] Fig.12 A confusion matrix diagram generated from the test set recognition results in an embodiment;
[0079] Fig.13 is a comparison curve of accuracy and loss of ablation experiments in the embodiment;
[0080] Fig.14 This is a curve chart comparing the model accuracy and model loss of CC-2DCNN and other models on the test set in the embodiment;
[0081] Fig.15 It is the time consumed by the electronic nose in the embodiment to correctly identify all the beer samples, and the current environmental temperature and humidity map. DETAILED DESCRIPTION
[0082] The present invention is further described in detail below in conjunction with the accompanying drawings and specific examples. The following examples or drawings are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0083] A portable electronic nose based on a convolutional neural network for beer identification is provided with a vertical annular gas sensor array, the gas sensor array is connected to a preprocessing module via an ADC analog-to-digital converter, and the preprocessing module is connected to a beer identification module;
[0084] The gas sensor array is used to collect beer gas signals and transmit them to the pre-processing module;
[0085] The preprocessing module is used to perform preprocessing operations on the beer gas signal, and then transmit the preprocessed beer gas data to the beer identification module;
[0086] The beer recognition module is a two-dimensional convolutional neural network model CC-2DCNN based on a channel attention mechanism and a cosine annealing hot restart strategy, which is used to perform beer recognition based on beer gas data and output beer recognition results.
[0087] Figure 1 is a schematic block diagram of the hardware structure of a portable electronic nose based on a convolutional neural network in this embodiment, Figure 1 On the left is a vertical circular gas sensor array. Figure 1 The middle part is the MCU microcontroller unit of the electronic nose, on which the pre-processing module and the beer recognition module are deployed. Figure 1 On the right is the peripheral circuit of the portable electronic nose.
[0088] The MCU microcontroller unit is equipped with three 12-bit ADCs for converting analog signals output by the sensor into digital signals.
[0089] The JDY-31 Bluetooth module in the peripheral circuit wirelessly transmits the sensor's ADC readings to the host computer, where the data is saved and visualized in the form of a curve. The ambient temperature and relative humidity are measured by the DHT11 module to ensure that all samples are measured under consistent conditions. The TFTLCD display shows the results, including the beer brand and other information, while the buzzer module emits different sound patterns depending on the recognized beer brand. These designs improve the usability and interactivity of the electronic nose and significantly improve human-computer interaction.
[0090] like Figure 2 , Figure 3 As shown: the gas sensor array is provided with 8 gas sensors, each of which is provided on a rectangular circuit board, all rectangular circuit boards are vertically provided on the main circuit board, and are sequentially connected end to end to form a ring structure, and the detection heads of all gas sensors are located in the ring structure;
[0091] A sampling port corresponding to the gas sensor array is provided on the main circuit board, and the sampling port is located in the center of the annular structure. A culture dish for holding beer samples is provided directly below the sampling port, and the culture dish is close to the sampling port.
[0092] An acrylic chamber is also installed on the main circuit board, and the acrylic chamber covers the gas sensor array.
[0093] The eight gas sensors in this embodiment are mainly divided into two series: MQ series and TGS series. Table 1 lists the detailed information of the eight gas sensors, including sensitive gases, detection ranges, and sensitivity change rates.
[0094] Table 1
[0095]
[0096]
[0097] The sensing element of all gas sensors is tin dioxide (SnO2) semiconductor.
[0098] In this example, 11 popular beers with similar alcohol content and ingredients from around the world were selected. Table 2 lists the detailed information of the selected beers, including brand, origin, alcohol content, and main ingredients. All beer samples were carefully placed and preserved during the experiment to minimize the impact of the environment on the research results.
[0099] Table 2
[0100]
[0101]
[0102] Although different types of beer have similar main ingredients, each producer adds different types of yeast, fermentation time and temperature, different water sources, and unique processing methods during the brewing process, all of which affect the final characteristics of the beer. The main gas components of beer include carbon dioxide (CO2), ethanol (C2H5OH), hydrogen sulfide (H2S), and other volatile organic compounds (VOCs) such as esters and aldehydes. The slight differences between beer brands can be detected by gas sensors, allowing the electronic nose to effectively identify the differences between various beers through the feature recognition capabilities of neural networks.
[0103] Before the start of the entire experimental procedure, all gas sensors were aged for 48 hours to eliminate any initial fluctuations and improve the overall reliability and accuracy of the experiment. The heating voltage of all sensors was set to 5V and the test voltage was 3.3V. During the experiment, the ambient temperature was maintained at 30℃ and the relative humidity was controlled at around 30%. The analog signals generated by the sensor array were converted into digital signals through an ADC module with a 5Hz sampling frequency and 12-bit resolution.
[0104] Figure 3 The process of collecting beer data using the fabricated electronic nose device is demonstrated. The specific steps are as follows: First, a certain amount of beer sample is drawn using a microsyringe and dropped into the petri dish below the sensor array. Then, the sensor array is covered with a customized acrylic chamber with a volume of 1.0208L, which allows the gas to diffuse quickly in the chamber, allowing the sensor to fully contact and interact with the volatile beer gas. Next, the chamber is uncovered to allow the sensor to return to a stable state. During the entire process, the collected data is wirelessly transmitted to the host computer via a Bluetooth module for visualization and storage.
[0105] To generate the data set, the data acquisition experiment included three steps: cleaning, response, and recovery. In the cleaning step, the gas sensor was preheated until the data output was stable, and the baseline steady-state response of the sensor in air was measured for 95 seconds. Subsequently, the beer sample was dripped, the corresponding volatiles diffused in the chamber, and the sensor responded to the volatile gas for 190 seconds. Finally, the gas chamber was opened and the recovery phase data of the sensor was collected for 195 seconds. The volume of the beer sample was gradually increased from 1μL to 5μL with an incremental gradient of 1μL, and 5 different concentrations of beer volatiles were obtained. The above data acquisition process was repeated 25 times for each beer. Therefore, the total number of dynamic response curves was 1375, and the generated data set contained 3300000 data points.
[0106] Figure 4 (a) to (k) show the transient ADC readings of the eight gas sensors when exposed to 1 μL of beer sample. Figure 4 (l) shows the steady-state ADC readings during the sensor response phase, i.e., the maximum value of the ADC readings. Figure 4 As can be seen from (a) to (k), in each experiment, when the beer sample was introduced, all ADC readings experienced a sharp rise at 95 seconds, which shows the high sensitivity of all sensors to beer volatiles. Subsequently, after waiting for 200 seconds until all ADC readings reached a steady state, the readings returned to the baseline steady state after another 195 seconds of ventilation operation. In addition, by comparing the data curves of different beers, it can be easily observed that the characteristic information of the 11 samples is very similar, and the steady-state ADC readings of the 8 gas sensors are close, such as Figure 4 (l) This makes beer identification a difficult task. However, due to the non-specificity of semiconductor gas sensors, they are very sensitive to a wide range of compounds. Therefore, all sensors responded to the volatiles of the beer, and the sensors responded differently to different beers given the same volume. This variability enhances the ability of the pattern recognition algorithm to extract more detailed information about the gas, making the classification of the beer possible.
[0107] In the embodiment, the Pearson correlation coefficient ρ is used to calculate the similarity between different samples. The specific formula of the Pearson correlation coefficient ρ is as follows:
[0108]
[0109] Among them, X and Y are two vector variables, and are the means of X and Y, respectively, i represents the i-th sample, and n is the number of samples. Each two-dimensional sample data matrix is converted into a one-dimensional vector, that is, 2400×8 is converted to 1×19200 for calculation. The degree of correlation between variables is measured by the Pearson correlation coefficient ρ, whose value ranges from -1 to 1. When the value of ρ is between 0 and 1, it indicates that there is a positive correlation between the two variables. The closer the correlation coefficient is to 1, the stronger the strength of the positive correlation. On the contrary, there may also be a negative correlation between the two variables, and when ρ is closer to -1, the strength of the negative correlation is stronger.
[0110] Taking CQ as an example, the Pearson correlation coefficient ρ between CQ and other beer samples was calculated, and the results are shown in Table 3. It can be concluded that there is a strong positive correlation between CQ and all other beer samples. In addition, the ρ values between all other samples are greater than 0.964, which indicates that the beer samples in this study have a high similarity, so the beer identification task may be extremely difficult. Therefore, the demand for an efficient, portable and fast-responding electronic nose E-nose for beer identification becomes urgent.
[0111] Table 3
[0112]
[0113] The preprocessing module converts the beer gas signal read by the ADC analog-to-digital converter into a relative response value, and intercepts the relative response value within a set continuous time period as beer gas data and transmits it to the beer identification module;
[0114] The expression for the relative response value conversion is as follows:
[0115]
[0116] Among them, Response represents the relative response value; V Beer represents the current ADC reading of the gas sensor when exposed to the beer sample; V Air Represents the baseline ADC reading of the gas sensor.
[0117] The original data and the transformed data are shown in Figure 5 (a) and (b). It can be observed that by converting the data into relative responses, the Figure 5 The baseline differences of all sensors in (a) are as follows: Figure 5 (b) Therefore, the stability differences between different gas sensors can be reduced by relative response value conversion.
[0118] The set continuous time period is within 40 seconds from when the gas sensor is just exposed to the beer sample, that is, when the beer sample is just added.
[0119] Generally speaking, the traditional data analysis method of the electronic nose E-nose requires a complete response curve, including baseline, rise, stability and recovery, which leads to long training time, large amount of memory and time-consuming model detection, which is not conducive to deploying the model to the MCU and edge computing of the E-nose. In order to solve the above problems, this embodiment will use the data between 90 seconds and 130 seconds in the relative response curve of each sample, a total of 200 data points as input data to quickly identify beer samples. These data not only contain the moment when the sample is added, but also the rising trend of the curve and other rich data features, such as Figure 6 As shown. Choosing a time window that is too short will result in insufficient feature information, which will reduce the accuracy of the model. Conversely, a time window that is too long may increase memory usage, which will have an adverse impact on the efficiency of edge deployment. If good recognition results can be obtained using only one-twelfth of the original data volume, this optimization will prove beneficial for subsequent deployment on STM32 microcontrollers for edge computing. Since the computational requirements and memory usage will be reduced, the model training time can be significantly shortened and the recognition speed can be accelerated.
[0120] like Figure 7 , Figure 8 As shown: the beer recognition module is provided with an input layer, a first convolution block, a second convolution block, an extension layer, a discard layer, a fully connected layer and an output layer which are connected in sequence, and a SoftMax activation function is built into the output end of the fully connected layer;
[0121] The first convolution block is provided with a first two-dimensional convolution layer, a channel attention module and a first maximum pooling layer connected in sequence;
[0122] The second convolution block is provided with a second two-dimensional convolution layer and a second maximum pooling layer connected in sequence;
[0123] The output ends of the first two-dimensional convolutional layer and the second two-dimensional convolutional layer are both built-in with ReLU activation functions.
[0124] like Fig. 9 As shown: the channel attention module is provided with a channel input layer, the input end of the channel input layer is connected to the first two-dimensional convolutional layer, the output end of the channel input layer is respectively connected to the input ends of the global maximum pooling layer, the global average pooling layer and the multiplication unit, the output ends of the global maximum pooling layer and the global average pooling layer are connected to the input end of the addition unit, the output end of the addition unit is connected to the input end of the multiplication unit, the output end of the addition unit has a built-in Sigmoid activation function, and the output end of the multiplication unit is connected to the first maximum pooling layer via the channel output layer.
[0125] The global maximum pooling layer is provided with a maximum pooling unit, a first fully connected unit fc1, and a second fully connected unit fc2 connected in sequence, and the output end of the second fully connected unit fc2 is built-in with a ReLU activation function;
[0126] The maximum pooling unit is used to perform a maximum pooling operation on the input feature X of the channel attention module, and the expression is as follows:
[0127]
[0128] Among them, X m (i, j) represents the value of the mth input feature at position (i, j), MaxPool(·) is the maximum pooling function; the size of the input feature X is H×W×C, where H represents the height of the input feature, W represents the width of the input feature, C represents the number of feature channels, and Z m Represents the output data of the maximum pooling unit;
[0129] The output expression of the global maximum pooling layer is as follows:
[0130] M = fc1(fc2(ReLU(Z m )))
[0131] Where M represents the output data of the global maximum pooling layer, the first fully connected unit fc1 has 8 neurons, and the second fully connected unit fc2 has 16 neurons;
[0132] The global average pooling layer is provided with an average pooling unit, a third fully connected unit fc3, and a fourth fully connected unit fc4 connected in sequence, and the output end of the fourth fully connected unit fc4 is built-in with a ReLU activation function;
[0133] The average pooling unit is used to perform an average pooling operation on the input feature X of the channel attention module, and the expression is as follows:
[0134]
[0135] Among them, X a (i, j) represents the value of the ath input feature at position (i, j), AvgPool(·) represents the average pooling function, and Z a Represents the output data of the global average pooling unit;
[0136] The output expression of the global average pooling layer is as follows:
[0137] A=fc3(fc4(ReLU(Z a )))
[0138] Among them, A represents the output data of the global average pooling layer, the third fully connected unit fc3 has 8 neurons, and the fourth fully connected unit fc4 has 16 neurons.
[0139] The addition unit is used to sum the output data of the global maximum pooling layer and the global average pooling layer, and then map the sum value through the Sigmoid activation function to obtain a channel attention weight V in the range of [0, 1], which is expressed as follows:
[0140] V=Sigmoid(A+M)
[0141] The multiplication unit is used to multiply the input feature X and the channel attention weight V to obtain the output feature of the channel attention module The expression is as follows:
[0142]
[0143] The SoftMax activation function is used to output the probability distribution values of various beer sample labels to the output layer, and the output layer is used to output the beer sample label corresponding to the maximum value of the probability distribution as the beer recognition result.
[0144] The beer recognition module is trained by the cosine annealing hot restart strategy. Three learning rate restarts are set during the training process. Each restart starts from a high learning rate and then gradually reduces the learning rate. The training expression of the learning rate is as follows:
[0145]
[0146] in, represents the minimum learning rate for the i-th learning rate restart, represents the maximum learning rate of the i-th learning rate restart; ηt represents the current learning rate, T i represents the total number of cycles for the i-th learning rate restart, T cur Indicates the number of training cycles executed since the last restart; when the number of training cycles reaches the set number of training cycles, the training ends. The number of training cycles set in this embodiment is 100 times.
[0147] Fig.10 (a) shows the case where a standard learning rate schedule is used, in which the model eventually converges to a local minimum or may form a stable limit cycle near a saddle point. Fig.10 (b) shows the optimization process using cosine annealing hot restart scheduling, where SGD is allowed to converge to local minima multiple times on the optimization path until the global optimal solution is obtained. The x-axis and y-axis in the figure represent parameters 1 and 2, respectively, which are the weights in the neural network parameter space. The z-axis represents the value of the loss function, which represents the performance of the model under a given parameter combination.
[0148] In order to comprehensively evaluate the performance of the CC-2DCNN model, the following indicators will be analyzed: Accuracy, Precision, Recall, and F1-score. These indicators can measure the recognition ability of the model from different perspectives and help explain the advantages of the model when processing test data. Accuracy represents the overall performance of the model and indicates the proportion of correctly classified samples. Precision reflects the accuracy of the model in positive class prediction and measures the situation in which the model misclassifies negative classes as positive classes. Recall describes the sensitivity of the model and shows the performance of the model in reducing the missed detection rate. The F1 score effectively reconciles the precision and recall of the model in the case of class imbalance. The formulas for all indicators are as follows:
[0149]
[0150] Among them, TP represents true positive examples, TN represents true negative examples, FP represents false positive examples, and FN represents false negative examples.
[0151] The dataset is divided into training and test sets in a ratio of 8:2 to ensure a balanced split for model evaluation. The training process was performed for 100 iterations with a batch size of 64, and the random seed was set to 42 to ensure the reproducibility of the results. Fig.11 The model accuracy and model loss of the training set and test set are shown. It can be observed that there are 3 valleys in the accuracy and 3 peaks in the loss during the CC-2DCNN training process. The peaks and valleys are attributed to the introduction of the cosine annealing hot restart strategy, which helps the model escape the saddle point and find the global optimal solution. Fig.11(a) shows that CC-2DCNN achieves high accuracy of 100% and 99.3% on the training set and test set, respectively, indicating that the model has high accuracy and good robustness when processing test data. Fig.11 (b) shows the loss of CC-2DCNN on the training set and test set. The final loss stabilizes at 0, which reflects the excellent convergence of the model.
[0152] Table 4 shows the recognition performance of CC-2DCNN. It can be observed that the CC-2DCNN model performs well in terms of precision, recall, and F1 scores for various beer samples. Except for the precision of 92.9% for MLF and 90.1% for BW, the precision and recall of all other samples reached 100%. In particular, the model achieved an F1 score of 100% on most samples, further demonstrating the model's excellent ability in beer recognition, including accurate distinction between different brands and flavors of beer, sensitivity to subtle features between samples, and stability in the case of class imbalance.
[0153] Table 4
[0154]
[0155] Fig.12 The confusion matrix generated from the test set recognition results is shown. The confusion matrix visualizes the recognition accuracy and misclassification of CC-2DCNN on each beer sample, where each row represents the true label and each column represents the predicted label. In addition, the values on the diagonal represent the number of correct recognitions, while the values on the off-diagonal reflect the confusion between different beer samples. It can be seen that all samples in the test set are correctly classified, except for one BW sample that is misclassified as MLF, which is consistent with the precision, recall, and F1 score in Table 4.
[0156] Conducting ablation experiments helps to understand the actual contribution and role of each component in the model. Fig.13 The accuracy and loss during training observed in the ablation experiments are shown. The performance of the separated channel attention mechanism and cosine annealing hot restart strategy in CC-2DCNN is compared on the test set to explore the contribution of these two modules to the model performance. It can be noticed that the traditional 2DCNN performs the worst in terms of accuracy and loss. In contrast, the accuracy of Channel-2DCNN is slightly higher than that of Cos-2DCNN, while the loss of Cos-2DCNN is slightly lower than that of Channel-2DCNN. This phenomenon will be explained by analyzing the working mechanism of these two modules.
[0157] Channel-2DCNN gives more weight to important features through the channel attention mechanism, thereby improving the model's ability to detect features. However, the complexity of the model increases at the same time, so the channel attention mechanism may lead to greater losses. In contrast, the reason why Cos-2DCNN performs better in terms of loss is that the periodic adjustment of the learning rate by the cosine annealing hot restart strategy enables the model to find the global optimal solution, thereby reducing losses. However, the cosine annealing hot restart strategy does not directly enhance the feature capture ability, so it is limited in improving the recognition accuracy. Therefore, CC-2DCNN achieves the highest accuracy and lowest loss at the end of training by combining the advantages of both modules.
[0158] Considering that machine learning models are usually simpler in structure and require less memory, which is crucial in applications with limited computing resources, it is necessary to study the performance of machine learning models. Table 5 clearly shows that the highest accuracy rates obtained by traditional commonly used machine learning models, such as K-nearest neighbor (KNN), random forest (RF), and decision tree (DT) in the test set are all lower than 82%. The root cause of the low accuracy of traditional machine learning models can be summarized as reliance on manually designed features, limited ability to handle complex patterns and nonlinear relationships, and easy overfitting or underfitting.
[0159] Table 5 Accuracy of CC-2DCNN and other models on the test set.
[0160]
[0161] Therefore, the deep learning model is selected to complete beer recognition. Table 5 and Fig.14 (a) also shows the accuracy of CC-2DCNN and other deep learning models. Among all models, CC-2DCNN achieved the highest accuracy of 99.3%. In this study, multidimensional data from 8 sensors were used, which contained rich time series and spatial series information. Since GRU and LSTM only focus on time series, their accuracies are 90.1% and 92.0%, respectively. ANN and DNN achieved accuracies of 93.5% and 94.9%, which is because they are able to learn the nonlinear relationship of data. In addition, 1DCNN and ResNet extracted features from data through convolution operations and deep network structures, respectively, with accuracies of 95.2% and 96.4%. In summary, CC-2DCNN achieved the highest accuracy among all models, indicating that our proposed model is effective.
[0162] also, Fig.14(b) shows the loss comparison of CC-2DCNN and other models on the test set. It can be seen that CC-2DCNN reaches a stable state after about 65 epochs, but at the 75th epoch, the learning rate is increased through the cosine annealing hot restart strategy to help the model escape the saddle point and finally achieve the global optimal solution, that is, the model with the highest accuracy and lowest loss. All other models reach a stable state between the 75th and 80th epochs.
[0163] The comparison of model losses shows that CC-2DCNN effectively enhances key features and optimizes the learning rate, so it performs best in terms of loss descent rate and final loss value. The convolution kernel of 1DCNN can only slide along one dimension, so it is not capable of processing multi-dimensional data. The residual connection in ResNet causes interference between features, resulting in its weak loss performance. GRU and LSTM perform well in processing time series data, but their performance on multi-dimensional data is not as good as CNN, and the computational complexity is high. The structures of ANN and DNN are relatively simple, and their feature extraction capabilities are limited. Experimental results show that the optimization method significantly improves the accuracy and robustness of 2DCNN in beer recognition, verifying its effectiveness and feasibility in electronic nose applications.
[0164] Edge computing is crucial to the development of electronic noses, mainly in the following aspects: Directly processing data at the electronic nose terminal reduces the delay of data transmission and realizes real-time data processing. In addition, it can also reduce the risk of leakage during transmission and improve data privacy and security. In the food field, edge computing can detect odor changes during transportation and storage in real time to identify the authenticity of food and ensure food safety.
[0165] The final stage of this embodiment is to implement the data processing algorithm and CC-2DCNN into the electronic nose to evaluate the recognition performance of 11 beer samples. In one of the tests, when 1μL of CQ sample was added to the petri dish under the vertical circular sensor array, the electronic nose was able to correctly identify the beer sample, and the result was displayed on the TFTLCD. In addition, the temperature and humidity of the current environment were also captured instantly through the DHT11 module. This approach provides good human-computer interaction and enhances the user experience, making the electronic nose have great potential in practical applications of food recognition.
[0166] Fig.15 The time it took for the electronic nose to correctly identify all beer samples is shown, along with the current ambient temperature and humidity. It can be observed that the electronic nose outputs the correct identification information in about 40 seconds. Since only 200 data points between 90 seconds and 130 seconds are used as input to the neural network, Figure 6As shown, even with edge computing on STM32, fast recognition of beer samples is successfully achieved. The main reason for fast recognition is the lower computing requirements and memory usage, which can shorten the model training time and achieve fast recognition speed.
[0167] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A portable electronic nose based on convolutional neural network for beer identification, characterized by: A vertical annular gas sensor array is provided, the gas sensor array is connected to a preprocessing module via an ADC analog-to-digital converter, and the preprocessing module is connected to a beer identification module; The gas sensor array is used to collect beer gas signals and transmit them to the pre-processing module; The preprocessing module is used to perform preprocessing operations on the beer gas signal, and then transmit the preprocessed beer gas data to the beer identification module; The beer recognition module is a two-dimensional convolutional neural network model CC-2DCNN based on a channel attention mechanism and a cosine annealing hot restart strategy, which is used to perform beer recognition based on beer gas data and output beer recognition results.
2. The portable electronic nose based on convolutional neural network according to claim 1, characterized in that: The gas sensor array is provided with at least 3 gas sensors, each of which is provided on a rectangular circuit board, all rectangular circuit boards are vertically provided on the main circuit board, and are sequentially connected end to end to form a ring structure, and the detection heads of all gas sensors are located in the ring structure; A sampling port corresponding to the gas sensor array is provided on the main circuit board, and the sampling port is located in the center of the annular structure. A culture dish for holding beer samples is provided directly below the sampling port, and the culture dish is close to the sampling port. An acrylic chamber is also installed on the main circuit board, and the acrylic chamber covers the gas sensor array.
3. The portable electronic nose based on convolutional neural network according to claim 1, characterized in that: The preprocessing module converts the beer gas signal read by the ADC analog-to-digital converter into a relative response value, and intercepts the relative response value within a set continuous time period as beer gas data and transmits it to the beer identification module; The expression for the relative response value conversion is as follows: Among them, Response represents the relative response value; V Beer represents the current ADC reading of the gas sensor when exposed to the beer sample; V Air Represents the baseline ADC reading of the gas sensor.
4. The portable electronic nose based on convolutional neural network according to claim 3, characterized in that: The set continuous time period is within 40 seconds from when the gas sensor is just exposed to the beer sample, that is, when the beer sample is just added.
5. The portable electronic nose based on convolutional neural network according to claim 1, characterized in that: The beer recognition module is provided with an input layer, a first convolution block, a second convolution block, an extension layer, a discard layer, a fully connected layer and an output layer which are connected in sequence, and a SoftMax activation function is built into the output end of the fully connected layer; The first convolution block is provided with a first two-dimensional convolution layer, a channel attention module and a first maximum pooling layer connected in sequence; The second convolution block is provided with a second two-dimensional convolution layer and a second maximum pooling layer connected in sequence; The output ends of the first two-dimensional convolutional layer and the second two-dimensional convolutional layer are both built-in with ReLU activation functions.
6. The portable electronic nose based on convolutional neural network according to claim 5, characterized in that: The channel attention module is provided with a channel input layer, the input end of the channel input layer is connected to the first two-dimensional convolutional layer, the output end of the channel input layer is respectively connected to the input ends of the global maximum pooling layer, the global average pooling layer and the multiplication unit, the output ends of the global maximum pooling layer and the global average pooling layer are connected to the input end of the addition unit, the output end of the addition unit is connected to the input end of the multiplication unit, the output end of the addition unit has a built-in Sigmoid activation function, and the output end of the multiplication unit is connected to the first maximum pooling layer via the channel output layer.
7. The portable electronic nose based on convolutional neural network according to claim 6, characterized in that: The global maximum pooling layer is provided with a maximum pooling unit, a first fully connected unit fc1, and a second fully connected unit fc2 connected in sequence, and the output end of the second fully connected unit fc2 is built-in with a ReLU activation function; The maximum pooling unit is used to perform a maximum pooling operation on the input feature X of the channel attention module, and the expression is as follows: Among them, X m (i, j) represents the value of the mth input feature at position (i, j), MaxPool(·) is the maximum pooling function; the size of the input feature X is H×W×C, where H represents the height of the input feature, W represents the width of the input feature, C represents the number of feature channels, and Z m Represents the output data of the maximum pooling unit; The output expression of the global maximum pooling layer is as follows: M=fc1(fc2(ReLU(Z m ))) Where M represents the output data of the global maximum pooling layer, the first fully connected unit fc1 has 8 neurons, and the second fully connected unit fc2 has 16 neurons; The global average pooling layer is provided with an average pooling unit, a third fully connected unit fc3, and a fourth fully connected unit fc4 connected in sequence, and the output end of the fourth fully connected unit fc4 is built-in with a ReLU activation function; The average pooling unit is used to perform an average pooling operation on the input feature X of the channel attention module, and the expression is as follows: Among them, X a (i, j) represents the value of the ath input feature at position (i, j), AvgPool(·) represents the average pooling function, and Z a Represents the output data of the global average pooling unit; The output expression of the global average pooling layer is as follows: A=fc3(fc4(ReLU(Z a ))) Among them, A represents the output data of the global average pooling layer, the third fully connected unit fc3 has 8 neurons, and the fourth fully connected unit fc4 has 16 neurons.
8. The portable electronic nose based on convolutional neural network according to claim 7, characterized in that: The addition unit is used to sum the output data of the global maximum pooling layer and the global average pooling layer, and then map the sum value through the Sigmoid activation function to obtain the channel attention weight V in the range of [0,1], which is expressed as follows: V=Sigmoid(A+M) The multiplication unit is used to multiply the input feature X and the channel attention weight V to obtain the output feature of the channel attention module The expression is as follows:
9. The portable electronic nose based on convolutional neural network according to claim 5, characterized in that: The SoftMax activation function is used to output the probability distribution values of various beer sample labels to the output layer, and the output layer is used to output the beer sample label corresponding to the maximum value of the probability distribution as the beer recognition result.
10. The portable electronic nose based on convolutional neural network according to claim 1, characterized in that: The beer recognition module is trained through the cosine annealing hot restart strategy. At least two learning rate restarts are set during the training process. Each restart starts from a high learning rate and then gradually reduces the learning rate. The training expression of the learning rate is as follows: in, represents the minimum learning rate for the i-th learning rate restart, represents the maximum learning rate for the i-th learning rate restart; η t represents the current learning rate, T i represents the total number of cycles for the i-th learning rate restart, T cur Indicates the number of training cycles executed since the last restart; when the number of training cycles reaches the set number, the training ends.
Citation Information
Cited By
Multi-component gas monitoring device and method based on unmanned aerial vehicle carried sensor array
CN121299053A
A portable VOCs gas detection alarm device with adjustable alarm threshold
CN224744880U