Training methods, devices, and electronic equipment for machine learning models
By calculating sample rarity and anomaly, determining sample value, and applying a weighted loss function, this addresses the problem in existing technologies where sample data category weights affect model training, thereby improving the training effect of machine learning models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-15
- Publication Date
- 2026-04-03
AI Technical Summary
In existing methods, weights are determined solely based on the category of the sample data, which leads to duplicate, highly similar, and anomalous sample data affecting the training performance of machine learning models.
By calculating the sample rarity and anomaly of the sample data, the sample value is determined, and a loss function based on the sample value is used to avoid the impact of duplicate and highly similar sample data on model training.
This effectively avoids the negative impact of repetitive and highly similar sample data on machine learning model training, thus improving the training effect of the model.
Smart Images

Figure CN115994583B_ABST
Abstract
Description
[Technical Field]
[0001] This invention relates to the field of machine learning, and more particularly to a method, apparatus, and electronic device for training a machine learning model. [Background Technology]
[0002] Gradient descent is one of the most widely used training methods for machine learning models in recent years. It obtains the gradient of the model parameters by taking the partial derivative of the loss function, and then updates the model parameters based on the gradient. For sample sets with less-than-ideal data distributions, loss function weighting is a method to optimize the training performance of machine learning models on such sets. Specifically, it quantifies the importance or value of sample data using some method, and then multiplies it by the loss function calculated based on the sample data in the form of weights, thereby amplifying or reducing the gradient.
[0003] The main problem with existing methods is that they determine the weight of sample data based solely on the category of the sample data. This can lead to duplicate, highly similar, and anomalous sample data being assigned high weights in the loss function, which can negatively impact the training performance of machine learning models. [Summary of the Invention]
[0004] This invention provides a training method, apparatus, and electronic device for a machine learning model. By calculating the sample value of the sample data and weighting the sample data, the training effect of the machine learning model is avoided due to the repetition or high similarity of the sample data.
[0005] In a first aspect, embodiments of the present invention provide a method for training a machine learning model, comprising:
[0006] A sample set is determined, the sample set containing several sample data, each of the sample data containing a-dimensional input features and b-dimensional verification features, wherein the sum of a and b is d;
[0007] Each of the features is divided into q intervals, resulting in q d Each neighborhood;
[0008] Based on the values of the features of each dimension of the sample data, each sample data in the sample set is assigned to its corresponding neighborhood.
[0009] According to neighborhood D i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d ;
[0010] According to neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. iThe sample anomaly degree of each sample data;
[0011] Calculate the sample value of each sample data based on the sample rarity and the sample anomaly.
[0012] Based on the sample value, determine the weighting coefficient of the loss function corresponding to each sample data;
[0013] The loss function, weighted by the weighting coefficients, is used for training the machine model.
[0014] In one possible implementation, before dividing each dimension of the feature into q intervals, the method further includes:
[0015] Determine the maximum and minimum values of each dimension feature in the sample set;
[0016] Based on the maximum and minimum values of each dimension feature, the dimensional features of each sample data in the sample set are normalized.
[0017] In one possible implementation, based on the neighborhood D i The input features of the included sample data are used to calculate the neighborhood D. i Sample rarity includes:
[0018] According to the formula Calculate the neighborhood D i The input feature standard deviation of the included sample data, where x is the neighborhood D i The input feature vector containing the sample data. For neighborhood D i The mean of the input feature vectors. For x and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included;
[0019] According to the formula Calculate the neighborhood D i The sample rarity, of which, For q d The mean of the standard deviations of the input features in each neighborhood.
[0020] In one possible implementation, based on the neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly score for each sample data point includes:
[0021] According to the formula Calculate the neighborhood D i The included sample data contains the standard deviation of the validation features, where y is the neighborhood D. iThe included validation feature vectors of the sample data. For neighborhood D i The mean of the internal validation feature vectors. For y and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included;
[0022] According to the formula Calculate the neighborhood D i The sample anomaly of the sample data.
[0023] In one possible implementation, the sample value of each sample data is calculated based on the sample rarity and the sample anomaly, including:
[0024] According to the formula Calculate the neighborhood D i The sample value of the included sample data;
[0025] In one possible implementation, the weighting coefficients of the loss function corresponding to each sample data are determined based on the sample value, including:
[0026] Determine the maximum and minimum values of the sample values in the sample data;
[0027] For neighborhood D i The sample values of the included sample data are normalized to obtain the weight coefficients of the sample data.
[0028] In the training method of the above machine learning model, a sample set is first determined, which contains several sample data. Each sample data contains a-dimensional input features and b-dimensional validation features, where the sum of a and b is d. Then, each feature dimension is divided into q intervals to obtain q. d Each sample in the above sample set is assigned to a corresponding neighborhood based on the values of its features in each dimension. Then, based on the neighborhood D... i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d Then, based on the neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample abnormality of each sample data is determined; then, based on the sample sparseness and the sample abnormality, the sample value of each sample data is calculated; then, based on the sample value, the weighting coefficient of the loss function corresponding to each sample data is determined; wherein, the loss function weighted based on the weighting coefficient is used for training the machine model, avoiding the impact of sample data duplication and high similarity on the training effect of the machine learning model.
[0029] Secondly, embodiments of the present invention provide a training apparatus for a machine learning model, comprising:
[0030] The first determining module is used to determine a sample set, which contains a number of sample data, each of which contains a-dimensional input features and b-dimensional verification features, wherein the sum of a and b is d;
[0031] The partitioning module is used to divide each dimension of the feature into q intervals, resulting in q d Each neighborhood;
[0032] The allocation module is used to allocate each sample data in the sample set to its corresponding neighborhood according to the values of each dimension feature of the sample data.
[0033] The first calculation module is used to calculate based on the neighborhood D. i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d ;
[0034] The second calculation module is used to calculate based on the neighborhood D. i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly degree of each sample data;
[0035] The third calculation module is used to calculate the sample value of each sample data based on the sample rarity and the sample anomaly.
[0036] The second determining module is used to determine the weighting coefficient of the loss function corresponding to each sample data based on the sample value;
[0037] A training module is used to train a machine model using a loss function weighted based on the weighting coefficients.
[0038] In one possible implementation, the device further includes:
[0039] The preprocessing module is used to determine the maximum and minimum values of each dimension feature in the sample set; and to normalize each dimension feature of each sample data in the sample set based on the maximum and minimum values of each dimension feature.
[0040] Thirdly, embodiments of the present invention provide an electronic device, comprising:
[0041] At least one processor; and
[0042] At least one memory communicatively connected to the processor, wherein:
[0043] The memory stores program instructions that can be executed by the processor, and the processor can execute the method provided in the first aspect by calling the program instructions.
[0044] Fourthly, embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the method provided in the first aspect.
[0045] It should be understood that the second to fourth aspects of this specification are consistent with the technical solutions of the first aspect of this specification, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, so they will not be described again. [Attached Image Description]
[0046] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 A flowchart illustrating a training method for a machine learning model provided in an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of the structure of a training device for a machine learning model provided in an embodiment of the present invention;
[0049] Figure 3 A schematic diagram of the structure of a training device for another machine learning model provided in an embodiment of the present invention;
[0050] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
Detailed Implementation Methods
[0051] To better understand the technical solutions in this specification, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0052] It should be understood that the described embodiments are merely some, not all, of the embodiments in this specification. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without inventive effort are within the scope of protection of this specification.
[0053] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0054] Figure 1 This is a flowchart illustrating a method for training a machine learning model according to an embodiment of the present invention. This method can be used in processing devices capable of training machine learning models, such as… Figure 1 As shown, it may include:
[0055] Step 101: Determine a sample set, which contains several sample data, each of which contains a-dimensional input features and b-dimensional verification features, where the sum of a and b is d.
[0056] In this embodiment of the invention, each sample data in the sample set contains d-dimensional features, where a-dimensional features are input features and b-dimensional features are verification features.
[0057] Step 102: Divide each dimension of the feature into q intervals to obtain q d Each neighborhood.
[0058] In this embodiment of the invention, the processing device uniformly divides each dimension of the sample set into q intervals, generating a total of q intervals. d Each neighborhood is of equal size. For example, if the sample data contains two dimensions, dividing each dimension of the sample set into five equal intervals will produce 25 neighborhoods.
[0059] In one implementation, before dividing each dimension of the feature into q intervals, the processing device preprocesses the sample set. For sample data with missing or abnormal information, the processing device discards the sample data directly or replaces it with the average value of the corresponding dimension. Then, the processing device determines the maximum and minimum values of each dimension of the feature in the sample set, and then normalizes each dimension of the feature of each sample data in the sample set based on the maximum and minimum values of each dimension. The normalization formula is x... i =(x i -x min,i ) / (x max,i -x min,i ), where x min,i Let x be the minimum value of the i-th dimension feature of the sample data. max,i x is the maximum value of the i-th dimension feature of the sample data. i Let be the i-th feature of the sample data. The effect of normalization is that the value of each feature in all sample data is within the interval [0,1].
[0060] Step 103: Based on the values of the features of each dimension of the sample data, assign each sample data in the sample set to its corresponding neighborhood.
[0061] Step 104, based on neighborhood D i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d .
[0062] In this embodiment of the invention, the calculation is first performed according to the formula. Calculate the neighborhood D i9 The input feature standard deviation, where x is the neighborhood D. i The input feature vector containing the sample data. For neighborhood D i The mean of the input feature vectors. For x and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included. Neighborhood D i The standard deviation of the input features reflects the neighborhood D i The degree of concentration of input features in the sample data. A larger standard deviation of the input features indicates a larger neighborhood D. i The more dispersed the input features of the sample data, the lower the repetition; the smaller the standard deviation of the input features, the greater the neighborhood D. i The more concentrated the input features of the sample data, the higher the repetition rate. A standard deviation of the input features can be calculated for each neighborhood, totaling q. d The standard deviation of each input feature.
[0063] After calculating the standard deviation of the input features for each neighborhood, the processing device will proceed according to the formula. Calculate the neighborhood D i The sample rarity, of which, For q d The mean of the standard deviations of the input features in each neighborhood D. i The sample rarity and neighborhood D of the in-sample data i The sample rarity is the same.
[0064] Step 105, based on neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly degree of each sample data.
[0065] In this embodiment of the invention, the processing device will follow the formula Calculate the neighborhood D i The standard deviation of the validation features, where y is the neighborhood D iThe included validation feature vectors of the sample data. For neighborhood D i The mean of the internal validation feature vectors. For y and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included.
[0066] Afterwards, the processing equipment will proceed according to the formula. Calculate the neighborhood D i The sample anomaly score of the sample data. The sample anomaly score represents the degree of anomalousness of the validation features in the sample data; the higher the score, the greater the anomalousness of the sample data. Neighborhood D i The sample anomalies of the included sample data may not be the same.
[0067] Step 106: Calculate the sample value of each sample data based on the sample rarity and the sample anomaly.
[0068] In this embodiment of the invention, the processing device will follow the formula Calculate the neighborhood D i The sample value of included sample data. In a sample set, duplicate, highly similar, and anomalous sample data can negatively impact the training performance of machine learning models. Sample scarcity reflects the degree of duplication and similarity among sample data; higher scarcity indicates lower similarity and duplication, thus increasing the value of the sample data. Sample anomality reflects the degree of anomalousness among sample data; higher anomality indicates greater abnormality, resulting in lower value. Therefore, the sample value of sample data is calculated by subtracting sample scarcity from sample anomality.
[0069] Step 107: Determine the weighting coefficient of the loss function corresponding to each sample data based on the sample value.
[0070] In this embodiment of the invention, the higher the sample value of the sample data, the larger the weighting coefficient of the loss function corresponding to that sample data; the lower the sample value of the sample data, the smaller the weighting coefficient of the loss function corresponding to that sample data. First, the processing device determines the maximum and minimum sample values in the sample data, and then, according to the formula... For neighborhood D i The sample values of the included sample data are normalized to obtain the weight coefficients of the sample data, where, The minimum value of the sample. This represents the maximum value of the sample. After normalizing the sample values of the sample data, the values of the sample are all within the interval [0,1].
[0071] Step 108, wherein the loss function weighted based on the weighting coefficients is used for training the machine model.
[0072] According to the formula The loss function is weighted, where MSE is the original loss function and MSE′ is the loss function adjusted using this method. In training machine learning models, the loss function is used to adjust the model's parameters. Multiplying the loss function by the corresponding weighting coefficients before parameter adjustment can prevent duplicate, highly similar, and anomalous sample data from affecting the training performance of the machine learning model.
[0073] In this embodiment of the invention, a sample set is first determined, which contains several sample data. Each sample data contains a-dimensional input feature and b-dimensional validation feature, where the sum of a and b is d. Then, each feature dimension is divided into q intervals to obtain q. d Each sample in the above sample set is assigned to a corresponding neighborhood based on the values of its features in each dimension. Then, based on the neighborhood D... i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d Then, based on the neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample abnormality of each sample data is determined; then, based on the sample sparseness and the sample abnormality, the sample value of each sample data is calculated; then, based on the sample value, the weighting coefficient of the loss function corresponding to each sample data is determined; wherein, the loss function weighted based on the weighting coefficient is used for training the machine model, avoiding the impact of sample data duplication and high similarity on the training effect of the machine learning model.
[0074] In one implementation, the method of this invention can be used to predict the number of remaining parking spaces in a smart city. For example, there are three parking lots, A, B, and C. Parking lots A and B have parking space detection devices for detecting the remaining parking spaces, while parking lot C does not. In this case, the method of this invention can be used to predict the number of remaining parking spaces in parking lot C.
[0075] First, a sample set is determined, containing n data points. Each sample data point contains two input features and one validation feature. The two input features are the number of remaining parking spaces in parking lots A and B, denoted as Va and Vb, respectively; the validation feature is the number of remaining parking spaces in parking lot C, denoted as Vc. Known historical data is selected to train the model, where Va, Vb, and Vc are all known variables.
[0076] Next, the sample data is normalized. Taking Va as an example, the normalization formula is V a =(V a -V min,a ) / (V max,a -V min,a ), where V max,a and V min,a These represent the maximum and minimum number of remaining parking spaces provided for parking lot A, respectively. Vb and Vc are processed in the same way. The result of sample data normalization is that the values of Va, Vb, and Vc for all sample data are within the interval [0,1].
[0077] The sample set is divided into 5 equal parts on each feature dimension, resulting in a total of 25 neighborhoods. The sample data is assigned to the corresponding neighborhood according to the feature value.
[0078] According to the formula Calculate the neighborhood D i The standard deviation of the input features is given by x, where x is the input feature vector composed of (Va, Vb). For neighborhood D i The mean of the input feature vector composed of (Va, Vb) is given by the inner (Va, Vb) vector. For x and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included; according to the formula Calculate the neighborhood D i The sample rarity, of which, The mean of the standard deviations of the input features of the 25 neighborhoods.
[0079] According to the formula Calculate the neighborhood D i The standard deviation of the validation features is given by y, where y is Vc, i.e., the number of remaining parking spaces in parking lot C. For neighborhood D i The mean value of internal vitamin C, For y and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included; according to the formula Calculate the neighborhood D i The sample anomaly of the sample data.
[0080] Then, the sample value of the sample data is calculated, and the sample value is then normalized. This process is similar to... Figure 1 The methods described are the same. According to the formula... Calculate the loss function corresponding to the sample data. To predict the number of remaining parking spaces in parking lot C using the model, V cThis represents the actual number of remaining parking spaces in parking lot C. Then, according to the formula... The loss function is weighted, where MSE is the original loss function, and MSE′ is the weighted loss function.
[0081] Figure 2 This is a schematic diagram of a machine learning model training device provided in an embodiment of the present invention. The machine learning model training device in this embodiment can serve as a training device for the machine learning model to implement the machine learning model training method provided in this application. Figure 2 As shown, the training device for the above-mentioned machine learning model may include: a first determining module 21, a partitioning module 22, an allocation module 23, a first calculation module 24, a second calculation module 25, a third calculation module 26, a second determining module 27, and a training module 28.
[0082] The first determining module 21 is used to determine a sample set, which contains a number of sample data, each of which contains a-dimensional input features and b-dimensional verification features, wherein the sum of a and b is d.
[0083] The partitioning module 22 is used to divide each dimension of the feature into q intervals, thus obtaining q d Each neighborhood.
[0084] The allocation module 23 is used to allocate each sample data in the sample set to its corresponding neighborhood according to the values of each dimension feature of the sample data.
[0085] The first calculation module 24 is used to calculate based on the neighborhood D. i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d .
[0086] The second calculation module 25 is used to calculate based on the neighborhood D. i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly degree of each sample data.
[0087] The third calculation module 26 is used to calculate the sample value of each sample data based on the sample rarity and the sample anomaly.
[0088] The second determining module 27 is used to determine the weighting coefficient of the loss function corresponding to each sample data based on the sample value.
[0089] Training module 28 is used to train the machine model using a loss function weighted based on the weighting coefficients.
[0090] Figure 2The training apparatus for the machine learning model provided in the illustrated embodiment can be used to execute this specification. Figure 1 The implementation principle and technical effects of the method embodiment shown can be further referred to the relevant description in the method embodiment.
[0091] Figure 3 This is a schematic diagram of a training device for another machine learning model provided in an embodiment of the present invention. Figure 2 The difference between the training device shown and the training device for the machine learning model is that... Figure 3 The training apparatus for the machine learning model shown may further include: a preprocessing module 29.
[0092] Preprocessing module 29 is used to determine the maximum and minimum values of each dimension feature in the sample set;
[0093] Based on the maximum and minimum values of each dimension feature, the dimensional features of each sample data in the sample set are normalized.
[0094] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Figure 4 As shown, the electronic device may include at least one processor; and at least one memory communicatively connected to the processor, wherein the memory stores program instructions executable by the processor, and the processor can execute the training method of the machine learning model provided in the embodiments of this application by calling the program instructions.
[0095] The aforementioned electronic device may be the processing device mentioned in the method embodiment, and this embodiment does not limit the specific form of the aforementioned electronic device.
[0096] Figure 4 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present application is shown. Figure 4 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0097] like Figure 4 As shown, the electronic device is represented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: one or more processors 410, memory 430, and communication bus 440 connecting different system components (including memory 430 and processing unit 410).
[0098] Communication bus 440 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) buses, Micro Channel Architecture (MAC) buses, Enhanced ISA buses, Video Electronics Standards Association (VESA) local buses, and Peripheral Component Interconnect (PCI) buses.
[0099] Electronic devices typically include a variety of computer-readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, and removable and non-removable media.
[0100] Memory 430 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Although Figure 4 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disc drive for reading and writing to a removable non-volatile optical disc (e.g., a compact disc read-only memory (CD-ROM), a digital video disc read-only memory (DVD-ROM), or other optical media). In these cases, each drive can be connected to the communication bus 440 via one or more data media interfaces. The memory 430 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.
[0101] A program / utility having a set (at least one) of program modules can be stored in memory 430. Such program modules include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules typically perform the functions and / or methods described in the embodiments of this application.
[0102] The electronic device can also communicate with one or more external devices (such as a keyboard, pointing device, display, etc.), and with one or more devices that enable a user to interact with the electronic device, and / or with any device that enables the electronic device to communicate with one or more other computing devices (such as a network card, modem, etc.). This communication can be performed through communication interface 420. Furthermore, the electronic device can also communicate through a network adapter ( Figure 4 (Not shown) communicates with one or more networks (e.g., Local Area Network (LAN), Wide Area Network (WAN), and / or public networks, such as the Internet). The aforementioned network adapter can communicate with other modules of the electronic device via communication bus 440. It should be understood that, although... Figure 4 Not shown, other hardware and / or software modules can be used in conjunction with electronic devices, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Drives (RAID) systems, tape drives, and data backup storage systems.
[0103] The processor 410 executes various functional applications and data processing by running programs stored in the memory 430, such as implementing the training method of the machine learning model provided in the embodiments of the present invention.
[0104] This invention also provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the training method of the machine learning model provided in this invention.
[0105] The aforementioned non-transitory computer-readable storage medium may be any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in connection with an instruction execution system, apparatus, or device.
[0106] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0107] The program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0108] Computer program code for performing the operations described herein can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0110] In the description of this specification, the 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 this specification. 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. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0111] 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 specification, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0112] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this specification includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which the embodiments of this specification pertain.
[0113] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0114] It should be noted that the terminals involved in the embodiments of the present invention may include, but are not limited to, personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.
[0115] In the several embodiments provided in this specification, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0116] Furthermore, the functional units in the various embodiments of this specification can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0117] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this specification. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0118] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A method for training a machine learning model, characterized in that, The method is applied to smart cities, including: A sample set is determined, which contains several sample data. Each sample data contains an a-dimensional input feature and a b-dimensional verification feature, wherein the sum of a and b is d. The a-dimensional input feature includes Va, the number of remaining parking spaces in parking lot A, and Vb, the number of remaining parking spaces in parking lot B. The b-dimensional verification feature includes Vc, the number of remaining parking spaces in parking lot C. Each of the features is divided into q intervals, resulting in q d Each neighborhood; Based on the values of the features of each dimension of the sample data, each sample data in the sample set is assigned to its corresponding neighborhood. According to neighborhood D i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d ; According to neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly degree of each sample data; Calculate the sample value of each sample data based on the sample rarity and the sample anomaly. Based on the sample value, determine the weighting coefficient of the loss function corresponding to each sample data; The loss function, weighted by the weighting coefficients, is used for training the machine model. The step of calculating the sample value of each sample data based on the sample rarity and the sample anomaly includes: The sample rarity is calculated based on the standard deviation of the input features, and the sample anomaly is calculated based on the standard deviation of the validation features. The difference between the sample rarity and the sample anomaly is determined as the sample value of the sample data.
2. The method according to claim 1, characterized in that, Before dividing each dimension of the feature into q intervals, the method further includes: Determine the maximum and minimum values of each dimension feature in the sample set; Based on the maximum and minimum values of each dimension feature, the dimensional features of each sample data in the sample set are normalized.
3. The method according to claim 1, characterized in that, According to neighborhood D i The input features of the included sample data are used to calculate the neighborhood D. i Sample rarity includes: According to the formula Calculate the neighborhood D i The input feature standard deviation, where x is the neighborhood D i The input feature vector containing the sample data. For neighborhood D i The mean of the input feature vectors. For x and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included; According to the formula Calculate the neighborhood D i The sample rarity, where, For q d The mean of the standard deviations of the input features in each neighborhood.
4. The method according to claim 3, characterized in that, According to neighborhood D i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly score for each sample data point includes: According to the formula Calculate the neighborhood D i The standard deviation of the validation features, where y is the neighborhood D i The included validation feature vectors of the sample data. For neighborhood D i The mean of the internal validation feature vectors. For y and The sum of the absolute values of the differences, where n is the neighborhood D. i The number of sample data included; According to the formula Calculate the neighborhood D i The sample anomaly of the sample data.
5. The method according to claim 4, characterized in that, Based on the sample rarity and the sample anomaly, the sample value of each sample data is calculated, including: According to the formula Calculate the neighborhood D i The sample value of the included sample data.
6. The method according to claim 1, characterized in that, Based on the sample value, determine the weighting coefficients of the loss function corresponding to each sample data, including: Determine the maximum and minimum values of the sample values in the sample data; For neighborhood D i The sample values of the included sample data are normalized to obtain the weight coefficients of the sample data.
7. A training device for a machine learning model, characterized in that, The device is deployed in smart cities and includes: The first determining module is used to determine a sample set, which contains several sample data. Each sample data contains an a-dimensional input feature and a b-dimensional verification feature, wherein the sum of a and b is d. The a-dimensional input feature includes Va, the number of remaining parking spaces in parking lot A, and Vb, the number of remaining parking spaces in parking lot B. The b-dimensional verification feature includes Vc, the number of remaining parking spaces in parking lot C. The partitioning module is used to divide each dimension of the feature into q intervals, resulting in q d Each neighborhood; The allocation module is used to allocate each sample data in the sample set to its corresponding neighborhood according to the values of each dimension feature of the sample data. The first calculation module is used to calculate based on the neighborhood D. i The input features of the included sample data are used to calculate the neighborhood D. i The sample rarity, where i takes values of 1, 2, 3...q d ; The second calculation module is used to calculate based on the neighborhood D. i The included sample data's validation features are used to calculate the neighborhood D. i The sample anomaly degree of each sample data; The third calculation module is used to calculate the sample value of each sample data based on the sample rarity and the sample anomaly. The second determining module is used to determine the weighting coefficient of the loss function corresponding to each sample data based on the sample value; A training module, in which a loss function weighted based on the weighting coefficients is used to train a machine model; The step of calculating the sample value of each sample data based on the sample rarity and the sample anomaly includes: The sample rarity is calculated based on the standard deviation of the input features, and the sample anomaly is calculated based on the standard deviation of the validation features. The difference between the sample rarity and the sample anomaly is determined as the sample value of the sample data.
8. The apparatus according to claim 7, characterized in that, Also includes The preprocessing module is used to determine the maximum and minimum values of each dimension feature in the sample set; and to normalize each dimension feature of each sample data in the sample set based on the maximum and minimum values of each dimension feature.
9. An electronic device, characterized in that, include: At least one processor; as well as At least one memory communicatively connected to the processor, wherein: The memory stores program instructions that can be executed by the processor, and the processor can execute the method as described in any one of claims 1 to 6 by calling the program instructions.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause the computer to perform the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Neural network training method and device, apparatus, and medium
CN109272115A
Visual tracking method and device, computer equipment and medium
CN111104831A