Training method of smoke detection model, smoke detection method and electronic device
By using a smoke detection model based on a backpropagation neural network and optimizing the neural network weights with a sparrow search algorithm, combined with various environmental data, the false alarm and false alarm problems of existing smoke detection technologies are solved, and more accurate smoke recognition is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HEFEI KDLIAN SAFETY TECHNOLOGY CO LTD
- Filing Date
- 2022-12-15
- Publication Date
- 2026-05-19
AI Technical Summary
Existing smoke detection technologies are prone to false alarms and missed alarms, especially in the case of cooking fumes and smoldering. Photoelectric smoke detectors are not strong enough to resist interference and are difficult to accurately identify the type of smoke.
A smoke detection model based on a backpropagation neural network was adopted. By optimizing and correcting the training model, the weights and thresholds of the neural network were optimized using the sparrow search algorithm. Combined with voltage change data collected by blue light and infrared sensors, an accurate smoke recognition model was constructed.
It improves the accuracy of smoke detection, reduces false alarms and missed alarms, enhances anti-interference capabilities, and can more accurately identify different types of smoke.
Smart Images

Figure CN116432072B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smoke detection technology, and in particular to a training method for a smoke detection model, a smoke detection method, and an electronic device. Background Technology
[0002] Kitchen safety is crucial to people's daily lives and property. Currently, most smoke detection technologies on the market are photoelectric detection technologies. These work by emitting a beam of light that scatters across smoke particles, which is then received by a receiver to generate an electrical signal, thus calculating the current smoke concentration. Typical point-type smoke detectors are commonly used. These detectors often rely on threshold judgments to determine whether an alarm should be triggered, and are not sensitive to smoke not caused by fire, leading to false alarms and missed alarms. Furthermore, while many household photoelectric smoke detectors on the market improve their anti-interference capabilities through structure and hardware, this method is still not accurate enough for smoke detection.
[0003] For example: Option 1 uses an air intake device to determine whether the current smoke exceeds a threshold, but this option is prone to false alarms in environments with a lot of oil fumes; Option 2 uses an image recognition module to identify the flame, but this option is prone to missing alarms in smoldering conditions; Option 3 collects the current when smoke is sensed, but this option does not process the current and is easily affected by other smoke, resulting in false alarms. Summary of the Invention
[0004] This invention aims to at least partially solve one of the technical problems in related technologies. Therefore, the first objective of this invention is to propose a training method for a smoke detection model based on a BP neural network. By optimizing, correcting, and testing the smoke detection model, its anti-interference ability is improved, making the smoke detection model more accurate in identifying smoke types.
[0005] The second objective of this invention is to provide a smoke detection method.
[0006] The third objective of this invention is to provide an electronic device.
[0007] To achieve the above objectives, a first aspect of the present invention proposes a training method for a smoke detection model based on a backpropagation (BP) neural network. The method includes: collecting smoke detection data under various environmental conditions using a smoke sensor, and obtaining a training set, a validation set, and a test set based on the smoke detection data; constructing a smoke detection model, inputting the training data from the training set into the smoke detection model to obtain the predicted smoke type corresponding to each training data point, obtaining a loss function based on the predicted smoke type and the corresponding real smoke type, using the loss function as the fitness function of a sparrow search algorithm, and optimizing the smoke detection model using the sparrow search algorithm to obtain an optimized smoke detection model, wherein the smoke detection model employs a backpropagation BP neural network; inputting the validation data from the validation set into the optimized smoke detection model for correction to obtain a corrected smoke detection model, and inputting the test data from the test set into the corrected smoke detection model to obtain the final smoke detection model.
[0008] The training method for a smoke detection model based on a BP neural network according to an embodiment of the present invention improves the anti-interference ability of the smoke detection model by optimizing, correcting, and testing the smoke detection model, making the smoke detection model more accurate in identifying the type of smoke.
[0009] In addition, the training method of the smoke detection model based on the BP neural network in this embodiment of the invention may also have the following additional technical features:
[0010] According to one embodiment of the present invention, the multiple environments include smoke-free environments and smoky environments. The step of obtaining a training set, a validation set, and a test set based on the smoke detection data includes: using the smoke detection data in the smoke-free environment as baseline data; comparing the smoke detection data in each of the smoky environments with the baseline data to obtain multiple sets of smoke detection data variation data; and dividing the multiple sets of variation data to obtain the training set, the validation set, and the test set.
[0011] According to one embodiment of the present invention, the smoke sensor includes a blue light emitter, an infrared emitter, a full-band receiver, and a dark chamber with double-layered upper and lower air ducts for smoke inlet. The blue light emitter and the full-band receiver are arranged in a forward-scattering configuration, and the infrared emitter and the full-band receiver are arranged in a backward-scattering configuration. The blue light emitter, the infrared emitter, and the full-band receiver are all placed in the dark chamber. The full-band receiver is externally covered with a metal shield. The smoke detection data includes a first voltage value corresponding to the blue light emitter and a second voltage value corresponding to the infrared emitter. Each set of change data includes the change in the first voltage value, the change in the second voltage value, and the ratio of the two changes.
[0012] According to one embodiment of the present invention, the smoke detection model includes an input layer, a hidden layer, and an output layer, wherein the activation function of the hidden layer is:
[0013] Furthermore, the output of the hidden layer is: Among them, H j The output of the j-th neuron in the hidden layer is ω, where n is the number of neurons in the input layer. ij Let a be the weight from the i-th neuron in the input layer to the j-th neuron in the hidden layer. j The bias is the distance from the input layer to the j-th hidden layer.
[0014] Furthermore, the output of the output layer is: Among them, O k H represents the output of the k-th neuron in the output layer, l represents the number of neurons in the hidden layer, and H represents the output of the k-th neuron in the output layer. j ω is the output of the j-th neuron in the hidden layer. jk b represents the weights from the j-th neuron in the hidden layer to the k-th neuron in the output layer. k The bias is the distance from the hidden layer to the k-th neuron in the output layer.
[0015] According to one embodiment of the present invention, the loss function is: Where E is the loss function, N is the number of training data, and t i Let y be the quantized value of the predicted smoke type corresponding to the i-th training data. i This is the quantization value of the real smoke type corresponding to the i-th training data.
[0016] According to an embodiment of the present invention, the optimization of the smoke detection model by using the sparrow search algorithm includes:
[0017] Set the number of neurons in the input layer, hidden layer, and output layer, as well as the total number of sparrows n, the number of discoverers, the number of alarmers, and the number of followers;
[0018] Generate a random number and determine if it exceeds the alarm threshold. If so, iterate the location of the discoverer using the following formula:
[0019]
[0020] in, Let α be the position of the j-th dimension variable of the i-th sparrow individual in the t-th iteration, α be a random number in the interval [0,1], R2 be the alarm value in the interval [0,1], ST be the safety threshold, and iter maxLet L be the maximum number of iterations, Q be a random number following a normal distribution in the interval [0,1], L be a matrix with 1 row and d columns, where all elements are 1, and d be the variable t in the loss function. i dimensionality;
[0021] Determine if i is less than n / 2. If so, iterate the position of the follower using the following formula:
[0022]
[0023] in, This represents the optimal position of the discoverer in the (t+1)th iteration. Let A represent the position of the global worst-case scenario in the t-th iteration. Let A be a matrix with 1 row and d columns, whose elements are randomly assigned as 1 or -1. + =A T (AA T ) -1 ;
[0024] In the final step of each iteration, the position of the early warning system is changed using the following formula:
[0025]
[0026] Where β is a random number conforming to a standard normal distribution, used to control the step size, K is a uniformly distributed random number in the interval [-1, 1], ε is a preset constant, and f i f g and f w Let X represent the fitness values of the sparrows located at the i-th, best, and worst positions, respectively. best t This represents the globally optimal position in the t-th iteration;
[0027] The globally optimal position obtained in the last iteration is used as the weight and threshold of the optimized smoke detection model.
[0028] To achieve the above objectives, a second aspect of the present invention provides a smoke detection method, the method comprising: acquiring smoke detection data collected by a smoke sensor; comparing the smoke detection data with reference data to obtain a set of variation data; and using a smoke detection model obtained by the training method of the smoke detection model to determine the smoke type based on the variation data.
[0029] According to the smoke detection method of the present invention, the smoke detection model obtained by the training method of the smoke detection model described above is used to determine the smoke situation in the current environment, so as to make the identified smoke type more accurate.
[0030] To achieve the above objectives, a third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, it implements the training method for the smoke detection model based on a BP neural network, or the smoke detection method.
[0031] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0032] Figure 1 This is a flowchart illustrating the training method of a smoke detection model based on a BP neural network according to an embodiment of the present invention.
[0033] Figure 2 This is a schematic flowchart of a smoke detection method according to an embodiment of the present invention. Detailed Implementation
[0034] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0035] The following is a reference appendix. Figure 1-2 This invention describes the training method for the smoke detection model, the smoke detection method, and the electronic device according to embodiments of the present invention.
[0036] Figure 1 This is a flowchart illustrating the training method of a smoke detection model based on a BP neural network according to an embodiment of the present invention. Figure 1 As shown, the training method for the smoke detection model based on a BP neural network includes the following steps:
[0037] S101. Collect smoke detection data in various environments using a smoke sensor, and obtain training set, validation set and test set based on the smoke detection data.
[0038] Specifically, the various environments include smoke-free and smoky environments. The smoke sensor includes a blue light emitter, an infrared emitter, a full-band receiver, and a dark chamber with double-layered upper and lower air ducts for smoke entry. The blue light emitter and the full-band receiver are arranged in a forward-scattering configuration, while the infrared emitter and the full-band receiver are arranged in a backward-scattering configuration. The blue light emitter, the infrared emitter, and the full-band receiver are all placed in the dark chamber. The full-band receiver is externally covered with a metal shield. The smoke detection data includes a first voltage value corresponding to the blue light emitter and a second voltage value corresponding to the infrared emitter.
[0039] In addition, the training set, validation set, and test set obtained from the smoke detection data include: using smoke detection data in a smoke-free environment as baseline data; comparing the smoke detection data in each smoky environment with the baseline data to obtain multiple sets of smoke detection data variation data; and dividing the multiple sets of variation data to obtain the training set, validation set, and test set. Each set of variation data includes the change in a first voltage value, the change in a second voltage value, and the ratio of the two changes.
[0040] Specifically, the voltage values of the blue light emitter and infrared emitter of the smoke sensor in a smoke-free environment are obtained and recorded as baseline data. Then, the first voltage value of the blue light emitter and the second voltage value of the infrared emitter are obtained under various smoky environments (such as light, open flame, kitchen environments with different smoke particle sizes, moisture conditions, and natural aging). The difference between each set of first and second voltage values and the baseline data (i.e., voltage change) is calculated to obtain the change in the first and second voltage values for each set. The ratio of the change in the first and second voltage values is also calculated. Thus, multiple sets of smoke sensor data variation are obtained. Finally, the multiple sets of variation data are divided into training, validation, and test sets. It should be noted that ambient temperature is included in each training, validation, and test set. Furthermore, since relative values (i.e., the change in the first and second voltage values and the ratio of the two changes) are calculated, and voltage fluctuations generated by the hardware of the same type of smoke sensor have a relatively small impact on subsequent calculations, the anti-interference capability is improved.
[0041] S102. Construct a smoke detection model. Input the training data in the training set into the smoke detection model to obtain the predicted smoke type corresponding to each training data. Obtain the loss function based on the predicted smoke type and the corresponding real smoke type. Use the loss function as the fitness function of the sparrow search algorithm. Optimize the smoke detection model using the sparrow search algorithm. The smoke detection model adopts a backpropagation BP neural network.
[0042] Specifically, a smoke detection model may include an input layer, a hidden layer, and an output layer.
[0043] The activation function of the hidden layer is the sigmoid function, and its formula is: The output of the hidden layer is: Among them, H j ω is the output of the j-th neuron in the hidden layer, n is the number of neurons in the input layer, and ω ij Let a be the weight from the i-th neuron in the input layer to the j-th neuron in the hidden layer. j This is the bias from the input layer to the j-th hidden layer;
[0044] The output of the output layer is: Among them, O k H represents the output of the k-th neuron in the output layer, l is the number of neurons in the hidden layer, and H is the output of the k-th neuron in the output layer. j ω is the output of the j-th neuron in the hidden layer. jk Let b be the weight from the j-th neuron in the hidden layer to the k-th neuron in the output layer. k This represents the bias from the hidden layer to the k-th neuron in the output layer. It should be noted that no activation function is used in the output layer.
[0045] Furthermore, the changes in the first voltage value, the changes in the second voltage value, the ratio of the two changes, and the ambient temperature in the training set are used as inputs to train the neural network to obtain the predicted smoke type corresponding to each training data point. A loss function is then derived based on the predicted smoke type and the corresponding actual smoke type. Where E is the loss function, N is the number of training data, and t i Let y be the quantized value of the predicted smoke type corresponding to the i-th training data. i This is the quantization value of the real smoke type corresponding to the i-th training data.
[0046] Furthermore, sparrow individuals are used as the initial weights and thresholds of the backpropagation BP neural network, and the loss function is used as the fitness function of the sparrow search algorithm. The sparrow search algorithm is used to optimize the selection of weights and thresholds, and the optimal solution of weights and thresholds is selected to minimize the error, thus obtaining the optimized smoke detection model. Here, the loss function is used to represent the error.
[0047] Specifically, the optimized smoke detection model is obtained by optimizing the solution using the sparrow search algorithm, which may include steps S201-S205:
[0048] S201. Set the number of neurons in the input layer, hidden layer, and output layer, as well as the total number of sparrows n, the number of discoverers, the number of alarmers, and the number of followers.
[0049] Specifically, the number of neurons in the input layer, hidden layer, and output layer, as well as the total number of sparrows (n), the number of discoverers, the number of alarmers, and the number of followers can all be set by the user. For example, the number of neurons in the input layer can be set to 4, the number of neurons in the hidden layer to 10, and the number of neurons in the output layer to 2.
[0050] S202. Generate a random number and determine if it exceeds the alarm threshold. If so, iterate the location of the discoverer using the following formula:
[0051]
[0052] in, Let α be the position of the j-th dimension variable of the i-th sparrow individual in the t-th iteration, α be a random number in the interval [0,1], R2 be the alarm value in the interval [0,1], ST be the safety threshold, and iter max Let L be the maximum number of iterations, Q be a random number following a normal distribution in the interval [0,1], L be a matrix with 1 row and d columns, where all elements are 1, and d be the variable t in the loss function. i The dimension of . It should be noted that the variable t in this loss function... i The dimension is 1.
[0053] Specifically, the random number is any integer between 0 and 100, and the alarm threshold can be set to a certain integer between 0 and 100. In each iteration, a random number needs to be generated randomly. If the random number is greater than the alarm threshold, the location of the discoverer is iterated using the above formula.
[0054] S203. Determine if i is less than n / 2. If so, iterate the position of the follower using the following formula:
[0055]
[0056] in, This represents the optimal position of the discoverer in the (t+1)th iteration. Let A represent the position of the global worst-case scenario in the t-th iteration. Let A be a matrix with 1 row and d columns, whose elements are randomly assigned as 1 or -1. + =A T (AA T ) -1 .
[0057] Specifically, if the i-th sparrow individual is less than half the total number n of the sparrow population, it means that the joiner with low fitness has not obtained food, and the position of the follower is iterated using the above formula.
[0058] S204. In the final step of each iteration, the position of the warning device is changed using the following formula:
[0059]
[0060] Where β is a random number conforming to a standard normal distribution, used to control the step size, K is a uniformly distributed random number in the interval [-1, 1], ε is a preset constant, and f i f g and f w Let X represent the fitness values of the sparrows located at the i-th, best, and worst positions, respectively. best t This represents the globally optimal position in the t-th iteration.
[0061] Specifically, since the loss function is used as the fitness function of the sparrow search algorithm, the fitness value of each sparrow is obtained, and the best and worst positions are both reflected by comparing the fitness values of the sparrows.
[0062] S205. Use the globally optimal position obtained in the last iteration as the weights and thresholds of the optimized smoke detection model.
[0063] S103. Input the validation data from the validation set into the optimized smoke detection model for calibration to obtain the calibrated smoke detection model. Then input the test data from the test set into the calibrated smoke detection model to obtain the final smoke detection model.
[0064] Specifically, the changes in the first and second voltage values, the ratio of the two changes, and the ambient temperature in the validation set are used as inputs to calibrate the optimized smoke detection model, resulting in a calibrated smoke detection model. Then, the changes in the first and second voltage values, the ratio of the two changes, and the ambient temperature in the test set are used as inputs to test the calibrated smoke detection model. The smoke detection model that passes the test is taken as the final smoke detection model.
[0065] In summary, the training method of the smoke detection model based on BP neural network saves time, manpower, and resources by not building a separate model for each smoke sensor. By analyzing and learning from past data, it identifies the characteristics of smoke occurrence in fire situations, eliminates voltage rises in sensor data caused by other factors, improves anti-interference capabilities, and makes the smoke detection model more accurate in identifying smoke types.
[0066] Figure 2 This is a schematic flowchart of a smoke detection method according to an embodiment of the present invention. Figure 2 As shown, the smoke detection method includes the following steps:
[0067] S301. Acquire smoke detection data collected by the smoke sensor;
[0068] S302. Compare the smoke detection data with the baseline data to obtain a set of variation data;
[0069] S303. Using the smoke detection model obtained by the training method of the smoke detection model described above, the smoke type is obtained based on the changing data.
[0070] Therefore, by using the smoke detection model obtained through the training method of the smoke detection model described above, the smoke situation in the current environment can be judged, making the identification of smoke type more accurate.
[0071] The present invention also proposes an electronic device, including a memory, a processor, and a computer program stored in the memory. When the computer program is executed by the processor, it implements the above-described training method for the smoke detection model based on a BP neural network, or the above-described smoke detection method.
[0072] The electronic device of this invention, when the computer program in its memory is executed by the processor, can make the identification of smoke type more accurate.
[0073] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0074] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0075] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0076] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0077] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0078] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise explicitly limited. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0079] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0080] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A training method for a smoke detection model based on a BP neural network, characterized in that, The method includes: Smoke detection data is collected using smoke sensors in various environments, including smoke-free and smoky environments. Training, validation, and test sets are then derived from this smoke detection data, including: The smoke detection data in the smoke-free environment was used as the baseline data. The smoke perception data in each of the aforementioned smoky environments are compared with the baseline data to obtain multiple sets of smoke perception data variation data. The multiple sets of changing data are divided to obtain the training set, the validation set, and the test set; A smoke detection model is constructed by inputting training data from the training set into the smoke detection model to obtain the predicted smoke type corresponding to each training data. A loss function is obtained based on the predicted smoke type and the corresponding real smoke type. The loss function is used as the fitness function of the sparrow search algorithm. The optimized smoke detection model is obtained by optimizing the solution using the sparrow search algorithm. The smoke detection model adopts a backpropagation BP neural network. The validation data from the validation set is input into the optimized smoke detection model for calibration to obtain the calibrated smoke detection model. The test data from the test set is then input into the calibrated smoke detection model to obtain the final smoke detection model.
2. The training method for the smoke detection model based on a BP neural network according to claim 1, characterized in that, The smoke sensor includes a blue light emitter, an infrared emitter, a full-band receiver, and a dark chamber with double-layered upper and lower air ducts for smoke entry. The blue light emitter and the full-band receiver are arranged in a forward-scattering configuration, and the infrared emitter and the full-band receiver are arranged in a backward-scattering configuration. The blue light emitter, the infrared emitter, and the full-band receiver are all placed in the dark chamber. The full-band receiver is externally covered with a metal shield. The smoke detection data includes a first voltage value corresponding to the blue light emitter and a second voltage value corresponding to the infrared emitter. Each set of change data includes the change in the first voltage value, the change in the second voltage value, and the ratio of the two changes.
3. The training method for the smoke detection model based on a BP neural network as described in claim 1, characterized in that, The smoke detection model includes an input layer, a hidden layer, and an output layer. The activation function of the hidden layer is: .
4. The training method for the smoke detection model based on a BP neural network as described in claim 3, characterized in that, The output of the hidden layer is: , in, For the hidden layer number The output of n neurons, where n is the number of neurons in the input layer. For the input layer The first neuron is connected to the hidden layer. The weights of each neuron, For the input layer to the hidden layer The bias of each.
5. The training method for the smoke detection model based on a BP neural network as described in claim 3, characterized in that, The output of the output layer is: , in, The output of the k-th neuron in the output layer. The number of neurons in the hidden layer. The output of the j-th neuron in the hidden layer. For the hidden layer number The weights from each neuron to the k-th neuron in the output layer. The bias is the distance from the hidden layer to the k-th neuron in the output layer.
6. The training method for the smoke detection model based on a BP neural network as described in claim 3, characterized in that, The loss function is: , Where E is the loss function, N is the number of training data, and t i Let y be the quantized value of the predicted smoke type corresponding to the i-th training data. i This is the quantization value of the real smoke type corresponding to the i-th training data.
7. The training method for the smoke detection model based on a BP neural network as described in claim 3, characterized in that, The optimized smoke detection model obtained by optimizing the solution using the sparrow search algorithm includes: Set the number of neurons in the input layer, hidden layer, and output layer, as well as the total number of sparrows n, the number of discoverers, the number of alarmers, and the number of followers; Generate a random number and determine if it exceeds the alarm threshold. If so, iterate the location of the discoverer using the following formula: , in, In the first In the nth iteration The position of the j-th dimension variable of each sparrow individual A random number in the interval [0,1]. Let ST be the alarm value in the interval [0,1], and ST be the safety threshold. Let L be the maximum number of iterations, Q be a random number following a normal distribution in the interval [0,1], L be a matrix with 1 row and d columns, where all elements are 1, and d be the variable t in the loss function. i dimensionality; Determine if i is less than n / 2. If so, iterate the position of the follower using the following formula: , in, This represents the optimal position of the discoverer in the (t+1)th iteration. Let A represent the position of the global worst-case scenario in the t-th iteration. Let A be a matrix with one row and d columns, whose elements are randomly assigned as 1 or -1. ; In the final step of each iteration, the position of the early warning system is changed using the following formula: , in, The random numbers conforming to a standard normal distribution are used to control the step size, and K is a uniformly distributed random number in the interval [-1, 1]. As a preset constant, , and Let be the fitness values represented by the sparrows in the i-th, best, and worst positions, respectively. This represents the globally optimal position in the t-th iteration; The globally optimal position obtained in the last iteration is used as the weight and threshold of the optimized smoke detection model.
8. A smoke detection method, characterized in that, The method includes: Acquire smoke detection data collected by the smoke sensor; The smoke detection data is compared with the baseline data to obtain a set of variation data; The smoke detection model obtained by the training method of the smoke detection model as described in any one of claims 1-7 is used to determine the smoke type based on the change data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, When the computer program is executed by the processor, it implements the training method of the smoke detection model based on the BP neural network as described in any one of claims 1-7, or the smoke detection method as described in claim 8.