A method, device, computer equipment and storage medium for generating a neural network
By building a search space and combining the search base model structure and scaling strategy, the problem of low search efficiency of model structures of different scales in the existing technology is solved, and efficient neural network model structure search and multi-scale neural network generation are realized.
Patent Information
- Application Number
- CN202111235918.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-10-22
AI Technical Summary
The existing network structure search algorithm searches for the optimal model structure under fixed computing resource configuration, resulting in the need to search for model structures of different scales separately, which is not efficient and takes a long time.
Build a search space, including the first space for searching the basic model structure and the second space for searching the scaling strategy, obtain the target basic model structure and the scaling strategy corresponding to multiple scales through joint search, and generate multiple scales of Target neural network.
It improves the efficiency of model structure search, reduces the search time, and can generate target neural networks of multiple scales to meet the needs of different hardware resources and response times.
Smart Images

Figure CN113962366B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of deep learning technology, and in particular to a method, device, computer equipment and storage medium for generating a neural network. Background Art
[0002] Deep learning is a hot topic in the field of artificial intelligence and has been widely used in many fields such as image recognition, natural language modeling, object detection, and semantic segmentation. With the development of hardware equipment and large-scale machine learning training technology, many applications of deep learning are no longer satisfied with using only small models for calculation and prediction, but prefer to use large-scale models to obtain better prediction results. At the same time, in response to different hardware resources and different computing requirements such as response time, multiple deep neural network models of different sizes will be used as backbone models in the above scenarios. Multiple models of different sizes can be obtained by scaling a base model to multiple different scales.
[0003] However, existing network structure search algorithms all search for the optimal model structure under a fixed computing resource configuration, and for model structures of different scales, they need to search separately. Therefore, the search efficiency is low and the time consumption is long. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a method, apparatus, computer device and storage medium for generating a neural network.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for generating a neural network, comprising:
[0006] Construct a search space; the search space includes: a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling factor interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, the scaling factor of the base model structure based on the scaling factor interval corresponding to each first scale; the scalable dimensions include: a depth dimension, a width dimension, and a size dimension of the input data; based on the search space, jointly search the base model structure and the scaling strategies corresponding to each first scale in the plurality of first scales to obtain a target base model structure and a first target scaling strategy corresponding to each first scale in the plurality of first scales; wherein the first target scaling strategy corresponding to each first scale in the plurality of first scales is used to scale the target base model structure to generate a first target neural network corresponding to each first scale in the plurality of first scales.
[0007] In this way, by constructing a search space, which includes a first space for searching a base model structure and a second space for searching a scaling strategy, the search space is then used to jointly search the base model structure and the scaling strategies corresponding to the multiple first scales, so as to obtain a target base model structure and first target scaling strategies corresponding to the multiple first scales. The target base model structure and the first target scaling strategies corresponding to the multiple first scales can be used to generate first target neural networks corresponding to the multiple scales, thereby improving the efficiency of the model structure search and reducing the search time.
[0008] In a possible implementation manner, after obtaining the target base model structure and the first target scaling strategy corresponding to each of the plurality of first scales, the method further includes:
[0009] Based on a first target scaling strategy corresponding to each of the plurality of first scales, the target base model structure is scaled to generate a first target neural network corresponding to each of the plurality of first scales.
[0010] In a possible implementation, based on the search space, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales, including: based on the search space, a very large neural network is generated; the very large neural network includes: a plurality of base model structures determined based on the first space, and a neural network structure obtained by scaling the base model structure using a scaling strategy determined based on the second space; based on the search space and the very large neural network, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales.
[0011] In a possible implementation, based on the search space and the very large neural network, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales, including:
[0012] Perform multiple iteration cycles, and in each of the iteration cycles, perform the following steps:
[0013] Based on the first space, determining multiple first base model structures of the current iteration cycle;
[0014] Based on the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle, the multiple first base model structures, and the very large neural network, at least one generation of genetic processing is performed to determine the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures; based on the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures, the second base model structure is determined from the candidate base model structures; wherein the first scaling strategy is determined based on the second space or the previous iteration cycle;
[0015] Based on the first scaling strategies corresponding to each of the multiple first scales in the current iteration cycle, determine multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration cycle through at least one generation of genetic processing; based on the second performance information of the model structure obtained after the second base model structure corresponding to the current iteration cycle is scaled based on each of the intermediate scaling strategies, determine the second scaling strategy corresponding to each of the first scales in the current iteration cycle;
[0016] The second base model structure determined in the last iteration cycle is determined as the target base model structure, and the second scaling strategy corresponding to each of the multiple first scales in the last iteration cycle is determined as the first target scaling strategy corresponding to each of the multiple first scales.
[0017] In a possible implementation manner, determining multiple first base model structures of the current iteration cycle based on the first space includes:
[0018] Random sampling is performed in the first space to obtain a plurality of first base model structures of the current iteration cycle.
[0019] In a possible implementation manner, the method further includes:
[0020] In response to the current iteration cycle being a first iteration cycle, determining, based on the search space, a first scaling strategy corresponding to each first scale of the plurality of first scales in the first iteration cycle;
[0021] In response to the current iteration cycle not being the first iteration cycle, the second scaling strategies corresponding to each first scale of the multiple first scales in the iteration cycle before the current iteration cycle are determined as the first scaling strategies corresponding to each first scale in the current iteration cycle.
[0022] In a possible implementation, in response to the current iteration cycle being the first iteration cycle, determining, based on the search space, a first scaling strategy corresponding to each of the multiple first scales in the first iteration cycle includes:
[0023] A plurality of initial base model structures are obtained by random sampling in the first space, and a plurality of initial scaling strategies corresponding to each of the plurality of first scales are obtained by random sampling in the second space;
[0024] For each of the plurality of first scales, based on the plurality of initial base model structures, the plurality of initial scaling strategies corresponding to each of the first scales, and the very large neural network, determine third performance information of the model structures respectively corresponding to the plurality of initial scaling strategies corresponding to each of the first scales;
[0025] Based on the third performance information of the model structures respectively corresponding to the multiple initial scaling strategies corresponding to each first scale, the first scaling strategy corresponding to each first scale in the first iteration cycle is determined.
[0026] In a possible implementation, for each of the multiple first scales, based on multiple initial base model structures, multiple initial scaling strategies corresponding to each first scale, and the very large neural network, determining third performance information of the model structure corresponding to the multiple initial scaling strategies corresponding to each first scale includes:
[0027] For each of the multiple initial scaling strategies corresponding to each first scale, scaling the multiple initial base model structures respectively based on each initial scaling strategy and the super large neural network to generate multiple first neural networks;
[0028] Using the first validation data set, determining performance information corresponding to each of the plurality of first neural networks;
[0029] Based on the performance information respectively corresponding to the plurality of first neural networks, third performance information of the model structure corresponding to each initial scaling strategy is determined.
[0030] In a possible implementation manner, determining the candidate base model structures corresponding to the at least one generation of genetic processing respectively includes:
[0031] In response to the current generation genetic processing being the first generation genetic processing, determining the first base model structure as the candidate base model structure corresponding to the first generation genetic processing;
[0032] In response to the current generation of genetic processing being non-first generation genetic processing, based on the alternative base model structure corresponding to the previous generation of genetic processing corresponding to the current generation of genetic processing, and the first performance information corresponding to the alternative base model structure corresponding to the previous generation of genetic processing, the alternative base model structure corresponding to the previous generation of genetic processing is crossover and / or mutation processed to obtain the alternative base model structure corresponding to the current generation of genetic processing.
[0033] In a possible implementation, for the current generation of genetic processing, the first performance information of the candidate base model structure corresponding to the current generation of genetic processing is determined in the following manner:
[0034] For each candidate base model structure in the candidate base model structure corresponding to the current generation genetic processing, based on each candidate base model structure, a first scaling strategy corresponding to each first scale in the multiple first scales in the current iteration cycle, and the super large neural network, a second neural network corresponding to each first scale in the multiple first scales is constructed;
[0035] Determine, using a validation data set, performance information corresponding to each of the plurality of second neural networks;
[0036] Based on the performance information respectively corresponding to the plurality of second neural networks, the first performance information corresponding to each candidate base model structure is determined.
[0037] In a possible implementation manner, the first scaling strategy corresponding to each first scale in the multiple first scales in the current iteration cycle is determined by at least one generation of genetic processing to determine multiple intermediate scaling strategies corresponding to each first scale in the multiple first scales in the current iteration cycle, including:
[0038] For each of the multiple first scales, in each generation of genetic processing, the first scaling strategy corresponding to each first scale in the current iteration cycle is subjected to crossover and / or mutation processing of the contemporary genetic processing to obtain multiple intermediate scaling strategies corresponding to the contemporary genetic processing of each first scale in the current iteration cycle.
[0039] In a possible implementation manner, determining the second scaling strategy corresponding to each first scale in the current iteration period based on the second performance information of the model structure obtained after scaling the second base model structure corresponding to the current iteration period based on each intermediate scaling strategy includes:
[0040] Based on the second base model structure corresponding to the current iteration cycle, the multiple intermediate scaling strategies corresponding to each first scale in the current iteration cycle, and the super large neural network, generate multiple third neural networks corresponding to the first scale in the current iteration cycle;
[0041] Determine, using a third validation data set, second performance information respectively corresponding to a plurality of the third neural networks;
[0042] Based on the second performance information respectively corresponding to the plurality of third neural networks, a second scaling strategy corresponding to each first scale in the current iteration cycle is determined from the plurality of intermediate scaling strategies corresponding to each first scale.
[0043] In a possible implementation, the first target scaling strategy based on each of the multiple first scales respectively corresponding to the target base model structure is used to generate a first target neural network corresponding to each of the multiple first scales respectively, including:
[0044] Using the first target scaling strategy corresponding to each first scale, the target base model structure is scaled to obtain a scaled model corresponding to each first scale;
[0045] Based on the scaling model and the super large neural network, a plurality of first target neural networks corresponding to the first scales are generated.
[0046] In a possible implementation manner, the method further includes:
[0047] Based on the first target scaling strategies corresponding to the multiple first scales, respectively, in the fitting functions corresponding to at least one scaling dimension in the scaling strategies, respectively, the fitting parameters corresponding to the at least one scaling dimension are solved; and the target fitting functions corresponding to the at least one scaling dimension are obtained; wherein the fitting functions are used to fit the relationship between the base model structure and the scaling strategies;
[0048] Determine second target scaling strategies corresponding to a plurality of second scales respectively by using the target fitting function;
[0049] Based on the second target scaling strategy and the target base model structure, second target neural networks corresponding to multiple second scales are generated.
[0050] In a second aspect, the embodiments of the present disclosure further provide a neural network generation device, comprising: a construction module, for constructing a search space; the search space comprises: a first space, and a second space; wherein the second space comprises a plurality of first scales for scaling a base model structure; each scaling scale corresponds to a scaling multiple interval; the scaling strategy determined based on the scaling space comprises a scaling multiple for scaling the base model structure at any scaling scale; the scaling process comprises scaling process in at least one of the following dimensions: scaling process in the depth direction of the base model structure, scaling process in the width direction of the base model structure, and scaling process in the size of input data;
[0051] A search module is used to jointly search the base model structure and the scaling strategies corresponding to the multiple first scales based on the search space to obtain a target base model structure and the first target scaling strategies corresponding to the multiple first scales; wherein the target base model structure and the first target scaling strategies corresponding to the multiple first scales are used to generate first target neural networks corresponding to the multiple first scales, and the performance of the first target neural network meets the preset performance conditions.
[0052] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.
[0053] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are executed.
[0054] For a description of the effects of the above-mentioned neural network generation device, computer equipment, and computer-readable storage medium, please refer to the description of the above-mentioned neural network generation method, which will not be repeated here.
[0055] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0057] Figure 1 A flowchart of a method for generating a neural network provided by an embodiment of the present disclosure is shown;
[0058] Figure 2A flowchart showing a specific method for performing joint search of a base model structure and scaling strategies corresponding to a plurality of first scales in the method for generating a neural network provided by an embodiment of the present disclosure;
[0059] Figure 3 A flowchart showing another method for generating a neural network provided by an embodiment of the present disclosure is shown;
[0060] Figure 4 A schematic diagram of a neural network generation device provided by an embodiment of the present disclosure is shown;
[0061] Figure 5 A schematic diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure claimed for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0063] Research has found that existing network structure search algorithms all search for the optimal model structure under a fixed computing resource configuration (the demand for computing resources is positively correlated with the model scale, that is, the larger the scale of the model, the greater the demand for computing resources). However, for model structures of different scales, they need to be searched separately. Therefore, the search efficiency is not high and the search time is long.
[0064] In addition, the current technologies for discussing model scale are all based on a specific base model. According to the set scale range, a group of scaled models are manually trained, and the performance of this group of models is used to manually select which scale scaling strategy to use. There are several problems: first, the total time for training all models is too long, and the computing resources consumed are too large; second, the base model used may not be well suited for model scale scaling; third, it only considers the performance of the model obtained by evaluating the scale scaling once, but the results after multiple scale scaling are unknown, which makes these methods not stable enough in other larger scale scaling. Therefore, how to use as few computing resources as possible to search for the best multi-scale scaling strategy while building the backbone deep neural network base model structure is an urgent problem to be solved.
[0065] Based on the above research, the present disclosure provides a method for generating a neural network. By constructing a search space, a base model structure and scaling strategies corresponding to multiple first scales are jointly searched to obtain a target base model structure and first target scaling strategies corresponding to multiple first scales, thereby improving the efficiency of model search and reducing the search time.
[0066] The defects existing in the above solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.
[0067] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0068] To facilitate understanding of this embodiment, a method for generating a neural network disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the method for generating a neural network provided in an embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the method for generating a neural network can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0069] The following is an explanation of the method for generating a neural network provided by an embodiment of the present disclosure.
[0070] See also Figure 1 FIG. 1 is a flowchart of a method for generating a neural network provided in an embodiment of the present disclosure, wherein the method comprises steps S101 to S104, wherein:
[0071] S101: Constructing a search space; the search space includes: a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling multiple interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, scaling the base model structure based on the scaling multiple interval corresponding to each first scale; the scalable dimensions include: a depth dimension, a width dimension, and a size dimension of the input data;
[0072] S102: Based on the search space, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales; wherein the first target scaling strategy corresponding to each of the multiple first scales is used to scale the target base model structure to generate a first target neural network corresponding to each of the multiple first scales.
[0073] The disclosed embodiment constructs a search space, which includes a first space for searching a base model structure and a second space for searching a scaling strategy. The search space is then used to jointly search the base model structure and the scaling strategies corresponding to the multiple first scales to obtain a target base model structure and first target scaling strategies corresponding to the multiple first scales. The target base model structure and the first target scaling strategies corresponding to the multiple first scales can be used to generate first target neural networks corresponding to the multiple scales, thereby improving the efficiency of the model structure search and reducing the search time.
[0074] The above S101 to S102 are described in detail below.
[0075] With respect to the above S101, when constructing the search space, a first space and a second space may be constructed respectively;
[0076] Among them, the first space may include multiple pre-built base model structures; or, the first space includes multiple model structure units, each of which can form a complete base model structure after being combined and / or connected, and the combination and connection of multiple different model structure units can form multiple different base model structures. After assigning corresponding model parameters to different base model structures, a neural network of corresponding structure can be formed; here, the difference in base model structure can indicate that the specific operations corresponding to the network layer of the corresponding neural network are different. That is, there are M network layers in the base model structure, and each network layer corresponds to N optional specific operations, then the first space includes: M N An optional base model structure.
[0077] The above-mentioned specific operations include, for example, convolution operation, full connection operation, pooling operation, attention, etc. And for convolution operation, it can also include: at least one of group convolution, pointwise convolution, separable convolution, depthwise convolution, dilated convolution, etc.; for pooling operation, it can also include: at least one of mean-pooling, max-pooling, stochastic-pooling, etc. Attention operation refers to an operation based on the attention mechanism, for example, it can include multiple convolution operations and multiple pooling operations.
[0078] The second space includes a plurality of first scales for scaling the base model structure. Each first scale corresponds to a scaling multiple interval. The first scale for scaling the base model structure is characterized by the scaling multiple when scaling the base model structure.
[0079] Exemplarily, there are four first scales for scaling the base model structure, and the scaling intervals corresponding to the four first scales include, for example: (0, 1], (1, 2], (2, 3], and (3, 4].
[0080] The scaling strategy determined based on the second space includes: in at least one scalable dimension of the base model structure, scaling the base model structure by a multiple based on the scaling multiple interval corresponding to each of the first scales.
[0081] When scaling the base model structure, it can be achieved by scaling the base model structure in at least one of the following scaling dimensions:
[0082] (1): Scaling in the depth dimension; for example, scaling the number of network layers in the base model structure; for example, if the number of network layers included in the determined base model structure is 10, and the scaling factor of the base model structure in the depth direction is 1.5, then after scaling the base model structure in the depth direction, the number of network layers included in the formed model structure is 15.
[0083] (2): Scaling in the width dimension; Scaling in the width dimension is, for example, scaling the number of data channels in the network layer; for example, if the number of data channels in a network layer L (Layer) in a base model structure is 5, and the scaling factor of the base model structure in the width direction is 2.6, then after the base model structure is scaled in the width direction, the number of data channels in the network layer L in the formed model structure is 13.
[0084] (3): Scaling of the size of the input data; scaling of the input data volume, for example, scaling of the size of the data input to the neural network. For example, if the size of the input data in a base model structure is l(length)*h(height)*w(width), and the scaling factor of the input data volume of the base model is 2, then after scaling the input data volume of the base model structure, the size of the input data corresponding to the formed model structure is: 2l*2h*2w.
[0085] Regarding the above S102: when jointly searching the base model structure and the scaling strategies corresponding to multiple first scales based on the search space, for example, a very large neural network can be first generated based on the search space, and then based on the search space and the very large neural network, a joint search is performed on the base model structure and the scaling strategies corresponding to each of the multiple first scales to obtain the target base model structure and the first target scaling strategies corresponding to each of the multiple first scales.
[0086] When generating a very large neural network based on the search space, for example, multiple batches of training data sets may be determined, and the following training process may be performed multiple times:
[0087] Based on the search space, a base model structure and a scaling strategy at a first scale are randomly sampled, a neural network to be trained is generated based on the sampled base model structure and scaling strategy, and the generated neural network to be trained is trained using a batch of training data.
[0088] After multiple trainings as mentioned above, a super large neural network is obtained.
[0089] See also Figure 2As shown, the embodiment of the present disclosure provides a method for performing a joint search on a base model structure and a scaling strategy corresponding to each of a plurality of first scales based on the search space and the very large neural network to obtain a target base model structure and a first target scaling strategy corresponding to each of a plurality of first scales, including:
[0090] Perform multiple iterations, and in each iteration, perform the following steps:
[0091] S201: Based on the first space, determine multiple first base model structures of the current iteration cycle.
[0092] In a specific implementation, when determining a plurality of first base model structures of the current iteration cycle based on the first space, for example, the base model structures may be randomly sampled in the first space to obtain a plurality of first base model structures of the current iteration cycle.
[0093] Exemplarily, the current iteration cycle is the i-th iteration cycle, for example, m base model structures a1 can be randomly sampled in the first space. i 、a2 i , …, a m i .
[0094] For different iteration cycles, the structures of the various first basis models obtained by sampling are at least partially different.
[0095] S202: Based on the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle, the multiple first base model structures, and the very large neural network, perform at least one generation of genetic processing to determine the alternative base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the alternative base model structures; based on the alternative base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the alternative base model structures, determine the second base model structure from the alternative base model structures; wherein the first scaling strategy is determined based on the second space or the previous iteration cycle.
[0096] In a specific implementation, before determining the second base model structure based on the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle and the multiple first base model structures, the following method may be used to determine the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle:
[0097] A: In response to the current iteration cycle being the first iteration cycle, first scaling strategies corresponding to a plurality of first scales in the first iteration cycle are determined based on the first space.
[0098] In a specific implementation, when determining the first scaling strategies corresponding to the multiple first scales in the first iteration cycle based on the search space, for example, the following methods shown in step A-1 to step A-3 may be used:
[0099] Step A-1: randomly sampling the first space to obtain a plurality of initial base model structures, and randomly sampling the second space to obtain a plurality of initial scaling strategies corresponding to each of the plurality of first scales.
[0100] Here, when the second space is randomly sampled to obtain multiple initial scaling strategies corresponding to each of the multiple first scales, assuming that there are G first scales, for the g-th first scale among the G first scales, the n scaling strategies under the g-th first scale are sampled from the second space: B1 (0,g) 、B2 (0,g) , …, B n (0,g) The superscript indicates the g-th first scale in the 0-th iteration cycle; the subscript indicates the scaling strategy under the g-th first scale.
[0101] For example, if the scaling strategy includes three dimensions: scaling in the depth direction, scaling in the width direction, and scaling in the size of the input data, expressed as: (x, y, z), where x represents the scaling factor in the depth direction, y represents the scaling factor in the width direction, and z represents the scaling factor in the size of the input data; if for a first scale (1, 2], 5 scaling strategies at the first scale are randomly sampled, the 5 scaling strategies are: (1.2, 1.5, 1.1), (1.3, 1.7, 2), (1.1, 1.4, 1.9), (1.5, 1.6, 1.6), (1.8, 1.2, 1.1). If 5 scaling strategies are randomly sampled for the first scale (2, 3], the 5 scaling strategies are: (2.3, 2.5, 2.8), (2.1, 2.9, 3), (2.7, 2.3, 2.7), (2.9, 2.2, 2.4), (2.6, 2.1, 2.2).
[0102] Step A-2: For each of the multiple first scales, based on multiple initial base model structures, multiple initial scaling strategies corresponding to each first scale, and the ultra-large neural network, determine the third performance information of the model structure corresponding to the multiple initial scaling strategies corresponding to each first scale.
[0103] Step A-3: Determine the first scaling strategy corresponding to each first scale in the first iteration cycle based on the third performance information of the model structure corresponding to the multiple initial scaling strategies corresponding to each first scale.
[0104] Here, the third performance information can be based on the performance information of the neural network corresponding to the model structure corresponding to each of the multiple initial scaling strategies corresponding to each first scale. It should be noted that the performance information of the neural network refers to the performance information of the neural network in performing a specific deep learning task, and can be characterized by the accuracy rate, resource occupancy rate and other performance parameters of the neural network in performing a specific deep learning task.
[0105] When determining, for each of the multiple first scales, based on multiple initial base model structures and multiple initial scaling strategies corresponding to each first scale, the third performance information corresponding to the multiple initial scaling strategies corresponding to each first scale is determined, for example, in the following manner:
[0106] For each of the multiple initial scaling strategies corresponding to each first scale, scaling the multiple initial base model structures respectively based on each initial scaling strategy and the super large neural network to generate multiple first neural networks;
[0107] Using the first validation data set, determining performance information corresponding to each of the plurality of first neural networks;
[0108] Based on the performance information respectively corresponding to the plurality of first neural networks, third performance information of the model structure corresponding to each initial scaling strategy is determined.
[0109] Specifically, for the g-th first scale, there are n original scaling strategies for each first scale. At the same time, the randomly sampled m base model structures are: a1 0 、a2 0 , …, a m 0 , where the superscript 0 represents the 0th iteration, i.e., initialization, the process of determining the first scaling strategy corresponding to the first iteration cycle.
[0110] A1 0 、a2 0 , …, a m 0 Scale to each scaling strategy separately:
[0111] For B1 (0,g) , a1 0 、a2 0 , …, a m 0 Scale to scaling strategy B1 respectively (0,g) Next, based on the super large neural network, generate m first neural networks a1 0 _B1 (0,g) 、a2 0 _B1 (0,g) , …, a m0 _B1 (0,g) ;
[0112] For B2 (0,g) , a1 0 、a2 0 , …, a m 0 Scale to scaling strategy B2 0-g Next, based on the super large neural network, generate m first neural networks a1 0 _B2 (0,g) 、a2 0 _B2 (0,g) , …, a m 0 _B2 (0,g) ;
[0113] …
[0114] For B n (0,g) , a1 0 、a2 0 , …, a m 0 Scale to scaling strategy B respectively n (0,g) Next, based on the super large neural network, generate m first neural networks a1 0 _B n (0,g) 、a2 0 _B n (0,g) , …, a m 0 _B n (0,g) .
[0115] Then, for each scaling strategy corresponding to the multiple first neural networks, the validation sample set is used to determine the third performance information corresponding to the multiple first neural networks. Here, the third performance information is, for example, the processing accuracy when the validation sample set is processed by the first neural network.
[0116] For example, for B1 (0,g) , get m first neural networks a1 0 _B1 (0,g) 、a2 0 _B1 (0,g) , …, a m 0 _B1 (0,g) The corresponding third performance information respectively.
[0117] Then, according to the m first neural networks a1 0 _B1(0,g) 、a2 0 _B1 (0,g) , …, a m 0 _B1 (0,g) The corresponding third performance information is from a1 0 _B1 (0,g) 、a2 0 _B1 (0,g) , …, a m 0 _B1 (0,g) In the process, the first neural network with the best third performance information is selected, and the original scaling strategy corresponding to the first neural network with the best third performance information is used as the optimal original scaling strategy corresponding to the g-th first scale. The optimal original scaling strategy corresponding to the first scale of the gth type The first scaling strategy corresponding to the g-th first scale in the first iteration cycle is determined.
[0118] For the G first scales, the first scaling strategies of the G first scales in the first iteration cycle are obtained, which are:
[0119] B: In response to the current iteration cycle not being the first iteration cycle, determining the second scaling strategy corresponding to each first scale of the multiple first scales in the iteration cycle before the current iteration cycle as the first scaling strategy corresponding to each first scale in the current iteration cycle.
[0120] The specific method for determining the second scaling strategy may be referred to in S203 below, which will not be described in detail here.
[0121] After determining the first scaling strategies corresponding to the multiple first scales in the current iteration cycle, for example, the second base model structure can be determined based on the first scaling strategies corresponding to each of the multiple first scales in the current iteration cycle, the multiple first base model structures, and the very large neural network in the following manner:
[0122] Step B-1: Based on the first scaling strategies corresponding to the multiple first scales in the current iteration cycle, the multiple first base model structures, and the super large neural network, at least one generation of genetic processing is performed to determine the alternative base model structures corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the alternative base model structures. The first performance information corresponding to the alternative base model structure can be represented by performance parameters such as the accuracy and / or resource occupancy rate achieved by the neural network constructed based on the alternative base model structure in a specific deep learning task (such as an image classification task, a speech recognition task, a natural language understanding task, etc.), which can be obtained by constructing a test data set for the deep learning task and testing the test results of the neural network corresponding to the test base model structure on the test set.
[0123] In a specific implementation, when determining the candidate base model structures corresponding to at least one generation of genetic processing, for example, the following method can be used:
[0124] In response to the current generation genetic processing being the first generation genetic processing, the first base model structure is determined as the candidate base model structure corresponding to the first generation genetic processing.
[0125] In response to the current generation of genetic processing being non-first generation genetic processing, based on the alternative base model structure corresponding to the previous generation of genetic processing corresponding to the current generation of genetic processing, and the first performance information corresponding to the alternative base model structure corresponding to the previous generation of genetic processing, the alternative base model structure corresponding to the previous generation of genetic processing is crossover and / or mutation processed to obtain the alternative base model structure corresponding to the current generation of genetic processing.
[0126] For example, in the i-th iteration cycle, the sampled m first basis model structures a1 (i,1) 、a2 (i,1) , …, a m (i ,1) , where the superscript represents the first generation base model structure (1 on the right) in the corresponding genetic algorithm in the i-th iteration cycle (i on the left), and the subscript represents the first base model structure.
[0127] In the first generation of genetic processing in the i-th iteration cycle, a1 can be (i,1) 、a2 (i,1) , …, a m (i,1) , respectively as the alternative base model structures corresponding to the first genetic treatment.
[0128] In the jth generation genetic processing in the i-th iteration cycle, multiple candidate base model structures a1 corresponding to the (j-1)th generation genetic variation processing can be (i,j-1) 、a2 (i,j-1) , …, am (i,j-1) Perform genetic processing of crossover and / or mutation to obtain the alternative base model structure in the jth generation genetic processing: a1 (i,j) 、a2 (i,j) , …, a m (i,j) .
[0129] After obtaining the candidate base model structure corresponding to the current generation genetic processing, the first performance information of the candidate base model structure corresponding to the current genetic processing can be determined.
[0130] Exemplarily, for the current generation of genetic processing, the first performance information of the candidate base model structure corresponding to the current generation of genetic processing is determined in the following manner:
[0131] For each candidate base model structure in the candidate base model structures corresponding to the current generation genetic processing, based on each candidate base model structure, the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle, and the super large neural network, a plurality of second neural networks respectively corresponding to the first scales are constructed;
[0132] Determine, using a validation data set, performance information corresponding to each of the plurality of second neural networks;
[0133] Based on the performance information respectively corresponding to the plurality of second neural networks, the first performance information corresponding to each candidate base model structure is determined.
[0134] In a specific implementation, when constructing the second neural network, for example, the alternative base model structure can be scaled according to the first scaling strategies corresponding to multiple first scales to obtain the scaled alternative base model structure, and then the second neural network is generated based on the super large neural network and the alternative base model structure.
[0135] Here, for each alternative base model structure, each alternative base model structure is scaled based on the first scaling strategies corresponding to multiple first scales in the i-th iteration cycle to form a scaled alternative base model structure, and then a second neural network is generated based on the scaled alternative base model structure and the super large neural network.
[0136] For example, in the jth generation genetic processing in the i-th iteration cycle, the alternative base model structure is: a1 (i,j) 、a2 (i ,j) , …, a m (i,j) , the first scaling strategies corresponding to the G first scales in the i-th iteration cycle include:
[0137] For the alternative base model structure a1 (i,j) , a1 (i,j) The first scaling strategies corresponding to the i-th iteration period are based on the G first scales respectively. Scaling to G first scales, we get G second neural networks
[0138] Then, we use the validation sample set to determine a1 (i,j) The corresponding performance information of the plurality of second neural networks is respectively obtained. Here, the performance information is, for example, the processing accuracy when the second neural network is used to process the verification sample set. Then, a1 (i,j) The average value of the performance information corresponding to the corresponding multiple second neural networks is determined as a1 (i,j) The corresponding first performance information.
[0139] For the alternative base model structure a2 (i,j) , a2 (i,j) The first scaling strategies corresponding to the i-th iteration period are based on the G first scales respectively. Scaling to G first scales, we get G second neural networks
[0140] …
[0141] For the alternative base model structure a m (i,j) , a m (i,j) The first scaling strategies corresponding to the i-th iteration period are based on the G first scales respectively. Scaling to G first scales, we get G second neural networks
[0142] Step B-2: Based on the candidate base model structures corresponding to the at least one generation of genetic processing and the first performance information corresponding to the candidate base model structures, determine the second base model structure from the candidate base model structures.
[0143] Here, for example, the candidate base model structure with the highest first performance information among the candidate base model structures corresponding to at least one generation of genetic processing can be determined as the second base model structure. The second base model structure corresponding to the i-th iteration cycle can be expressed as
[0144] S203: Based on the first scaling strategy corresponding to each of the multiple first scales in the current iteration cycle, determine multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration cycle through at least one generation of genetic processing; based on second performance information of the model structure obtained after scaling the second base model structure corresponding to the current iteration cycle based on each intermediate scaling strategy, determine the second scaling strategy corresponding to each of the first scales in the current iteration cycle.
[0145] Here, the second performance information represents the performance information of a neural network corresponding to a model structure obtained after scaling the second base model structure based on each intermediate scaling strategy, performing a specific deep learning task.
[0146] Based on the first scaling strategy corresponding to each of the multiple first scales in the current iteration period, when determining multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration period through at least one generation of genetic processing, for example, the following method may be used:
[0147] For each of the multiple first scales, in each generation of genetic processing, the first scaling strategy corresponding to each first scale in the current iteration cycle is subjected to crossover and / or mutation processing of the contemporary genetic processing to obtain multiple intermediate scaling strategies corresponding to the contemporary genetic processing of each first scale in the current iteration cycle.
[0148] For example, the first scaling strategies corresponding to the G first scales in the i-th iteration period include:
[0149] Then for the first scale of the gth type, Perform crossover and / or mutation processing to obtain n intermediate scaling strategies B1 corresponding to the g-th first scale. i,g) 、B2 (i,g) , …, B n (i,g) .
[0150] After obtaining the intermediate scaling strategy, the second scaling strategy corresponding to each first scale in the current iteration period is determined based on the second performance information of the model structure obtained after scaling the second base model structure corresponding to the current iteration period based on each intermediate scaling strategy.
[0151] Specifically, the second scaling strategy may be determined in the following manner:
[0152] Step D-1: Based on the second base model structure corresponding to the current iteration cycle, the multiple intermediate scaling strategies corresponding to each first scale in the current iteration cycle, and the super large neural network, generate multiple third neural networks corresponding to the first scale in the current iteration cycle.
[0153] Here, for example, for each of the multiple intermediate scaling strategies in each first scale, the second base model structure can be scaled to each intermediate scaling strategy to obtain a third neural network corresponding to each intermediate scaling strategy in each first scale.
[0154] For example, the second basic model structure determined for the i-th iteration cycle is And the n intermediate scaling strategies B1 corresponding to the g-th first scale determined in the i-th iteration cycle i,g) 、B2 (i,g) , …, B n (i,g) :
[0155] The second basic model structure determined by the i-th iteration cycle Zoom to B1 (i,g) Next, we get the third neural network:
[0156] The second basic model structure determined by the i-th iteration cycle Zoom to B2 (i,g) Next, we get the third neural network:
[0157] …
[0158] The second basic model structure determined by the i-th iteration cycle Zoom to B n (i,g) Next, we get the third neural network:
[0159] Step D-2: Using a third validation data set, determine the second performance information corresponding to each of the plurality of third neural networks.
[0160] Step D-3: Based on the second performance information respectively corresponding to the plurality of third neural networks, determine the second scaling strategy corresponding to the current iteration cycle for each first scale from the plurality of intermediate scaling strategies corresponding to each first scale.
[0161] Exemplarily, for the g-th first scale, a total of n third neural networks are obtained: Then, a third neural network with the best performance information is selected, and the intermediate scaling strategy corresponding to the third neural network with the best performance is used as the second scaling strategy corresponding to the g-th first scale.
[0162] After multiple rounds of iterations of S201 to S203, the following S204 is executed:
[0163] S204: Determine the second base model structure determined in the last iteration cycle as the target base model structure, and determine the second scaling strategy corresponding to each first scale among the plurality of first scales in the last iteration cycle as the first target scaling strategy corresponding to each first scale among the plurality of first scales.
[0164] Through the above process, a joint search can be performed on the base model structure and the scaling strategies corresponding to the multiple first scales to obtain the target base model structure and the first target scaling strategies corresponding to the multiple first scales.
[0165] The present disclosure also provides a specific example of generating a neural network, including the following steps:
[0166] Step 1: Generate a very large neural network:
[0167] 1: Constructing a search space, including a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling multiple interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, scaling the base model structure based on the scaling multiple interval corresponding to each first scale; the scalable dimension includes: a depth dimension, a width dimension, and a size dimension of input data;
[0168] 2: Based on the constructed search space, multiple batches of training are performed. In each batch training process, a base model structure and a scaling strategy at a first scale are sampled. Based on the sampled base model structure and the sampled scaling strategy, a neural network is constructed, and the constructed neural network is trained using sample data. After multiple batches of training, a super large neural network (Super Net, hereinafter referred to as Super Net) is obtained.
[0169] Step 2: Based on the supernet, search for the target base model structure and the first target scaling strategies corresponding to multiple first scales:
[0170] S1: Iteration cycle 0: Initialization.
[0171] 1: Randomly sample m initial base model structures a1 in the first space 0 、a2 0 , …, a m 0 (0 indicates the 0th iteration). For each of the G first scales, multiple initial scaling strategies corresponding to each first scale are determined; for the g-th first scale, the n initial scaling strategies under the g-th first scale are determined as follows: B1 (0,g) 、B2 (0,g) , …, B n (0,g) The superscript indicates the g-th first scale in the 0-th iteration cycle; the subscript indicates the initial scaling strategy under the g-th first scale.
[0172] The initial base model structure a1 0 、a2 0 , …, a m 0 Scale to each initial scaling strategy respectively:
[0173] For B1 (0,g) , a1 0 、a2 0 , …, a m 0 Scale to the initial scaling strategy B1 respectively (0,g) Next, based on the super large neural network, generate m first neural networks a1 0 _B1 (0,g) 、a2 0 _B1 (0,g) , …, a m 0 _B1 (0,g) ;
[0174] For B2 (0,g) , a1 0 、a2 0 , …, a m 0 Scale to scaling strategy B2 0-g Next, based on the super large neural network, generate m first neural networks a1 0 _B2 (0,g) 、a2 0 _B2 (0,g) , …, a m 0 _B2 (0,g) ;
[0175] …
[0176] For B n (0,g) , a1 0、a2 0 , …, a m 0 Scale to scaling strategy B respectively n (0,g) Next, based on the super large neural network, generate m first neural networks a1 0 _B n (0,g) 、a2 0 _B n (0,g) , …, a m 0 _B n (0,g) .
[0177] 2. Targeting B1 (0,g) , according to a1 0 _B1 (0,g) 、a2 0 _B1 (0,g) , …, a m 0 _B1 (0,g) The first performance information corresponding to each other is obtained as B1 (0,g) average performance.
[0178] For B2 (0,g) , according to a1 0 _B2 (0,g) 、a2 0 _B2 (0,g) , …, a m 0 _B2 (0,g) The first performance information corresponding to each other is obtained as B2 (0,g) Average performance of
[0179] …
[0180] For B n (0,g) , according to a1 0 _B n (0,g) 、a2 0 _B n (0,g) , …, a m 0 _B n (0,g) The first performance information corresponding to each other is used to obtain the scaling strategy B n (0,g) average performance.
[0181] 3. According to B1 (0,g) 、B2 (0,g) , …, B n(0,g) The average performance corresponding to each of them (that is, the third performance information in the above embodiment) is selected from them to select the scaling strategy with the best performance under the g-th first scale, for example,
[0182] For the G first scales, the first scaling strategies of the G first scales in the first iteration cycle are obtained, which are:
[0183] S2: The first iteration cycle:
[0184] 1. Screening base model structure:
[0185] (1): First generation genetic algorithm:
[0186] ①: Randomly sample m base first model structures a1 in the first space (1,1) 、a2 (1,1) , …, a m (1,1) As the first generation alternative base model structure in the genetic algorithm, the superscript indicates the first generation alternative base model structure (1 on the right) in the genetic algorithm corresponding to the first iteration cycle (1 on the left), and the subscript indicates which number of the alternative base model structure.
[0187] ②: The first scaling strategy corresponding to the first iteration cycle for the G first scales: A1 (1,1) 、a2 (1,1) , …, a m (1,1) Scale to each first scale separately:
[0188] For a1 (1,1) , a1 (1,1) The first scaling strategies corresponding to the G first scales are respectively Scaling to G first scales, we get G second neural networks
[0189] For a2 (1,1) , a2 (1,1) The first scaling strategies corresponding to the G first scales are respectively Scaling to G first scales, we get G second neural networks
[0190] …
[0191] For a m (1,1), a m (1,1) The first scaling strategies corresponding to the G first scales are respectively Scaling to G first scales, we get G second neural networks
[0192] ③: For a1 (1,1) ,according to The corresponding performance is a1 (1,1) First performance information at multiple first scales, the first performance information is determined as a1 (1,1) corresponding first performance information;
[0193] For a2 (1,1) ,according to The corresponding performance is a2 (1,1) first performance information at multiple first scales;
[0194] …
[0195] For a m (1,1) ,according to The corresponding performance is obtained m (1,1) First performance information at multiple first scales.
[0196] (2): Second generation genetic algorithm:
[0197] ①: Based on a1 (1,1) 、a2 (1,1) , …, a m (1,1) The first performance information corresponding to a1 (1,1) 、a2 (1,1) , …, a m (1,1) Perform crossover and mutation to obtain the second generation candidate base model structure in the genetic algorithm: a1 (1,2) 、a2 (1,2) , …, a m (1,2) The superscript represents the m second generation candidate base model structures (2 on the right) in the genetic algorithm of the first iteration (1 on the left), and the subscript represents the number of the candidate base model structures.
[0198] ②: The first scaling strategies corresponding to the G first scales: a1 (1 ,2) 、a2 (1,2) , …, a m (1,2)Scale to each first scale separately:
[0199] For a1 (1,2) , a1 (1,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales, we get the second neural network:
[0200] For a2 (1,2) , a2 (1,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0201] …
[0202] For a m (1,2) , a m (1,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0203] ③: For a1 (1,2) ,according to The corresponding performance is a1 (1,2) first performance information at multiple first scales;
[0204] For a2 (1,2) ,according to The corresponding performance is a2 (1,2) first performance information at multiple first scales;
[0205] …
[0206] For a m (1,2) ,according to The corresponding performance is obtained m (1,2) First performance information at multiple first scales.
[0207] …
[0208] (3) The rth generation genetic algorithm:
[0209] ①: Based on a1 (1,r-1) 、a2 (1,r-1), …, a m (1,r-1) The first performance information corresponding to a1 (1,r-1) 、a2 (1 ,r-1) , …, a m (1,r-1) Perform crossover and mutation to obtain the rth generation candidate base model structure in the genetic algorithm: a1 (1,r) 、a2 (1 ,r) , …, a m (1,r) The superscript represents the m r-th generation candidate base model structures (r on the right) in the genetic algorithm of the first iteration (1 on the left), and the subscript represents the number of candidate base model structures.
[0210] ②: The first scaling strategies corresponding to the G first scales: A1 (1 ,r) 、a2 (1,r) , …, a m (1,r) Scale to each first scale separately:
[0211] For a1 (1,r) , a1 (1,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0212] For a2 (1,r) , a2 (1,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0213] …
[0214] For a m (1,r) , a m (1,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0215] ③: For a1 (1,r) ,according to The corresponding performance is a1 (1,r) first performance information at multiple first scales;
[0216] For a2 (1,r) ,according to The corresponding performance is a2 (1,r) first performance information at multiple first scales;
[0217] …
[0218] For a m (1,r) ,according to The corresponding performance is obtained m (1,r) First performance information at multiple first scales.
[0219] Based on a1 (1,1) 、a2 (1,1) , …, a m (1,1) 、a1 (1,2) 、a2 (1,2) , …, a m (1,2) , …, a1 (1,r) 、a2 (1,r) , …, a m (1,r) The first performance information corresponding to each other is used to select the second base model structure with the best performance
[0220] 2: Based on the selected second base model structure Filter the scaling strategies at each first scale:
[0221] (1): The first scaling strategies corresponding to the G first scales: Perform crossover and mutation processing to obtain multiple intermediate scaling strategies corresponding to G first scales in the first iteration cycle. Under each first scale, there are multiple intermediate scaling strategies. Among them, the n intermediate scaling strategies B1 under the gth first scale are (1,g) 、B2 (1 ,g) , …, B n (1,g) , where the superscript indicates the g-th first scale in the first iteration cycle; the subscript indicates the intermediate scaling strategy under the g-th first scale.
[0222] (2): Based on the multiple intermediate scaling strategies corresponding to the G first scales, Scaling to G first scales respectively, we get multiple neural networks corresponding to the G first scales, among which, for the g-th first scale:
[0223] Will Zoom to B1 (1,g) Next, we get the third neural network: and confirm Second performance information;
[0224] Will Zoom to B2 (1,g) Next, we get the third neural network: and confirm Second performance information;
[0225] …
[0226] Will Zoom to B n (1,g) Next, we get the third neural network: and confirm Second performance information.
[0227] (3) According to The corresponding performances are obtained to obtain the optimal scaling strategy at the first scale of g: The As the second scaling strategy corresponding to the g-th first scale.
[0228] For G first scales, G second scaling strategies are obtained in the first iteration cycle, which are:
[0229] S3: The second iteration cycle:
[0230] (1): First generation genetic algorithm:
[0231] ①: Randomly sample m first base model structures a1 in the first space (2,1) 、a2 (2,1) , …, a m (2,1) As the first generation candidate base model structure in the genetic algorithm, the superscript represents the first generation base model structure (the 1 on the right) in the genetic algorithm of the second iteration cycle (the 2 on the left), and the subscript represents the number of the base model structure. And, the second scaling strategies corresponding to the G first scales determined in the first iteration cycle are respectively used as the first scaling strategies corresponding to the G first scales in the second iteration cycle.
[0232] ②: The first scaling strategy based on G first scales in the second iteration cycle A1 (2,1) 、a2 (2,1) , …, a m(2,1) Scale to each first scale separately:
[0233] For a1 (2,1) , a1 (2,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0234] For a2 (2,1) , a2 (2,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0235] …
[0236] For a m (2,1) , a m (2,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0237] ③: For a1 (2,1) ,according to The corresponding performance is a1 (2,1) first performance information at multiple first scales;
[0238] For a2 (2,1) ,according to The corresponding performance is a2 (2,1) first performance information at multiple first scales;
[0239] …
[0240] For a m (2,1) ,according to The corresponding performance is obtained m (2,1) First performance information at multiple first scales.
[0241] (2): Second generation genetic algorithm:
[0242] ①: Based on a1 (2,1) 、a2 (2,1) , …, a m(2,1) The first performance information corresponding to a1 (2,1) 、a2 (2,1) , …, a m (2,1) Perform crossover and mutation to obtain the second generation candidate base model structure in the genetic algorithm: a1 (2,2) 、a2 (2,2) , …, a m (2,2) The superscript represents the m second generation candidate base model structures (the 2 on the right) in the genetic algorithm of the second iteration (the 2 on the left), and the subscript represents the number of candidate base model structures.
[0243] ②: The first scaling strategy based on G first scales in the first iteration cycle A1 (2,2) 、a2 (2,2) , …, a m (2,2) Scale to each first scale separately:
[0244] For a1 (2,2) , a1 (2,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0245] For a2 (2,2) , a2 (2,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0246] …
[0247] For a m (2,2) , a m (2,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0248] ③: For a1 (2,2) ,according to The corresponding performance is a1 (2,2) first performance information at multiple first scales;
[0249] For a2 (2,2) ,according to The corresponding performance is a2 (2,2) first performance information at multiple first scales;
[0250] …
[0251] For a m (2,2) ,according to The corresponding performance is obtained m (2,2) First performance information at multiple first scales.
[0252] …
[0253] (3) The rth generation genetic algorithm:
[0254] ①: Based on a1 (2,r-1) 、a2 (2,r-1) , …, a m (2,r-1) The second performance information corresponding to a1 (2,r-1) 、a2 (2 ,r-1) , …, a m (2,r-1) Perform crossover and mutation to obtain the rth generation candidate base model structure in the genetic algorithm: a1 (2,r) 、a2 (2 ,r) , …, a m (2,r) The superscript represents the m r-th generation candidate base model structures (r on the right) in the genetic algorithm of the second iteration (2 on the left), and the subscript represents the number of candidate base model structures.
[0255] ②: The first scaling strategies corresponding to the G first scales: A1 (2,r) 、a2 (2,r) , …, a m (2,r) Scale to each first scale separately:
[0256] For a1 (2,r) , a1 (2,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0257] For a2 (2,r) , a2 (2,r)First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0258] …
[0259] For a m (2,r) , a m (2,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0260] ③: For a1 (2,r) ,according to The corresponding performance is a1 (2,r) first performance information at multiple first scales;
[0261] For a2 (2,r) ,according to The corresponding performance is a2 (2,r) first performance information at multiple first scales;
[0262] …
[0263] For a m (2,r) ,according to The corresponding performance is obtained m (2,r) First performance information at multiple first scales.
[0264] Based on a1 (2,1) 、a2 (2,1) , …, a m (2,1) 、a1 (2,2) 、a2 (2,2) , …, a m (2,2) 、a1 (2,r) 、a2 (2,r) , …, a m (2,r) The first performance information corresponding to each other is respectively selected, and the base model structure with the best performance is determined as the second base model structure.
[0265] 2: Based on the selected base model structure Filter the second scaling strategy under each first scale:
[0266] (1): The first scaling strategy for the G first scales in the first iteration cycle Perform crossover and mutation processing to obtain the intermediate scaling strategies of G first scales in the second iteration cycle. Under each first scale, there are multiple intermediate scaling strategies. Among them, the n intermediate scaling strategies B1 under the gth first scale are (2,g) 、B2 (2 ,g) , …, B n (2,g) , where the superscript indicates the g-th first scale in the second iteration cycle; the subscript indicates the nth intermediate scaling strategy under the g-th first scale.
[0267] (2): Based on the multiple intermediate scaling strategies corresponding to the G first scales, Scaling to G first scales respectively, a plurality of third neural networks corresponding to the G first scales are obtained, wherein for the g-th first scale:
[0268] Will Zoom to B1 (2,g) Next, we get the third neural network: and confirm Second performance information;
[0269] Will Zoom to B2 (2,g) Next, we get the third neural network: and confirm Second performance information;
[0270] …
[0271] Will Zoom to B n (2,g) Next, we get the third neural network: and confirm Second performance information.
[0272] (3) According to The corresponding second performance information is used to obtain the optimal scaling strategy under the g-th first scale:
[0273] For the G first scales, G second scaling strategies in the second iteration cycle are obtained, which are:
[0274] …
[0275] S4: In the kth iteration cycle:
[0276] (1): First generation genetic algorithm:
[0277] ①: Randomly sample m base model structures a1 in the first space (k,1) 、a2 (k,1) , …, a m (k,1) As the first generation alternative base model structure in the genetic algorithm, the superscript represents the first generation alternative base model structure (1 on the right) in the genetic algorithm of the kth iteration cycle (k on the left), and the subscript represents the number of the alternative base model structure.
[0278] ②: The first scaling strategy for the G first scales in the k-1th iteration cycle A1 (k,1) 、a2 (k,1) , …, a m (k,1) Scale to each first scale separately:
[0279] For a1 (k,1) , a1 (k,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0280] For a2 (k,1) , a2 (k,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0281] …
[0282] For a m (k,1) , a m (k,1) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0283] ③: For a1 (k,1) ,according to The corresponding performance is a1 (k,1) first performance information at multiple first scales;
[0284] For a2 (k,1) ,according to The corresponding performance is a2 (k,1) first performance information at multiple first scales;
[0285] …
[0286] For a m (k,1) ,according to The corresponding performance is obtained m (k,1) First performance information at multiple first scales.
[0287] (2): Second generation genetic algorithm:
[0288] ①: Based on a1 (k,1) 、a2 (k,1) , …, a m (k,1) The second performance information corresponding to a1 (k,1) 、a2 (k,1) , …, a m (k,1) Perform crossover and mutation to obtain the second generation candidate base model structure in the genetic algorithm: a1 (k,2) 、a2 (k,2) , …, a m (k,2) The superscript represents the m second generation candidate base model structures (2 on the right) in the genetic algorithm of the kth iteration (k on the left), and the subscript represents the number of the candidate base model structures.
[0289] ②: The first scaling strategy for the G first scales in the k-1th iteration cycle A1 (k,2) 、a2 (k,2) , …, a m (k,2) Scale to each first scale separately:
[0290] For a1 (k,2) , a1 (k,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0291] For a2 (k,2) , a2 (k,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0292] …
[0293] For a m (k,2) , a m (k,2) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0294] ③: For a1 (k,2) ,according to The corresponding performance is a1 (k,2) first performance information at multiple first scales;
[0295] For a2 (k,2) ,according to The corresponding performance is a2 (k,2) first performance information at multiple first scales;
[0296] …
[0297] For a m (k,2) ,according to The corresponding performance is obtained m (k,2) First performance information at multiple first scales.
[0298] …
[0299] (3) The rth generation genetic algorithm:
[0300] ①: Based on a1 (k,r-1) 、a2 (k,r-1) , …, a m (k,r-1) The first performance information corresponding to a1 (k,r-1) 、a2 (k ,r-1) , …, a m (k,r-1) Perform crossover and mutation to obtain the rth generation candidate base model structure in the genetic algorithm: a1 (k,r) 、a2 (k ,r) , …, a m (k,r)The superscript represents the m rth generation candidate base model structures (r on the right) in the genetic algorithm of the kth iteration (k on the left), and the subscript represents the number of candidate base model structures.
[0301] ②: The first scaling strategy for the G first scales in the k-1th iteration cycle A1 (k,r) 、a2 (k,r) , …, a m (k,r) Scale to each first scale separately:
[0302] For a1 (k,r) , a1 (k,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales, we get
[0303] For a2 (k,r) , a2 (k,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0304] …
[0305] For a m (k,r) , a m (k,r) First scaling strategies corresponding to multiple first scales respectively Scaling to multiple first scales to obtain the second neural network
[0306] ③: For a1 (k,r) ,according to The corresponding performance is a1 (k,r) first performance information at multiple first scales;
[0307] For a2 (k,r) ,according to The corresponding performance is a2 (k,r) first performance information at multiple first scales;
[0308] …
[0309] For a m (k,r),according to The corresponding performance is obtained m (k,r) First performance information at multiple first scales.
[0310] Based on a1 (k,1) 、a2 (k,1) , …, a m (k,1) 、a1 (k,2) 、a2 (k,2) , …, a m (k,2) , …, a1 (k,r) 、a2 (k,r) , …, a m (k,r) The first performance information corresponding to each other is respectively selected, and the candidate base model structure with the best performance is selected, and the candidate base model structure with the best performance is determined to be the second base model structure
[0311] 2: Based on the selected second base model structure Filter the second scaling strategy under each first scale:
[0312] (1): The first scaling strategy for the G first scales in the k-1th iteration cycle Perform crossover and mutation processing to obtain the intermediate scaling strategies of G first scales in the kth iteration cycle. Under each first scale, there are multiple intermediate scaling strategies. Among them, the n intermediate scaling strategies B1 under the gth first scale are (k,g) 、B2 (k,g) , …, B n (k,g) , where the superscript represents the g-th first scale in the k-th iteration cycle; the subscript represents the intermediate scaling strategy under the g-th first scale.
[0313] (2): Based on the multiple intermediate scaling strategies corresponding to the G first scales, Scaling to G first scales respectively, a plurality of third neural networks corresponding to the G first scales are obtained, wherein for the g-th first scale:
[0314] Will Zoom to B1 (k,g) Next, we get the third neural network: and confirm Second performance information;
[0315] Will Zoom to B2 (k,g) Next, we get the third neural network: and confirm Second performance information;
[0316] …
[0317] Will Zoom to B n (k,g) Next, we get the third neural network: and confirm Second performance information.
[0318] (3) According to The second performance information corresponding to each other is used to obtain the optimal scaling strategy under the g-th first scale: the optimal scaling strategy under the g-th first scale is determined as the second scaling strategy under the g-th first scale
[0319] For G first scales, G second scaling strategies are obtained in the kth iteration cycle, which are:
[0320] The optimal base model structure determined by the kth iteration cycle As the target base model structure, and the G first scales are respectively scaled in the kth iteration cycle As the first target scaling strategy corresponding to each first scale.
[0321] In another embodiment of the present disclosure, following S102, the following steps may also be included:
[0322] S103: After obtaining the target base model structure and the first target scaling strategies corresponding to the plurality of first scales, for example, the following method may be used to generate the first target neural networks corresponding to the plurality of first scales.
[0323] Here, when generating the first target neural network,
[0324] Using the first target scaling strategy corresponding to each first scale, the target base model structure is scaled to obtain a scaled model corresponding to each first scale;
[0325] Based on the scaling model and the super large neural network, a plurality of first target neural networks corresponding to the first scales are generated.
[0326] Afterwards, the obtained first target neural network may be retrained using the training sample set to improve the accuracy of the first target neural network.
[0327] See also Figure 3 As shown, in another embodiment of the present disclosure, another method for generating a neural network is also provided, including:
[0328] S301: constructing a search space;
[0329] S302: Based on the search space, jointly search a base model structure and a scaling strategy corresponding to each of the multiple first scales to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales.
[0330] The specific implementation of S301 to S302 is similar to that of S101 to S102 above, and will not be described in detail here.
[0331] S303: Based on the first target scaling strategies corresponding to the multiple first scales, in the fitting functions corresponding to at least one scaling dimension in the scaling strategy, the fitting parameters corresponding to the at least one scaling dimension are solved; and the target fitting functions corresponding to the at least one scaling dimension are obtained. The fitting functions are used to fit the relationship between the base model structure and the scaling strategy.
[0332] S304: Determine second target scaling strategies corresponding to a plurality of second scales respectively by using the target fitting function;
[0333] S305: Generate a plurality of second target neural networks corresponding to the second scales by using the target base model structure and the second target scaling strategies corresponding to the plurality of second scales.
[0334] In a specific implementation, when estimating scaling strategies of other second scales based on the first target scaling strategies corresponding to the G first scales, when the scaling dimensions include the scaling factor in the depth direction of the neural network, the scaling factor in the width direction of the neural network, and the scaling factor of the size of the input data, the fitting function is expressed as the following formula (1), for example:
[0335]
[0336] Where g = 1, 2, ..., G, represents the first scale; d, w, r are the scaling factors of the scaling strategy on the model depth, model width, and input image size; Respectively represent the fitting parameters of the fitting functions of d, w, and r. Where i = 0, 1, and 2.
[0337] When estimating the scaling strategies of other second scales based on the first target scaling strategies corresponding to the G first scales, first use the first target scaling strategies corresponding to the G first scales. Fit the above fitting function to obtain the optimal fitting parameters Then use the optimal fitting parameters The second target scaling strategies corresponding to the second scale predicted by the above fitting function: g′=G+1, G+2, …, G′ are:
[0338] According to the target scaling strategies (first target scaling strategy and second target scaling strategy) corresponding to G′ scales (including the first scale and the second scale): And the target base model structure Determine the target neural networks corresponding to the G′ scales (including the first target neural network and the second target neural network):
[0339]
[0340] In this way, through the above method, the present disclosure can be firstly adopted Figure 1 In a corresponding embodiment, first target scaling strategies corresponding to a plurality of first scales are determined, and then the first target scaling strategies are used to estimate a second target scaling strategy of a larger scale, thereby reducing the estimation time for the scaling strategy of the larger scale and improving the efficiency of determining the scaling scale. At the same time, since the first target scaling strategies corresponding to a plurality of first scales are used to estimate the second target scaling strategy of the second scale, the correlation between the scale and the scaling strategy can be better determined, thereby making the obtained second target scaling strategy have better performance.
[0341] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0342] Based on the same inventive concept, the embodiments of the present disclosure also provide a device for generating a neural network corresponding to the method for generating a neural network. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the method for generating a neural network in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0343] Reference Figure 4 FIG. 1 is a schematic diagram of a neural network generation device provided by an embodiment of the present disclosure, wherein the device comprises:
[0344] A construction module 41 is used to construct a search space; the search space includes: a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling multiple interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, a multiple of scaling the base model structure based on the scaling multiple interval corresponding to each first scale; the scalable dimension includes: a depth dimension, a width dimension, and a size dimension of the input data;
[0345] A search module 42 is used to jointly search the base model structure and the scaling strategies corresponding to each of the multiple first scales based on the search space to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales; wherein the first target scaling strategy corresponding to each of the multiple first scales is used to scale the target base model structure to generate a first target neural network corresponding to each of the multiple first scales.
[0346] In a possible implementation manner, the method further includes: a generating module 43, which is used to scale the target base model structure based on the first target scaling strategy corresponding to each of the multiple first scales to generate a first target neural network corresponding to each of the multiple first scales, and is used to:
[0347] Based on the search space, a super large neural network is generated; the super large neural network includes: a plurality of base model structures determined based on the first space, and a neural network structure obtained by scaling the base model structures using a scaling strategy determined based on the second space;
[0348] Based on the search space and the very large neural network, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales.
[0349] In a possible implementation manner, the search module 42, when performing a joint search on a base model structure and a scaling strategy corresponding to each of the multiple first scales based on the search space and the very large neural network to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales, is used to:
[0350] Perform multiple iteration cycles, and in each of the iteration cycles, perform the following steps:
[0351] Based on the first space, determining multiple first base model structures of the current iteration cycle;
[0352] Based on the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle, the multiple first base model structures, and the very large neural network, at least one generation of genetic processing is performed to determine the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures; based on the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures, the second base model structure is determined from the candidate base model structures; wherein the first scaling strategy is determined based on the second space or the previous iteration cycle;
[0353] Based on the first scaling strategies corresponding to each of the multiple first scales in the current iteration cycle, determine multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration cycle through at least one generation of genetic processing; based on the second performance information of the model structure obtained after the second base model structure corresponding to the current iteration cycle is scaled based on each of the intermediate scaling strategies, determine the second scaling strategy corresponding to each of the first scales in the current iteration cycle;
[0354] The second base model structure determined in the last iteration cycle is determined as the target base model structure, and the second scaling strategy corresponding to each of the multiple first scales in the last iteration cycle is determined as the first target scaling strategy corresponding to each of the multiple first scales.
[0355] In a possible implementation manner, when determining the multiple first base model structures of the current iteration cycle based on the first space, the search module 42 is configured to:
[0356] A plurality of first base model structures of the current iteration cycle are obtained by random sampling in the first space.
[0357] In a possible implementation manner, the search module 42 is further configured to: in response to the current iteration cycle being the first iteration cycle, determine, based on the search space, a first scaling strategy corresponding to each first scale of the plurality of first scales in the first iteration cycle;
[0358] In response to the current iteration cycle not being the first iteration cycle, the second scaling strategies corresponding to each first scale of the multiple first scales in the iteration cycle before the current iteration cycle are determined as the first scaling strategies corresponding to each first scale in the current iteration cycle.
[0359] In a possible implementation manner, in response to the current iteration cycle being the first iteration cycle, the search module 42, when determining, based on the search space, a first scaling strategy corresponding to each of the multiple first scales in the first iteration cycle, is configured to:
[0360] Random sampling in the first space to obtain a plurality of initial base model structures; and random sampling in the second space to obtain a plurality of initial scaling strategies corresponding to each of the plurality of first scales;
[0361] For each of the plurality of first scales, based on the plurality of initial base model structures, the plurality of initial scaling strategies corresponding to each of the first scales, and the very large neural network, determine third performance information of the model structures respectively corresponding to the plurality of initial scaling strategies corresponding to each of the first scales;
[0362] Based on the third performance information of the model structures respectively corresponding to the multiple initial scaling strategies corresponding to each first scale, the first scaling strategy corresponding to each first scale in the first iteration cycle is determined.
[0363] In a possible implementation manner, the search module 42, when determining, for each of the multiple first scales, based on multiple initial base model structures, multiple initial scaling strategies corresponding to each first scale, and the very large neural network, the third performance information of the model structure corresponding to the multiple initial scaling strategies corresponding to each first scale, is configured to:
[0364] For each of the multiple initial scaling strategies corresponding to each first scale, scaling the multiple initial base model structures respectively based on each initial scaling strategy and the super large neural network to generate multiple first neural networks;
[0365] Using the first validation data set, determining performance information corresponding to each of the plurality of first neural networks;
[0366] Based on the performance information respectively corresponding to the plurality of first neural networks, third performance information of the model structure corresponding to each initial scaling strategy is determined.
[0367] In a possible implementation manner, the search module 42, when determining the candidate base model structures corresponding to the at least one generation of genetic processing, is used to:
[0368] In response to the current generation genetic processing being the first generation genetic processing, determining the first base model structure as the candidate base model structure corresponding to the first generation genetic processing;
[0369] In response to the current generation of genetic processing being non-first generation genetic processing, based on the alternative base model structure corresponding to the previous generation of genetic processing corresponding to the current generation of genetic processing, and the first performance information corresponding to the alternative base model structure corresponding to the previous generation of genetic processing, the alternative base model structure corresponding to the previous generation of genetic processing is crossover and / or mutation processed to obtain the alternative base model structure corresponding to the current generation of genetic processing.
[0370] In a possible implementation manner, the search module 42 is used to determine the first performance information of the candidate base model structure corresponding to the current generation genetic processing in the following manner:
[0371] For each candidate base model structure in the candidate base model structure corresponding to the current generation genetic processing, based on each candidate base model structure, a first scaling strategy corresponding to each first scale in the multiple first scales in the current iteration cycle, and the super large neural network, a second neural network corresponding to each first scale in the multiple first scales is constructed;
[0372] Determine, using a validation data set, performance information corresponding to each of the plurality of second neural networks;
[0373] Based on the performance information respectively corresponding to the plurality of second neural networks, the first performance information corresponding to each candidate base model structure is determined.
[0374] In a possible implementation manner, the search module 42, based on the first scaling strategy corresponding to each of the multiple first scales in the current iteration period, determines multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration period through at least one generation of genetic processing, is configured to:
[0375] For each of the multiple first scales, in each generation of genetic processing, the first scaling strategy corresponding to each first scale in the current iteration cycle is subjected to crossover and / or mutation processing of the contemporary genetic processing to obtain multiple intermediate scaling strategies corresponding to the contemporary genetic processing of each first scale in the current iteration cycle.
[0376] In a possible implementation manner, the search module 42, when determining the second scaling strategy corresponding to each first scale in the current iteration period based on the second performance information of the model structure obtained after scaling the second base model structure corresponding to the current iteration period based on each intermediate scaling strategy, is configured to:
[0377] Based on the second base model structure corresponding to the current iteration cycle, the multiple intermediate scaling strategies corresponding to each first scale in the current iteration cycle, and the super large neural network, generate multiple third neural networks corresponding to the first scale in the current iteration cycle;
[0378] Determine, using a third validation data set, second performance information corresponding to each of the plurality of third neural networks;
[0379] Based on the second performance information respectively corresponding to the plurality of third neural networks, a second scaling strategy corresponding to each first scale in the current iteration cycle is determined from the plurality of intermediate scaling strategies corresponding to each first scale.
[0380] In a possible implementation manner, the generating module 43, when scaling the target base model structure based on the first target scaling strategy corresponding to each of the multiple first scales to generate a first target neural network corresponding to each of the multiple first scales, is used to:
[0381] Using the first target scaling strategy corresponding to each first scale, the target base model structure is scaled to obtain a scaled model corresponding to each first scale;
[0382] Based on the scaling model and the super large neural network, a plurality of first target neural networks corresponding to the first scales are generated.
[0383] In a possible implementation manner, the search module 42 is further used to: based on first target scaling strategies corresponding to multiple first scales, solve the fitting parameters corresponding to the at least one scaling dimension in the scaling strategy in the fitting functions corresponding to the at least one scaling dimension respectively; obtain the target fitting function corresponding to the at least one scaling dimension respectively, wherein the fitting function is used to fit the relationship between the base model structure and the scaling strategy;
[0384] Determine second target scaling strategies corresponding to a plurality of second scales respectively by using the target fitting function;
[0385] Based on the second target scaling strategy and the target base model structure, second target neural networks corresponding to multiple second scales are generated.
[0386] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0387] The present disclosure also provides a computer device, such as Figure 5 FIG. 1 is a schematic diagram of a computer device structure provided in an embodiment of the present disclosure, including:
[0388] A processor 51 and a memory 52; the memory 52 stores machine-readable instructions executable by the processor 51, and the processor 51 is used to execute the machine-readable instructions stored in the memory 52. When the machine-readable instructions are executed by the processor 51, the processor 51 performs the following steps:
[0389] Constructing a search space; the search space includes: a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling multiple interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, scaling the base model structure based on the scaling multiple interval corresponding to each first scale; the scalable dimension includes: a depth dimension, a width dimension, and a size dimension of the input data;
[0390] Based on the search space, a base model structure and a scaling strategy corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales; wherein the first target scaling strategy corresponding to each of the multiple first scales is used to scale the target base model structure to generate a first target neural network corresponding to each of the multiple first scales;
[0391] The target base model structure and the first target scaling strategies corresponding to the first scales are used to generate the first target neural networks corresponding to the first scales. The memory 52 includes a memory 521 and an external memory 522; the memory 521 is also called an internal memory, which is used to temporarily store the operation data in the processor 51 and the data exchanged with the external memory 522 such as a hard disk. The processor 51 exchanges data with the external memory 522 through the memory 521.
[0392] The specific execution process of the above instructions can refer to the steps of the neural network generation method described in the embodiment of the present disclosure, which will not be repeated here.
[0393] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for generating a neural network described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0394] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the method for generating a neural network described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0395] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0396] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0397] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0398] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0399] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0400] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for generating a neural network, characterized in that: include: Constructing the search space; The search space includes: a first space for searching a base model structure, and a second space for searching a scaling strategy; wherein the second space includes a plurality of first scales for scaling the base model structure; each first scale corresponds to a scaling multiple interval; the scaling strategy determined based on the second space includes: on at least one scalable dimension of the base model structure, scaling the base model structure based on the scaling multiple interval corresponding to each first scale; the scalable dimensions include: a depth dimension, a width dimension, and a size dimension of input data; Based on the search space, a super large neural network is generated; the super large neural network includes: a plurality of base model structures determined based on the first space, and a neural network structure obtained by scaling the base model structures using a scaling strategy determined based on the second space; Based on the search space and the very large neural network, a base model structure and scaling strategies corresponding to each of the multiple first scales are jointly searched to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales; wherein the first target scaling strategy corresponding to each of the multiple first scales is used to scale the target base model structure to generate a first target neural network corresponding to each of the multiple first scales.
2. The generation method according to claim 1, characterized in that: After obtaining the target base model structure and the first target scaling strategy corresponding to each of the multiple first scales, the method further includes: Based on a first target scaling strategy corresponding to each of the plurality of first scales, the target base model structure is scaled to generate a first target neural network corresponding to each of the plurality of first scales.
3. The generation method according to claim 1, characterized in that: The step of performing a joint search on a base model structure and a scaling strategy corresponding to each of the multiple first scales based on the search space and the super large neural network to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales, including: Perform multiple iteration cycles, and in each of the iteration cycles, perform the following steps: Based on the first space, determining multiple first base model structures of the current iteration cycle; Based on the first scaling strategies respectively corresponding to the multiple first scales in the current iteration cycle, the multiple first base model structures, and the very large neural network, at least one generation of genetic processing is performed to determine the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures; based on the candidate base model structures respectively corresponding to the at least one generation of genetic processing, and the first performance information corresponding to the candidate base model structures, a second base model structure is determined from the candidate base model structures; wherein the first scaling strategy is determined based on the second space or the previous iteration cycle; Based on the first scaling strategies corresponding to each of the multiple first scales in the current iteration cycle, determine multiple intermediate scaling strategies corresponding to each of the multiple first scales in the current iteration cycle through at least one generation of genetic processing; based on the second performance information of the model structure obtained after the second base model structure corresponding to the current iteration cycle is scaled based on each of the intermediate scaling strategies, determine the second scaling strategy corresponding to each of the first scales in the current iteration cycle; The second base model structure determined in the last iteration cycle is determined as the target base model structure, and the second scaling strategy corresponding to each of the multiple first scales in the last iteration cycle is determined as the first target scaling strategy corresponding to each of the multiple first scales.
4. The generation method according to claim 3, characterized in that: The determining of multiple first base model structures of the current iteration cycle based on the first space includes: A plurality of first base model structures of the current iteration cycle are obtained by random sampling in the first space.
5. The generation method according to claim 3 or 4, characterized in that: The method further comprises: In response to the current iteration cycle being a first iteration cycle, determining, based on the search space, a first scaling strategy corresponding to each first scale of the plurality of first scales in the first iteration cycle; In response to the current iteration cycle not being the first iteration cycle, the second scaling strategies corresponding to each first scale of the multiple first scales in the iteration cycle before the current iteration cycle are determined as the first scaling strategies corresponding to each first scale in the current iteration cycle.
6. The generation method according to claim 5, characterized in that: In response to the current iteration cycle being the first iteration cycle, determining, based on the search space, a first scaling strategy corresponding to each of the multiple first scales in the first iteration cycle, includes: A plurality of initial base model structures are obtained by random sampling in the first space, and a plurality of initial scaling strategies corresponding to each of the plurality of first scales are obtained by random sampling in the second space; For each of the plurality of first scales, based on the plurality of initial base model structures, the plurality of initial scaling strategies corresponding to each of the first scales, and the very large neural network, determine third performance information of the model structures respectively corresponding to the plurality of initial scaling strategies corresponding to each of the first scales; Based on the third performance information of the model structures respectively corresponding to the multiple initial scaling strategies corresponding to each first scale, the first scaling strategy corresponding to each first scale in the first iteration cycle is determined.
7. The generation method according to claim 6, characterized in that: The method of determining, for each of the plurality of first scales, third performance information of the model structures respectively corresponding to the plurality of initial scaling strategies corresponding to each of the first scales based on the plurality of initial base model structures, the plurality of initial scaling strategies corresponding to each of the first scales, and the very large neural network, includes: For each of the multiple initial scaling strategies corresponding to each first scale, scaling the multiple initial base model structures respectively based on each initial scaling strategy and the super large neural network to generate multiple first neural networks; Using the first validation data set, determining performance information corresponding to each of the plurality of first neural networks; Based on the performance information respectively corresponding to the plurality of first neural networks, third performance information of the model structure corresponding to each initial scaling strategy is determined.
8. The generation method according to claim 3, characterized in that: The step of determining the candidate base model structures corresponding to the at least one generation of genetic processing respectively comprises: In response to the current generation genetic processing being the first generation genetic processing, determining the first base model structure as the candidate base model structure corresponding to the first generation genetic processing; In response to the current generation of genetic processing being non-first generation genetic processing, based on the alternative base model structure corresponding to the previous generation of genetic processing corresponding to the current generation of genetic processing, and the first performance information corresponding to the alternative base model structure corresponding to the previous generation of genetic processing, the alternative base model structure corresponding to the previous generation of genetic processing is crossover and / or mutation processed to obtain the alternative base model structure corresponding to the current generation of genetic processing.
9. The generation method according to claim 3, characterized in that: For the current generation of genetic processing, the first performance information of the candidate base model structure corresponding to the current generation of genetic processing is determined in the following manner: For each candidate base model structure in the candidate base model structure corresponding to the current generation genetic processing, based on each candidate base model structure, a first scaling strategy corresponding to each first scale in the multiple first scales in the current iteration cycle, and the super large neural network, a second neural network corresponding to each first scale in the multiple first scales is constructed; Determine, using a validation data set, performance information corresponding to each of the plurality of second neural networks; Based on the performance information respectively corresponding to the plurality of second neural networks, the first performance information corresponding to each candidate base model structure is determined.
10. The generation method according to claim 3, characterized in that: The first scaling strategy corresponding to each first scale in the current iteration cycle among the multiple first scales is determined by at least one generation of genetic processing to correspond to multiple intermediate scaling strategies for each first scale in the current iteration cycle, including: For each of the multiple first scales, in each generation of genetic processing, the first scaling strategy corresponding to each first scale in the current iteration cycle is subjected to crossover and / or mutation processing of the contemporary genetic processing to obtain multiple intermediate scaling strategies corresponding to the contemporary genetic processing of each first scale in the current iteration cycle.
11. The generation method according to claim 3, characterized in that: The determining, based on the second performance information of the model structure obtained after scaling the second base model structure corresponding to the current iteration period based on each intermediate scaling strategy, the second scaling strategy corresponding to each first scale in the current iteration period includes: Based on the second base model structure corresponding to the current iteration cycle, the multiple intermediate scaling strategies corresponding to each first scale in the current iteration cycle, and the super large neural network, generate multiple third neural networks corresponding to the first scale in the current iteration cycle; Determine, using a third validation data set, second performance information respectively corresponding to a plurality of the third neural networks; Based on the second performance information respectively corresponding to the plurality of third neural networks, a second scaling strategy corresponding to each first scale in the current iteration cycle is determined from the plurality of intermediate scaling strategies corresponding to each first scale.
12. The generation method according to claim 2, characterized in that: The first target scaling strategy based on each of the plurality of first scales respectively corresponds to scaling the target base model structure to generate a first target neural network respectively corresponding to each of the plurality of first scales, including: Using the first target scaling strategy corresponding to each first scale, the target base model structure is scaled to obtain a scaled model corresponding to each first scale; Based on the scaling model and the super large neural network, a plurality of first target neural networks corresponding to the first scales are generated.
13. The generation method according to claim 1, characterized in that: The method further comprises: Based on the first target scaling strategies corresponding to the multiple first scales, respectively, solving the fitting parameters corresponding to the at least one scaling dimension in the scaling strategy in the fitting functions corresponding to the at least one scaling dimension respectively; obtaining the target fitting functions corresponding to the at least one scaling dimension respectively, wherein the fitting functions are used to fit the relationship between the base model structure and the scaling strategy; Determine second target scaling strategies corresponding to a plurality of second scales respectively by using the target fitting function; Based on the second target scaling strategy and the target base model structure, second target neural networks corresponding to multiple second scales are generated.
14. A device for generating a neural network, characterized in that: include: Building blocks, used to construct the search space; The search space includes: a first space and a second space; wherein the second space includes a plurality of first scales for scaling the base model structure; each scaling scale corresponds to a scaling multiple interval; the scaling strategy determined based on the scaling space includes a scaling multiple for scaling the base model structure at any scaling scale; the scaling process includes scaling in at least one of the following dimensions: scaling in the depth direction of the base model structure, scaling in the width direction of the base model structure, and scaling in the size of the input data; A search module is used to generate a very large neural network based on the search space; the very large neural network includes: multiple base model structures determined based on the first space, and a neural network structure obtained after scaling the base model structure using a scaling strategy determined based on the second space; based on the search space and the very large neural network, a joint search is performed on the base model structure and the scaling strategy corresponding to each of the multiple first scales to obtain a target base model structure and a first target scaling strategy corresponding to each of the multiple first scales; wherein the target base model structure and the first target scaling strategy corresponding to the multiple first scales are used to generate first target neural networks corresponding to the multiple first scales, and the performance of the first target neural network meets a preset performance condition.
15. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor executes the method for generating a neural network as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer device, the computer device executes the method for generating a neural network according to any one of claims 1 to 13.
Citation Information
Patent Citations
Target detection network construction method and device, target detection method and device and storage medium
CN112464930A
Neural network structure search method and device, computer equipment and storage medium
CN113344181A