Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 shows a schematic diagram of a training method of a super network according to an embodiment of the present disclosure. As shown in fig. 1, the method includes:
step S110, performing N times of iterative operations based on a preset super network to obtain a target super network; wherein N is an integer greater than or equal to 2;
The ith iteration operation in the N iteration operations comprises the following steps:
step S111, i times of the preset resolution is taken as the resolution of the feature map, and an extended sub-network is obtained based on the resolution of the feature map and the preset skeleton structure; wherein i is a positive integer less than or equal to N;
step S112, updating a preset super network based on the extended sub network, and training the updated preset super network to obtain a converged super network;
Step S113, in the case where i is equal to the preset threshold N, determining the converged super network as the target super network.
The method provided by the embodiment of the disclosure is used for training the super network, and all network structures in the search space of the super network, namely all sub-networks in the search space, share the parameters of the super network. Therefore, through training the super network, the training of each sub network can be replaced, and the training efficiency is improved. The individual subnetworks in the search space of the super network may also be referred to as individual subnetworks of the super network.
Illustratively, the preset skeleton structure and the preset resolution may be derived based on an initial search space. In one example, an initial search space, such as MobileNet-like search space or ResNet-like search space, may be predetermined. The initial search space includes a plurality of model structures or subnetworks. Illustratively, the initial search space includes a plurality of sub-networks having different skeletal structures. Here, the skeleton structure may refer to a collection of structural information such as types and numbers of various modules (blocks), sub-modules (sub-blocks), or network layers (layers) in the neural network. The skeleton structure of each sub-network in the initial search space may be regarded as a preset skeleton structure, and the resolution of the feature map of each sub-network in the initial search space may be the preset resolution.
Illustratively, the preset hypernetwork may be derived based on initial hypernetwork parameters, which may be derived by pre-configuration. According to the embodiment of the disclosure, in each iteration operation, an extended sub-network is obtained based on a multiple of a preset resolution and a preset skeleton structure, and a preset super-network is updated based on the extended sub-network. Here, the update of the preset super network based on the extended sub network may be based on the extended sub network and the sub network existing in the search space of the preset super network, to reselect the sub network as the sub network in the search space, or to add the extended sub network in the search space of the preset super network, or the like. Training the updated preset super network until convergence is performed after the preset super network is updated each time so as to optimize the super network parameters and improve the performance of each sub-network sharing the super network parameters.
For example, the predetermined skeleton structure is A, B, C, and the predetermined resolution is R. In the ith iteration operation, i times i×r of the preset resolution is taken as the feature map resolution, and 3 extended subnetworks with the framework structures being the preset framework structure A, B, C and the feature map resolutions being the preset resolution i×r can be obtained by combining the preset framework structures A, B and C. And updating the preset super network based on the extended sub network and training to be converged. And obtaining a target super-network through N times of iterative operations, wherein a search space of the target super-network comprises a plurality of groups of sub-networks corresponding to a plurality of preset skeleton structures, and each group of sub-networks comprises N sub-networks with preset resolutions of R, 2R, 3R, … … and N x R respectively. And, the subnetworks are trained by sharing the parameters of the subnetworks. Based on the method, the sub-networks with better performance can be searched from all the sub-networks of the target super-network according to the actual application requirements.
It can be seen that, according to the method of the embodiment of the present disclosure, a plurality of iterative operations are performed based on a preset super network. In each iteration operation, an expansion sub-network is obtained based on i times of the preset resolution and the preset skeleton structure, a preset super-network is updated based on the expansion sub-network, and the preset super-network is trained to be converged. Therefore, the obtained target super-network comprises a plurality of sub-networks with different feature map resolutions corresponding to the preset skeleton structure, and the performance of the sub-networks searched in the search space of the target super-network in the image processing scene can be improved. For example, in an image processing scene such as image classification, image recognition, or the like, the speed and accuracy of image processing, or the like, can be improved. In particular, using sub-networks searched in the search space of the target super-network on specific hardware, better hardware performance can be obtained, for example, higher processing accuracy can be obtained on a processor with limited operation speed, or faster operation can be achieved on a processor with limited processing accuracy, etc. In some scenarios, hardware costs may also be reduced, e.g., equivalent hardware performance may be achieved with less hardware than before, reducing hardware costs by reducing the number of hardware uses.
In an exemplary embodiment, in the step S112, updating the preset super network based on the extended sub network includes:
and adding an extended subnetwork in the search space of the preset super network.
For example, in the 2 nd iteration operation, the extended subnetwork includes 3 subnetworks with skeleton structures of preset skeleton structure A, B, C and feature map resolutions of preset resolution 2R. Adding an extended subnetwork in the search space, the search space includes: the framework structures are all A, and the resolution of the feature map is 2 first subnetworks of R and 2R respectively; the framework structures are all B, and the resolution of the feature map is 2 second subnetworks of R and 2R respectively; and 2 third sub-networks with skeleton structures of C and feature map resolutions of R and 2R respectively.
By adding the expansion sub-network in the search space of the preset super-network, the search space of the target super-network obtained through final training can contain the sub-network with the full quantity of the characteristic map resolution being 1 to N times of the preset resolution. Therefore, the method is beneficial to searching and obtaining the sub-network which meets the actual application requirements.
In an exemplary embodiment, in step S112, training the updated preset super network to obtain a converged super network includes:
Selecting m sub-networks from the updated search space of the preset super-network based on the preset resolution; wherein m is a positive integer;
training the updated preset super network based on the m sub-networks to obtain a converged super network.
For example, in the updated search space of the preset super-network, selecting m sub-networks with the feature map resolution being the preset resolution. The updated preset super-network is trained based on the selected sub-network, rather than the full amount of sub-networks.
According to the above embodiment, in each iteration operation, all the sub-networks are not considered, but the super-network is updated by using the sub-network corresponding to the preset resolution. Therefore, the calculation amount can be effectively reduced. And compared with the sub-network corresponding to the multiple of the preset resolution, the sub-network corresponding to the preset resolution is adopted to update the super-network, so that the calculation complexity can be reduced, and the calculation efficiency is further improved.
After the target super-network is obtained, a target sub-network can be selected in a search space of the target super-network based on a preset algorithm, such as a genetic algorithm, for image processing. In an exemplary embodiment, the selection may also be made using a performance prediction model. As shown in fig. 2, the method may further include:
step S210, selecting a target sub-network from the search space of the target super-network by using the performance prediction model.
The performance prediction model is used for predicting the performance of each sub-network of the super-network to obtain the predicted performance of each sub-network of the super-network. The performance prediction model may be a linear estimation model, or a probability model, for example, a joint gaussian distribution model, or the like.
According to the embodiment, the performance prediction model is utilized to select the target sub-network, so that the target sub-network with better performance can be selected, the performance of the target sub-network in an image processing scene, such as the speed and the precision of image processing, is improved, and the hardware cost is reduced.
Illustratively, the performance prediction model may be trained using a plurality of sub-networks and corresponding performance information. Specifically, the method may further include:
Randomly sampling k sub-networks in a search space of a target super-network; wherein k is a positive integer;
Evaluating the k sub-networks based on the super-network parameters of the target super-network to obtain the evaluation performance of the k sub-networks;
based on the estimated performance of k sub-networks, training a preset model to obtain a performance prediction model.
For example, the k sub-networks may be respectively evaluated based on differences between the parameters of the k sub-networks and the super-network parameters of the target super-network, respectively, to obtain the evaluation performance. And training a preset model by taking the subnetwork and the evaluation performance thereof as training data pairs, so as to obtain a performance prediction model.
According to the embodiment, an accurate performance prediction model can be obtained through training, the target sub-network is selected from the search space of the target super-network based on the accurate performance prediction model, performance of the target sub-network in an image processing scene, such as speed and precision of image processing, can be improved, and hardware cost is reduced.
In an exemplary embodiment, as shown in fig. 3, the method further includes:
step S310, obtaining an image to be processed;
Step S320, the target sub-network is utilized to process the image to be processed, and an image processing result of the image to be processed is obtained.
For example, the image to be processed may be an image to be identified or classified. And processing the image to be processed by using the target sub-network, so that an image processing result can be obtained, wherein the image processing result comprises a recognition result or a classification result of the image to be processed. The recognition result may include a target detection result, a semantic segmentation result, and the like.
According to the embodiment, the target sub-network obtained based on the super-network search is applied to the image processing scene, so that the processing precision and/or the processing speed can be improved.
An application example of the embodiments of the present disclosure is provided below. In this application example, the training method of the super network includes:
in step S10, a general skeleton structure search space, such as MobileNet-like search space or ResNet-like search space, is designed.
In step S20, a resolution search space is designed, where each block, sub block or layer in the search space has multiple selectable resolutions (multiple of the preset resolution in the case of fixed preset resolution), and the resolution of each block, sub block or layer may be r_1, r_2, … …, r_k, and other k values. Where for any k1< k2, the resolution r_k1 is greater than the resolution r_k2, that is, r_k is the smallest resolution and r_1 to r_k-1 are multiples of r_k. If the search efficiency in the search space needs to be increased, the resolution may be extended only in the key block, sub block or layer.
In step S30, when k=1 is initialized, the resolution search space only includes the sub-network with the resolution r_1.
Step S40, training the super network until convergence by using the sub network with the resolution of r_k.
Step S50, if k is smaller than the preset threshold, let k=k+1, and return to step S40. At this time, r_k remains at the lowest resolution, but the selectable number of resolutions in the search space increases.
Step S60, if k reaches a preset threshold, outputting the trained super network supernet.
Step S70, randomly sampling m sub-networks based on the super-network, wherein each sub-block or layer of each sub-network has a determined resolution and skeleton structure.
Step S80, evaluating the performance of the m sub-networks based on the super network.
Step S90, a data pair (pair) is obtained based on the sub-network and the performance of the sub-network, and a performance prediction model is obtained by training the data pair.
Step S100, searching to obtain an optimal sub-network with optimal resolution based on the performance prediction model.
It should be appreciated that the scope of applicability of the present disclosure is not limited to the image processing field described above, but may also be applicable to other artificial intelligence fields. Illustratively, PADDLESLIM for model compression, paddlecloud for cloud computing, easyDL for image recognition, and so forth may be applicable. According to the method of the embodiment of the disclosure, multiple iterative operations are performed based on the preset super network. In each iteration operation, an expansion sub-network is obtained based on i times of the preset resolution and the preset skeleton structure, a preset super-network is updated based on the expansion sub-network, and the preset super-network is trained to be converged. Therefore, the obtained target super-network comprises a plurality of sub-networks with different feature map resolutions corresponding to the preset skeleton structure, and the performance of the sub-networks searched in the search space of the target super-network in the image processing scene can be improved.
As the implementation of the above methods, the present disclosure also provides a training device for a super network. Fig. 4 is a schematic diagram of a training apparatus of a super network provided in one embodiment of the present disclosure. As shown in fig. 4, the apparatus includes:
An iteration module 410, configured to perform N iteration operations based on a preset super-network, to obtain a target super-network; wherein N is an integer greater than or equal to 2;
wherein the iteration module 410 comprises:
A resolution expansion unit 411, configured to obtain an expanded sub-network based on the feature map resolution and a preset skeleton structure, with i times of the preset resolution as the feature map resolution; wherein i is a positive integer less than or equal to N;
The super network training unit 412 is configured to update a preset super network based on the extended sub-network, and train the updated preset super network to obtain a converged super network;
the target determining unit 413 is configured to determine the converged super network as a target super network in a case where i is equal to a preset threshold N.
Illustratively, the super network training unit 412 is configured to:
and adding an extended subnetwork in the search space of the preset super network.
Illustratively, the super network training unit 412 is configured to:
Selecting m sub-networks from the updated search space of the preset super-network based on the preset resolution; wherein m is a positive integer;
training the updated preset super network based on the m sub-networks to obtain a converged super network.
Illustratively, as shown in fig. 5, the training apparatus of the super network further includes:
the subnetwork selection module 510 is configured to select a target subnetwork in the search space of the target subnetwork by using the performance prediction model.
Illustratively, as shown in fig. 5, the training apparatus of the super network further includes:
a random sampling module 520, configured to randomly sample k sub-networks in a search space of the target super-network; wherein k is a positive integer;
The performance evaluation module 530 is configured to evaluate the k sub-networks based on the super-network parameters of the target super-network, to obtain an evaluation performance of the k sub-networks;
the model determining module 540 is configured to train a preset model based on the estimated performance of the k sub-networks, to obtain a performance prediction model.
Illustratively, as shown in fig. 5, the training apparatus of the super network further includes:
An image acquisition module 550, configured to acquire an image to be processed;
The image processing module 560 is configured to process the image to be processed by using the target sub-network, so as to obtain an image processing result of the image to be processed.
The super-network training method provided by the embodiment of the disclosure can realize the super-network training device provided by the embodiment of the disclosure and has the corresponding beneficial effects.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
Fig. 6 illustrates a schematic block diagram of an example electronic device 600 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the electronic device 600 includes a computing unit 601 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, ROM 602, and RAM 603 are connected to each other by a bus 604. An input output (I/O) interface 605 is also connected to bus 604.
A number of components in the electronic device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, mouse, etc.; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information/data with other devices through a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as the training method of the super network. For example, in some embodiments, the training method of the super network may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 600 via the ROM 602 and/or the communication unit 609. When the computer program is loaded into RAM 603 and executed by computing unit 601, one or more steps of the above-described training method of the super network may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the training method of the super network by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.