Disclosure of Invention
An object of the embodiments of the present application is to provide a device abnormality detection method and apparatus, an electronic device, and a computer-readable storage medium, which are used for performing device abnormality detection while making use of data information as much as possible.
In one aspect, the present application provides an apparatus anomaly detection method, including:
constructing an operation parameter vector based on the collected multiple operation parameters;
inputting the operation parameter vector and a plurality of historical operation parameter vectors as an operation parameter vector sequence into a trained self-encoder to obtain a prediction vector sequence output by the self-encoder;
judging whether the difference between the operation parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold value or not;
and if the difference threshold is reached, outputting alarm information.
In one embodiment, the operating parameter is a time-domain discrete signal; the method for constructing the operation parameter vector based on the collected multiple operation parameters comprises the following steps:
and constructing the operation parameter vector by using various operation parameters corresponding to the same sampling point.
In one embodiment, the self-encoder is trained by:
taking the sample vector sequence as the input of a long-time and short-time memory network self-encoder to obtain a prediction sample vector sequence output by the long-time and short-time memory network self-encoder; wherein the sequence of sample vectors comprises a specified number of consecutive sample vectors;
adjusting network parameters of the long-time memory network self-encoder based on a difference between the prediction sample vector sequence and the sample vector sequence;
and repeating the process until the self-encoder of the network is memorized to be converged at the long time and the short time, and obtaining the self-encoder.
In an embodiment, before the determining whether the difference between the operating parameter vector and the corresponding predicted vector in the sequence of predicted vectors reaches a preset difference threshold, the method further includes:
taking a test vector sequence in a preset test set as the input of the self-encoder to obtain a prediction test vector sequence output by the self-encoder;
calculating a difference between a last test vector in the sequence of test vectors and a corresponding predicted test vector in the sequence of predicted test vectors, the difference corresponding to the sequence of test vectors;
determining an observer operating characteristic curve of the abnormal judgment based on the difference;
determining the difference threshold from the observer operating characteristic.
In an embodiment, before the determining whether the difference between the operating parameter vector and the corresponding predicted vector in the sequence of predicted vectors reaches a preset difference threshold, the method further includes:
taking a test vector sequence in a preset test set as the input of the self-encoder to obtain a prediction test vector sequence output by the self-encoder;
calculating a difference between a last test vector in the sequence of test vectors and a corresponding predicted test vector in the sequence of predicted test vectors, the difference corresponding to the sequence of test vectors;
determining an accuracy-recall curve for the anomaly determination based on the difference;
determining the difference threshold from the precision-recall curve.
In one embodiment, the difference threshold is a distance threshold;
the determining whether the difference between the operating parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold includes:
calculating the mahalanobis distance between the operating parameter vector and the corresponding prediction vector;
and judging whether the Mahalanobis distance reaches a preset distance threshold value.
In one embodiment, the difference threshold is a distance threshold;
the determining whether the difference between the operating parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold includes:
calculating Euclidean distance between the operation parameter vector and the corresponding prediction vector;
and judging whether the Euclidean distance reaches a preset distance threshold value.
On the other hand, the present application further provides an apparatus anomaly detection device, including:
the construction module is used for constructing an operation parameter vector based on the collected various operation parameters;
the input module is used for inputting the operation parameter vector and a plurality of historical operation parameter vectors into a trained self-encoder as an operation parameter vector sequence to obtain a prediction vector sequence output by the self-encoder;
the judging module is used for judging whether the difference between the operation parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold value or not;
and the alarm module is used for outputting alarm information if the difference threshold value is reached.
Further, the present application also provides an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the above-described device anomaly detection method.
In addition, the present application also provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be executed by a processor to perform the above-mentioned device abnormality detection method.
In the embodiment of the application, the self-encoder calculates the input operation parameter vector sequence to obtain the prediction vector sequence, further calculates the difference between the operation parameter vector and the corresponding prediction vector, and judges whether the difference reaches the difference threshold value; the self-encoder can accurately output a prediction vector similar to an operation parameter vector constructed by the operation parameters under the normal operation state of the equipment after training; when equipment fails, the difference between the operation parameter vector and the corresponding prediction vector reaches a difference threshold value, and alarm information can be output according to the difference threshold value; according to the method and the device, a data dimension reduction processing process is not needed, data information is kept as much as possible in the equipment anomaly detection process, and the accuracy of anomaly detection can be improved.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Fig. 1 is a schematic view of an application scenario of the device anomaly detection method according to the embodiment of the present application. As shown in fig. 1, the application scenario includes a server 30 and a client 20, where the client 20 may be a Programmable Logic Controller (PLC) and is configured to acquire an operating parameter acquired by each sensor on a device and transmit the operating parameter to the server 30; the server 30 may be a host for performing device anomaly detection.
As shown in fig. 2, the present embodiment provides an electronic apparatus 1 including: at least one processor 11 and a memory 12, one processor 11 being exemplified in fig. 2. The processor 11 and the memory 12 are connected by a bus 10, and the memory 12 stores instructions executable by the processor 11, and the instructions are executed by the processor 11, so that the electronic device 1 can execute all or part of the flow of the method in the embodiments described below. In an embodiment, the electronic device 1 may be the server 30.
The Memory 12 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk.
The present application also provides a computer-readable storage medium storing a computer program executable by the processor 11 to perform the device anomaly detection method provided by the present application.
Referring to fig. 3, a flowchart of a device anomaly detection method according to an embodiment of the present application is shown, and as shown in fig. 3, the method may include the following steps 310 to 340.
Step 310: and constructing an operation parameter vector based on the collected multiple operation parameters.
The operating parameters may be voltage, current, temperature, vibration parameters, etc. at which the device is operating. The operation parameters can be collected by the equipment sensor and reported to the programmable logic controller, and the operation parameters are transmitted to the host computer executing the equipment abnormality detection method by the programmable logic controller.
The host computer can periodically collect various operation parameters and construct an operation parameter vector according to the collected operation parameters. Wherein each element in the operating parameter vector corresponds to an operating parameter.
In an embodiment, since the operation parameters reported by the sensor are actually time-domain discrete signals, the host can directly construct an operation parameter vector with a plurality of operation parameters corresponding to the same sampling point. If the sampling frequency of each sensor is the same, the host can directly construct the operation parameter vector by using the operation parameters corresponding to each sampling point of each sensor. Such as: the sampling frequency of each sensor is 50 Hz, and each sensor has 50 sampling points per second; sampling points of different sensors at the same moment can be regarded as the same sampling points, and therefore, the operation parameter vectors can be constructed by using different operation parameters of the same sampling points. If the sampling frequency of each sensor is different, the host can carry out sampling rate conversion and unify the sampling frequency of all the sensors. The manner of sample rate conversion may include interpolation, decimation, and the like. After the sampling frequency is unified, the host can construct an operation parameter vector according to the operation parameters corresponding to each sampling point of each sensor. Such as: the sampling frequency of 3 sensors is 60 Hz, the sampling frequency of the rest 1 sensor is 30 Hz, and the host can unify the sampling frequency to be 60 Hz in an interpolation mode. At this time, each sensor has 60 sampling points, and the host computer can construct an operation parameter vector by using different operation parameters of the same sampling point.
In this embodiment, the host may directly perform device anomaly detection on the time-domain discrete signal without a complex signal processing process, thereby reducing the computational complexity.
Step 320: and inputting the operation parameter vector and a plurality of historical operation parameter vectors as an operation parameter vector sequence into the trained self-encoder to obtain a prediction vector sequence output by the self-encoder.
The historical operating parameter vector is an operating parameter vector that was constructed prior to the construction of the operating parameter vector. Such as: the time point when the host acquires the operation parameter and constructs the operation parameter vector each time is recorded as t1、t2、t3、……、tn-1、tnWhen the host is at tnAt the moment when the above-mentioned operation parameter vector is constructed, at tnBefore (e.g. t)n-1、tn-2、tn-3Etc.) is the historical operating parameter vector.
The sequence of operational parameter vectors includes a specified number of operational parameter vectors. In one embodiment, the sequence of operating parameter vectors includes 5 operating parameter vectors, and the host computer is at tnAfter the operation parameter vector is constructed at a moment, t can be calculatedn、tn-1、tn-2、tn-3、tn-4The operation parameter vector constructed at these 5 moments serves as an operation parameter vector sequence.
The self-encoder is oneAn Artificial Neural Networks (ANNs) comprises an encoder and a decoder, and is used for performing characterization learning on input information by taking the input information as a learning target. In an embodiment of the present application, the self-encoder is configured to output a sequence of prediction vectors that approximates the sequence of operating parameter vectors. The self-encoder is trained by an operation parameter vector sequence constructed during normal operation of the equipment, and can output a prediction vector which is very similar to the operation parameter vector for the operation parameter vector constructed by the operation parameters acquired during normal operation of the equipment. Referring to fig. 4, a schematic diagram of a network structure of an auto encoder according to an embodiment of the present application is provided. As shown in fig. 4, v1、v2、v3、v4The operation parameter vector constructed based on the operation parameters is input into an ENCODER (ENCODER), v1、v2、v3、v4Forming a running parameter vector sequence; v. of1’、v2’、v3’、v4' prediction vector, v, output for DECODER (DECODER)1’、v2’、v3’、v4' constitute a sequence of prediction vectors. Vector of operating parameters viAnd a prediction vector vi' correspondingly, each vector predictor in the sequence of vector predictors corresponds to each vector of operating parameters in the sequence of vector of operating parameters.
After the host machine constructs the operation parameter vectors, a plurality of historical operation parameter vectors constructed before are used as operation parameter vector sequences and input into the trained self-encoder to obtain a prediction vector sequence output by the self-encoder, wherein the prediction vector sequence comprises a specified number of prediction vectors.
Step 330: and judging whether the difference between the operation parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold value or not.
The host computer may calculate a distance between the operation parameter vector and the corresponding prediction vector as a difference between the two, and at this time, the difference threshold is a distance threshold, and the host computer may determine whether the calculated distance reaches the distance threshold.
In one embodiment, the host computer may calculate a mahalanobis distance between the operating parameter vector and the corresponding predicted vector, and determine whether the mahalanobis distance reaches a predetermined distance threshold.
In another embodiment, the host computer may calculate a euclidean distance between the operating parameter vector and the corresponding prediction vector, and determine whether the euclidean distance reaches a predetermined distance threshold.
Step 340: and if the difference threshold is reached, outputting alarm information.
The host determines whether the difference between the operating parameter vector and the predicted vector reaches a difference threshold by whether the calculated distance reaches a distance threshold. If the difference threshold is reached, alarm information may be output indicating that the device is malfunctioning. If the difference threshold is not met, the host computer may continue to collect operating parameters and perform the device anomaly detection methods of steps 310-340.
In an embodiment, before the host executes the device anomaly detection method, the self-Encoder may be trained, and the self-Encoder may be trained by a Long Short-Term Memory network self-Encoder (Long Short-Term Memory Auto Encoder). Referring to fig. 5, a flow chart of a training method for an auto-encoder according to an embodiment of the present application is shown, and as shown in fig. 5, the method may include the following steps 510 to 530.
Step 510: taking the sample vector sequence as the input of the long-time and short-time memory network self-encoder to obtain a prediction sample vector sequence output by the long-time and short-time memory network self-encoder; wherein the sequence of sample vectors comprises a specified number of consecutive sample vectors.
The sample vector sequence is a sequence of sample vectors in a training set, which includes a large number of sample vectors. The host may construct a sample vector based on the operating parameters of the device during normal operation and adjust from sample vector to construct a sequence of sample vectors. Illustratively, the training set includes 100 sample vectors, each denoted as y1、y2、y3、……、y99、y100And the sample vector sequence comprises a continuous 10 sample vector, the host computer can assign y1、y2、y3、……、y9、y10As a sample vector sequence, let y2、y3、y4、……、y9、y10、y11As a sample vector sequence, let y3、y4、y2、……、y9、y10、y12As a sample vector sequence, and so on.
The prediction sample vector sequence is a learning result of the long-time memory network self-encoder on the sample vector sequence, and the prediction sample vector sequence comprises a specified number of prediction sample vectors. The prediction sample vectors in the prediction sample vector sequence correspond to the sample vectors in the sample vector sequence one to one.
The network parameter of the long-time memory network self-encoder in the initial condition can be a random number.
The host inputs the sample vector sequence into the long-time and short-time memory network self-encoder, and the prediction sample vector sequence output by the long-time and short-time memory network self-encoder can be obtained.
Step 520: and adjusting network parameters of the long-time memory network self-encoder based on the difference between the prediction sample vector sequence and the sample vector sequence.
Step 530: and repeating the process until the self-encoder of the memory network converges in long time, and obtaining the self-encoder.
The host may adjust network parameters of the long-term memory network autoencoder based on a difference between a prediction sample vector in the prediction sample vector sequence and a corresponding sample vector in the sample vector sequence. After multiple iterations, the difference between the prediction sample vector sequence and the sample vector sequence is basically not changed, and the self-encoder of the long-time memory network can be considered to be converged, so that the self-encoder for executing equipment anomaly detection is obtained.
In one embodiment, the host may first determine a difference threshold before performing the device anomaly detection method.
The host computer may use the test vector sequence in the preset test set as an input of the trained self-encoder to obtain the predicted test vector sequence output from the encoder. The test set includes a number of test vector sequences, each test vector sequence including a specified number of test vectors. The test vector sequence comprises a normal test vector sequence and an abnormal test vector sequence, and each test vector in the normal test vector sequence is constructed by the operation parameters acquired when the equipment operates normally; the abnormal test vector sequence at least comprises a test vector constructed by the operation parameters collected when the equipment fails, and the last test vector of the abnormal test vector sequence is constructed by the operation parameters collected when the equipment fails. The prediction test vector sequence comprises a specified number of prediction test vectors, and the prediction test vectors in the prediction test vector sequence correspond to the test vectors in the test vector sequence one by one.
The host computer may calculate a difference between a last test vector in the sequence of test vectors and a corresponding predicted test vector in the sequence of predicted test vectors, the difference corresponding to the sequence of test vectors. Here, the host may determine the difference by calculating the mahalanobis or euclidean distance of the two. The host computer may determine an observer Operating Characteristic (ROC) curve for anomaly determination based on a difference corresponding to each test vector sequence, and determine a difference threshold from the observer Operating Characteristic curve. After obtaining the difference corresponding to each test vector sequence, the host computer may calculate a difference mean value, and determine whether the device operating condition indicated by each test vector sequence has a fault by using the difference mean value as a specified threshold. The number of true positive examples, false positive examples, true negative examples and false negative examples can be obtained by comparing the judgment result with the actual condition, and the true positive example rate and the false positive example rate are calculated according to the number of the true positive examples, the false positive examples, the true negative examples and the false negative examples.
The host machine increases or decreases the designated step length (for example, the designated step length can be one twentieth of the difference mean value) based on the difference mean value, so as to obtain a new designated threshold, and after the judgment and the calculation are performed, a plurality of groups of true rate and false rate can be obtained. The host draws an observer operation characteristic curve according to multiple groups of true and false positive rates, and the coordinate axis of the curve can take the true positive rate as a horizontal axis and the false positive rate as a vertical axis. The host may use the specified threshold value corresponding to the point on the curve where the first derivative is 1 as the difference threshold value.
In one embodiment, the host may determine a Precision-Recall curve of the anomaly determination based on differences corresponding to the test vector sequences, and determine a difference threshold from the Precision-Recall curve. After obtaining the difference corresponding to each test vector sequence, the host computer may calculate a difference mean value, and determine whether the device operating condition indicated by each test vector sequence has a fault by using the difference mean value as a specified threshold. The number of true positive examples, false positive examples, true negative examples and false negative examples can be obtained by comparing the judgment result with the actual condition, and the precision ratio and the recall ratio are calculated according to the number of true positive examples, false positive examples, true negative examples and false negative examples.
The host machine increases or decreases the designated step length (for example, the designated step length can be one twentieth of the difference mean value) by taking the difference threshold value as a reference, so as to obtain a new designated threshold value, and after judgment and calculation are performed, a plurality of groups of precision ratios and recall ratios can be obtained. The host draws an accuracy-recall ratio curve according to the plurality of groups of accuracy ratios and recall ratios, and the coordinate axis of the curve can take the recall ratio as a horizontal axis and the accuracy ratio as a vertical axis. The host computer may use a specified threshold corresponding to a point on the curve where the precision is a specified precision (for example, the specified precision is 80%) as the difference threshold. Alternatively, the host computer may use a specified threshold value corresponding to a point on the curve with a specified recall ratio (for example, a specified recall ratio of 90%) as the difference threshold value.
Referring to fig. 6, a block diagram of an apparatus anomaly detection device according to an embodiment of the present application is shown in fig. 6, where the block diagram may include:
and a construction module 610, configured to construct an operation parameter vector based on the collected multiple operation parameters.
An input module 620, configured to input the running parameter vector and a plurality of historical running parameter vectors as a running parameter vector sequence into a trained self-encoder, so as to obtain a prediction vector sequence output by the self-encoder.
A determining module 630, configured to determine whether a difference between the operating parameter vector and a corresponding predicted vector in the predicted vector sequence reaches a preset difference threshold.
And the alarm module 640 is used for outputting alarm information if the difference threshold value is reached.
In one embodiment, the operating parameter is a time-domain discrete signal; a building block 610, further configured to:
and constructing the operation parameter vector by using various operation parameters corresponding to the same sampling point.
In one embodiment, the apparatus includes a training module to:
taking the sample vector sequence as the input of a long-time and short-time memory network self-encoder to obtain a prediction sample vector sequence output by the long-time and short-time memory network self-encoder; wherein the sequence of sample vectors comprises a specified number of consecutive sample vectors;
adjusting network parameters of the long-time memory network self-encoder based on a difference between the prediction sample vector sequence and the sample vector sequence;
and repeating the process until the self-encoder of the network is memorized to be converged at the long time and the short time, and obtaining the self-encoder.
In one embodiment, the apparatus further comprises a determining module configured to:
taking a test vector sequence in a preset test set as the input of the self-encoder to obtain a prediction test vector sequence output by the self-encoder;
calculating a difference between a last test vector in the sequence of test vectors and a corresponding predicted test vector in the sequence of predicted test vectors, the difference corresponding to the sequence of test vectors;
determining an observer operating characteristic curve of the abnormal judgment based on the difference;
determining the difference threshold from the observer operating characteristic.
In one embodiment, the apparatus further comprises a determining module configured to:
taking a test vector sequence in a preset test set as the input of the self-encoder to obtain a prediction test vector sequence output by the self-encoder;
calculating a difference between a last test vector in the sequence of test vectors and a corresponding predicted test vector in the sequence of predicted test vectors, the difference corresponding to the sequence of test vectors;
determining an accuracy-recall curve for the anomaly determination based on the difference;
determining the difference threshold from the precision-recall curve.
In one embodiment, the difference threshold is a distance threshold; the determining module 630 is further configured to:
calculating the mahalanobis distance between the operating parameter vector and the corresponding prediction vector;
and judging whether the Mahalanobis distance reaches a preset distance threshold value.
In one embodiment, the difference threshold is a distance threshold; the determining module 630 is further configured to:
the determining whether the difference between the operating parameter vector and the corresponding prediction vector in the prediction vector sequence reaches a preset difference threshold includes:
calculating Euclidean distance between the operation parameter vector and the corresponding prediction vector;
and judging whether the Euclidean distance reaches a preset distance threshold value.
The implementation process of the functions and actions of each module in the above device is specifically detailed in the implementation process of the corresponding step in the above method for detecting device abnormality, and is not described herein again.
In the embodiments provided in the present application, the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.