Learning device, method and program
The learning device balances normal and abnormal data loss values to ensure consistent model performance, enhancing anomaly detection accuracy by updating model parameters using an adjustment parameter-based loss function.
Patent Information
- Application Number
- JP2021110283
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-07-01
- Publication Date
- 2024-08-13
- Estimated Expiration
- 2041-07-01
AI Technical Summary
Existing anomaly detection models using machine learning face issues with maintaining consistency before and after updates, leading to inconsistent performance due to the lack of consideration for model consistency during data updates.
A learning device and method that includes an acquisition section, a first calculation section, a second calculation section, and an update section to acquire, calculate, and update model parameters using an adjustment parameter-based loss function to balance normal and abnormal data loss values, ensuring consistent model performance.
The solution enhances model performance by maintaining consistency before and after updates, improving anomaly detection accuracy and reducing biased learning, especially when incorporating new abnormal data.
Smart Images

Figure 0007532318000005 
Figure 0007532318000006 
Figure 0007532318000007
Abstract
Description
[Technical field]
[0001] FIELD An embodiment of the present invention relates to a learning device, a method, a program, and an inference device. [Background technology]
[0002] There has been much research into the use of machine learning for anomaly detection. In such anomaly detection using machine learning, there is a need to improve the performance of anomaly detection by utilizing anomalous data that occurs during operation. However, in a situation where abnormal data is available in stages during operation, if the model is updated each time, the consistency of the model before and after the model update is not taken into consideration, and there is a problem that the continuity of the degree of anomaly output by the model before and after the update will be lost. [Prior art documents] [Patent documents]
[0003] [Patent Document 1] JP 2020-91661 A [Non-patent literature]
[0004] [Non-Patent Document 1] Munawar, A., Vinayavekhin, P., De Magistris, G. “Limiting the reconstruction capability of generative neural network using negative learning”, 2017 IEEE 27th International Workshop on Machine Learning for Signal Processing. Summary of the Invention [Problem to be solved by the invention]
[0005] The present disclosure has been made to solve the above-mentioned problems, and aims to provide a learning device, a method, a program, and an inference device that can improve the performance of a model while ensuring consistency before and after a model update. [Means for solving the problem]
[0006] The learning device according to the present embodiment includes an acquisition unit, a first calculation unit, a second calculation unit, and an update unit. The acquisition unit acquires data to which a label indicating whether the data is normal data or abnormal data is assigned. The first calculation unit calculates an anomaly degree indicating the degree to which the data is abnormal data using an output of a model for the data. The second calculation unit calculates a loss value related to the anomaly degree using an adjustment parameter based on a previously calculated loss value and a loss function based on the label. The update unit updates the parameters of the model so as to minimize the loss value. [Brief description of the drawings]
[0007] [Figure 1] FIG. 1 is a block diagram showing a learning device according to a first embodiment. [Diagram 2] 4 is a flowchart showing a learning process of the learning device according to the first embodiment. [Diagram 3] FIG. 4 is a conceptual diagram showing balance adjustment of a loss function by an adjustment parameter according to the first embodiment. [Figure 4] FIG. 11 is a block diagram showing an inference device according to a second embodiment. [Diagram 5] FIG. 11 is a diagram showing an example of an abnormality degree determination result by the inference device according to the second embodiment. [Figure 6] FIG. 11 is a diagram showing an example of an image output of a reconstruction error, which is a processing result of the inference device according to the second embodiment. [Figure 7] FIG. 2 is a block diagram showing an example of the hardware configuration of a learning device and an inference device according to the embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0008] Hereinafter, the learning device, method, program, and inference device according to the present embodiment will be described in detail with reference to the drawings. Note that in the following embodiments, parts with the same reference numerals perform similar operations, and duplicated descriptions will be omitted as appropriate.
[0009] (First embodiment) A learning device according to a first embodiment will be described with reference to the block diagram of FIG. The learning device 10 according to the first embodiment includes a data acquisition unit 101, an anomaly degree calculation unit 102, a loss calculation unit 103, a loss holding unit 104, an update unit 105, and a display control unit 106.
[0010] The data acquiring unit 101 acquires a data set from an external source. Here, the data set includes a plurality of pairs of data x used for learning and a label indicating which of two classifications (normal data and abnormal data) the data falls into.
[0011] The anomaly degree calculation unit 102 receives a data set from the data acquisition unit 101, and calculates an anomaly degree indicating the degree to which the data is anomalous data, using the output of the model for the data. The model here is a network model such as an autoencoder whose task is anomaly detection.
[0012] The loss calculation unit 103 receives a label associated with data for which an anomaly degree has been calculated from the data acquisition unit 101, an anomaly degree from the anomaly degree calculation unit 102, and a previously calculated loss value from the loss holding unit 104 described below. The loss calculation unit 103 calculates a loss value related to the anomaly degree using a loss function. The loss function is a function based on an adjustment parameter based on a loss value calculated in a previous process and on the label. The loss holding unit 104 holds one or more loss values calculated by the loss calculation unit 103 in past processes.
[0013] The update unit 105 receives the loss value from the loss calculation unit 103 and updates the model parameters so as to minimize the loss value. When the update unit 105 stops updating the model parameters based on a predetermined condition, the learning of the model is completed and a trained model is generated.
[0014] The display control unit 106 controls so as to display, for example, the degree of anomaly calculated by the anomaly calculation unit 102, and information on the loss function and loss value during model training on an external display. Note that the learning device 10 may include a display unit (not shown) and display information on the display unit.
[0015] Next, the learning process of the learning device 10 according to the first embodiment will be described with reference to the flowchart of FIG. In this embodiment, the purpose is to generate a trained model for performing an anomaly detection task, but is not limited thereto. For example, in the case of a machine learning model for a task of performing a binary judgment such as separating two types of products or judging positive / negative, the degree of classification into one of two types (degree of deviation from a certain classification) can be set, and the learning device 10 according to this embodiment can be applied to generate a desired trained model.
[0016] Furthermore, in the learning process of the learning device 10 shown in Fig. 2, if there is no abnormal data before operation, a model is generated by unsupervised learning using only correct answer data. If abnormal data is subsequently obtained during operation, the learning process shown in Fig. 2 is executed by supervised learning in which normal data is labeled as normal and abnormal data is labeled as abnormal. Note that if abnormal data is also obtained before operation, the learning process shown in Fig. 2 may be executed in the same manner. The learning process may be executed each time abnormal data is obtained during operation, or may be executed when a predetermined number of abnormal data have been obtained. Alternatively, the learning process may be executed at predetermined intervals, such as every six months.
[0017] In step S201, the data acquisition unit 101 acquires a data set. Specifically, X={xm, ym} is given as a data set X including m pieces of data (m is a natural number of 2 or more). Here, data xn is the nth piece of data (n is a natural number of 1 or more, 1≦n≦m), and each piece of data has a D-dimensional feature vector. That is, it can be expressed as xn=[xn1, xn2, ..., xnD]. For example, data x n If m is a monochrome image of 64x64 pixels, then it has a feature vector for each pixel, i.e., D=64x64=4096 feature vectors. The label yn is the nth label (n is a natural number greater than or equal to 1, 1≦n≦m), where yn=0 indicates normal data and yn=1 indicates abnormal data.
[0018] In step S202, the anomaly calculation unit 102 calculates the anomaly degree of the data. For example, if the model is an autoencoder, the reconstruction error may be used as the anomaly degree. Also, if the model is a variational autoencoder, the negative log-likelihood of the probability distribution may be used.
[0019] Specifically, let us assume that the model is an autoencoder. The degree of anomaly S(xn), which is the reconstruction error, can be expressed by, for example, the mean square error between the data and the output of the autoencoder, as shown in Equation (1).
[0020]
number
[0021] θ is a parameter of the model. f(xn,θ) is the output when data xn is input to an autoencoder having parameter θ. In other words, if xn is an image, the mean square of the difference values for each pixel constituting the image is the reconstruction error. The degree of anomaly may be expressed as a likelihood function. The degree of anomaly calculation unit 102 only needs to be able to calculate a value that is low when the probability of occurrence of data is high, i.e., normal data, and high when the probability of occurrence is low, i.e., abnormal data.
[0022] In step S203, the loss calculation unit 103 calculates a loss value from the degree of abnormality calculated in step S202 by using a loss function. The loss function can be expressed by, for example, formula (2).
[0023]
number
[0024] where l(xn) is the loss value, and α is an adjustment parameter to be described later. The loss function in equation (2) is designed so that the smaller the loss value l(xn), the lower the degree of anomaly for normal data, and vice versa.
[0025] The loss function is not limited to formula (2), and any function that increases with the degree of anomaly for normal data and decreases with the degree of anomaly for abnormal data and calculates low values for normal data and high values for abnormal data may be used.
[0026] Here, in equation (2), the first term on the right hand side, “(1-yn)S(xn)”, is also called the normal label term for the loss of the normal label that indicates normality. Similarly, the second term, “-ynlog e (1-e -αS(xn) The term "α" is also called the abnormal label term, which is related to the loss of the abnormal label that indicates an abnormality. The adjustment parameter α can be expressed, for example, by equation (3).
[0027]
number
[0028] Here, lprev(xn) is the loss value one step before. "One step before" is assumed to be, for example, one epoch before or one iteration before in model learning. Specifically, when "one step before" is one epoch before, lprev(xn) is the average value of the loss values calculated within one epoch. Note that the value based on the loss value is not limited to the average value, and may be a statistic such as a maximum value or a combination of the average value and the standard deviation.
[0029] In step S204, the update unit 105 determines whether learning has ended. The end of learning may be determined, for example, when a predetermined number of epochs of learning have ended, when the loss value l(xn) is equal to or less than a threshold, or when the decrease in the loss value has converged. When learning has ended, the update of the parameters is discontinued and the process ends. This generates a trained model. On the other hand, when learning has not ended, the process proceeds to step S205.
[0030] In step S205, the update unit 105 updates the adjustment parameter α using the loss value calculated in step S203. When the loss value l(xn) calculated from the loss function of the above-mentioned formula (2) is minimized without considering the balance between the first and second terms on the right side of formula (2), i.e., the normal label term and the abnormal label term, the minimization of either the loss value for normal data or the loss value for abnormal data may be dominant. Therefore, when minimizing the loss value l(xn), the update unit 105 adjusts the adjustment parameter α so as to balance the first and second terms on the right side of formula (2). Specifically, for example, the adjustment parameter α may be updated so that a loss function for normal data among the loss functions and a loss function for abnormal data among the loss functions intersect with a value based on a previously calculated loss value.
[0031] In step S206, the update unit 105 updates the model parameters θ, specifically, the weights and biases of the neural network, for example, by gradient descent and backpropagation so as to minimize the loss value l(xn) calculated by the loss function. Then, the process returns to step S201, and the processes from step S201 to step S206 are repeatedly performed on the next data set.
[0032] Next, the balance adjustment of the loss function by the adjustment parameter α will be described with reference to the conceptual diagram of FIG. FIG. 3 is a graph of the loss function shown in the above-mentioned equation (2), where the vertical axis indicates the loss value and the horizontal axis indicates the reconstruction error (the degree of abnormality in this embodiment).
[0033] The graph 301 of the normal label term is designed so that the loss value is smaller when the reconstruction error is small, since it can be said that the normal data is reproduced more easily as the reconstruction error is smaller. In other words, it is expressed as a linear graph in which the loss value increases in proportion to the reconstruction error. On the other hand, the graphs 302 and 303 of the abnormal label term are loss values related to abnormal data, and it can be said that the larger the reconstruction error, the more abnormal the data is from normal data, so they are designed so that the loss value is smaller when the reconstruction error is large. In addition, the difference between the graphs 302 and 303 occurs because the curve of the abnormal label term is adjusted depending on the value of the adjustment parameter α. Below, the abnormal label term will be explained using the graph 302 as an example.
[0034] Here, the intersection of graphs 301 and 302 indicates that the loss values of the normal label terms and the abnormal label terms match. In other words, by updating the model parameters so that the graphs 301 and 302 intersect at the loss value of the previous step and the loss value becomes smaller by using the adjustment parameter α, it is possible to calculate parameters that minimize the loss value while maintaining a balance between the loss value due to the normal label terms and the loss value due to the abnormal label terms. Note that the adjustment parameter α is automatically calculated in the model learning process because it is based on a previously calculated loss value and is incorporated into the loss function. Alternatively, for example, the display control unit may display a graph relating to the loss function as shown in FIG. 3, and the user may specify a loss value present on the graph 301 of the previously calculated normal label term, thereby calculating a curve in which the abnormal label term intersects the specified point.
[0035] According to the first embodiment described above, model parameters are learned using a loss function including an adjustment parameter based on the loss value of the previous step. Specifically, parameters such as model weights that minimize the loss value calculated by the loss function using the adjustment parameter are determined, thereby determining parameters that provide a good balance between normal label terms and abnormal label terms in the loss function. This avoids biased learning such as learning dominated by abnormal labels, and ensures consistency with a trained model trained by unsupervised learning using only normal data when there is no abnormal data, while also obtaining the learning effect of abnormal data. In other words, the model's performance can be improved while ensuring the model's consistency.
[0036] Second embodiment In the second embodiment, an example of executing inference using a trained model trained by the learning device of the first embodiment will be described.
[0037] FIG. 4 shows a block diagram of an inference device according to the second embodiment. The inference device 40 shown in FIG. 4 includes a data acquisition unit 101, a model execution unit 401, and a display control unit 106.
[0038] The data acquisition unit 101 acquires target data to be processed, for example image data of a product for which it is desired to determine whether the data is abnormal or not. The model executing unit 401 includes a trained model 400 generated by the learning device 10 according to the first embodiment. The model executing unit 401 acquires target data from the data acquiring unit 101, inputs the target data to the trained model 400, executes inference, and outputs an anomaly degree. Here, it is assumed that the trained model 400 is a trained autoencoder. Specifically, the parameter of the trained model determined by the update unit 105 is assumed to be θ^. The superscript "^" indicates that "^" is added directly above a character. The model execution unit 401 receives the parameter θ^ and the target data x for which the degree of anomaly is to be calculated. * n is input. The trained model of the parameter θ^ is used to * The degree of abnormality for n is calculated, for example, by equation (4).
[0039]
number
[0040] The model execution unit 401 may also determine whether the data is abnormal based on the degree of abnormality and output the determination result. For example, if the degree of abnormality is equal to or greater than a threshold, the target data x * n can be judged as abnormal data. Conversely, if the degree of abnormality is less than the threshold, the target data x * It can be determined that n is normal data. The display control unit 106 receives the determination result from the model execution unit 401, and outputs the determination result to the outside.
[0041] Next, the result of the abnormality degree determination by the inference device 40 according to the second embodiment will be described with reference to the graph of FIG.
[0042] Graph 501 is a graph of the calculation result of the degree of anomaly by the inference device 40 according to the second embodiment including the trained model according to the first embodiment. Graph 502 is a graph of the calculation result of the degree of anomaly by a trained model that is an autoencoder trained only with normal data before abnormal data is obtained, assuming a state before the trained model according to the first embodiment is put into operation. Graph 503 is a graph of a comparative example, which is a graph of the calculation result of the degree of anomaly by a trained model generated by learning without adjustment parameters in a loss function including a normal label term and an abnormal label term.
[0043] 5 shows the results of inference by each trained model when three types of data, normal data, known abnormal data, and unknown abnormal data, are input to each trained model from which the results of graphs 501 to 503 are obtained. In the case of the trained model according to the first embodiment from which the results of graph 501 are obtained and the trained model serving as a comparative example from which the results of graph 503 are obtained, the normal data and the known abnormal data are normal data and abnormal data used in training the model, respectively. The unknown abnormal data is abnormal data that is not involved in training the model. On the other hand, in the case of the trained model of the autoencoder from which the results of graph 502 were obtained, the model was trained using only normal data, so the normal data is the data used to train the model, and the known abnormal data and unknown abnormal data are abnormal data that were not involved in training the model.
[0044] First, looking at the calculation results of the degree of anomaly for normal data on the left side of FIG. 5, graph 501 has almost the same degree of anomaly as graph 502. Therefore, it can be said that the trained model for graph 501 and the trained model for graph 502 have high consistency in inference for normal data. On the other hand, graph 503 has a higher degree of anomaly than graphs 501 and 502, even though it is a processing result for normal data. This is because the reconstruction error of normal data also increases as the reconstruction error of abnormal data is maximized. Therefore, it can be said that the autoencoder for graph 502 and the trained model for graph 503 have low consistency.
[0045] 5, the degree of anomaly is higher in graph 501 than in graph 502. Therefore, the trained model according to the present embodiment using graph 501 can determine abnormal data with higher accuracy than the autoencoder using graph 502.
[0046] Next, an example of an image output of the reconstruction error will be described with reference to FIG. 6 shows, from the top, (input) image data of the target data input to the trained model, (output) image data output from the trained model, and (reconstruction error) image data that is the difference between the image of the target data and the trained model output. Note that it is assumed that the target data is abnormal data that includes an abnormal region 603.
[0047] An image group 601 is image data related to a trained model according to the second embodiment, and an image group 602 is image data related to a trained model trained without adjustment parameters for a loss function, similar to the graph 503. In the trained model according to the second embodiment, an abnormal region 603 included in the target data does not exist in the output from the trained model. Image data of a reconstruction error, which is the difference between input image data and output image data, includes the abnormal region 603, and accurate anomaly detection is performed.
[0048] On the other hand, in the trained model trained without adjustment parameters for the loss function, the output does not reproduce the normal data, and it can be seen that the abnormal region 603 cannot be correctly extracted with respect to the reconstruction error.
[0049] According to the second embodiment described above, by performing inference using a trained model including parameters generated in the first embodiment, it is possible to increase the degree of anomaly for known abnormal data while maintaining consistency with a trained model trained only with normal data. It also becomes easy to determine an abnormal location from the reconstruction error.
[0050] An example of the hardware configuration of the learning device 10 and the inference device 40 according to the above-described embodiment is shown in a block diagram in FIG. The learning device 10 and the inference device 40 include a CPU (Central Processing Unit) 71, a RAM (Random Access Memory) 72, a ROM (Read Only Memory) 73, a storage 74, a display device 75, an input device 76, and a communication device 77, each of which is connected by a bus.
[0051] The CPU 71 is a processor that executes arithmetic processing and control processing according to a program. The CPU 71 executes the processing of each part of the learning device 10 and the inference device 40 described above in cooperation with the programs stored in the ROM 73 and the storage 74, etc., using a predetermined area of the RAM 72 as a working area.
[0052] The RAM 72 is a memory such as a Synchronous Dynamic Random Access Memory (SDRAM), and functions as a work area for the CPU 71. The ROM 73 is a memory that stores programs and various information in a non-rewritable manner.
[0053] The storage 74 is a device that writes and reads data to a magnetic recording medium such as a hard disk drive (HDD), a semiconductor storage medium such as a flash memory, a magnetically recordable storage medium such as a HDD, an optically recordable storage medium, etc. The storage 74 writes and reads data to the storage medium in response to control from the CPU 71.
[0054] The display device 75 is a display device such as an LCD (Liquid Crystal Display), etc. The display device 75 displays various information based on a display signal from the CPU 71. The input device 76 is an input device such as a mouse, a keyboard, etc. The input device 76 receives information input by a user as an instruction signal, and outputs the instruction signal to the CPU 71. The communication device 77 communicates with external devices via a network under the control of the CPU 71 .
[0055] The instructions shown in the processing procedures shown in the above-mentioned embodiments can be executed based on a program, which is software. A general-purpose computer system can store this program in advance and obtain the same effect as the control operation of the learning device and inference device described above by reading this program. The instructions described in the above-mentioned embodiments are recorded as a program that can be executed by a computer on a magnetic disk (flexible disk, hard disk, etc.), an optical disk (CD-ROM, CD-R, CD-RW, DVD-ROM, DVD±R, DVD±RW, Blu-ray (registered trademark) Disc, etc.), a semiconductor memory, or a recording medium similar thereto. The recording medium may be in any storage format as long as it is readable by a computer or an embedded system. If the computer reads the program from this recording medium and causes the CPU to execute the instructions described in the program based on this program, it can realize an operation similar to the control of the learning device and inference device of the above-mentioned embodiments. Of course, when the computer acquires or reads the program, it may acquire or read it through a network. In addition, an OS (operating system), database management software, network, or other MW (middleware) running on a computer may execute some of the processes required to realize this embodiment based on instructions from a program installed on the computer or embedded system from a recording medium. Furthermore, the recording medium in this embodiment is not limited to a medium independent of a computer or an embedded system, but also includes a recording medium that stores or temporarily stores a program downloaded via a LAN, the Internet, or the like. Furthermore, the number of recording media is not limited to one, and cases in which the processing in this embodiment is executed from multiple media are also included in the recording media in this embodiment, and the media may have any configuration.
[0056] The computer or embedded system in this embodiment is for executing each process in this embodiment based on a program stored in a recording medium, and may be configured as any one of a device such as a personal computer or a microcomputer, or a system in which multiple devices are connected to a network. In addition, the computer in this embodiment is not limited to a personal computer but also includes an arithmetic processing device, a microcomputer, etc. included in information processing equipment, and is a general term for equipment or devices that can realize the functions in this embodiment by a program.
[0057] Although several embodiments of the present invention have been described, these embodiments are presented as examples and are not intended to limit the scope of the invention. These novel embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope and spirit of the invention, and are included in the scope of the invention and its equivalents described in the claims. [Explanation of symbols]
[0058] 10...Learning device, 40...Inference device, 71...CPU, 72...RAM, 73...ROM, 74...storage, 75...display device, 76...input device, 77...communication device, 101...data acquisition unit, 102...anomaly degree calculation unit, 103...loss calculation unit, 104...loss holding unit, 105...update unit, 106...display control unit, 301-303, 501-503...graph, 400...trained model, 401...model execution unit, 601, 602...image group, 603...abnormal area
Claims
1. an acquisition unit that acquires data to which a label indicating whether the data is normal data or abnormal data is assigned; a first calculation unit that calculates an anomaly degree indicating a degree to which the data is abnormal data by using an output of a model for the data; A second calculation unit that calculates a loss value related to the degree of anomaly using an adjustment parameter based on a previously calculated loss value and a loss function based on the label; an update unit that updates parameters of the model so as to minimize the loss value; A learning device comprising:
2. The normal data is more likely to occur than the abnormal data; The learning device according to claim 1 , wherein the first calculation unit calculates the degree of abnormality so that the degree of abnormality is low for the normal data and high for the abnormal data.
3. The learning device according to claim 1 or 2, wherein the first calculation unit calculates, as the degree of anomaly, a reconstruction error when the model is an autoencoder, and calculates a negative log-likelihood of a probability distribution when the model is a variational autoencoder.
4. 4. The learning device according to claim 1, wherein the second calculation unit calculates a low value for the normal data and a high value for the abnormal data using, as the loss function, a function that increases according to the degree of abnormality for the normal data having a high probability of occurrence and decreases according to the degree of abnormality for the abnormal data having a lower probability of occurrence than the normal data.
5. 5. The learning device according to claim 2, wherein the update unit updates the adjustment parameters such that a loss function of the loss functions for the normal data and a loss function of the loss functions for the abnormal data intersect at an intersection point that is the previously calculated loss value.
6. The learning device according to claim 1 , wherein the update unit calculates the value based on the previously calculated loss value based on statistics of the previously calculated loss values.
7. The learning device according to claim 1 , wherein the previously calculated loss value is a loss value one epoch earlier or a loss value one iteration earlier in training the model.
8. Obtain data that has been labeled to indicate whether it is normal or abnormal, Calculating an anomaly degree indicating the degree to which the data is abnormal data using the output of the model for the data; Calculating a loss value related to the degree of anomaly using a loss function based on the label and adjustment parameters based on a previously calculated loss value; A learning method for updating parameters of the model so as to minimize the loss value.
9. Computer, An acquisition means for acquiring data to which a label indicating whether the data is normal data or abnormal data is assigned; a first calculation means for calculating an anomaly degree indicating a degree to which the data is abnormal data by using an output of a model for the data; A second calculation means for calculating a loss value related to the degree of anomaly using an adjustment parameter based on a previously calculated loss value and a loss function based on the label; a learning program to function as an update means for updating parameters of the model so as to minimize the loss value.
Citation Information
Patent Citations
Learning device, estimation device, parameter calculation method, and program
JP2020091661A
Learning device, diagnostic device, and learning method
JP2021015405A
