A method for finding initial values ​​of neural network based on genetic algorithm

By constructing multiple networks in the neural network and using directional mutation operations, and calculating errors based on test battery data, the problem of multiple and random parameter selection directions in the genetic algorithm during the optimization process is solved, and the optimal neural network is quickly found. Effect.

CN118014009BActive Publication Date: 2024-09-03广芯微电子(广州)股份有限公司
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202410208110.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-26
Publication Date
2024-09-03
Estimated Expiration
2044-02-26

AI Technical Summary

Technical Problem

When using a genetic algorithm to optimize the initial value of a neural network that calculates battery power, the randomness of parameter selection and cross-mutation results in a long optimization time, making it difficult to quickly find the pre-trained neural network with the smallest error.

Method used

By constructing multiple neural networks, the error is calculated based on the test battery data, and the errors are put into different sets through directional mutation operations, the total error value is compared to determine the value of the target parameter, the parameters are gradually updated, and the neural network with the smallest error is selected as the Pretrained neural network.

Benefits of technology

Determine the parameters of the neural network in a short period of time, quickly find the optimal pre-trained neural network, reduce the optimization time, and improve the efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118014009B
    Figure CN118014009B
Patent Text Reader

Abstract

The present application belongs to the field of computer technology, and discloses a method for optimizing the initial value of a neural network based on a genetic algorithm, including: constructing multiple neural networks; taking the first parameter in each neural network as the target parameter; mutating each target parameter; calculating the error of each neural network; if the target parameter undergoes a first mutation operation, the error of the neural network is placed in a first set, and if the target parameter undergoes a second mutation operation, the error of the neural network is placed in a second set; calculating the total value of the first error of the first set and the total value of the second error of the second set; comparing the total value of the first error and the total value of the second error to determine the value of each target parameter; taking the next parameter as the target parameter until all parameters in each neural network are updated; and selecting the neural network with the smallest error as the pre-trained neural network. The present application can determine the initial value of the parameters of the neural network in a relatively short time, and quickly find the optimal pre-trained 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 method for optimizing initial values ​​of a neural network based on a genetic algorithm. Background Art

[0002] Genetic Algorithm (GA) is a computational model of biological evolution that simulates the natural selection and genetics mechanism of Darwin's theory of biological evolution. It is a method for searching for the optimal solution by simulating the natural evolution process. Its main features are that it operates directly on structural objects, without the limitation of derivative and function continuity; it has inherent implicit parallelism and better global optimization ability; it adopts a probabilistic optimization method, and can automatically obtain and guide the optimization search space without the need for certain rules, and adaptively adjust the search direction. The genetic algorithm takes all individuals in a population as the object, and uses randomization technology to guide the efficient search of an encoded parameter space. Among them, selection, crossover and mutation constitute the genetic operation of the genetic algorithm; parameter encoding, initial population setting, fitness function design, genetic operation design, and control parameter setting constitute the core content of the genetic algorithm. However, when using the genetic algorithm to optimize the initial value of the neural network for calculating the battery power, due to the large number of selection points for parameter selection / crossover / mutation, the parameters of the neural network cannot be guaranteed to change to the optimal value in a short time, that is, the process of finding a pre-trained neural network with the smallest error is tortuous and random, resulting in a long optimization time. Summary of the invention

[0003] The present application provides a method for finding initial values ​​of a neural network based on a genetic algorithm, which can determine various parameters of the neural network in a relatively short time, thereby quickly finding the optimal pre-trained neural network that can be used to train an electric power calculation model.

[0004] In a first aspect, an embodiment of the present application provides a method for optimizing initial values ​​of a neural network based on a genetic algorithm, comprising:

[0005] Step S1, constructing multiple neural networks;

[0006] Step S2, taking the first parameter in each neural network as the target parameter;

[0007] Step S3, mutating each target parameter based on the value of each target parameter;

[0008] Step S4, calculating the error of each neural network based on the test battery data;

[0009] Step S5, if the target parameter undergoes a first mutation operation, the error of the neural network is placed in the first set; if the target parameter undergoes a second mutation operation, the error of the neural network is placed in the second set;

[0010] Step S6, calculating a first total error value of the first set and a second total error value of the second set;

[0011] Step S7, comparing the first total error value and the second total error value to determine the value of each target parameter;

[0012] Step S8, taking the next parameter of the target parameter in each neural network as the target parameter, and returning to step S3 until all the parameters in each neural network are updated;

[0013] Step S9, execute step S4, and select the neural network with the smallest error as the pre-trained neural network.

[0014] Furthermore, the method also includes:

[0015] After constructing multiple sets of neural networks, the initial error of each neural network is calculated based on the test battery data;

[0016] Sort the initial errors and divide them according to a preset ratio to obtain several neural network batches;

[0017] Steps S2-S8 are performed on each neural network in each neural network batch.

[0018] Furthermore, the above-mentioned variation of each target parameter based on the value of each target parameter includes:

[0019] If the target parameter is a first value, a first mutation operation is performed to change it to a second value;

[0020] If the target parameter is the second value, a second mutation operation is performed to change it to the first value.

[0021] Furthermore, the test battery data includes a test current value and a test voltage value.

[0022] Furthermore, the above calculation of the error of each neural network based on the test battery data includes:

[0023] Input the test battery data into the neural network to obtain the output value;

[0024] Calculate actual value based on test battery data;

[0025] The difference between the actual value and the output value is taken as the error of the neural network.

[0026] Furthermore, the above-mentioned comparing the first total error value and the second total error value to determine the value of each target parameter includes:

[0027] If the first total error value is greater than the second total error value, the target parameter of each neural network is set to the second value; otherwise, the target parameter of each neural network is set to the first value.

[0028] Furthermore, the first value is 0 and the second value is 1.

[0029] Furthermore, the number of constructed neural networks is 30, 40 or 50.

[0030] Furthermore, the preset ratio is 1:1, 4:6 or 3:7.

[0031] In a second 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. When the processor executes the computer program, the steps of a method for finding initial values ​​of a neural network based on a genetic algorithm as in any of the above embodiments are performed.

[0032] 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:

[0033] The present application provides a method for finding initial values ​​of a neural network based on a genetic algorithm. By performing directed mutation on the parameters of each constructed neural network and determining the parameter value based on the error after the mutation, compared with using the blind original genetic algorithm for optimization, the present application does not have too many selection directions when determining the parameters of the neural network, and can determine the various parameters of the neural network in a relatively short time, thereby quickly finding the optimal pre-trained neural network that can be used to train an electric power calculation model. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A flowchart of a method for finding initial values ​​of a neural network based on a genetic algorithm is provided as an embodiment of the present application. DETAILED DESCRIPTION

[0035] 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.

[0036] 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.

[0037] See also Figure 1 The present application embodiment provides a method for optimizing initial values ​​of a neural network based on a genetic algorithm, comprising:

[0038] Step S1, construct multiple neural networks.

[0039] Among them, the type of neural network is BP neural network or CNN convolutional neural network.

[0040] The number of neural networks constructed can be 30, 40, or 50.

[0041] Step S2, taking the first parameter in each neural network as the target parameter.

[0042] Step S3, mutating each target parameter based on the value of each target parameter.

[0043] Specifically, if the target parameter is a first value, a first mutation operation is performed to change it to a second value; if the target parameter is a second value, a second mutation operation is performed to change it to the first value.

[0044] Because in the optimization process, the parameters of the neural network can be represented by integers, and each bit in the integer variable is 0 or 1, so the parameter variation is also 0 to 1 and 1 to 0, that is, the first value is 0 and the second value is 1.

[0045] Step S4, calculating the error of each neural network based on the test battery data.

[0046] The test battery data includes a test current value and a test voltage value.

[0047] Specifically, the test battery data is input into the neural network to obtain the output value, the actual value is calculated based on the test battery data, and the difference between the actual value and the output value, that is, (actual value-output value) is used as the error of the neural network.

[0048] Step S5, if the target parameter undergoes a first mutation operation, the error of the neural network is placed in the first set; if the target parameter undergoes a second mutation operation, the error of the neural network is placed in the second set.

[0049] Step S6, calculating a first total error value of the first set and a second total error value of the second set.

[0050] Step S7, comparing the first total error value and the second total error value to determine the value of each target parameter.

[0051] Specifically, if the first total error value is greater than the second total error value, the target parameter of each neural network is set to the second value; otherwise, the target parameter of each neural network is set to the first value.

[0052] In the specific implementation process, the errors of the neural network corresponding to the parameters changing from 0 to 1 can be recorded as delta_V1, delta_V2..., and the errors of the neural network corresponding to the parameters changing from 1 to 0 can be recorded as alpha_V1, alpha_V2... Then the total value of the first error delta_V=delta_V1+delta_V2+..., and the total value of the second error alpha_V=alpha_V1+alpha_V2+...

[0053] Determine the size of delta_V and alpha_V. If delta_V is larger, the parameter corresponding to the change from 0 to 1 should be set to 1. Similarly, if alpha_V is larger, the corresponding parameter should be set to 0.

[0054] Step S8, taking the next parameter of the target parameter in each neural network as the target parameter, and returning to step S3 until all the parameters in each neural network are updated.

[0055] Step S9, execute step S4, and select the neural network with the smallest error as the pre-trained neural network.

[0056] Specifically, the minimum error indicates that the initial values ​​of the parameters of the neural network are optimal and can be used as a pre-trained neural network to enter the training stage.

[0057] The above-mentioned embodiment provides a method for optimizing the initial values ​​of a neural network based on a genetic algorithm. By performing directed mutation on the parameters of each constructed neural network and determining the parameter value based on the error after the mutation, compared with using the blind original genetic algorithm for optimization, the present application does not have too many selection directions when determining the parameters of the neural network. It can determine the various parameters of the neural network in a relatively short time and quickly find the optimal pre-trained neural network that can be used to train an electric power calculation model.

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

[0059] After constructing multiple sets of neural networks, the initial error of each neural network is calculated based on the test battery data.

[0060] The initial errors are sorted and divided according to a preset ratio to obtain several neural network batches.

[0061] Steps S2-S8 are performed on each neural network in each neural network batch.

[0062] Among them, the preset ratios are 1:1, 4:6 or 3:7.

[0063] Specifically, before performing parameter mutation, optimization is performed in batches according to the initial error of the neural network; for example, when the preset ratio is 1:1, the first 50% of the neural networks are taken to execute steps S2-S8, and after all parameters are updated, the last 50% of the neural networks are taken to execute steps S2-S8, and finally step S9 is executed for all the neural networks whose initial values ​​have been updated.

[0064] The above embodiment optimizes the neural network in batches, reducing the computing power required for mutation and calculation.

[0065] 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 method for optimizing the initial value of a neural network based on a genetic algorithm as in any of the above embodiments.

[0066] 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 method for optimizing initial values ​​of a neural network based on a genetic algorithm, which will not be described in detail here.

[0067] 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 method for optimizing the initial value of a neural network based on a genetic algorithm 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 method for optimizing the initial value of a neural network based on a genetic algorithm, and will not be repeated here.

[0068] 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).

[0069] 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.

[0070] 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 method for optimizing initial values ​​of a neural network based on a genetic algorithm, characterized in that: include: Step S1, constructing multiple neural networks; Step S2, taking the first parameter in each of the neural networks as the target parameter; Step S3, mutating each of the target parameters based on the value of each of the target parameters; Specifically, if the target parameter is a first value, a first mutation operation is performed to change it to a second value; if the target parameter is the second value, a second mutation operation is performed to change it to the first value; Wherein, the first value is 0, and the second value is 1; Step S4, calculating the error of each neural network based on the test battery data; Step S5, if the target parameter undergoes the first mutation operation, the error of the neural network is placed in a first set; if the target parameter undergoes the second mutation operation, the error of the neural network is placed in a second set; Step S6, calculating a first total error value of the first set and a second total error value of the second set; Step S7, comparing the first total error value and the second total error value to determine the value of each target parameter; Specifically, if the first total error value is greater than the second total error value, the target parameter of each of the neural networks is set to the second value; otherwise, the target parameter of each of the neural networks is set to the first value; Step S8, taking the next parameter of the target parameter in each neural network as the target parameter, and returning to step S3 until all parameters in each neural network are updated; Step S9, executing step S4, selecting the neural network with the smallest error as the pre-trained neural network.

2. The method for finding initial values ​​of a neural network based on a genetic algorithm according to claim 1, characterized in that: Also includes: After constructing a plurality of sets of the neural networks, calculating an initial error of each of the neural networks based on the test battery data; Sorting the initial errors and dividing them according to a preset ratio to obtain a number of neural network batches; Steps S2-S8 are performed on each of the neural networks in each of the neural network batches.

3. The method for finding initial values ​​of a neural network based on a genetic algorithm according to claim 1, characterized in that: The test battery data includes a test current value and a test voltage value.

4. The method for finding initial values ​​of a neural network based on a genetic algorithm according to claim 1, characterized in that: The calculating the error of each neural network based on the test battery data comprises: Inputting the test battery data into the neural network to obtain an output value; Calculating an actual value based on the test battery data; The difference between the actual value and the output value is taken as the error of the neural network.

5. The method for finding initial values ​​of a neural network based on a genetic algorithm according to claim 1, characterized in that: The number of the constructed neural networks is 30, 40 or 50.

6. The method for finding initial values ​​of a neural network based on a genetic algorithm according to claim 2, characterized in that: The preset ratio is 1:1, 4:6 or 3:

7.

7. 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 initial value optimization method based on genetic algorithm as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Wind power forecasting method based on genetic algorithm optimization BP neural network

    CN101706335A

  • Variation particle swarm optimized BP neural network proportion integration differentiation (PID) control algorithm

    CN104834215A

  • Transformer state evaluation method by optimizing neural network with dynamic mutation particle swarm

    CN105138717A

  • Genetic algorithm-wavelet neural network-based gyroscope random error compensation method and system

    CN108764475A

  • A parameter optimization method of Modelica model based on surrogate model

    CN109522602A