A neural network training method, device and computer equipment

By sorting and dividing the sample errors, training the second neural network and combining the outputs of the first and second neural networks, the problem of unstable accuracy of the calculation of battery parameters by neural networks is solved, and a more stable final result is achieved.

CN118278490BActive Publication Date: 2024-11-19广芯微电子(广州)股份有限公司
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410297227.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-15
Publication Date
2024-11-19
Estimated Expiration
2044-03-15

AI Technical Summary

Technical Problem

When training the neural network to calculate battery-related parameters, since the neural network operates consistently on all samples, the error is large or small, resulting in unstable accuracy of the final result.

Method used

By obtaining multiple sample input neural networks, calculating errors, sorting and dividing them into low error sample sets and high error sample sets, training the second neural network based on the high error sample sets, combining the output results of the first and second neural networks to obtain The final result.

Benefits of technology

It improves the calculation accuracy stability of neural networks when formally applied, avoids the problem of poor fitting accuracy of a single network, and ensures accurate final results under different conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118278490B_ABST
    Figure CN118278490B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of computer technology, and discloses a neural network training method, device and computer equipment, the method comprising: obtaining multiple samples and inputting them into a first neural network to obtain a first output result of each sample; repeating the above steps until a preset number of times is reached; calculating the error of each sample during the last training; sorting each sample based on each error; dividing the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set; training a second neural network based on the high-error sample set; calculating the high-error average sample value of the high-error sample set and the low-error average sample value of the low-error sample set; obtaining a target sample, calculating a first distance from the target sample to the high-error average sample value and a second distance to the low-error average sample value; obtaining a final result based on the magnitude relationship between the first distance and the second distance. The present application can ensure the accuracy and stability of the final result output by the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a neural network training method, apparatus and computer equipment. Background Art

[0002] In the process of training the neural network to calculate battery-related parameters, since the training process of the neural network is to perform a forward calculation on all samples and adjust the network parameters by error back propagation, that is, the operation process of the neural network for all samples is consistent and the same loss function is used, this will cause the neural network to have large errors when acting on some samples and small errors when acting on other samples, resulting in the calculation of the input battery parameters being neglected and the accuracy being unstable when the neural network is formally applied. Summary of the invention

[0003] The present application provides a neural network training method, apparatus and computer equipment, which can ensure the stability of the accuracy of the final result obtained through neural network calculation.

[0004] In a first aspect, an embodiment of the present application provides a neural network training method, comprising:

[0005] Step S1, obtaining multiple samples and inputting them into a first neural network to obtain a first output result of each sample;

[0006] Step S2, returning to step S1 until the number of repeated training reaches a preset number;

[0007] Step S3, calculating the error of each sample during the last training;

[0008] Step S4, sorting the samples based on the errors;

[0009] Step S5, dividing the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set;

[0010] Step S6, training a second neural network based on the high error sample set;

[0011] Step S7, calculating the high error average sample value of the high error sample set and the low error average sample value of the low error sample set;

[0012] Step S8, obtaining a target sample, and calculating a first distance from the target sample to a high error average sample value and a second distance from the target sample to a low error average sample value;

[0013] Step S9, if the first distance is greater than or equal to the second distance, the target sample is input into the trained first neural network to obtain the final result; otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is used as the final result.

[0014] Furthermore, the method also includes:

[0015] After executing step S1, the error of each sample is calculated;

[0016] Accumulating each error to obtain a first error accumulation value;

[0017] Determining whether the first error accumulation value is lower than a first preset threshold;

[0018] If yes, the training ends, otherwise, the process returns to step S1.

[0019] Furthermore, the above calculation of the error of each sample during the last training includes:

[0020] Subtracting the first output result of the sample from the supervisory signal of the sample to obtain a first difference;

[0021] The square of the first difference is taken as the error of the sample passing through the first neural network.

[0022] Furthermore, the above-mentioned training of the second neural network based on the high error sample set includes:

[0023] Step S61, inputting each sample in the high error sample set into the second neural network to obtain a second output result;

[0024] Step S62, obtaining a second error accumulation value based on the errors of each sample and the second output result;

[0025] Step S63, determining whether the second error accumulation value is less than a second preset threshold;

[0026] Step S64, if yes, end the training, otherwise return to step S61.

[0027] Furthermore, the second error accumulation value is obtained based on the errors of each sample and the second output result, including:

[0028] The inverse of the error of the sample passing through the first neural network is used as the latest supervisory signal of the sample;

[0029] Subtract the second output result from the latest supervisory signal to obtain a second difference;

[0030] The squares of the second difference values ​​are added together to obtain a second error accumulation value.

[0031] Furthermore, the preset ratio is 3:7.

[0032] Furthermore, the first distance and the second distance are both two-norm distances.

[0033] Furthermore, the sample is battery data, and the battery data includes the current value of the battery at the current moment and the previous moment, and the voltage value of the battery at the current moment and the previous moment;

[0034] The first neural network and the second neural network are used to calculate the battery power or the remaining charge and discharge time.

[0035] In a second aspect, an embodiment of the present application provides a neural network training device, comprising:

[0036] A first input module is used to obtain multiple samples and input them into a first neural network to obtain a first output result of each sample;

[0037] A first training module, used to repeatedly execute the first input module until a preset number of times is reached;

[0038] The error calculation module is used to calculate the error of each sample during the last training;

[0039] A sorting module, for sorting each sample based on each error;

[0040] A partitioning module is used to partition the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set;

[0041] A second training module, used for training a second neural network based on a high error sample set;

[0042] A sample average calculation module, used to calculate a high error average sample value of a high error sample set and a low error average sample value of a low error sample set;

[0043] A distance calculation module, used for acquiring a target sample, and calculating a first distance from the target sample to a high error average sample value and a second distance from the target sample to a low error average sample value;

[0044] The second input module is used to input the target sample into the trained first neural network to obtain the final result when the first distance is greater than or equal to the second distance; otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is used as the final result.

[0045] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of a neural network training method as described in any of the above embodiments are performed.

[0046] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0047] The embodiments of the present application provide a neural network training method, apparatus and computer equipment. After training the first neural network, the second neural network is trained using samples with low fitting accuracy of the first network, that is, a high-error sample set, thereby avoiding the effect of poor fitting accuracy of the single network for the samples due to the definition of the loss function. Therefore, in formal application, if the second distance from the target sample to the low-error average sample value is small, only the first neural network needs to be used to obtain an accurate final result. When the first distance from the high-error average sample value is small, it means that the first neural network has poor fitting accuracy for the target sample. At this time, it is necessary to use the second neural network trained with the high-error sample set in combination with the outputs of the first neural network and the second neural network to obtain an accurate final result. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A flowchart of a neural network training method provided for an exemplary embodiment of the present application.

[0049] Figure 2 A structural diagram of a neural network training device provided as an exemplary embodiment of the present application.

[0050] Figure 3 A simulation diagram of a neural network training method provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0051] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0052] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.

[0053] See also Figure 1 , the present application embodiment provides a neural network training method, comprising:

[0054] Step S1, obtaining multiple samples and inputting them into a first neural network to obtain a first output result of each sample.

[0055] The sample may be battery data, including the current value of the battery at the current moment and the previous moment, and the voltage value of the battery at the current moment and the previous moment; the first output result may be the power level of the battery or the remaining charge and discharge time.

[0056] Step S2, return to step S1, until the number of repeated training reaches a preset number.

[0057] Step S3, calculating the error of each sample during the last training.

[0058] Specifically, subtract the first output result of the sample from the supervisory signal of the sample to obtain a first difference, and take the square of the first difference as the error of the sample passing through the first neural network, that is, error = (supervisory signal of the sample - first output result)^2.

[0059] Among them, the supervisory signal of the sample is the true value corresponding to the sample, which is known for the samples in the training phase.

[0060] Step S4, sorting the samples based on the errors.

[0061] Step S5, dividing the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set.

[0062] Specifically, the preset ratio may be 3:7, 4:6, etc. Taking 3:7 as an example, 30% of the samples with the highest errors in the sorting results are taken as the high-error sample set, and the remaining 70% are taken as the low-error sample set.

[0063] Step S6, training the second neural network based on the high error sample set.

[0064] The first neural network and the second neural network are both used to calculate the battery power or the remaining charge and discharge time.

[0065] Step S7, calculating the high error average sample value of the high error sample set and the low error average sample value of the low error sample set.

[0066] Step S8, obtaining a target sample, and calculating a first distance from the target sample to the high error average sample value and a second distance from the target sample to the low error average sample value, wherein both the first distance and the second distance are two-norm distances.

[0067] Step S9, if the first distance is greater than or equal to the second distance, the target sample is input into the trained first neural network to obtain the final result; otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is used as the final result.

[0068] The above-mentioned embodiment provides a neural network training method, device and computer equipment. After training the first neural network, the second neural network is trained using samples with low fitting accuracy of the first network, that is, a high-error sample set, thereby avoiding the effect of poor fitting accuracy of a single network for samples due to the definition of the loss function. Therefore, in formal application, if the second distance from the target sample to the low-error average sample value is small, only the first neural network needs to be used to obtain an accurate final result. When the first distance from the high-error average sample value is small, it means that the first neural network has poor fitting accuracy for the target sample. At this time, it is necessary to use the second neural network trained with the high-error sample set in combination with the outputs of the first neural network and the second neural network to obtain an accurate final result.

[0069] In some embodiments, the method further comprises:

[0070] After executing step S1, the error of each sample is calculated; each error is accumulated to obtain a first error accumulation value.

[0071] Determine whether the first error accumulation value is lower than a first preset threshold; if so, end the training, otherwise return to step S1.

[0072] The calculation method of the error in this embodiment is consistent with the method of calculating the error in step S3 of the above embodiment.

[0073] Specifically, the standard for completing the training of the first neural network in the present application can be that the number of training times reaches a preset number of times set manually, or it can be the judgment result of the first error cumulative value after each training is completed; if the first error cumulative value is already lower than the first preset threshold before reaching the preset number of times, the training can be terminated in advance to obtain a trained first neural network.

[0074] In some embodiments, the training of the second neural network based on the high error sample set includes:

[0075] Step S61, input each sample in the high error sample set into the second neural network to obtain a second output result.

[0076] Step S62: obtaining a second error accumulation value based on the errors of each sample and the second output result.

[0077] Specifically, the inverse of the error of the sample passing through the first neural network is used as the latest supervisory signal of the sample, the second output result is subtracted from the latest supervisory signal to obtain a second difference, and the squares of the second differences are added to obtain a second error accumulated value.

[0078] Step S63, determining whether the second error accumulation value is less than a second preset threshold.

[0079] Step S64, if yes, end the training, otherwise return to step S61.

[0080] In the above embodiment, when training the second neural network, the latest supervisory signal used is the opposite of the output error of the first neural network, so that the second neural network can be trained in the direction of poor fitting accuracy of the first neural network. In the actual application process, the output of the second neural network can compensate for the error of the output of the first neural network.

[0081] See also Figure 2 Another embodiment of the present application provides a neural network training device, comprising:

[0082] The first input module 101 is used to obtain multiple samples and input them into the first neural network to obtain a first output result of each sample.

[0083] The first training module 102 is used to repeatedly execute the first input module until a preset number of times is reached.

[0084] The error calculation module 103 is used to calculate the error of each sample during the last training.

[0085] The sorting module 104 is used to sort the samples based on the errors.

[0086] The division module 105 is used to divide the sorting result according to a preset ratio to obtain a low-error sample set and a high-error sample set.

[0087] The second training module 106 is used to train the second neural network based on the high error sample set.

[0088] The sample average calculation module 107 is used to calculate the high error average sample value of the high error sample set and the low error average sample value of the low error sample set.

[0089] The distance calculation module 108 is used to obtain a target sample and calculate a first distance from the target sample to a high error average sample value and a second distance from the target sample to a low error average sample value.

[0090] The second input module 109 is used to input the target sample into the trained first neural network to obtain the final result when the first distance is greater than or equal to the second distance; otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is used as the final result.

[0091] See also Figure 3 ,From the simulation graph, it can be seen that the dual network error represented by the yellow ,curve is lower than the single network error represented by the green ,curve, that is, the calculation accuracy of the dual network is higher than that of the single ,network.

[0092] The specific limitations of a neural network training device provided in this embodiment can be found in the above embodiment of a neural network training method, which will not be repeated here. Each module in the above neural network training device can be implemented in whole or in part by software, hardware, and a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0093] An embodiment of the present application provides a computer device, which may include a processor, a memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the processor executes the steps of a neural network training method as in any of the above embodiments.

[0094] The working process, working details and technical effects of the computer device provided in this embodiment can be found in the above embodiment of a neural network training method, which will not be described in detail here.

[0095] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of a neural network training method as in any of the above embodiments are implemented. Wherein, the computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive and / or a memory stick (Memory Stick), etc., and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The working process, working details and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment of a neural network training method, and will not be repeated here.

[0096] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0097] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0098] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A neural network training method, characterized in that: include: Step S1, obtaining a plurality of samples and inputting them into a first neural network to obtain a first output result of each of the samples; Step S2, returning to step S1 until the number of repeated training reaches a preset number; Step S3, calculating the error of each sample during the last training; Step S4, sorting the samples based on the errors; Step S5, dividing the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set; Step S6, training a second neural network based on the high error sample set; The sample includes the current value of the battery at the current moment and the previous moment, and the voltage value of the battery at the current moment and the previous moment; The first neural network and the second neural network are used to calculate the power level or the remaining charge and discharge time of the battery; Step S7, calculating the high error average sample value of the high error sample set and the low error average sample value of the low error sample set; Step S8, obtaining a target sample, and calculating a first distance from the target sample to the high error average sample value and a second distance from the target sample to the low error average sample value; Step S9, if the first distance is greater than or equal to the second distance, the target sample is input into the trained first neural network to obtain the final result; otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is used as the final result.

2. The neural network training method according to claim 1, characterized in that: Also includes: After executing step S1, calculating the error of each sample; Accumulating the errors to obtain a first error accumulation value; Determining whether the first error accumulation value is lower than a first preset threshold; If yes, the training ends, otherwise, the process returns to step S1.

3. The neural network training method according to claim 1, characterized in that: The calculating the error of each sample during the last training comprises: Subtracting the first output result of the sample from the supervisory signal of the sample to obtain a first difference; The square of the first difference is used as the error of the sample passing through the first neural network.

4. The neural network training method according to claim 1, characterized in that: The step of training a second neural network based on the high error sample set comprises: Step S61, inputting each sample in the high error sample set into the second neural network to obtain a second output result; Step S62, obtaining a second error accumulation value based on the error of each of the samples and the second output result; Step S63, determining whether the second error accumulation value is less than a second preset threshold; Step S64, if yes, end the training, otherwise return to step S61.

5. The neural network training method according to claim 4, characterized in that: The obtaining a second error accumulation value based on the error of each of the samples and the second output result comprises: Taking the inverse of the error of the sample passing through the first neural network as the latest supervisory signal of the sample; Subtracting the second output result from the latest supervisory signal to obtain a second difference; The squares of the second differences are added together to obtain the second error accumulation value.

6. The neural network training method according to claim 1, characterized in that: The preset ratio is 3:

7.

7. The neural network training method according to claim 1, characterized in that: The first distance and the second distance are both two-norm distances.

8. A neural network training device, characterized in that: include: A first input module, used to obtain a plurality of samples and input them into a first neural network to obtain a first output result of each of the samples; A first training module, used for repeatedly executing the first input module until a preset number of times is reached; An error calculation module, used to calculate the error of each sample during the last training; A sorting module, used for sorting the samples based on the errors; A partitioning module is used to partition the sorting results according to a preset ratio to obtain a low-error sample set and a high-error sample set; A second training module, used for training a second neural network based on the high error sample set; The sample includes the current value of the battery at the current moment and the previous moment, and the voltage value of the battery at the current moment and the previous moment; The first neural network and the second neural network are used to calculate the power level or the remaining charge and discharge time of the battery; A sample average calculation module, used to calculate a high error average sample value of a high error sample set and a low error average sample value of a low error sample set; A distance calculation module, used for acquiring a target sample, and calculating a first distance from the target sample to the high error average sample value and a second distance from the target sample to the low error average sample value; A second input module, used for inputting the target sample into the trained first neural network to obtain a final result when the first distance is greater than or equal to the second distance; Otherwise, the target sample is input into the trained first neural network and the second neural network respectively, and the sum of the outputs of the first neural network and the second neural network is taken as the final result.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the neural network training method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Human face detection method and device

    CN108171196A

  • Game model training method and device, electronic equipment and medium

    CN111389011A

  • Data processing method, network training method, electronic equipment and storage medium

    CN114298280A

  • Training method and training device of neural network for object recognition

    CN114444558A

  • Double-layer neural network wind speed prediction method based on training set segmentation and error correction

    CN116777039A