A leafy vegetable pesticide residue measurement device and method based on an improved transfer learning model
Through the improved transfer learning model, the high-quality data set obtained by the tableting method is generalized into the target domain data obtained by the bonding method, which solves the problems of complex pesticide residue detection equipment and long sample preparation period in the existing technology, and realizes the problem of Accurate detection in situ.
Patent Information
- Application Number
- CN202410775143.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-06-17
AI Technical Summary
Although existing leafy vegetable pesticide residue detection methods such as tableting modeling can achieve better modeling results, there are too many instruments required and the sample preparation period is long, which cannot meet the in-situ and on-site inspection requirements.
Using the leaf vegetable pesticide residue measurement device and method based on the improved transfer learning model, transfer learning is carried out by using the sample spectral data obtained based on the tableting method as the source domain data, and the sample spectral data obtained based on the bonding method as the target domain data. , generalize the high-quality data set into the target domain data obtained by the bonding method.
While ensuring the accuracy of pesticide residue measurement in leafy vegetables, it meets the in-situ measurement needs, simplifies the sample preparation process and reduces the complexity of the detection equipment.
Smart Images

Figure CN118643295B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of leafy vegetable pesticide residue detection, and in particular to a leafy vegetable pesticide residue measurement device and method based on an improved transfer learning model. Background Art
[0002] Pesticide residues on the surface of leafy vegetables are seriously harmful to human health, so it is of great significance to quickly and accurately determine the pesticide residue content in leafy vegetables. With the development of technology, a method has emerged to help detect pesticide residues in leafy vegetables by combining deep learning technology with spectral data.
[0003] The current methods for detecting pesticide residues in leafy vegetables are mainly based on the tableting modeling method, which involves transporting the leafy vegetable tissues back to the laboratory for pre-treatment such as crushing, drying, grinding, screening, and tableting, and then collecting spectra. The spectrum is then modeled and predicted using machine learning methods. Although the tableting modeling method can achieve better modeling results, it requires too many instruments and a long sample preparation cycle, and cannot meet the needs of in-situ and on-site testing. Summary of the invention
[0004] The purpose of the present invention is to provide a leafy vegetable pesticide residue measurement device and method based on an improved transfer learning model to solve the problems mentioned in the above background technology.
[0005] To achieve the above object, the present invention provides a leafy vegetable pesticide residue measurement device based on an improved transfer learning model, comprising the following contents:
[0006] A data acquisition module is used to acquire a first number of source domain training data and a second number of target domain training data, wherein one source domain training data includes laser induced breakdown spectrum data corresponding to one source domain sample and a corresponding pesticide residue content label, and one target domain training data includes laser induced breakdown spectrum data corresponding to one target domain sample and a corresponding pesticide residue content label, the source domain sample is a sample obtained by processing leafy vegetables by a tabletting method, and the target domain sample is a sample obtained by processing leafy vegetables by a bonding method;
[0007] A first training module is used to perform supervised training on the convolutional neural network model to obtain a first pesticide residue measurement model;
[0008] The second training module is used to perform transfer learning training on the first pesticide residue measurement model to obtain a second pesticide residue measurement model;
[0009] A target domain data to be processed acquisition module is used to acquire the target domain data to be processed, wherein the target domain data to be processed includes laser induced breakdown spectroscopy data corresponding to the target domain samples for which the pesticide residue content prediction is to be performed;
[0010] A target training batch determination module is used to determine the target training batch based on the similarity between the target domain to-be-processed data and the candidate training data corresponding to each training batch;
[0011] A contribution matrix determination module is used to determine the contribution matrix corresponding to any training batch in the training process of the pesticide residue measurement model to be trained, based on the candidate training data corresponding to the training batch and the batch size;
[0012] A first data adjustment module is used to determine the adjusted candidate training data corresponding to any training batch based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch; when the pesticide residue measurement model to be trained is a convolutional neural network model, the candidate training data is the source domain training data; when the pesticide residue measurement model to be trained is the first pesticide residue measurement model, the candidate training data is the target domain training data;
[0013] A second data adjustment module is used to obtain adjusted target domain data to be processed based on the target domain data to be processed and the contribution matrix corresponding to the target training batch;
[0014] The processing module is used to process the adjusted target domain data to be processed by using the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
[0015] Preferably, the laser induced breakdown spectroscopy data is laser induced breakdown spectroscopy data with spectral lines corresponding to nitrogen, hydrogen and oxygen elements eliminated.
[0016] Preferably, the wavelength range corresponding to the laser induced breakdown spectroscopy data is 200.18 nm-871.99 nm. A method for measuring pesticide residues in leafy vegetables based on an improved transfer learning model comprises the following steps:
[0017] S1. Obtain a first number of source domain training data and a second number of target domain training data;
[0018] S2. According to the first number of source domain training data, the convolutional neural network model is trained in batches using the adjusted source domain training data corresponding to each training batch obtained by the first data adjustment module to obtain a first pesticide residue measurement model;
[0019] S3, according to the second number of target domain training data, using the adjusted target domain training data corresponding to each training batch, performing batch transfer learning training on the first pesticide residue measurement model to obtain a second pesticide residue measurement model;
[0020] S4. Input the target domain data to be processed into the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
[0021] Preferably, according to any training batch in the training process of the pesticide residue measurement model to be trained, based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch, the adjusted candidate training data corresponding to the training batch is determined.
[0022] Preferably, the contribution matrix c new The calculation formula is as follows:
[0023]
[0024] Among them, r j represents the correlation between the jth spectral feature in the laser-induced breakdown spectroscopy data and the pesticide residue content label Y, X i×j Indicates that the i-th sample in a training batch corresponds to the spectral intensity under the j-th spectral feature, represents the average spectrum of all samples in a training batch corresponding to the jth spectral feature, Represents the average value of the pesticide residue content labels of all samples in a batch, Y i represents the pesticide residue content label of the i-th sample in a training batch, C j represents the contribution corresponding to the jth spectral feature, represents the contribution of the j-th spectral feature after normalization, μ represents the average contribution of the j-th spectral features, σ represents the standard deviation of the contribution of the j-th spectral features, m represents the batch size corresponding to a training batch, n represents the total number of spectral features in a sample, 1≤i≤m, 1≤j≤n.
[0025] Preferably, the steps of obtaining the target and the data to be processed in S4 are as follows:
[0026] a. Determine the target training batch based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch;
[0027] b. Based on the target domain data to be processed and the contribution matrix corresponding to the target training batch, the adjusted target domain data to be processed is obtained.
[0028] Therefore, the present invention adopts the above-mentioned leafy vegetable pesticide residue measurement device and method based on the improved transfer learning model. By using the spectral data of the samples obtained by the tablet pressing method as the source domain data and the spectral data of the samples obtained by the bonding method as the target domain data, the high-quality data set collected by the tablet pressing method can be well generalized to the target domain data obtained by the bonding method, thereby ensuring the accuracy of the leafy vegetable pesticide residue measurement while meeting the in-situ measurement requirements.
[0029] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a method flow chart of an embodiment of the present invention;
[0031] Figure 2 is a schematic diagram of a device according to an embodiment of the present invention;
[0032] Figure 3 FIG. 4 is a block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] Example
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] In the related art, processing leafy vegetable samples by tableting may include the following process:
[0036] A certain amount of leafy vegetable samples are collected, crushed and placed in a dryer until the leafy vegetables are completely dry; then, an electric grinder is used to grind the samples; then, the ground leafy vegetable samples are sieved to a preset particle size and stored; then, the sieved samples are taken and compressed in an automatic press to obtain leafy vegetable samples processed by the tableting method, i.e., the source domain samples in subsequent embodiments.
[0037] In addition to processing leafy vegetable samples by the tableting method, there is also a method of processing leafy vegetable samples by the bonding method in the related art. In the embodiment of the present disclosure, processing leafy vegetable samples by the bonding method may include the following process:
[0038] First, the leafy vegetable tissue is dried, and then double-sided tape is adhered to a microscope slide, and the dried leafy vegetables are spread on the double-sided tape and flattened to obtain a leafy vegetable sample treated by the bonding method, that is, the target domain sample in the subsequent embodiments.
[0039] Compared with the tableting method for processing leafy vegetables, the bonding method has the advantages of simple operation, no need for experienced personnel, and short time consumption. It can be used for on-site preparation of target domain samples for pesticide residue content prediction to facilitate in-situ testing.
[0040] However, the training data obtained by the bonding method faces the problems of large spectral fluctuations and inaccurate predictions. Therefore, even if a large amount of training data obtained by the bonding method is used alone to train the pesticide residue measurement model, a good prediction effect cannot be obtained. Based on the above problems, this embodiment proposes a leafy vegetable pesticide residue measurement method, device, storage medium and electronic device based on an improved transfer learning model.
[0041] Reference Figure 2 The present invention discloses a leafy vegetable pesticide residue measurement device based on an improved transfer learning model, comprising the following contents:
[0042] An acquisition module is used to acquire a first number of source domain training data and a second number of target domain training data, wherein one source domain training data includes laser induced breakdown spectrum data corresponding to a source domain sample and a corresponding pesticide residue content label, and one target domain training data includes laser induced breakdown spectrum data corresponding to a target domain sample and a corresponding pesticide residue content label, the source domain sample is a sample obtained by processing leafy vegetables by a tabletting method, and the target domain sample is a sample obtained by processing leafy vegetables by a bonding method.
[0043] The first training module is used to perform supervised training on the convolutional neural network model according to a first number of source domain training data to obtain a first pesticide residue measurement model.
[0044] The second training module is used to perform transfer learning on the first pesticide residue measurement model according to a second number of target domain training data to obtain a second pesticide residue measurement model. The second pesticide residue measurement model is used to predict the pesticide residue content corresponding to the target domain data to be processed. The target domain data to be processed includes laser induced breakdown spectroscopy data corresponding to the target domain samples for which pesticide residue content prediction is to be performed.
[0045] A contribution matrix determination module is used to determine the contribution matrix corresponding to any training batch in the training process of the pesticide residue measurement model to be trained, based on the candidate training data corresponding to the training batch and the batch size, wherein the contribution matrix represents the contribution of each spectral feature in the laser induced breakdown spectrum during feature extraction, wherein when the pesticide residue measurement model to be trained is a convolutional neural network model, the candidate training data is the source domain training data, and when the pesticide residue measurement model to be trained is the first pesticide residue measurement model, the candidate training data is the target domain training data.
[0046] The first data adjustment module is used to determine the adjusted candidate training data corresponding to the training batch based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch.
[0047] In this case, the first training module is also used to train the convolutional neural network model in batches using the adjusted source domain training data corresponding to each training batch, so as to obtain the first pesticide residue measurement model.
[0048] The first training module is also used to train the first pesticide residue measurement model in batches using the adjusted target domain training data corresponding to each training batch, so as to obtain the second pesticide residue measurement model.
[0049] The contribution matrix c corresponding to any training batch new Calculated by the following formula:
[0050]
[0051]
[0052] Among them, r j represents the correlation between the jth spectral feature in the laser-induced breakdown spectroscopy data and the pesticide residue content label Y, X i×j Indicates that the i-th sample in a training batch corresponds to the spectral intensity under the j-th spectral feature, represents the average spectrum of all samples in a training batch corresponding to the jth spectral feature, Represents the average value of the pesticide residue content labels of all samples in a batch, Y i represents the pesticide residue content label of the i-th sample in a training batch, C j represents the contribution corresponding to the jth spectral feature, represents the contribution of the j-th spectral feature after normalization, μ represents the average contribution of the j-th spectral features, σ represents the standard deviation of the contribution of the j-th spectral features, m represents the batch size corresponding to a training batch, and n represents the total number of spectral features in a sample, (1≤i≤m), (1≤j≤n).
[0053] The target domain data to be processed acquisition module is used to acquire the target domain data to be processed.
[0054] The target training batch determination module is used to determine the target training batch based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch.
[0055] The second data adjustment module is used to obtain adjusted target domain data to be processed based on the target domain data to be processed and the contribution matrix corresponding to the target training batch.
[0056] The processing module is used to process the adjusted target domain data to be processed by using the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
[0057] The laser-induced breakdown spectroscopy data are laser-induced breakdown spectroscopy data in which the spectral lines corresponding to nitrogen, hydrogen and oxygen elements are eliminated.
[0058] The wavelength range corresponding to the laser-induced breakdown spectroscopy data is 200.18nm–871.99nm.
[0059] Reference Figure 1 , a leafy vegetable pesticide residue measurement method based on an improved transfer learning model includes:
[0060] S1. Obtain a first number of source domain training data and a second number of target domain training data;
[0061] A first number of source domain training data and a second number of target domain training data are obtained, wherein one source domain training data includes laser induced breakdown spectrum data corresponding to a source domain sample and a corresponding pesticide residue content label, and one target domain training data includes laser induced breakdown spectrum data corresponding to a target domain sample and a corresponding pesticide residue content label. The source domain sample is a sample obtained by processing leafy vegetables by a tabletting method, and the target domain sample is a sample obtained by processing leafy vegetables by a bonding method.
[0062] In the disclosed embodiment, the laser induced breakdown spectroscopy is LIBS (Laser-Induced Breakdown Spectroscopy) spectroscopy.
[0063] In the disclosed embodiments, the sample leafy vegetables can be processed by a tabletting method to obtain source domain samples, and the sample leafy vegetables can be processed by a bonding method to obtain target domain samples. After obtaining the source domain samples and the target domain samples, LIBS spectral detection is performed on the source domain samples and the target domain samples, respectively, to obtain corresponding laser induced breakdown spectral data. In addition, the source domain samples and the target domain samples can be processed by a Dumas combustion method to obtain the physical and chemical characteristics of the leafy vegetable samples and obtain the pesticide residue content in the source domain samples and the target domain samples, thereby further constructing the source domain training data and the target domain training data.
[0064] In some embodiments, in order to improve the feature perception ability of the model, the first number is greater than the second number.
[0065] S2. According to the first number of source domain training data, the convolutional neural network model is trained in batches using the adjusted source domain training data corresponding to each training batch obtained by the first data adjustment module to obtain a first pesticide residue measurement model;
[0066] S3. According to the second number of target domain training data, using the adjusted target domain training data corresponding to each training batch, the first pesticide residue measurement model is trained by batch transfer learning to obtain a second pesticide residue measurement model.
[0067] The target domain data to be processed include laser induced breakdown spectroscopy data corresponding to the target domain samples for which the pesticide residue content is to be predicted.
[0068] In the disclosed embodiment, after obtaining a first number of source domain training data, the first number of source domain training data can be used to perform supervised training on the convolutional neural network model to obtain a first pesticide residue measurement model. Then, the second number of target domain training data can be used to perform supervised training on the first pesticide residue measurement model to obtain a second pesticide residue measurement model. The process of using the second number of target domain training data to perform supervised training on the first pesticide residue measurement model is the process of transfer learning of the first pesticide residue measurement model.
[0069] The convolutional neural network model consists of four convolutional layers and one fully connected layer. Each convolutional layer is connected to a batch normalization operation and a rectified linear unit (ReLU) activation function. As the number of layers increases, the number of filters in the convolutional layer increases, which are 16, 32, 64, and 128 respectively.
[0070] In some embodiments, when the first pesticide residue measurement model is transferred for learning using the second number of target domain training data, the convolutional layer parameters of the first pesticide residue measurement model can be frozen without updating the parameters, while the parameters of the fully connected layer of the first pesticide residue measurement model are fine-tuned.
[0071] In some embodiments, after obtaining the second pesticide residue measurement model, when leafy vegetable pesticide residue detection is required, the leafy vegetables for which the pesticide residue content is to be predicted can be processed by a bonding method to obtain target domain samples for which the pesticide residue content is to be predicted, and further the target domain samples for which the pesticide residue content is to be predicted can be spectrally measured to obtain corresponding laser induced breakdown spectral data, i.e., target domain data to be processed. Subsequently, the target domain data to be processed can be predicted by the second pesticide residue measurement model to obtain the pesticide residue content of the leafy vegetables for which the pesticide residue content is to be predicted.
[0072] By adopting the above method, after obtaining a first number of source domain training data and a second number of target domain training data, the convolutional neural network model can be supervised trained according to the first number of source domain training data to obtain a first pesticide residue measurement model, and then the first pesticide residue measurement model can be further transferred learned according to the second number of target domain training data to obtain a second pesticide residue measurement model for predicting the pesticide residue content corresponding to the target domain data to be processed, wherein one source domain training data includes laser induced breakdown spectrum data corresponding to a source domain sample and a corresponding pesticide residue content label, one target domain training data includes laser induced breakdown spectrum data corresponding to a target domain sample and a corresponding pesticide residue content label, the source domain sample is a sample obtained by processing leafy vegetables by a tabletting method, and the target domain sample is a sample obtained by processing leafy vegetables by a bonding method.
[0073] By using the spectral data of samples obtained by the tablet pressing method as source domain data and the spectral data of samples obtained by the bonding method as target domain data, the high-quality data set collected by the tablet pressing method can be well generalized to the target domain data obtained by the bonding method, thereby ensuring the accuracy of leafy vegetable pesticide residue measurement while meeting the in-situ measurement needs.
[0074] It should be noted that the transfer learning method in the related art is usually applied to scenarios where target domain training data is difficult to obtain, while in the present embodiment, the problem of poor measurement accuracy of the pesticide residue measurement model trained solely with the training data obtained by the splicing method is taken into consideration. That is, the target domain samples faced by the present embodiment are easy to obtain, but the prediction accuracy of the pesticide residue prediction model trained solely based on the target domain training data is poor. Therefore, it can be understood that the embodiment of the present disclosure is not a simple application of the transfer learning method.
[0075] In some embodiments, the laser induced breakdown spectroscopy data is laser induced breakdown spectroscopy data with spectral lines corresponding to nitrogen, hydrogen, and oxygen eliminated.
[0076] In the disclosed embodiment, in order to eliminate the interference of nitrogen, hydrogen and oxygen elements in the air, the spectral lines corresponding to these three elements can be removed from the laser induced breakdown spectroscopy data, that is, the spectral lines corresponding to the three elements of nitrogen, hydrogen and oxygen are eliminated from the originally collected laser induced breakdown spectroscopy data.
[0077] In some embodiments, eliminating the spectral lines corresponding to the three elements nitrogen, hydrogen, and oxygen in the originally collected laser induced breakdown spectroscopy data can be eliminating the spectral lines corresponding to the substance (NI) in the nitrogen atomic state in the originally collected laser induced breakdown spectroscopy data, for example, eliminating the spectral lines corresponding to wavelengths 744.63, 746.83, 868.03, and 868.34, eliminating the spectral lines corresponding to the substance (HI) in the hydrogen atomic state in the originally collected laser induced breakdown spectroscopy data, for example, eliminating the spectral lines corresponding to the wavelength 656.27, and eliminating the spectral lines corresponding to the substance (OⅠ) in the oxygen atomic state in the originally collected laser induced breakdown spectroscopy data, for example, eliminating the spectral lines corresponding to wavelengths 777.18, 777.41, 777.54, 844.63, 84.65, and 844.68.
[0078] In some embodiments, the region with large fluctuation in the laser induced breakdown spectroscopy data can be eliminated. In this case, the wavelength range corresponding to the laser induced breakdown spectroscopy data is 200.18 nm-871.99 nm.
[0079] In one example, after eliminating the region with large fluctuation in the laser-induced breakdown spectroscopy data and eliminating the spectral lines corresponding to nitrogen, hydrogen and oxygen elements, spectral data including 10793 spectral features can be obtained, wherein one spectral feature corresponds to one wavelength in the spectral data.
[0080] In addition, considering that different spectral features in the laser induced breakdown spectroscopy data contribute differently to the measurement of the pesticide residue content, in order to differentiate the contribution of different features and thus improve the detection accuracy of the pesticide residue content, in some embodiments, the method of the embodiment of the present disclosure may further include the following steps:
[0081] For any training batch in the training process of the pesticide residue measurement model to be trained, based on the candidate training data corresponding to the training batch and the batch size, the contribution matrix corresponding to the training batch is determined, and the contribution matrix represents the contribution of each spectral feature in the laser induced breakdown spectroscopy during feature extraction. When the pesticide residue measurement model to be trained is a convolutional neural network model, the candidate training data is the source domain training data, and when the pesticide residue measurement model to be trained is the first pesticide residue measurement model, the candidate training data is the target domain training data;
[0082] Determine the adjusted candidate training data corresponding to the training batch based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch;
[0083] In this case, according to the first number of source domain training data, supervised training is performed on the convolutional neural network model to obtain a first pesticide residue measurement model, which may include the following steps:
[0084] The convolutional neural network model is trained in batches using the adjusted source domain training data corresponding to each training batch, and the first pesticide residue measurement model is obtained;
[0085] Similarly, performing transfer learning on the first pesticide residue measurement model according to the second number of target domain training data to obtain a second pesticide residue measurement model may include the following steps:
[0086] The first pesticide residue measurement model is trained in batches using the adjusted target domain training data corresponding to each training batch, so as to obtain the second pesticide residue measurement model.
[0087] Among them, the training batch is each batch in the model training, and each batch corresponds to a batch size, that is, batch_size, which represents the amount of training data used each time the model updates its parameters. In an example, batch_size can be 32.
[0088] In the disclosed embodiment, the pesticide residue measurement model to be trained includes a convolutional neural network model and a first pesticide residue measurement model. For any training batch in the training process of the convolutional neural network model and the first pesticide residue measurement model, a contribution matrix can be calculated accordingly.
[0089] In one example, the batch size of each batch can be set to be the same. Combined with the foregoing content, it can be seen that, for example, it can be set to 32. In this case, m is equal to 32, and n can be set to 10793.
[0090] In some embodiments, based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch, determining the adjusted candidate training data corresponding to the training batch can be by multiplying the contribution matrix corresponding to the training batch and each candidate training data corresponding to the training batch respectively to obtain each adjusted candidate training data corresponding to the training batch.
[0091] S4. Input the target domain data to be processed into the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
[0092] In combination with the foregoing content, it can be known that after obtaining the second pesticide residue measurement model, the second pesticide residue measurement model can be used to predict the pesticide residue content corresponding to the target domain data to be processed, and in the case of considering the contribution matrix corresponding to the training batch, the method of the embodiment of the present disclosure can also include the following steps:
[0093] Get the target domain data to be processed:
[0094] Determine the target training batch based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch;
[0095] Based on the target domain data to be processed and the contribution matrix corresponding to the target training batch, the adjusted target domain data to be processed is obtained;
[0096] The adjusted target domain data to be processed are processed using the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
[0097] In the disclosed embodiment, in order to further improve the accuracy of pesticide residue measurement, a contribution matrix is also introduced in the model application stage to process the target domain data to be processed, so as to obtain adjusted target domain data to be processed.
[0098] Specifically, in the model application stage, the target training batch can be determined based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch, and then the contribution matrix corresponding to the target training batch can be further determined as the contribution matrix for processing the target domain data to be processed.
[0099] In some embodiments, the candidate training data corresponding to each training batch can be obtained, and then for any training batch, all the candidate training data of the batch are averaged in the spectral feature dimension to obtain the average feature data corresponding to each spectral feature. Then, the difference between the data corresponding to each spectral feature in the target domain to be processed data and the average feature data corresponding to the same spectral feature can be calculated, and the sum of the differences corresponding to each spectral feature is determined as the similarity between the target domain to be processed data and the candidate training data of the training batch. Thus, through this method, the similarity between each target domain to be processed data and the candidate training data corresponding to each training batch can be calculated. Furthermore, the training batch corresponding to the smallest similarity value can be determined as the target training batch.
[0100] For example, 32 source domain training data of the first training batch can be obtained. Assuming that each source domain training data includes 10793 spectral features, the average value can be calculated with 32 values for each spectral feature, so that the average feature data corresponding to each spectral feature can be obtained. The target domain data to be processed also includes 10793 spectral features. Therefore, for each spectral feature, the difference can be calculated to obtain 10793 differences. Finally, the sum of the 10793 differences can be determined as the similarity.
[0101] The above method is used to determine the corresponding contribution matrix based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch. When the second pesticide residue measurement model is applied to predict the target domain data to be processed, the influence of the contribution matrix is considered, so that the prediction process can refer to the spectral feature ratio law in the training process, thereby further improving the prediction accuracy of pesticide residue measurement.
[0102] This embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, and the steps of the above method are implemented when the processor executes the computer program.
[0103] In a possible manner, the block diagram of the electronic device may be as follows Figure 3 See Figure 3 The electronic device may include: a processor, a memory. The electronic device may also include one or more of a multimedia component 303, an input / output (I / O) interface, and a communication component.
[0104] Wherein, the processor is used to control the overall operation of the electronic device to complete all or part of the steps in the above-mentioned leafy vegetable pesticide residue measurement method based on the improved transfer learning model. The memory is used to store various types of data to support the operation of the electronic device, and these data may include instructions for any application or method used to operate on the electronic device, as well as application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in a memory or sent through a communication component. The audio component also includes at least one speaker for outputting audio signals. The I / O interface provides an interface between the processor and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component is used for wired or wireless communication between the electronic device and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0105] In an exemplary embodiment, the electronic device can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned leafy vegetable pesticide residue measurement method based on the improved transfer learning model.
[0106] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for measuring leafy vegetable pesticide residues based on the improved transfer learning model are implemented. For example, the computer-readable storage medium can be the above-mentioned memory including program instructions, and the above-mentioned program instructions can be executed by a processor of an electronic device to complete the above-mentioned method for measuring leafy vegetable pesticide residues based on the improved transfer learning model.
[0107] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned leafy vegetable pesticide residue measurement method based on the improved transfer learning model when executed by the programmable device.
[0108] Therefore, the present invention adopts the above-mentioned leafy vegetable pesticide residue measurement device and method based on the improved transfer learning model. By using the spectral data of the samples obtained by the tablet pressing method as the source domain data and the spectral data of the samples obtained by the bonding method as the target domain data, the high-quality data set collected by the tablet pressing method can be well generalized to the target domain data obtained by the bonding method, thereby ensuring the accuracy of the leafy vegetable pesticide residue measurement while meeting the in-situ measurement requirements.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A leafy vegetable pesticide residue measurement device based on an improved transfer learning model, characterized in that: Includes the following: A data acquisition module is used to acquire a first number of source domain training data and a second number of target domain training data, wherein one source domain training data includes laser induced breakdown spectrum data corresponding to one source domain sample and a corresponding pesticide residue content label, and one target domain training data includes laser induced breakdown spectrum data corresponding to one target domain sample and a corresponding pesticide residue content label, the source domain sample is a sample obtained by processing leafy vegetables by a tabletting method, and the target domain sample is a sample obtained by processing leafy vegetables by a bonding method; A first training module is used to perform supervised training on the convolutional neural network model to obtain a first pesticide residue measurement model; The second training module is used to perform transfer learning training on the first pesticide residue measurement model to obtain a second pesticide residue measurement model; A target domain data to be processed acquisition module is used to acquire the target domain data to be processed, wherein the target domain data to be processed includes laser induced breakdown spectroscopy data corresponding to the target domain samples for which the pesticide residue content prediction is to be performed; A target training batch determination module is used to determine the target training batch based on the similarity between the target domain to-be-processed data and the candidate training data corresponding to each training batch; A contribution matrix determination module is used to determine the contribution matrix corresponding to any training batch in the training process of the pesticide residue measurement model to be trained, based on the candidate training data corresponding to the training batch and the batch size; Contribution matrix c new The calculation formula is as follows: Among them, r j represents the correlation between the jth spectral feature in the laser-induced breakdown spectroscopy data and the pesticide residue content label Y, X i×j Indicates that the i-th sample in a training batch corresponds to the spectral intensity under the j-th spectral feature, represents the average spectrum of all samples in a training batch corresponding to the jth spectral feature, Represents the average value of the pesticide residue content labels of all samples in a batch, Y i represents the pesticide residue content label of the i-th sample in a training batch, C j represents the contribution corresponding to the jth spectral feature, represents the contribution of the jth spectral feature after normalization, μ represents the average contribution of the jth spectral feature, σ represents the standard deviation of the contribution of the jth spectral feature, m represents the batch size corresponding to a training batch, n represents the total number of spectral features in a sample, 1≤i≤m, 1≤j≤n; A first data adjustment module is used to determine the adjusted candidate training data corresponding to any training batch based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch; when the pesticide residue measurement model to be trained is a convolutional neural network model, the candidate training data is the source domain training data; when the pesticide residue measurement model to be trained is the first pesticide residue measurement model, the candidate training data is the target domain training data; A second data adjustment module is used to obtain adjusted target domain data to be processed based on the target domain data to be processed and the contribution matrix corresponding to the target training batch; The processing module is used to process the adjusted target domain data to be processed by using the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
2. The leafy vegetable pesticide residue measurement device based on the improved transfer learning model according to claim 1, characterized in that: The laser-induced breakdown spectroscopy data are laser-induced breakdown spectroscopy data in which the spectral lines corresponding to nitrogen, hydrogen and oxygen elements are eliminated.
3. The leafy vegetable pesticide residue measurement device based on the improved transfer learning model according to claim 1, characterized in that: The wavelength range corresponding to the laser-induced breakdown spectroscopy data is 200.18nm–871.99nm.
4. A method for using a leafy vegetable pesticide residue measurement device based on an improved transfer learning model as described in any one of claims 1 to 3, characterized in that: The following steps are involved: S1. Obtain a first number of source domain training data and a second number of target domain training data; S2. According to the first number of source domain training data, the convolutional neural network model is trained in batches using the adjusted source domain training data corresponding to each training batch obtained by the first data adjustment module to obtain a first pesticide residue measurement model; S3, according to the second number of target domain training data, using the adjusted target domain training data corresponding to each training batch, performing batch transfer learning training on the first pesticide residue measurement model to obtain a second pesticide residue measurement model; S4. Input the target domain data to be processed into the second pesticide residue measurement model to obtain the pesticide residue content corresponding to the target domain data to be processed.
5. The method of the leafy vegetable pesticide residue measurement device based on the improved transfer learning model according to claim 4, characterized in that: According to any training batch in the training process of the pesticide residue measurement model to be trained, based on the contribution matrix corresponding to the training batch and the candidate training data corresponding to the training batch, the adjusted candidate training data corresponding to the training batch is determined.
6. The method of the leafy vegetable pesticide residue measurement device based on the improved transfer learning model according to claim 4, characterized in that: The steps for obtaining the target and data to be processed in S4 are as follows: a. Determine the target training batch based on the similarity between the target domain data to be processed and the candidate training data corresponding to each training batch; b. Based on the target domain data to be processed and the contribution matrix corresponding to the target training batch, the adjusted target domain data to be processed is obtained.
Citation Information
Patent Citations
Agricultural product soluble solid prediction method based on supervised transfer learning
CN116312860A
Multi-view zero sample node classification network model, training method and device thereof and storage medium
CN117150018A