Food production chain Internet of Things intelligent monitoring system

By designing the Internet of Things intelligent monitoring system of the food production chain, and using convolutional neural network and DQN algorithm to update control parameters in real time, the problem of lack of real-time monitoring in the food production process is solved, real-time monitoring and automatic optimization of the food production process is realized, and production efficiency and resource utilization are improved.

CN120010332AInactive Publication Date: 2025-05-16JUBEI INTELLIGENT TECHNOLOGY (XUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510076027.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-05-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The lack of real-time monitoring and information management systems in the food production process leads to incomplete and accurate data recording, making it difficult to realize real-time monitoring, analysis and sharing of production data, and is unable to respond quickly to market changes and customer needs.

Method used

Design an intelligent monitoring system for the Internet of Things in the food production chain, collect available data in the production process through the food data sensing module, use the convolutional neural network and DQN algorithm in the central processing module to update control parameters in real time, and the intelligent monitoring module visualizes data to realize remote monitoring and management.

Benefits of technology

Real-time monitoring and automatic optimization of the food production process are realized, resource utilization and production efficiency are improved, abnormal situations can be detected in a timely manner, rework and resource waste can be reduced, and market changes and customer needs are quickly responded to market changes and customer needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010332A_ABST
    Figure CN120010332A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of food production monitoring, and particularly relates to a food production chain Internet of Things intelligent monitoring system which comprises a food data sensing module, a food data transmission module, a central processing module and a monitoring interface module. The system adopts a real-time automatic control method to intelligently monitor the food production process, can continuously monitor the food production process by collecting available data of the food production process, using a context freshness monitoring technology and updating data signals of the available data in real time, and can continuously monitor the food production process according to real-time environmental parameters of the food production process. Control parameters are automatically adjusted, and the influence of different food production process parameters on food quality is learned, so that the production process is automatically optimized, and the resource utilization rate and the production efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of food production monitoring, and specifically refers to an Internet of Things intelligent monitoring system for a food production chain. Background Art

[0002] Monitoring of the food production process refers to comprehensive and systematic supervision and control of the entire process of food from raw material procurement, production and processing, storage and transportation, sales to the hands of consumers, covering the monitoring of physical, chemical and biological factors in each link to ensure the quality, safety and compliance of food. The traditional method of monitoring the food production process is usually to conduct sampling inspection after production is completed. It is difficult to find production problems in real time during the production process. If quality problems are found in the late stage of production, a lot of rework or product scrapping is required, which increases production costs and causes waste of resources.

[0003] The current monitoring of food production processes has the following deficiencies:

[0004] (1) The data records of the food production process are not complete and accurate. The control parameters and environmental parameters of the production process are not recorded in detail, making it difficult to conduct a comprehensive analysis and optimization of the production process, and is not conducive to tracing the root causes of product quality problems.

[0005] (2) Due to the lack of real-time monitoring and information management systems, the food production process cannot achieve real-time monitoring, analysis and sharing of production data. This makes food production decisions mainly rely on the experience of managers and it is difficult to respond quickly to market changes and customer needs. Summary of the invention

[0006] In response to the problem of lack of real-time monitoring of the above-mentioned food production process, the present invention provides an Internet of Things intelligent monitoring system for a food production chain, which collects available data on food production, uses contextual freshness monitoring technology to update the available data in real time, and can continuously monitor the food production process. According to the real-time environmental parameters of the food production process, the control parameters are automatically adjusted, and the impact of different food production process parameters on food quality is learned, thereby automatically optimizing the production process and improving resource utilization and production efficiency.

[0007] A food production chain Internet of Things intelligent monitoring system comprises: a food data sensing module, a food data transmission module, a central processing module and an intelligent monitoring module.

[0008] The food data sensing module is connected to the food data transmission module, the central processing module and the intelligent monitoring module, the food data transmission module is connected to the central processing module, the central processing module is connected to the intelligent monitoring module, and the intelligent monitoring module is connected to the central processing module.

[0009] The food data sensing module collects available data during the food production process;

[0010] The food data transmission module stably transmits the available data collected by various sensors to the central processing module;

[0011] The central processing module updates the control parameters of the food production process in real time through convolutional neural networks and DQN algorithms;

[0012] The intelligent monitoring module visualizes the available data of the food production process and realizes remote monitoring and management.

[0013] An IoT intelligent monitoring system for a food production chain uses a real-time automatic control method to intelligently monitor the food production process. The method includes the following steps:

[0014] Step S1: Collect available data of the food production process through a food data sensing module;

[0015] Step S2: pre-processing the available data through the food data sensing module to obtain a data signal;

[0016] Step S3: Transmitting data signals through the food data transmission module;

[0017] Step S4: setting control parameters through the central processing module, analyzing the data signal, obtaining analysis results, and updating the control parameters according to the analysis results;

[0018] Step S5: Visualize the analysis results and control parameters through the intelligent monitoring module.

[0019] Furthermore, in step S1, available data of the food production process is collected, including the following steps:

[0020] Step S11: using a temperature sensor to detect the temperature during the food production process, including food raw material storage, processing, and cooking; using a humidity sensor to monitor the humidity of the food raw material storage environment;

[0021] Step S12: using a pressure sensor to detect the pressure during the food production process, including filling and compression; using a weight sensor to weigh the food in accordance with industry standards;

[0022] Step S13: using an image sensor to obtain image information of the food, detect the appearance, shape and color of the food, and determine whether the food has defects and foreign matter; using a near-infrared spectrum sensor to analyze the chemical composition, nutritional components and additives of the food;

[0023] Step S14: using a pH sensor to measure the pH value of the food and evaluate its acidity and alkalinity; using a conductivity sensor to detect the conductivity of the food to determine the purity and concentration of the food, and to detect whether there are contaminants; using a gas sensor to detect the gas composition in the food production process, including oxygen, carbon dioxide and ammonia;

[0024] Step S15: Use a location sensor to track the real-time location of food during transportation; use a barcode label to manage food raw materials, indicate the source of food raw materials, and conduct quality traceability.

[0025] Further, step S2 includes the following steps:

[0026] Step S21: using a mean-variance normalization method to normalize the available data to a specific range to obtain normalized data, and using a binary encoding method to encode the normalized data;

[0027] The mean variance normalization method uses the following formula:

[0028] ;

[0029] in, represents the mean of the available data, represents the standard deviation of the available data, X represents the available data, represents normalized data, i represents the i-th available data;

[0030] Step S22: using the PCA method, performing a linear transformation operation on the normalized data, removing noise and redundant information, retaining the main features, and obtaining feature data;

[0031] Step S23: All feature data are combined to obtain a data signal.

[0032] Further, step S22 includes the following steps:

[0033] Step S221: normalize the normalized data to obtain standardized data with a mean of 0 and a variance of 1;

[0034] Step S222: Calculate the covariance matrix of the standardized data, perform eigenvalue decomposition on the covariance matrix, and obtain characteristic data, including eigenvalues ​​and eigenvectors;

[0035] Step S223: According to the size of the eigenvalue, select the eigenvectors corresponding to the first k largest eigenvalues, and project the feature data to the new coordinate system.

[0036] Further, in step S3, transmitting the data signal includes the following steps:

[0037] Step S31: using context parameters to describe the data signal during transmission, marking context attributes of the context parameters, where the context attributes are all available data on food production;

[0038] Step S32: using the AHP method, weighting and ranking each context attribute according to the relative importance of the context attribute, and using a pairwise comparison matrix to determine the weight and priority of the context attribute;

[0039] Step S33: setting a preset threshold, obtaining the weight and priority of the context attribute, and when the context attribute exceeds the preset threshold, using a sliding window algorithm to receive the context attribute and the preset threshold;

[0040] Step S34: using the continuous monitoring unit to check the context attribute of each context parameter according to a preset threshold value to obtain a check result;

[0041] Step S35: updating the context attributes in real time according to the inspection results, marking the context freshness of the context attributes, where the context freshness indicates the timeliness of the context parameters;

[0042] Step S36: Using the AoI method, according to the context freshness, the waiting time and transmission time of the data signal are calculated to estimate the transmission status of the food data transmission module.

[0043] Further, step S36 includes the following steps:

[0044] Step S361: Use the Shannon formula to analyze the transmission rate and transmission time of the data signal size. The formula used is as follows:

[0045] ;

[0046] Among them, C represents the channel capacity, that is, the maximum transmission rate, and B represents the channel bandwidth. represents the signal-to-noise ratio;

[0047] Step S362: Analyze the time variation trend of the transmission rate through the AoI method and the calculation formula of the time average age, obtain the average AoI expression, and periodically update the time average age. The formula used is as follows:

[0048] ;

[0049] ;

[0050] in, represents the average age over time, represents the average AoI, n represents the total number of updates, i represents the current number of updates, Indicates the current time. Indicates the current data signal;

[0051] Step S363: Based on Little's law, the expected waiting time of the data signal in the queue is calculated. Based on the maximum entropy principle, the waiting time of the data signal in the queue is estimated. The formula used is as follows:

[0052] ;

[0053] ;

[0054] in, represents the average queue length, represents the expected waiting time, represents the average arrival rate, represents the transmission queue utilization rate of the food data transmission module, and q represents the food data transmission module parameter;

[0055] Step S364: Analyze the process of transmitting the food data from the food data module to the central processing module, calculate the expected transmission time of the data signal, and estimate the transmission time of the data signal. The formula used is as follows:

[0056] ;

[0057] ;

[0058] Where D represents the data signal quantity, represents the mean, R represents the transmission rate, Indicates a fixed value for the transmission rate. represents the expected transmission time, Indicates the estimated transfer time, Indicates the current transmission rate;

[0059] Step S365: remotely estimating the transmission status of the food data transmission module by collecting the expected waiting time, the expected transmission time, the waiting time and the transmission time;

[0060] The waiting time is recorded as WT, and the expected waiting time is recorded as EWT. If WT is significantly greater than EWT, it means that the current transmission situation is congested and the resource allocation is unreasonable; if WT is less than EWT, it means that the current transmission situation is relatively ideal and the transmission efficiency is high.

[0061] The transmission time is recorded as TT, and the expected transmission time is recorded as ETT. If TT is much greater than ETT, it means that there is a failure in the transmission, the performance of the food data transmission module is degraded, and the data volume is abnormally increased; if TT is less than ETT, it means that the transmission is good and the food data transmission module is operating normally.

[0062] Further, step S4 includes the following steps:

[0063] Step S41: establishing a convolutional neural network, wherein the processing layers of the convolutional neural network are three convolutional layers, three maximum pooling layers, three activation functions, three normalization layers, two early exit layers, two fully connected layers and a softmax classification block, wherein the early exit layer includes a convolution filter and a ReLU activation function;

[0064] Step S42: setting a confidence threshold, taking 20% ​​of the data signals as environmental parameters, using an early exit layer, providing category prediction, and terminating the category prediction in advance if the confidence of the category prediction reaches the confidence threshold, and inputting an additional 20% of the data signals after the first early exit layer;

[0065] Step S43: training the convolutional neural network, determining the logit of each category prediction, and providing the category prediction with the highest logit value as the label;

[0066] Step S44: Set control parameters according to the labels, use the DQN algorithm, and update the control parameters according to the gradient descent algorithm.

[0067] Further, step S44 includes the following steps:

[0068] Step S441: Initialize the fully connected layers of the convolutional neural network, one fully connected layer is the state value function, and the other fully connected layer is the advantage function. The state value function and the advantage function are combined into a category prediction output;

[0069] Step S442: Initialize the experience replay buffer, and use the experience replay buffer to store experience data, where the experience data includes current environment parameters, actions, rewards, and next environment parameters;

[0070] Step S443: according to the current environment parameters, the control parameters are set, and according to the ε-greedy strategy, the current random action is selected with probability ε, and the action with the maximum current Q value is selected with probability 1-ε;

[0071] Step S444: Use the proxy function to perform random actions, observe the feedback of the current environment parameters, calculate the reward, and observe the next environment parameters to obtain new control parameters and rewards, and obtain experience data;

[0072] Step S445: store the current experience data in the experience playback buffer, randomly select experience data, and calculate the target Q value. The formula used is as follows:

[0073] y=r+γmax a Q(s',a';θ⁻);

[0074] Among them, y represents the target Q value, r represents the reward obtained after taking random actions with the current environment parameters, γ represents the discount factor, s' represents the environment parameters reached after taking random actions with the current environment parameters, a' represents the action with the largest current Q value, θ⁻ represents the control parameters some time ago, and max a Q(s',a';θ⁻) represents the Q value corresponding to the action a' that maximizes the Q value under the environment parameter s';

[0075] Step S446: Use the mean square error loss function to combine the losses of each random action to form a weighted loss. The formula used is as follows:

[0076] L(θ)=(yQ(s,a;θ))²;

[0077] Where L(θ) represents the loss function, which is used to measure the difference between the output Q value estimate and the target Q value y under the current control parameter θ, s represents the current environment parameter, a represents the random action, and Q(s,a;θ) represents the Q value determined by the current control parameter θ when taking the random action a under the current environment parameter s.

[0078] Step S447: Use the stochastic gradient descent algorithm to update the control parameters, minimize the weighted loss, set the stopping condition, and repeat steps 443-446 until the stopping condition is met.

[0079] The beneficial effects achieved by the present invention are as follows:

[0080] (1) The system collects available data, uses temperature sensors to detect the temperature during the bread production process, pressure sensors to detect the pressure in the compression process, image sensors to detect the appearance and defects of bread, near-infrared spectroscopy sensors to analyze chemical composition and additives, and uses position sensors to track the location of food. Barcode labels manage raw materials and record test results. These complete and accurate data records provide a basis for comprehensive analysis and optimization of the production process, which is conducive to tracing the root causes of quality problems. It can continuously monitor the production process and detect abnormal conditions in a timely manner, thus avoiding rework and waste of resources caused by problems discovered later. If the temperature is abnormal, the system can provide category prediction10 and issue an alarm in a timely manner so that measures can be taken to adjust the production process and reduce losses.

[0081] (2) The system visualizes available data through an intelligent monitoring module to achieve remote monitoring and management. The central processing module uses a convolutional neural network and a DQN algorithm to update control parameters in real time and automatically adjust the production process according to the real-time environmental parameters of the food production process. When the confidence level is greater than the confidence threshold, the early exit layer performs category prediction, thereby reducing manual intervention and improving production efficiency. The system can quickly respond to market changes and customer needs, and improve resource utilization and production efficiency.

[0082] (3) The system uses the AoI method to calculate the waiting time and transmission time of the data signal according to the context freshness, and can remotely estimate the transmission status of the food data transmission module. When the waiting time and transmission time change, it can determine whether there is congestion, unreasonable resource allocation or failure in the transmission situation, and promptly check whether the network load is abnormal, thereby ensuring stable and efficient data transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] Figure 1 This is a module diagram of a food production chain IoT intelligent monitoring system proposed by the present invention;

[0084] Figure 2 A flow chart of a real-time automatic control method proposed by the present invention;

[0085] Figure 3 This is a diagram of the convolutional neural network architecture proposed in the present invention. DETAILED DESCRIPTION

[0086] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0087] Example 1: Reference Figure 1 , this embodiment provides a food production chain Internet of Things intelligent monitoring system including: a food data sensing module, a food data transmission module, a central processing module and an intelligent monitoring module.

[0088] The food data sensing module is connected to the food data transmission module, the central processing module and the intelligent monitoring module, the food data transmission module is connected to the central processing module, the central processing module is connected to the intelligent monitoring module, and the intelligent monitoring module is connected to the central processing module.

[0089] The food data sensing module collects available data during the food production process;

[0090] The food data transmission module stably transmits the available data collected by various sensors to the central processing module;

[0091] The central processing module analyzes the production process through convolutional neural networks and DQN algorithms;

[0092] The intelligent monitoring module visualizes available data and realizes remote monitoring and management.

[0093] Example 2: Reference Figure 2 This embodiment is based on the above embodiment, a food production chain IoT intelligent monitoring system, which uses a real-time automatic control method to intelligently monitor the food production process. The method includes the following steps:

[0094] Step S1: Collect available data through a food data sensing module;

[0095] Step S2: pre-processing the available data through the food data sensing module to obtain a data signal;

[0096] Step S3: Transmitting data signals through the food data transmission module;

[0097] Step S4: setting control parameters through the central processing module, analyzing the data signal, obtaining analysis results, and updating the control parameters according to the analysis results;

[0098] Step S5: Visualize the analysis results and control parameters through the intelligent monitoring module.

[0099] Embodiment 3: This embodiment is based on the above embodiment. In step S1, available data of the food production process is collected, including the following steps:

[0100] Step S11: Use a temperature sensor to detect the temperature during the bread production process, including the food raw material storage temperature of 10°C and the processing temperature of 180°C; use a humidity sensor to monitor the humidity of the food raw material storage environment at 40%;

[0101] Step S12: using a pressure sensor to detect the pressure during the bread production process, including the compression stage of 1.5 MPa; using a weight sensor to weigh the bread according to the industry standard of 150 g, and weighing the weight of 152 g of bread;

[0102] Step S13: using an image sensor to obtain image information of the food, detecting that the appearance of the food is a regular circular outline and the color is chocolate color, and detecting that the bread has no defects and foreign matter; using a near-infrared spectral sensor to analyze the chemical composition of the food to be water, starch, fat and protein, and the additives are sorbic acid and aspartame;

[0103] Step S14: using a pH sensor to measure the pH value of the food to be 5.5, indicating that the bread fermentation is normal; using a conductivity sensor to detect that there are no contaminants in the bread; using a gas sensor to detect the gas composition in the food production process, including 0.7% oxygen, 1.5% carbon dioxide, and 0.02% ammonia;

[0104] Step S15: Use location sensors to track the real-time location of food; use barcode labels to manage food raw materials, indicate the source of food raw materials, and the detection results of various sensors in the production process, and conduct quality traceability.

[0105] Embodiment 4: This embodiment is based on the above embodiment, and step S2 includes the following steps:

[0106] Step S21: Use the mean-variance normalization method to normalize the available data to a specific range (0, 1) to obtain normalized data, and use the binary coding method to encode the normalized data, where the normal code is 00, the risk code is 01, the abnormal code is 10, and the fault code is 11;

[0107] The mean variance normalization method uses the following formula:

[0108] ;

[0109] in, represents the mean of the available data, represents the standard deviation of the available data, X represents the available data, represents normalized data, i represents the i-th available data;

[0110] Step S22: using the PCA method, performing a linear transformation operation on the normalized data, removing noise and redundant information, retaining the main features, and obtaining feature data;

[0111] Step S23: All feature data are combined to obtain a data signal.

[0112] Embodiment 5: This embodiment is based on the above embodiment, and step S22 includes the following steps:

[0113] Step S221: normalize the normalized data, set the mean to 0 and the variance to 1, and obtain standardized data;

[0114] Step S222: Calculate the covariance matrix of the standardized data, perform eigenvalue decomposition on the covariance matrix, and obtain characteristic data, including eigenvalues ​​and eigenvectors. The eigenvalues ​​are 2 and 8, and the eigenvectors are [-0.8, 0.6] and [0.6, 0.8]. The eigenvalues ​​represent the variance of the characteristic data in the direction of the corresponding eigenvector, and the eigenvectors represent the main direction of the change of the characteristic data.

[0115] Step S223: According to the size of the eigenvalue, select the eigenvector [0.6, 0.8] corresponding to the maximum eigenvalue, project the feature data to the coordinate system formed by the eigenvector, and reduce the feature data from two dimensions to one dimension.

[0116] Embodiment 6: This embodiment is based on the above embodiment. In step S3, transmitting a data signal includes the following steps:

[0117] Step S31: using context parameters to describe the data signal during transmission, the context parameters including context attributes, marking the context attributes of the context parameters, the context attributes being all available data of food production;

[0118] Step S32: using the AHP method, weighting and ranking each context attribute, using a pairwise comparison matrix, comparing the context attributes at the same level, comparing the relative importance of the context attributes at the previous level, using a 1-9 scale, where 1 means that the context attributes of temperature and humidity are equally important, and 9 means that the context attribute of oxygen is extremely important than the context attribute of appearance, to determine the weight and priority of the context attributes;

[0119] Step S33: setting the preset threshold to 0.8, obtaining the priority and weight of the context attribute for caching. In this embodiment, the context attribute exceeds the preset threshold. At this time, the priority 0.9 is passed to the sliding window algorithm, and the sliding window algorithm is used to receive the context attribute and the preset threshold.

[0120] Step S34: using the continuous monitoring unit to check the context attribute of each context parameter according to a preset threshold value to obtain a check result;

[0121] Step S35: updating the context attributes in real time according to the check result, marking the context freshness of the context attributes as 1 minute, where the context freshness indicates the timeliness of the context parameters;

[0122] Step S36: Using the AoI method, according to the context freshness, the waiting time and transmission time of the data signal are calculated to estimate the transmission status of the food data transmission module.

[0123] Embodiment 7: This embodiment is based on the above embodiment, and step S36 includes the following steps:

[0124] Step S361: According to Shannon's formula, the transmission rate of the data signal of 100 Mbps is analyzed as follows: bps, the transmission time is 2.89 seconds, and the formula used is as follows:

[0125] ;

[0126] Among them, C represents the channel capacity, that is, the maximum transmission rate, and B represents the channel bandwidth. represents the signal-to-noise ratio;

[0127] Step S362: Analyze the time variation trend of the transmission rate through the AoI method and the calculation formula of the time average age, obtain the average AoI expression, and periodically update the time average age. The formula used is as follows:

[0128] ;

[0129] ;

[0130] in, represents the average age over time, represents the average AoI, n represents the total number of updates, i represents the current number of updates, Indicates the current time. Indicates the current data signal;

[0131] Step S363: Based on Little's law, the expected waiting time of the data signal in the queue is calculated to be 5 seconds. Based on the maximum entropy principle, the waiting time of the data signal in the queue is estimated to be 8 seconds. The formula used is as follows:

[0132] ;

[0133] ;

[0134] in, represents the average queue length, represents the expected waiting time, represents the average arrival rate, represents the transmission queue utilization rate of the food data transmission module, and q represents the parameter of the food data transmission module;

[0135] Step S364: Analyze the process of transmitting the food data from the food data module to the central processing module, calculate that the expected transmission time of the data signal is 10 seconds, and estimate that the transmission time of the data signal is 12 seconds. The formula used is as follows:

[0136] ;

[0137] ;

[0138] Where D represents the data signal quantity, represents the mean, R represents the transmission rate, Indicates a fixed value for the transmission rate. represents the expected transmission time, Indicates the estimated transfer time, Indicates the current transmission rate;

[0139] Step S365: remotely estimating the transmission status of the food data transmission module by collecting the expected waiting time, the expected transmission time, the waiting time and the transmission time;

[0140] The waiting time is recorded as WT, and the expected waiting time is recorded as EWT. If WT is significantly greater than EWT, it means that the current transmission situation is congested and the resource allocation is unreasonable; if WT is less than EWT, it means that the current transmission situation is relatively ideal and the transmission efficiency is high.

[0141] The transmission time is recorded as TT, and the expected transmission time is recorded as ETT. If TT is much greater than ETT, it means that there is a problem with the transmission situation, the performance of the food data transmission module is reduced, and the amount of data increases abnormally; if TT is less than ETT, it means that the transmission situation is good and the food data transmission module is operating normally.

[0142] In this embodiment, EWT is 5 seconds, ETT is 10 seconds, WT is 8 seconds, and TT is 12 seconds. The waiting time and transmission time of this transmission situation are increased, and it is necessary to check whether the LoRa network load is abnormal.

[0143] Embodiment 8: This embodiment is based on the above embodiment, and step S4 includes the following steps:

[0144] Step S41: Establish a convolutional neural network. The processing layers are three convolutional layers, three maximum pooling layers, three activation functions, three normalization layers, two early exit layers, two fully connected layers and a softmax classification block. The early exit layer includes a convolution filter and a ReLU activation function. The pseudo code used is as follows:

[0145] import torch

[0146] import torch.nn as nn

[0147] class EE_CNN(nn.Module):

[0148] def __init__(self):

[0149] super(EE_CNN, self).__init__()

[0150] # Convolutional layer

[0151] self.conv1 = nn.Conv2d(in_channels=3, out_channels=16,kernel_size=3, padding=1)

[0152] self.conv2 = nn.Conv2d(in_channels=16, out_channels=32,kernel_size=3, padding=1)

[0153] self.conv3 = nn.Conv2d(in_channels=32, out_channels=64,kernel_size=3, padding=1)

[0154] # Max pooling layer

[0155] self.pool = nn.MaxPool2d(kernel_size=2, stride=2)

[0156] # Activation function

[0157] self.relu = nn.ReLU()

[0158] # Normalization layer

[0159] self.batch_norm1 = nn.BatchNorm2d(num_features=16)

[0160] self.batch_norm2 = nn.BatchNorm2d(num_features=32)

[0161] self.batch_norm3 = nn.BatchNorm2d(num_features=64)

[0162] # Fully connected layer

[0163] self.fc1 = nn.Linear(in_features=64 * 8 * 8, out_features=128)

[0164] self.fc2 = nn.Linear(in_features=128, out_features=10)

[0165] # softmax classification block

[0166] self.softmax = nn.Softmax(dim=1)

[0167] # Early exit layer

[0168] self.early_exit1 = nn.Linear(in_features=16 * 16 * 16, out_features=10)

[0169] self.early_exit2 = nn.Linear(in_features=32 * 8 * 8, out_features=10)

[0170] def forward(self, x):

[0171] # First layer of convolution, activation, normalization, pooling

[0172] x = self.conv1(x)

[0173] x = self.batch_norm1(x)

[0174] x = self.relu(x)

[0175] x = self.pool(x)

[0176] # Early exit 1

[0177] early_exit1_output = self.early_exit1(x.view(x.size(0), -1))

[0178] if self.training and torch.rand(1) < 0.5: # Early exit with a certain probability

[0179] return early_exit1_output

[0180] # Second layer of convolution, activation, normalization, pooling

[0181] x = self.conv2(x)

[0182] x = self.batch_norm2(x)

[0183] x = self.relu(x)

[0184] x = self.pool(x)

[0185] # Early exit 2

[0186] early_exit2_output = self.early_exit2(x.view(x.size(0), -1))

[0187] if self.training and torch.rand(1) < 0.5:

[0188] return early_exit2_output

[0189] # The third layer of convolution, activation, normalization, pooling

[0190] x = self.conv3(x)

[0191] x = self.batch_norm3(x)

[0192] x = self.relu(x)

[0193] x = self.pool(x)

[0194] # Fully connected layer

[0195] x = x.view(x.size(0), -1)

[0196] x = self.fc1(x)

[0197] x = self.relu(x)

[0198] x = self.fc2(x)

[0199] # softmax classification

[0200] x = self.softmax(x)

[0201] return x;

[0202] Step S42: Set the confidence threshold to 0.8, take 20% of the data signals as environmental parameters, input the environmental parameters into the early exit layer, provide category prediction for food production, and the category prediction is divided into 00, 01, 10, and 11. 00 is normal, 01 is risk, 10 is abnormal, and 11 is fault. The confidence of the category prediction reaches the confidence threshold, and the category prediction is terminated in advance. After the first early exit layer, input an additional 20% of the data signals;

[0203] Step S43: train the convolutional neural network to determine the logit of each category prediction, 00 is 0.5, 01 is 1.0, 10 is 1.5, 11 is 2.0, and provide the category prediction with the highest logit value as the label;

[0204] Step S44: Set control parameters according to the labels, use the DQN algorithm, and update the control parameters according to the gradient descent algorithm.

[0205] Embodiment 9: This embodiment is based on the above embodiment, and step S44 includes the following steps:

[0206] Step S441: Initialize the fully connected layers of the convolutional neural network. One fully connected layer is the state value function, and the other fully connected layer is the advantage function. The state value function and the advantage function are calculated during the forward propagation process, and the state value and the advantage value are respectively combined into an output of a category prediction. The pseudo code used is as follows:

[0207] # Initialize the fully connected layer of the convolutional neural network

[0208] initialize_fully_connected_layers()

[0209] # Define the state value function fully connected layer

[0210] state_value_layer = FullyConnectedLayer(input_dimension, output_dimension_state_value)

[0211] #Define advantage function fully connected layer

[0212] advantage_layer = FullyConnectedLayer(input_dimension, output_dimension_advantage)

[0213] # Forward propagation function

[0214] def forward(input_data):

[0215] state_value = state_value_layer.forward(input_data)

[0216] advantage = advantage_layer.forward(input_data)

[0217] # Combine the state value function and advantage function as the output of category prediction

[0218] category_prediction = state_value + (advantage - advantage.mean())

[0219] return category_prediction;

[0220] Step S442: Initialize the experience replay buffer and use the experience replay buffer to store experience data. The experience data includes current environment parameters, actions, rewards, and next environment parameters. The pseudo code used is as follows:

[0221] class ExperienceReplayBuffer:

[0222] def __init__(self, buffer_size):

[0223] self.buffer = [] # Experience data storage list

[0224] self.buffer_size = buffer_size # buffer size

[0225] def store_experience(self, experience):

[0226] if len(self.buffer) >= self.buffer_size:

[0227] self.buffer.pop(0) # If the buffer is full, remove the oldest experience

[0228] self.buffer.append(experience) # store new experience

[0229] # Initialize the experience replay buffer

[0230] buffer_size = 1000 # Set the buffer size

[0231] replay_buffer = ExperienceReplayBuffer(buffer_size);

[0232] Step S443: according to the current environment parameters, the control parameters are set, and according to the ε-greedy strategy, the current random action is selected with probability ε, and the action with the largest current Q value is selected with probability 1-ε. The pseudo code used is as follows:

[0233] epsilon = 0.1 # Set the value of epsilon

[0234] def select_action(current_state, q_values):

[0235] if random.random() < epsilon: # choose a random action with probability epsilon

[0236] action = random.choice(all_possible_actions)

[0237] else: # Select the action with the largest Q value with probability 1 - ε

[0238] action = all_possible_actions[np.argmax(q_values)]

[0239] return action;

[0240] Step S444: Use the proxy function to perform random actions, observe the feedback of the current environment parameters, calculate the reward, and observe the next environment parameters to obtain new control parameters and rewards, and obtain experience data. The pseudo code used is as follows:

[0241] def perform_action_and_observe(action):

[0242] # Use the proxy function to perform actions

[0243] proxy.perform_action(action)

[0244] # Observe environmental feedback and calculate rewards

[0245] reward = observe_environment_and_calculate_reward()

[0246] # Observe the next environment parameter

[0247] next_state = observe_next_environment_parameters()

[0248] # Get new control parameters and rewards to form experience data

[0249] experience = (current_state, action, reward, next_state)

[0250] return experience;

[0251] Step S445: store the current experience data in the experience playback buffer, randomly select experience data, and calculate the target Q value. The formula used is as follows:

[0252] y=r+γmax a Q(s',a';θ⁻);

[0253] Among them, y represents the target Q value, r represents the reward obtained after taking random actions with the current environment parameters, γ represents the discount factor, s' represents the environment parameters reached after taking random actions with the current environment parameters, a' represents the action with the largest current Q value, θ⁻ represents the control parameters some time ago, and max a Q(s',a';θ⁻) represents the Q value corresponding to the action a' that maximizes the Q value under the environment parameter s';

[0254] Step S446: Use the mean square error loss function to combine the losses of each random action to form a weighted loss. The formula used is as follows:

[0255] L(θ)=(yQ(s,a;θ))²;

[0256] Where L(θ) represents the loss function, which is used to measure the difference between the output Q value estimate and the target Q value y under the current control parameter θ, s represents the current environment parameter, a represents the random action, and Q(s,a;θ) represents the Q value determined by the current control parameter θ when taking the random action a under the current environment parameter s.

[0257] The pseudo code used is as follows:

[0258] #Define mean square error loss function

[0259] def mse_loss(prediction, target):

[0260] return ((prediction - target) ** 2).mean()

[0261] # Define weighted loss calculation function

[0262] def calculate_weighted_loss(random_actions_loss, weights):

[0263] weighted_loss = 0

[0264] for loss, weight in zip(random_actions_loss, weights):

[0265] weighted_loss += loss * weight

[0266] return weighted_loss;

[0267] Step S447: Use the stochastic gradient descent algorithm to update the control parameters, minimize the weighted loss, set the stop condition, and repeat steps 443-446 until the stop condition is met. The stop condition is to reach the maximum number of iterations of 1000. The pseudo code used is as follows:

[0268] # Initialize control parameters

[0269] initialize_control_parameters()

[0270] # Define loss function

[0271] def loss_function(prediction, target, weights):

[0272] error = prediction - target

[0273] weighted_loss = (error ** 2) * weights

[0274] return weighted_loss.mean()

[0275] # Learning rate for stochastic gradient descent algorithm

[0276] learning_rate = 0.01

[0277] # Stop condition: reaching the maximum number of iterations

[0278] stop_threshold = 0.001

[0279] max_iterations = 1000

[0280] iteration = 0

[0281] while True:

[0282] # Calculate gradients

[0283] gradients = compute_gradients(loss_function)

[0284] # Update control parameters

[0285] control_parameters -= learning_rate * gradients

[0286] # Calculate current loss

[0287] current_loss = loss_function(...)

[0288] # Check stop condition

[0289] if current_loss < stop_threshold or iteration >= max_iterations:

[0290] break

[0291] iteration += 1.

[0292] The present invention and its implementation methods are described above. Such description is not restrictive. If a person skilled in the art is inspired by it and creatively designs structures and implementation methods similar to the technical solution without departing from the purpose of the present invention, they should all fall within the protection scope of the present invention.

Claims

1. An IoT intelligent monitoring system for food production chain, characterized by: It includes food data sensing module, food data transmission module, central processing module and intelligent monitoring module; The system adopts a real-time automatic control method to intelligently monitor the food production process. The real-time automatic control method includes the following steps: Step S1: Collect available data of the food production process through a food data sensing module; Step S2: pre-processing the available data through the food data sensing module to obtain a data signal; Step S3: Transmitting data signals through the food data transmission module; Step S4: setting control parameters through the central processing module, analyzing the data signal, obtaining analysis results, and updating the control parameters according to the analysis results; Step S5: Visualize the analysis results and control parameters through the intelligent monitoring module.

2. According to claim 1, the food production chain Internet of Things intelligent monitoring system is characterized by: In step S3, transmitting the data signal comprises the following steps: Step S31: using context parameters, the context parameters including context attributes, describing the data signal during transmission, and marking the context attributes of the context parameters; Step S32: using the AHP method, weighting and ranking each context attribute according to the relative importance of the context attribute, and determining the weight and priority of the context attribute; Step S33: setting a preset threshold, obtaining the weight and priority of the context attribute, and when the context attribute exceeds the preset threshold, using a sliding window algorithm to receive the context attribute and the preset threshold; Step S34: using the continuous monitoring unit to check the context attribute of each context parameter according to a preset threshold value to obtain a check result; Step S35: according to the inspection result, the context attributes are updated in real time, and the context freshness of the context attributes is marked, where the context freshness indicates the timeliness of the context parameters; Step S36: Using the AoI method, according to the context freshness, the waiting time and transmission time of the data signal are calculated to estimate the transmission status of the food data transmission module.

3. The food production chain IoT intelligent monitoring system according to claim 2 is characterized by: Step S36 includes the following steps: Step S361: using Shannon's formula to analyze the transmission rate of the data signal; Step S362: Analyze the time variation trend of the transmission rate through the AoI method and the calculation formula of the time average age, obtain the average AoI expression, and update the time average age; Step S363: Based on Little's law, the expected waiting time of the data signal is calculated, and based on the maximum entropy principle, the waiting time of the data signal in the queue is estimated; Step S364: Calculate the expected transmission time of the data signal and estimate the transmission time of the data signal; Step S365: Estimate the transmission status of the food data transmission module by collecting the expected waiting time, the expected transmission time, the waiting time and the transmission time.

4. The food production chain IoT intelligent monitoring system according to claim 1 is characterized by: Step S4 includes the following steps: Step S41: establishing a convolutional neural network, wherein the processing layers of the convolutional neural network are three convolutional layers, three maximum pooling layers, three activation functions, three normalization layers, two early exit layers, two fully connected layers and a softmax classification block; Step S42: setting a confidence threshold, taking 20% ​​of the data signals as environmental parameters, using an early exit layer, providing category prediction, and terminating the category prediction in advance if the confidence of the category prediction reaches the confidence threshold, and inputting an additional 20% of the data signals after the first early exit layer; Step S43: training the convolutional neural network, determining the logit of each category prediction, and providing the category prediction with the highest logit value as the label; Step S44: Set control parameters according to the labels, use the DQN algorithm, and update the control parameters in real time according to the gradient descent algorithm.

5. The food production chain IoT intelligent monitoring system according to claim 4 is characterized by: Step S44 includes the following steps: Step S441: Initialize two fully connected layers of the convolutional neural network, one fully connected layer is a state value function, and the other fully connected layer is an advantage function, and merge the state value function and the advantage function into a category prediction output; Step S442: Initialize the experience replay buffer, and use the experience replay buffer to store experience data, where the experience data includes current environment parameters, actions, rewards, and next environment parameters; Step S443: according to the current environment parameters, the control parameters are set, and according to the ε-greedy strategy, the current random action is selected with probability ε, and the action with the maximum current Q value is selected with probability 1-ε; Step S444: Use the proxy function to perform random actions, observe the feedback of the current environment parameters, calculate the reward, and observe the next environment parameters to obtain new control parameters and rewards, and obtain experience data; Step S445: storing the experience data into the experience playback buffer, randomly selecting the experience data, and calculating the target Q value; Step S446: Using the mean square error loss function, the loss of each random action is combined to form a weighted loss; Step S447: Use the stochastic gradient descent algorithm to update the control parameters, minimize the weighted loss, set the stopping condition, and repeat steps S443-S446 until the stopping condition is met.