Neural network structure search, model construction method, electronic device, and storage medium
By employing unbiased random search and weight-sharing fine-tuning techniques, the stability and efficiency issues of neural network structure search algorithms were resolved, achieving stable and efficient search across different tasks and data, thus ensuring the accuracy and reliability of the target AI model.
Patent Information
- Application Number
- CN202011346367.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-25
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2040-11-25
AI Technical Summary
Existing neural network structure search algorithms are unstable and have search biases, resulting in insufficient stability on different tasks and data, failing to guarantee the search for good structures, and being inefficient.
An unbiased random search method is used to search for network structures in the search space of neural networks. By sharing weights and fine-tuning the weight model, the search bias is reduced, the structural stability and evaluation accuracy are improved, and computational power is not wasted on poor structures.
It improves the stability and efficiency of neural network architecture search, ensures the accuracy of determining the target AI model among multiple fine-tuned models, and reduces the waste of resources for training on poor architectures.
Smart Images

Figure CN114611679B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a neural network structure search method, a model construction method, an electronic device and a storage medium. BACKGROUND
[0002] Deep learning models have achieved very good results on many tasks, but the design of neural network structures is highly dependent on expert experience, and the time period for manually designing network structures is long, and the cost of hiring corresponding experts is high. Neural network structure search algorithms can replace experts to design neural network structures, and greatly improve model performance. Compared with manually designing neural network structures, neural network structure search algorithms automatically search for machines without human intervention, and the search efficiency is higher than that of manual design.
[0003] Existing neural network structure search algorithms are unstable, and due to search bias, the stability is insufficient on different tasks and data, and it cannot be guaranteed that a better structure is searched on any task. SUMMARY
[0004] The present application provides a neural network structure search method, a model construction method, an electronic device and a storage medium, aiming to improve the adaptability of AI models generated by AutoML technology and reduce the use threshold.
[0005] In a first aspect, an embodiment of the present application provides a neural network structure search method, comprising:
[0006] Obtaining a search space of a neural network;
[0007] Based on a random search strategy, a network structure is searched in the search space;
[0008] According to the shared weight corresponding to the search space, the weight parameter of the network structure is determined to obtain a weight model;
[0009] According to a search sample set, the weight model is fine-tuned to obtain a fine-tuned model;
[0010] A target AI model is determined from a plurality of fine-tuned models.
[0011] In a second aspect, an embodiment of the present application provides a neural network model construction method, comprising:
[0012] Obtaining a sample set determined by a terminal device, the sample set comprising a search sample set;
[0013] Determining a target AI model according to the neural network structure search method described above;
[0014] deploy the target AI model to a target device and / or publish the target AI model to a model transaction platform according to an instruction of the terminal device.
[0015] In a third aspect, an electronic device is provided, including a memory and a processor.
[0016] The memory is configured to store a computer program.
[0017] The processor is configured to execute the computer program and, when executing the computer program, implement:
[0018] the neural network structure searching method described above; or
[0019] the neural network model construction method described above.
[0020] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. The computer program, when executed by a processor, causes the processor to implement:
[0021] the neural network structure searching method described above; or
[0022] the neural network model construction method described above.
[0023] The embodiments of the present application provide a neural network structure searching method, a model construction method, an electronic device and a storage medium. The search space of a neural network is obtained, a network structure is searched in the search space based on a random search strategy, the weight parameters of the network structure are determined according to the shared weight corresponding to the search space, and a weight model is obtained. The weight model is fine-tuned according to a search sample set, and a fine-tuned model is obtained. A target AI model is determined from a plurality of fine-tuned models. The network structure is searched in the search space based on the unbiased random search method, the search bias on different tasks and data is reduced or eliminated, the stability of the searched network structure is ensured, the weight model is fine-tuned, the accuracy of the network structure evaluation is improved, the waste of computing power in training of poor network structure is prevented, and the efficiency of the search is improved.
[0024] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the disclosure of the embodiments of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0026] Figure 1 is a flow diagram of a neural network structure search method provided by an embodiment of the present application;
[0027] Figure 2 is a schematic diagram of an application scenario of the neural network structure search method;
[0028] Figure 3 is a schematic diagram of a search space of a neural network;
[0029] Figures 4A-4C is a process diagram of the neural network structure search in an embodiment;
[0030] Figure 5 is a flow diagram of a neural network model construction method provided by another embodiment of the present application;
[0031] Figure 6 is a schematic block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0032] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.
[0033] The flow diagrams shown in the drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor do they have to be executed in the described order. For example, some operations / steps can be further decomposed, combined or partially merged, so the actual execution order may be changed according to the actual situation.
[0034] Some embodiments of the present application will be described in detail below with reference to the drawings. The following embodiments and features in the embodiments can be combined with each other without conflict.
[0035] Please refer to Figure 1 , Figure 1is a flowchart of a neural network structure search method provided by an embodiment of the present application. The neural network structure search method can be applied in an electronic device, such as a terminal device or a server, for generating an AI model and the like; wherein the terminal device can be a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device, and the like; and the server can be a standalone server or a server cluster.
[0036] As shown in the example, Figure 2 As shown in the example, the neural network structure search method is applied in a scenario of a server. The server executes the neural network structure search method to generate a target AI model, and can also send the generated target AI model to a terminal device for model testing or deployment and the like.
[0037] The existing neural network structure search algorithm is unstable, and due to search bias on different tasks and data, the stability is insufficient, and it cannot be guaranteed that a better structure is searched on any task. The neural network structure search method of the embodiment of the present application searches the network structure in the search space based on the unbiased random search method, reduces or eliminates the search bias on different tasks and data, guarantees the stability of the searched network structure, and improves the accuracy of the evaluation of the network structure by fine-tuning the weight model, prevents wasting computing power on training poor network structures, and thus improves the search efficiency.
[0038] As shown in the example, Figure 1 The neural network structure search method of the embodiment of the present application includes steps S110 to S150.
[0039] S110, obtaining a search space of a neural network.
[0040] Specifically, the neural network can be used for processing images, texts, or speech.
[0041] As an example, the neural network can be a neural network for classifying images, a neural network for segmenting images, a neural network for detecting images, a neural network for recognizing images, a neural network for generating specified images, a neural network for translating texts, a neural network for paraphrasing texts, a neural network for generating specified texts, a neural network for recognizing speech, a neural network for translating speech, a neural network for generating specified speech, and the like.
[0042] From another dimension, the neural network can include, but is not limited to, a convolutional neural network or a recurrent neural network, etc.
[0043] In some embodiments, referring to Figure 3 , the search space includes a search space graph including a plurality of network units and connections between the plurality of network units.
[0044] In some other embodiments, the search space can also be described in the form of a vector, and each element in the vector can be used to represent a network unit and a connection between network units. Of course, embodiments of the present application are not limited thereto.
[0045] S120, based on a random search strategy, searching for a network structure in the search space.
[0046] The search space can include a plurality of operations, and all or part of the operations can constitute different neural networks based on different connection modes, or in other words, the network structure of the neural networks constituted by all or part of the operations based on different connection modes can be different.
[0047] As shown in Figure 3 , the search space includes network units such as convolution (Conv) operations and depthwise (DW) convolution operations. From top to bottom, the connections between Conv33, DW33, DW33, and Conv33 are used to indicate the connections between these network units, thereby constituting a neural network.
[0048] For example, the searching for a network structure in the search space includes searching in the search space graph, determining a directed path including a plurality of network units and connections between the plurality of network units, and determining the network structure according to the directed path. As shown in Figure 3 , a network structure can be determined according to a directed path including nodes Conv33, DW33, DW33, and Conv33 and edges between these nodes.
[0049] It can be understood that compared with search methods based on gradient information, search methods based on reinforcement learning, search methods based on evolutionary algorithms, etc., the random search method itself is unbiased, and there is no search bias, which can be applied to a variety of different tasks. Therefore, based on the random search strategy, the network structure is searched in the search space, which can reduce or eliminate the search bias on different tasks and data, and ensure the stability of the searched network structure.
[0050] In some embodiments, the network structure is searched in the search space based on a random search strategy, and searching the network structure in the search space comprises searching the network structure in the search space based on a search control network initialized randomly.
[0051] For example, the search control network can also be referred to as a controller, which can be set by using an LSTM neural network, but is not limited thereto, and can also be set by using an RNN neural network. The search control network is used to determine a plurality of network units and connections between the plurality of network units in the search space, thereby obtaining the network structure.
[0052] In this embodiment, the search control network is untrained and can be randomly sampled, thereby achieving the network structure searched in the search space based on the random search strategy.
[0053] S130, determining a weight parameter of the network structure according to the shared weight corresponding to the search space, thereby obtaining a weight model.
[0054] The weight sharing strategy is to share the weights of all network structures in the search space, thereby accelerating the search. The weights of different network structures in the search space are shared and reused by using the weight sharing strategy, thereby improving the search efficiency.
[0055] S140, fine-tuning the weight model according to the search sample set, thereby obtaining a fine-tuned model.
[0056] For example, the training sample set and the test sample set can be obtained, and the search sample set and the validation sample set can be cut from the training sample set. Of course, the search sample set and the validation sample set can also be obtained independently.
[0057] For example, the weight model is fine-tuned to convergence, thereby obtaining the fine-tuned model, or the weight model is fine-tuned for several cycles, thereby obtaining the fine-tuned model.
[0058] Specifically, after the network structure and the shared weight are configured, the weight model is fine-tuned by using the search sample set, thereby improving the reliability of the network based on the shared weight parameter, and preventing the network structure using the shared weight parameter from completing the task, such as the performance of the prediction cannot effectively reflect the performance of the network after the real training, thereby improving the search efficiency.
[0059] S150, determining a target AI model from the plurality of fine-tuned models.
[0060] For example, the steps S120 to S140 are repeatedly performed for a predetermined number of times, such as 100 times, to obtain a corresponding number of fine-tuned models.
[0061] For example, according to the evaluation parameters of the fine-tuned models, a target AI model can be determined from the plurality of fine-tuned models, which can improve the performance of the search.
[0062] Compared with the weight model of the weight sharing parameter, the model performance of the fine-tuned fine-tuned model can be closer to the performance of the model after real training, and the correlation between the evaluation parameters of the fine-tuned model and the evaluation parameters of the model after real training is stronger.
[0063] It can be understood that when using a random search strategy to search for a network structure, each time a network structure is searched out, the network structure is configured with shared weights, and then the network structure is fine-tuned for a predetermined number of steps on the search sample set, which can solve the problem of weak correlation of weight sharing. For example, the predetermined number of steps of fine-tuning can be one epoch, because experiments have found that one epoch can improve a large enough correlation.
[0064] In some embodiments, the step S150 of determining a target AI model from the plurality of fine-tuned models includes steps S151 to S155.
[0065] S151, determining a first evaluation parameter of each of the plurality of fine-tuned models according to a validation sample set.
[0066] For example, each fine-tuned fine-tuned model is tested on a validation sample set (valid set) to obtain a first evaluation parameter. The first evaluation parameter can be referred to as a valid reward, for example. Taking a classification task as an example, the reward is the accuracy.
[0067] S152, determining a plurality of candidate models from the plurality of fine-tuned models according to the first evaluation parameter.
[0068] The first evaluation parameter can be used to evaluate the effect of the fine-tuned model. According to the first evaluation parameter, a fine-tuned model with better effect is determined as a candidate model. For example, the K fine-tuned models with the best valid reward are selected as the candidate models, and K is a natural number greater than or equal to 1.
[0069] S153, training each of the candidate models based on a training sample set to obtain a training model corresponding to each of the candidate models.
[0070] Exemplarily, the candidate models are trained to convergence on a training sample set to obtain a training model corresponding to each of the candidate models.
[0071] S154, determining a second evaluation parameter of each of the training models based on a test sample set.
[0072] Exemplarily, each of the training models is tested on a test sample set to obtain a second evaluation parameter, which can be referred to as test reward.
[0073] The evaluation parameter of the fine-tuned fine-tuned model can be closer to the evaluation parameter of the training model trained in step S153, and by determining the candidate model in the fine-tuned fine-tuned model, a more desirable candidate model can be obtained, and a training model with better performance can be obtained after training, thereby improving the search efficiency.
[0074] It can be understood that the evaluation system for whether the search method is effective is the correlation between the K valid rewards and the K test rewards. Generally, the higher the monotonic consistency of the K valid rewards and the K test rewards, the better the search method, and K is a natural number greater than or equal to 1.
[0075] S155, determining a target AI model from the training models corresponding to the candidate models according to the second evaluation parameter.
[0076] Exemplarily, the training model with the best test reward is selected as the target AI model.
[0077] In some embodiments, although the step of fine-tuning the weight model is added, the time-consuming of training the controller is saved, and the overall time does not increase, but the robustness of the search result is increased.
[0078] If random search is directly used, the following problems will be encountered: 1) the variance of the searched result is large, resulting in low efficiency, and 2) the search result is unreliable. Therefore, more structures need to be searched to find a better network structure. The embodiments of the present application can improve the search efficiency and reliability by weight sharing, fine-tuning the weight model, and determining the target AI model from the fine-tuned model, which can solve the above technical problems.
[0079] Exemplarily, the period of the fine-tuning is lower than the period of the training, and / or the search sample set used for the fine-tuning is smaller than the training sample set used for the training. For example, the fine-tuning training is defaulted to one epoch, because it is found through experiments that one epoch can improve a large enough correlation and can also improve the search efficiency.
[0080] In some embodiments, the step S110 obtaining the search space of the neural network comprises: randomly sampling a sample neural network based on a randomly initialized search control network; and determining the search space and shared weights corresponding to the search space according to a result of the random sampling. The search space obtained based on the random sampling can further reduce or eliminate search bias on different tasks and data, and ensure the stability of the network structure obtained by the search.
[0081] For example, an LSTM neural network is used to set a controller as the search control network, which is responsible for sampling the network structure of the sample neural network to obtain the search space. Specifically, the search control network is not trained and can maintain random sampling. For example, as long as the controller is not trained, the controller always maintains random sampling. Any random sampler can be used. According to the result of the random sampling, the structure of the search space is determined and the shared weights corresponding to the search space are configured.
[0082] For example, a back propagation algorithm (BP algorithm) is used to train a batch of data of the search space on the training sample set.
[0083] For example, based on the randomly initialized search control network, the search spaces of multiple neural networks can be obtained, for example, 310 epochs are repeated to obtain 310 search spaces.
[0084] In some embodiments, the efficiency of the network structure search based on the weight sharing strategy can be further improved by pre-setting a pre-trained search space (such as a pretrain graph). The pre-set pre-trained search space can be trained using a random strategy to ensure unbiasedness.
[0085] For example, the method further comprises: obtaining a data set of a preset task; and pre-training a global network structure corresponding to the search space based on a random training strategy according to the data set. The training of the entire search space can be referred to as the training of the global network structure corresponding to the search space, which is different from the training of part of the network structure (which can be referred to as a sub-network) in the search space. The pre-trained search space is obtained by pre-training, so as to be directly obtained in the step S110.
[0086] Exemplarily, a large data set corresponding to a preset task is prepared in advance, such as an imagenet for a classification task, a COCO for a detection task, a graph is trained on the prepared open source data by using a random strategy (the random strategy can make the graph training process unbiased), and a pre-trained search space is obtained. In actual use, the search space obtained in step S110 can be the pre-trained search space, which can save the step of training the graph and greatly improve the search efficiency.
[0087] By pre-setting the pre-trained search space, the search process can use only one set of pre-trained search space on the same type of task, without training the search space from scratch each time. Taking a classification task as an example, a graph pre-trained on an imagenet can be used as a pre-set pretrain graph for implementing most classification tasks. In actual classification scenarios, only the network structure needs to be searched on the pre-set pretrain graph, and the scene data needs to be fine-tuned and tested for a valid reward.
[0088] Exemplarily, in a classification task, the steps of network structure search are as follows:
[0089] 1. Prepare a graph trained based on an imagenet data set. The data scene data is a train set and a test set. The train set in the scene data is divided into a search set and a valid set, and the test set remains unchanged.
[0090] 2. Export the structure: 1) use a controller to generate a network structure (the controller is an initial state, and is still randomly sampled); 2) the graph accepts the network structure and configures weights shared with the parameters of the corresponding network structure; 3) fine tune the network structure with the corresponding shared weights on the search set for a predetermined number of steps, such as an epoch, then test the fine-tuned structure and the corresponding weights on the valid set to obtain a valid reward. 4) repeat 1), 2), and 3) until a predetermined number of times, such as 100 times. 5) take the top K models with the best valid reward, train them on the train set, and test them on the test set. The highest model structure on the test set is the expected searched structure.
[0091] Exemplarily, the search space can be a trained global network structure, that is, a pretrain graph such as Figure 4AAs shown, there are 4 nodes, namely nodes 0, 1, 2 and 3, but the operations between the nodes (also known as network units) are unknown, which is represented by the question mark "?" in the figure.
[0092] Here, nodes can be understood as feature layers. For example, in Figure 4A In this implementation, the global network structure includes one input feature layer, two intermediate feature layers, and one output feature layer. Node 0 represents the input feature layer, nodes 1 and 2 represent the intermediate feature layers, and node 3 represents the output feature layer. It should be understood that node 0 includes the feature data (feature vector or feature matrix, similar to the examples below) from the input feature layer, node 1 includes the feature data from the first intermediate feature layer, node 2 includes the feature data from the second intermediate feature layer, and node 3 includes the feature data from the output feature layer. The operation between two nodes refers to the operation required to process the feature data on one node into the feature data on the other node. The operations mentioned in this embodiment can be convolution operations, pooling operations, fully connected operations, or other neural network operations. The operations between two nodes can be considered as constituting the operation layer between these two nodes. Typically, the operation layer between two nodes has multiple searchable operations, i.e., multiple candidate operations, such as... Figure 4B As shown. The purpose of neural network architecture search is to determine an operation at each operational layer.
[0093] Neural network structure search can determine the operations between nodes 0, 1, 2, and 3 in the search space. Different combinations of operations between nodes 0, 1, 2, and 3 correspond to different network structures. Therefore, the corresponding network structure can be obtained through neural network structure search. Specifically, a controller can be used to determine the operations from multiple candidate operations to generate the network structure.
[0094] For example, the method of searching for the network structure in the search space based on a random search strategy includes: determining one of a plurality of candidate operations between nodes as the operation in the network structure with equal probability.
[0095] For example, such as Figure 4B As shown, the search space defines various operations on the operation layer between two nodes. For example, the search space defines three operations for each operation layer, where different lines represent operations 1, 2, and 3, respectively. Operation 1 is a convolution operation, operation 2 is a pooling operation, and operation 3 is a fully connected operation. For an operation layer of a neural network, the goal of neural network architecture search is to select one of these three operations as the operation for that operation layer.
[0096] Based on a random search strategy, a network structure is searched in the search space, and parameters of the obtained network structure are determined according to weights of operations in the trained global network structure, weight sharing is realized, and a candidate weight model is obtained, as shown in Figure 4C
[0097] After multiple neural network structure searches and weight sharing, multiple weight models can be obtained. Then, according to a search sample set, each weight model is fine-tuned to obtain a corresponding multiple fine-tuned models. According to a verification sample set, a first evaluation parameter of each of the multiple fine-tuned models is determined, and a fine-tuned model with a better first evaluation parameter is determined as a candidate model.
[0098] Then, the candidate model is trained based on a training sample set to obtain a training model corresponding to each of the candidate models, and a training model with a better second evaluation parameter is determined as a target AI model, that is, a desired searched structure.
[0099] In some embodiments, the efficiency of the structure derivation link is improved by a search method with a guidance mechanism. For example, a better network structure can be found with a high probability in a smaller number of search times (such as within 50 times).
[0100] Illustratively, based on a random search strategy, a network structure is searched in the search space, including: based on a random search strategy, a network structure is searched in the search space according to a sampling distribution.
[0101] Illustratively, the method further includes: updating the sampling distribution according to the network structure corresponding to the fine-tuned model and the first evaluation parameter of the fine-tuned model, until the difference between the network structures searched according to the sampling distribution for a preset number of consecutive times meets a preset condition. Illustratively, the sampling distribution is used to constrain the probability of determining an operation (as an operation in the network structure) from multiple candidate operations between nodes. This improves the efficiency of the structure derivation link, for example, a better network structure can be found with a high probability in a smaller number of search times (such as within 50 times).
[0102] Illustratively, based on a Bayesian criterion, the sampling distribution is updated according to the network structure corresponding to the fine-tuned model and the first evaluation parameter of the fine-tuned model.
[0103] Illustratively, the network structure search step is as follows:
[0104] 1. Prepare a graph trained based on an imagenet dataset. The data scene data is a train set and a test set. The train set in the scene data is divided into a search set and a valid set, and the test set remains unchanged.
[0105] 2. Based on Bayesian optimization to derive the structure: 1) construct a sampling distribution, based on the sampling distribution, randomly sample the network structure; 2) the graph accepts the network structure and configures the parameters of the corresponding network structure under weight sharing; 3) fine-tune the network structure with the corresponding shared weights on the search set for a certain number of steps, such as an epoch, then test the fine-tuned structure and corresponding weights on the valid set to obtain the valid reward; 4) using the network structure sampled in 1) and the valid reward, update the sampling distribution based on the Bayesian criterion. 5) Repeat 1), 2), 3), and 4) until the convergence requirement is met, such as the difference between the network structures sampled before and after is very small. 6) Take the top K models with the best valid reward, train them on the train set, and test them on the test set. The highest model structure on the test set is the expected structure to be searched.
[0106] The structure derivation based on the Bayesian optimization method can greatly improve the efficiency of structure derivation. It can be understood that the method includes but is not limited to all iterative algorithms with guidance mechanisms such as Bayesian optimization.
[0107] The neural network structure search method provided by the embodiment of the application comprises the following steps: obtaining a search space of a neural network; searching for a network structure in the search space based on a random search strategy; determining weight parameters of the network structure according to shared weights corresponding to the search space, to obtain a weight model; and fine-tuning the weight model according to a search sample set, to obtain a fine-tuned model, so as to determine a target AI model in the plurality of fine-tuned models. The unbiased random search method is used to search for a network structure in the search space, which reduces or eliminates search bias on different tasks and data, and ensures the stability of the searched network structure. The weight model is fine-tuned, which improves the accuracy of the evaluation of the network structure and prevents wasting computing power on training of a poor network structure, thereby improving the search efficiency.
[0108] Please refer to the above embodiment Figure 5 , Figure 5 is a flowchart of a neural network model construction method provided by another embodiment of the application. The neural network model construction method can be applied in electronic devices, such as terminal devices or servers, for generating AI models and the like. The terminal device can be a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device, or the like. The server can be a standalone server or a server cluster.
[0109] For example, Figure 2As shown in FIG. 1, a schematic diagram of a scenario in which the neural network model construction method is applied to a server. The server can interact with a terminal device for data, execute a neural network structure search method to generate a target AI model, and can also deploy the generated target AI model to a target device and / or publish the target AI model to a model transaction platform according to an instruction of the terminal device. The target device can be the terminal device or other electronic devices other than the terminal device.
[0110] As shown in FIG. 1, a schematic diagram of a scenario in which the neural network model construction method is applied to a server. The server can interact with a terminal device for data, execute a neural network structure search method to generate a target AI model, and can also deploy the generated target AI model to a target device and / or publish the target AI model to a model transaction platform according to an instruction of the terminal device. The target device can be the terminal device or other electronic devices other than the terminal device. Figure 5 As shown in FIG. 1, a schematic diagram of a scenario in which the neural network model construction method is applied to a server. The server can interact with a terminal device for data, execute a neural network structure search method to generate a target AI model, and can also deploy the generated target AI model to a target device and / or publish the target AI model to a model transaction platform according to an instruction of the terminal device. The target device can be the terminal device or other electronic devices other than the terminal device.
[0111] S210, acquiring a sample set determined by a terminal device, wherein the sample set includes a search sample set.
[0112] In some embodiments, the server can acquire the sample set uploaded by the terminal device, or acquire a storage address of the sample set from the terminal device, and acquire the sample set according to the storage address.
[0113] For example, the sample set includes a plurality of data samples processed by data annotation, such as a plurality of images labeled with category labels.
[0114] For example, a training sample set and a test sample set can be determined in the sample set, and a search sample set and a validation sample set can also be cut out from the training sample set. Of course, the search sample set and the validation sample set can also be independently acquired sample sets. The search sample set is used to fine-tune the weight model to convergence to obtain a fine-tuned model, or to fine-tune the weight model for several cycles (epochs) to obtain a fine-tuned model.
[0115] S220, determining a target AI model according to the foregoing neural network structure search method.
[0116] Specifically, determining the target AI model according to the neural network structure search method includes: acquiring a search space of a neural network; searching for a network structure in the search space based on a random search strategy; determining weight parameters of the network structure according to shared weights corresponding to the search space to obtain a weight model; fine-tuning the weight model according to the search sample set to obtain a fine-tuned model; and determining a target AI model from a plurality of fine-tuned models.
[0117] In an example, the determining the target AI model from the plurality of fine-tuned models comprises: determining a first evaluation parameter of each of the plurality of fine-tuned models according to a validation sample set; determining a plurality of candidate models from the plurality of fine-tuned models according to the first evaluation parameter; training each of the plurality of candidate models based on a training sample set to obtain a training model corresponding to each of the plurality of candidate models; determining a second evaluation parameter of each of the training models based on a test sample set; and determining the target AI model from the training models corresponding to the plurality of candidate models according to the second evaluation parameter.
[0118] In an example, the fine-tuning period is shorter than the training period, and / or a search sample set used for the fine-tuning is smaller than a training sample set used for the training.
[0119] In an example, the searching for the network structure in the search space based on the random search strategy comprises: searching for the network structure in the search space based on a sampling distribution according to the random search strategy.
[0120] In an example, the method further comprises: updating the sampling distribution according to the network structure corresponding to the fine-tuned model and the first evaluation parameter of the fine-tuned model until a difference between network structures searched according to the sampling distribution for a preset number of consecutive times satisfies a preset condition.
[0121] In an example, the search space comprises a search space graph comprising a plurality of network units and connections between the plurality of network units. The searching for the network structure in the search space comprises: searching in the search space graph to determine a directed path comprising a plurality of network units and connections between the plurality of network units, and determining the network structure according to the directed path.
[0122] In an example, the searching for the network structure in the search space based on the random search strategy comprises: searching for the network structure in the search space based on a search control network initialized randomly.
[0123] In an example, the obtaining the search space of the neural network comprises: randomly sampling a sample neural network based on a search control network initialized randomly; and determining the search space and shared weights corresponding to the search space according to a result of the random sampling.
[0124] In an example, the method further comprises: obtaining a data set of a preset task; and pre-training a global network structure corresponding to the search space based on a random training strategy according to the data set.
[0125] S230, deploying the target AI model to a target device and / or publishing the target AI model to a model transaction platform according to an instruction of the terminal device.
[0126] For example, the server can obtain a target device specified by the terminal device through interaction with the terminal device, and the target device is an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device, etc. for deploying the target AI model, so that the server can deploy the target AI model to the target device to enable the target device to apply the target AI model to perform a preset task such as image classification.
[0127] For example, the model transaction platform can be understood as a SaaS service platform for providing AI models, and a model external release button can be set on a web interface of a terminal device of a user, and the button is linked to the transaction platform to realize publishing the target AI model to the model transaction platform according to the instruction of the terminal device.
[0128] Please refer to the above embodiments Figure 6 , Figure 6 is a schematic block diagram of an electronic device 600 provided by the embodiments of the present application.
[0129] For example, the electronic device can include a terminal device or a server; the terminal device can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device; and the server can be a stand-alone server or a server cluster.
[0130] The electronic device 600 includes a processor 601 and a memory 602.
[0131] For example, the processor 601 and the memory 602 are connected through a bus 603, such as an I2C (Inter-integrated Circuit) bus.
[0132] Specifically, the processor 601 can be a microcontroller unit (MCU), a central processing unit (CPU), or a digital signal processor (DSP), etc.
[0133] Specifically, the memory 602 can be a Flash chip, a read-only memory (ROM) disk, an optical disk, a U disk, or a mobile hard disk, etc.
[0134] The processor 601 is configured to run a computer program stored in the memory 602, and realize the following functions when executing the computer program:
[0135] The neural network structure searching method described above; or
[0136] The neural network model construction method described above.
[0137] The processor 601 is configured to run a computer program stored in the memory 602 and implement the following steps when the computer program is executed.
[0138] Obtain a search space of a neural network;
[0139] Search for a network structure in the search space based on a random search strategy;
[0140] Determine weight parameters of the network structure according to shared weights corresponding to the search space, to obtain a weight model;
[0141] Fine-tune the weight model according to a search sample set, to obtain a fine-tuned model;
[0142] Determine a target AI model from the plurality of fine-tuned models.
[0143] The processor 601 is configured to run a computer program stored in the memory 602 and implement the following steps when the computer program is executed.
[0144] Obtain a sample set determined by a terminal device, the sample set including a search sample set;
[0145] Determine a target AI model according to the neural network structure searching method described above;
[0146] Deploy the target AI model to a target device and / or publish the target AI model to a model transaction platform according to an instruction of the terminal device.
[0147] The specific principles and implementation manners of the electronic device provided in the embodiments of the present application are similar to the neural network structure searching method of the foregoing embodiments, and thus will not be described herein.
[0148] The embodiments of the present application further provide a computer readable storage medium storing a computer program, and the computer program is executed by a processor to make the processor implement the steps of the neural network structure searching method provided in the foregoing embodiments or implement the steps of the neural network model construction method provided in the foregoing embodiments.
[0149] The computer readable storage medium can be an internal storage unit of the electronic device, such as a hard disk or a memory of the electronic device. The computer readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like.
[0150] It should be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application.
[0151] It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items, and that the term "at least one of' as used herein means one, two, three, four, or more, but does not preclude further items or groups of items.
[0152] The above description is merely illustrative of the application and no limitation of the scope of the application is thereby intended, as it will be apparent that, for example, further equivalents and modifications than those set forth herein will occur to those skilled in the art. Thus, the intended scope of the application is to be defined only by the following claims and equivalents thereof.
Claims
1. A neural network architecture search method, characterized in that, The method comprises the following steps: obtaining a search space of a neural network, the neural network being used for processing images, texts or voices, wherein the processing of images comprises at least one of the following: classification, segmentation, detection, identification, generation, the processing of texts comprises at least one of the following: translation, paraphrasing, generation, and the processing of voices comprises at least one of the following: identification, translation, generation; the search space comprises a search space graph, the search space graph comprising a plurality of network units and connections between the plurality of network units; searching for a network structure in the search space based on a random search strategy; determining a weight parameter of the network structure according to a shared weight corresponding to the search space, to obtain a weight model; fine-tuning the weight model according to a search sample set, to obtain a fine-tuned model; determining a target AI model from a plurality of fine-tuned models; wherein the obtaining of the search space of the neural network comprises: randomly sampling a sample neural network based on a search control network initialized randomly; and determining the search space and a shared weight corresponding to the search space according to a result of the random sampling; the searching for the network structure in the search space based on the random search strategy comprises: searching in the search space graph based on the search control network initialized randomly, to determine a directed path comprising a plurality of network units and connections between the plurality of network units, and to determine the network structure according to the directed path.
2. The neural network architecture search method of claim 1, wherein, The determining of the target AI model from the plurality of fine-tuned models comprises: determining a first evaluation parameter of each of the plurality of fine-tuned models according to a verification sample set; determining a plurality of candidate models from the plurality of fine-tuned models according to the first evaluation parameter; training each of the plurality of candidate models based on a training sample set, to obtain a training model corresponding to each of the plurality of candidate models; determining a second evaluation parameter of each of the plurality of training models based on a test sample set; determining the target AI model from the training models corresponding to the plurality of candidate models according to the second evaluation parameter.
3. The neural network architecture search method of claim 2, wherein, The period of the fine-tuning is lower than the period of the training, and / or the search sample set used for the fine-tuning is smaller than the training sample set used for the training.
4. The neural network architecture search method of claim 2, wherein, The searching for the network structure in the search space based on the random search strategy comprises: searching for the network structure in the search space based on the random search strategy according to a sampling distribution; The method further comprises: updating the sampling distribution according to the first evaluation parameter of the fine-tuned model corresponding to the network structure of the fine-tuned model, until a difference between network structures searched according to the sampling distribution for a preset number of consecutive times meets a preset condition.
5. The neural network architecture search method of any one of claims 1-4, wherein, The method further comprises: obtaining a data set of a preset task; pre-training a global network structure corresponding to the search space based on a random training strategy and the data set. 6.A method for constructing a neural network model, characterized in that, The method comprises the following steps: obtaining a sample set determined by a terminal device, the sample set comprising a search sample set; determining a target AI model by using the neural network structure searching method according to any one of claims 1-5; deploying the target AI model to a target device and / or publishing the target AI model to a model transaction platform according to an instruction of the terminal device.
7. An electronic device, comprising: comprising a memory and a processor; the memory is configured to store a computer program; the processor is configured to execute the computer program and realize the following when executing the computer program: the neural network structure searching method according to any one of claims 1-5; or the neural network model constructing method according to claim 6.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to make the processor realize the following: the neural network structure searching method according to any one of claims 1-5; or the neural network model constructing method according to claim 6.
Citation Information
Patent Citations
Perceptual network structure searching method and device
CN111401517A
Resource-efficient neural architects
US20190354837A1