WO2020221200A1 - Neural network construction method, image processing method and devices - Google Patents

Neural network construction method, image processing method and devices Download PDF

Info

Publication number
WO2020221200A1
WO2020221200A1 PCT/CN2020/087222 CN2020087222W WO2020221200A1 WO 2020221200 A1 WO2020221200 A1 WO 2020221200A1 CN 2020087222 W CN2020087222 W CN 2020087222W WO 2020221200 A1 WO2020221200 A1 WO 2020221200A1
Authority
WO
WIPO (PCT)
Prior art keywords
neural network
network
search
construction
stage
Prior art date
Application number
PCT/CN2020/087222
Other languages
French (fr)
Chinese (zh)
Inventor
陈鑫
谢凌曦
田奇
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020221200A1 publication Critical patent/WO2020221200A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/55Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/50Context or environment of the image
    • G06V20/56Context or environment of the image exterior to a vehicle by using sensors mounted on the vehicle

Definitions

  • This application relates to the field of artificial intelligence, and more specifically, to a neural network construction method, image processing method and device.
  • Artificial intelligence is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results.
  • artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a similar way to human intelligence.
  • Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
  • Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, and basic AI theories.
  • neural networks for example, deep neural networks
  • a neural network with good performance often has a sophisticated network structure, which requires human experts with superb skills and rich experience to spend a lot of energy to construct.
  • NAS neural architecture search
  • the search method is generally based on a certain number of building units to build a search network, and then search for each node in the search network in the search space.
  • the connection relationship of is optimized to obtain the optimized building unit, and finally the target neural network is built according to the optimized building unit.
  • the search method puts all possible operations into the search space, which leads to a huge video memory space required during the optimization process, which can only be stacked into a shallow search network.
  • the final target neural network to be built is often deeper, which leads to a large difference in depth between the search network and the target neural network, and the construction unit obtained due to the shallower search network optimization is not completely suitable for the deeper ones.
  • the target neural network so that the final target neural network may not meet the application requirements well.
  • This application provides a neural network construction method, image processing method, device, computer readable storage medium, and chip to better construct a neural network that meets the needs.
  • a method for constructing a neural network includes: determining a search space and a plurality of building units; stacking the plurality of building units to obtain a search network, which is a neural network for searching the structure of a neural network Network; optimize the network structure of the building unit in the search network in the search space to obtain the optimized building unit; build the target neural network according to the optimized building unit.
  • the above search space is determined according to the application requirements of the target neural network to be constructed, and the above multiple construction units are determined according to the search space and the size of the video memory resources of the equipment that constructs the target neural network.
  • the construction units are determined by multiple A network structure obtained by the basic operation of the neural network between nodes.
  • the building unit is the basic module for building the neural network.
  • the optimization process for optimizing the network structure of the building unit in the search network includes N stages.
  • the i-th and j-th stages are any two of the N stages.
  • the search space is in the i-th stage.
  • the size is larger than the size of the search network in the j-th stage, and the number of building units included in the search network in the i-th stage is smaller than the number of building units in the search space in the j-th stage, and the search space of the search network is reduced
  • the increase in the number of building units of the search network makes the video memory consumption in the optimization process within the preset range.
  • the difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is expected within the range, the number of building units included in the target neural network is determined according to the application requirements of the target neural network, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j .
  • the aforementioned search space is determined according to the application requirements of the target neural network to be constructed, and specifically includes: the aforementioned search space is determined according to the type of processing data of the target neural network.
  • the type and number of operations included in the above-mentioned search space should be adapted to the processing of image data.
  • the aforementioned search space may include convolution operations, pooling operations, skip-connect operations, and so on.
  • the type and number of operations contained in the above-mentioned search space should be adapted to the processing of voice data.
  • the target neural network is a neural network for processing voice data
  • the above search space may include activation functions (such as ReLU, Tanh) and so on.
  • the number of building units included in the target neural network is determined according to the application requirements of the target neural network, including: the number of building units included in the target neural network is based on the type of data and/or calculations to be processed by the target neural network The complexity is determined.
  • the target neural network when the above target neural network is used to process some simple text data, the target neural network only needs to contain a smaller number of building units. When the above target neural network is used to process some more complex image data, the target neural network needs Contains a large number of building units.
  • the target neural network needs to contain a larger number of building units; when the target neural network needs to process data with low complexity, the target neural network needs a smaller number
  • the building unit can be.
  • the above-mentioned video memory resource may be replaced with a cache resource, which is a memory or storage unit used for storing operation data during the optimization process of the device used to construct the neural network.
  • a cache resource which is a memory or storage unit used for storing operation data during the optimization process of the device used to construct the neural network.
  • the foregoing cache resources may specifically include video memory resources.
  • the foregoing stacking of multiple building units to obtain a search network includes: stacking the multiple building units in sequence in a preset stacking manner to obtain a search network, wherein, in the search network, the search network is located The output of the building unit in front of the network is the input of the building unit located in the back of the search network.
  • the foregoing preset stacking manner may include what type of building units are stacked at which position, the number of stacks, and so on.
  • the video memory resources saved by reducing the search space can be used to increase the number of building units, so that the building units can be stacked as much as possible when the video memory resources are limited.
  • a search network whose number is close to the number of building units of the target neural network to be built finally.
  • the optimized construction unit can be better adapted to the construction of the target neural network, and the target neural network built according to the optimized construction unit can better meet the application requirements.
  • this application gradually reduces the size of the search space and increases the number of construction units of the search network, so as to construct a target neural network that can better meet the needs of the application.
  • the dependence on the video memory resources in the optimization process is reduced, so that the target neural network that satisfies the application needs can be obtained by relying on less video memory resources in the optimization process, and also improves the utilization of video memory resources to a certain extent. rate.
  • the optimized construction unit in the search network is more suitable for building the target neural network.
  • the depth of the neural network is positively correlated with the number of building units contained. Therefore, when the number of building units of the search network is close to the number of building units of the target neural network, the network depth of the search network is the same as that of the target neural network. Also relatively close.
  • the size of the search space for the i-th stage S i, S j of the above-described search space size in the j-th stage, the number of the search network construction unit included in the i-th stage is L i
  • the number of construction units included in the j-th stage of the search network is L j , where the size of L j -L i is determined according to the size of S i -S j , or the size of S i -S j is Determined according to the size of L j -L i .
  • the size of S i -S j can be preset, and then the size of L j -L i can be determined according to the size of S i -S j , so that the video memory saved due to the reduced search space
  • the increase in resources and building units causes the difference between the excessively consumed video memory resources to be within a certain threshold range.
  • the size of L j -L i can also be preset, and then the size of S i -S j is determined according to the size of L j -L i , so that the increase in the building unit causes more memory resources to be consumed
  • the difference between the video memory resources saved and the search space reduction is within a certain threshold range.
  • the above-mentioned size of N is preset.
  • the size of the above N can be determined according to the construction requirements of the target neural network. Specifically, when the target neural network needs to be constructed in a relatively short time, N can be set to a small value, and when the target neural network can be constructed in a relatively long time, N can be set to a Larger value.
  • the second stage is compared with the first stage and the fourth stage is satisfied with the third stage: the search space is reduced, and the number of construction units of the search network is increased.
  • the search space and the number of building units contained in the search network in the second and third phases have not changed.
  • j i+1.
  • the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
  • the number of construction units increased in the i+1th stage relative to the i-th stage may be based on the aforementioned value N, the number of construction units included in the search network before optimization, and the construction of the target neural network The number of units is determined.
  • the number of building units increased by the search network in the i+1 stage relative to the i-th stage is X
  • the number of building units contained in the search network before the optimization starts is U
  • the number of building units in the target neural network is V
  • the extent of the reduction in the size of the search space and the extent of the increase in the number of search network construction units can be determined in various ways, as long as the reduction in the search space of the search network during the optimization process and the search
  • the increase in the number of building units of the network makes the memory consumption generated in the optimization process within a preset range.
  • the size of the search space can be reduced in advance, and then the amount of increase in the number of search network construction units can be determined; or the size of the search network can be preset, and then the size of the search space can be reduced.
  • This application does not limit this, and all implementations to ensure that the video memory consumption is within the preset range are within the protection scope of this application.
  • the number of the first type of operations included in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first type of operation is not Contains operations for neural network trainable parameters.
  • the number of operations of the first type is limited to a certain range, so that the trainable parameters of the final target neural network are maintained at a relatively stable level, and the performance of the target neural network remains stable.
  • the first type of operation mentioned above is an operation that does not contain trainable parameters. If there are too many such operations, it will result in fewer other operations containing trainable parameters, so that the overall neural network has fewer trainable parameters, and the characteristics of the neural network Decreased expression ability.
  • the number of first-type operations in the construction units obtained by each search will have a certain difference.
  • the neural network structure obtained by the search ie, the construction unit
  • Limiting the number of operations of the first type can keep the trainable parameters of the test network constructed from the neural network structure obtained by the search at a relatively stable level, thereby reducing performance fluctuations on the corresponding tasks.
  • the building units in the search network include the first type of building unit, and the first type of building unit is the number and size of the input feature maps and the number and the output feature maps, respectively. Building units of the same size.
  • the building units in the search network include the second type of building unit, and the resolution of the output feature map of the second type of building unit is 1/M of the input feature map,
  • the number of output feature maps of the second type of construction unit is M times the number of input feature maps, and M is a positive integer greater than 1.
  • an image processing method includes: acquiring an image to be processed; classifying the image to be processed according to a target neural network to obtain a classification result of the image to be processed, wherein the target neural network It is a neural network constructed according to any one of the realization methods in the first aspect.
  • the target neural network used in the image processing method in the second aspect performs image classification
  • the target neural network needs to be trained according to the training image, and the trained target neural network can then classify the image to be processed .
  • the neural network structure search method in the first aspect can be used to obtain the target neural network. Then, the target neural network can be trained according to the training image. After the training is completed, the target neural network can be used to perform the processing of the image to be processed. Classified.
  • the target neural network is constructed using the above-mentioned first aspect, it is more in line with or close to the application requirements of the neural network.
  • Using such a neural network for image classification can achieve better image classification effects (for example, The classification results are more accurate, etc.).
  • an image processing method includes: acquiring an image to be processed; and classifying the image to be processed according to a target neural network to obtain a classification result of the image to be processed.
  • the target neural network is constructed by multiple optimized building units, and the multiple optimized building units are obtained by optimizing the network structure of the building units in the search network in N stages.
  • the i-th stage and The j-th stage is any two of the N stages.
  • the size of the search space in the i-th stage is greater than the size of the search network in the j-th stage, and the number of building units included in the search network in the i-th stage is less than
  • the number of construction units included in the search space at the jth stage, the reduction of the search space of the search network and the increase of the number of construction units of the search network make the memory consumption generated during the optimization process within the preset range, and the search network is in the first
  • the difference between the number of building units included in the N stages and the number of building units included in the target neural network is within a preset range.
  • the number of building units included in the target neural network is determined according to the application requirements of the target neural network, and N is greater than A positive integer of 1, i and
  • the optimized construction unit of the search network can be better adapted to the construction of the target neural network, and a better performance target neural network can be obtained.
  • Using the target neural network for image classification can achieve better image classification results (for example, The classification results are more accurate, etc.).
  • j i+1.
  • the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
  • the above-mentioned target neural network is a neural network obtained by training through training pictures.
  • the target neural network can be trained by training pictures and the category information marked by the training pictures, and the trained neural network can be used for image classification.
  • an image processing method includes: obtaining a road image; performing convolution processing on the road image according to a target neural network to obtain multiple convolution feature maps of the road image; and processing the road image according to the target neural network Deconvolution processing is performed on multiple convolution feature maps of to obtain the semantic segmentation result of the road image.
  • the above-mentioned target neural network is a neural network constructed according to any one of the implementation methods in the first aspect.
  • an image processing method includes: obtaining a face image; performing convolution processing on the face image according to a target neural network to obtain a convolution feature map of the face image; The product feature map is compared with the convolution feature map of the ID image to obtain the verification result of the face image.
  • the convolution feature map of the aforementioned ID image may be obtained in advance and stored in the corresponding database. For example, perform convolution processing on the image of the ID document in advance, and store the obtained convolution feature map in the database.
  • the above-mentioned target neural network is a neural network constructed according to any one of the implementation methods in the first aspect.
  • a neural network construction device in a sixth aspect, includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the The processor is configured to execute the method in any one of the implementation manners in the first aspect.
  • an image processing device which includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the processing The device is used to execute the method in any one of the second aspect to the fifth aspect.
  • a computer-readable medium stores program code for device execution, and the program code includes a method for executing any one of the first to fifth aspects. .
  • a computer program product containing instructions is provided.
  • the computer program product runs on a computer, the computer executes the method in any one of the foregoing first to fifth aspects.
  • a chip in a tenth aspect, includes a processor and a data interface.
  • the processor reads instructions stored in a memory through the data interface, and executes any one of the first to fifth aspects above The method in the implementation mode.
  • the chip may further include a memory in which instructions are stored, and the processor is configured to execute the instructions stored in the memory.
  • the processor is configured to execute the method in any one of the implementation manners of the first aspect to the fifth aspect.
  • FIG. 1 is a schematic diagram of an artificial intelligence main body framework provided by an embodiment of the present application
  • Figure 2 is a schematic diagram of an application environment provided by an embodiment of the application.
  • FIG. 3 is a schematic diagram of a convolutional neural network structure provided by an embodiment of the application.
  • FIG. 4 is a schematic diagram of a convolutional neural network structure provided by an embodiment of the application.
  • FIG. 5 is a schematic structural diagram of a neural network processor provided by an embodiment of this application.
  • FIG. 6 is a schematic structural diagram of a processor provided by an embodiment of the application.
  • FIG. 7 is a schematic diagram of the hardware structure of a chip provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of a system architecture provided by an embodiment of the application.
  • FIG. 9 is a schematic flowchart of a neural network construction method according to an embodiment of the present application.
  • FIG. 10 is a schematic diagram of a construction unit of an embodiment of the present application.
  • Fig. 11 is a schematic diagram of a search network according to an embodiment of the present application.
  • FIG. 12 is a schematic diagram of a neural network construction method according to an embodiment of the present application.
  • FIG. 13 is a schematic diagram of a neural network construction system according to an embodiment of the present application.
  • FIG. 14 is a schematic diagram of a network structure optimization process of a construction unit of a search network according to an embodiment of the present application.
  • 15 is a schematic diagram of the processing procedure of the operation quantity specification module of the embodiment of the present application.
  • FIG. 16 is a schematic flowchart of an image processing method according to an embodiment of the present application.
  • FIG. 17 is a schematic block diagram of a neural network construction device according to an embodiment of the present application.
  • FIG. 18 is a schematic block diagram of an image processing device according to an embodiment of the present application.
  • Fig. 19 is a schematic block diagram of a neural network training device according to an embodiment of the present application.
  • Figure 1 shows a schematic diagram of an artificial intelligence main framework, which describes the overall workflow of the artificial intelligence system and is suitable for general artificial intelligence field requirements.
  • Intelligent Information Chain reflects a series of processes from data acquisition to processing. For example, it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has gone through the condensing process of "data-information-knowledge-wisdom".
  • Infrastructure provides computing power support for artificial intelligence systems, realizes communication with the outside world, and realizes support through the basic platform.
  • the infrastructure can communicate with the outside through sensors, and the computing power of the infrastructure can be provided by smart chips.
  • the smart chip here can be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), and an application specific integrated circuit (application specific).
  • Hardware acceleration chips such as integrated circuit (ASIC) and field programmable gate array (FPGA).
  • the basic platform of infrastructure can include distributed computing framework and network and other related platform guarantees and support, and can include cloud storage and computing, interconnection networks, etc.
  • data can be obtained through sensors and external communication, and then these data can be provided to the smart chip in the distributed computing system provided by the basic platform for calculation.
  • the data in the upper layer of the infrastructure is used to represent the data source in the field of artificial intelligence.
  • This data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
  • the above-mentioned data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other processing methods.
  • machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, training, etc.
  • Reasoning refers to the process of simulating human intelligent reasoning in a computer or intelligent system, using formal information to conduct machine thinking and solving problems based on reasoning control strategies.
  • the typical function is search and matching.
  • Decision-making refers to the decision-making process of intelligent information after reasoning, and usually provides functions such as classification, ranking, and prediction.
  • some general capabilities can be formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image Recognition and so on.
  • Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields. It is an encapsulation of the overall solution of artificial intelligence, productizing intelligent information decision-making and realizing landing applications. Its application fields mainly include: intelligent manufacturing, intelligent transportation, Smart home, smart medical, smart security, autonomous driving, safe city, smart terminal, etc.
  • the embodiments of this application can be applied to many fields in artificial intelligence, for example, smart manufacturing, smart transportation, smart home, smart medical care, smart security, automatic driving, safe cities and other fields.
  • the embodiments of the present application can be specifically applied in fields that require the use of (deep) neural networks, such as image classification, image retrieval, image semantic segmentation, image super-resolution, and natural language processing.
  • deep neural networks such as image classification, image retrieval, image semantic segmentation, image super-resolution, and natural language processing.
  • recognizing the images in the album can facilitate the user or the system to classify and manage the album and improve the user experience.
  • the neural network structure search method of the embodiment of the present application can search for a neural network structure suitable for album classification, and then train the neural network according to the training pictures in the training picture library to obtain the album classification neural network.
  • the album classification neural network can be used to classify the pictures, so that different categories of pictures can be labeled for users to view and find.
  • the classification tags of these pictures can also be provided to the album management system for classification management, saving users management time, improving the efficiency of album management, and enhancing user experience.
  • a neural network suitable for album classification can be constructed through a neural network construction system (corresponding to the neural network structure search method in the embodiment of the present application).
  • the network structure of the building unit in the search network can be optimized by using the training image library to obtain the optimized building unit, and then the optimized building unit can be used to build the neural network.
  • the neural network can be trained according to the training pictures to obtain the album classification neural network.
  • the album classification neural network processes the input pictures, and the picture category is tulip.
  • a neural network suitable for data processing in an autonomous driving scenario can be constructed, and then the neural network can be trained through the data in the autonomous driving scenario to obtain The sensor data processing network can finally use the sensor processing network to process the input road images to identify different objects in the road images.
  • the neural network construction system can construct a neural network according to the vehicle detection task.
  • the sensor data can be used to optimize the network structure of the building units in the search network to obtain the optimized construction Unit, and then use the optimized building unit to build a neural network.
  • the neural network can be trained according to the sensor data to obtain the sensor data processing network.
  • the sensor data processing network processes the input road picture, and can identify the vehicle in the road picture (as shown in the rectangular frame in the lower right corner of Fig. 3).
  • a neural network can be composed of neural units.
  • a neural unit can refer to an arithmetic unit that takes x s and intercept 1 as inputs.
  • the output of the arithmetic unit can be:
  • s 1, 2,...n, n is a natural number greater than 1
  • W s is the weight of x s
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal.
  • the output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function.
  • a neural network is a network formed by connecting multiple above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected with the local receptive field of the previous layer to extract the characteristics of the local receptive field.
  • the local receptive field can be a region composed of several neural units.
  • Deep neural network also called multi-layer neural network
  • DNN can be understood as a neural network with multiple hidden layers.
  • DNN is divided according to the positions of different layers.
  • the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer.
  • the first layer is the input layer
  • the last layer is the output layer
  • the number of layers in the middle are all hidden layers.
  • the layers are fully connected, that is to say, any neuron in the i-th layer must be connected to any neuron in the i+1th layer.
  • DNN looks complicated, it is not complicated in terms of the work of each layer. Simply put, it is the following linear relationship expression: among them, Is the input vector, Is the output vector, Is the offset vector, W is the weight matrix (also called coefficient), and ⁇ () is the activation function.
  • Each layer is just the input vector After such a simple operation, the output vector is obtained Due to the large number of DNN layers, the coefficient W and the offset vector The number is also relatively large.
  • the definition of these parameters in the DNN is as follows: Take the coefficient W as an example: Suppose that in a three-layer DNN, the linear coefficients from the fourth neuron in the second layer to the second neuron in the third layer are defined as The superscript 3 represents the number of layers where the coefficient W is located, and the subscript corresponds to the output third layer index 2 and the input second layer index 4.
  • the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as
  • the input layer has no W parameter.
  • more hidden layers make the network more capable of portraying complex situations in the real world. Theoretically speaking, a model with more parameters is more complex and has a greater "capacity", which means it can complete more complex learning tasks.
  • Training a deep neural network is also a process of learning a weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (a weight matrix formed by vectors W of many layers).
  • Convolutional neural network (convolutional neuron network, CNN) is a deep neural network with convolutional structure.
  • the convolutional neural network contains a feature extractor composed of a convolution layer and a sub-sampling layer.
  • the feature extractor can be regarded as a filter.
  • the convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network.
  • a neuron can be connected to only part of the neighboring neurons.
  • a convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units in the same feature plane share weights, and the shared weights here are the convolution kernels.
  • Sharing weight can be understood as the way to extract image information has nothing to do with location.
  • the convolution kernel can be initialized in the form of a matrix of random size. During the training of the convolutional neural network, the convolution kernel can obtain reasonable weights through learning. In addition, the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
  • RNN Recurrent Neural Networks
  • RNN can process sequence data of any length.
  • the training of RNN is the same as the training of traditional CNN or DNN.
  • the neural network can use an error back propagation (BP) algorithm to modify the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, forwarding the input signal to the output will cause error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss is converged.
  • the backpropagation algorithm is a backpropagation motion dominated by error loss, and aims to obtain the optimal neural network model parameters, such as the weight matrix.
  • an embodiment of the present application provides a system architecture 100.
  • the data collection device 160 is used to collect training data.
  • the training data may include training images and classification results corresponding to the training images, where the results of the training images may be manually pre-labeled results.
  • the data collection device 160 stores the training data in the database 130, and the training device 120 trains to obtain the target model/rule 101 based on the training data maintained in the database 130.
  • the training device 120 processes the input original image and compares the output image with the original image until the output image of the training device 120 differs from the original image. The difference is less than a certain threshold, thereby completing the training of the target model/rule 101.
  • the above-mentioned target model/rule 101 can be used to implement the image processing method or the image processing method of the embodiment of the present application.
  • the target model/rule 101 in the embodiment of the present application may specifically be a neural network.
  • the training data maintained in the database 130 may not all come from the collection of the data collection device 160, and may also be received from other devices.
  • the training device 120 does not necessarily perform the training of the target model/rule 101 completely based on the training data maintained by the database 130. It may also obtain training data from the cloud or other places for model training.
  • the above description should not be used as a reference to this application Limitations of Examples.
  • the target model/rule 101 trained according to the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. 4, which can be a terminal, such as a mobile phone terminal, a tablet computer, notebook computers, augmented reality (AR) AR/virtual reality (VR), vehicle-mounted terminals, etc., can also be servers or clouds.
  • the execution device 110 is configured with an input/output (input/output, I/O) interface 112 for data interaction with external devices.
  • the user can input data to the I/O interface 112 through the client device 140.
  • the input data in this embodiment of the application may include: the image to be processed input by the client device.
  • the preprocessing module 113 and the preprocessing module 114 are used for preprocessing according to the input data (such as the image to be processed) received by the I/O interface 112.
  • the preprocessing module 113 and the preprocessing module may not be provided 114 (there may only be one preprocessing module), and the calculation module 111 is directly used to process the input data.
  • the execution device 110 may call data, codes, etc. in the data storage system 150 for corresponding processing .
  • the data, instructions, etc. obtained by corresponding processing may also be stored in the data storage system 150.
  • the I/O interface 112 returns the processing result, such as the denoising processed image obtained as described above, to the client device 140 to provide it to the user.
  • the training device 120 can generate corresponding target models/rules 101 based on different training data for different goals or tasks, and the corresponding target models/rules 101 can be used to achieve the above goals or complete The above tasks provide the user with the desired result.
  • the user can manually set input data, and the manual setting can be operated through the interface provided by the I/O interface 112.
  • the client device 140 can automatically send input data to the I/O interface 112. If the client device 140 is required to automatically send the input data and the user's authorization is required, the user can set the corresponding authority in the client device 140.
  • the user can view the result output by the execution device 110 on the client device 140, and the specific presentation form may be a specific manner such as display, sound, and action.
  • the client device 140 can also be used as a data collection terminal to collect the input data of the input I/O interface 112 and the output result of the output I/O interface 112 as new sample data, and store it in the database 130 as shown in the figure.
  • the I/O interface 112 directly uses the input data input to the I/O interface 112 and the output result of the output I/O interface 112 as a new sample as shown in the figure.
  • the data is stored in the database 130.
  • FIG. 4 is only a schematic diagram of a system architecture provided by an embodiment of the present application.
  • the positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation.
  • the data The storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
  • the target model/rule 101 is obtained by training according to the training device 120.
  • the target model/rule 101 may be the neural network in this application in the embodiment of this application, specifically, the neural network provided in the embodiment of this application Can be CNN, deep convolutional neural networks (deep convolutional neural networks, DCNN), recurrent neural networks (recurrent neural network, RNNS) and so on.
  • CNN is a very common neural network
  • the structure of CNN will be introduced in detail below in conjunction with Figure 5.
  • a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture.
  • a deep learning architecture refers to a machine learning algorithm. Multi-level learning is carried out on the abstract level of
  • CNN is a feed-forward artificial neural network. Each neuron in the feed-forward artificial neural network can respond to the input image.
  • a convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (where the pooling layer is optional), and a neural network layer 230.
  • the input layer 210 can obtain the image to be processed, and pass the obtained image to be processed to the convolutional layer/pooling layer 220 and the subsequent neural network layer 230 for processing, and the image processing result can be obtained.
  • the convolutional layer/pooling layer 220 may include layers 221-226, for example: in an implementation, layer 221 is a convolutional layer, layer 222 is a pooling layer, and layer 223 is a convolutional layer. Layers, 224 is the pooling layer, 225 is the convolutional layer, and 226 is the pooling layer; in another implementation, 221 and 222 are the convolutional layers, 223 is the pooling layer, and 224 and 225 are the convolutional layers. Layer, 226 is the pooling layer. That is, the output of the convolution layer can be used as the input of the subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
  • the convolution layer 221 can include many convolution operators.
  • the convolution operator is also called a kernel. Its function in image processing is equivalent to a filter that extracts specific information from the input image matrix.
  • the convolution operator is essentially It can be a weight matrix. This weight matrix is usually pre-defined. In the process of convolution on the image, the weight matrix is usually one pixel after one pixel (or two pixels after two pixels) along the horizontal direction on the input image. ...It depends on the value of stride) to complete the work of extracting specific features from the image.
  • the size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix and the depth dimension of the input image are the same.
  • the weight matrix will extend to Enter the entire depth of the image. Therefore, convolution with a single weight matrix will produce a single depth dimension convolution output, but in most cases, a single weight matrix is not used, but multiple weight matrices of the same size (row ⁇ column) are applied. That is, multiple homogeneous matrices.
  • the output of each weight matrix is stacked to form the depth dimension of the convolutional image, where the dimension can be understood as determined by the "multiple" mentioned above.
  • Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract edge information of the image, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to eliminate unwanted noise in the image.
  • the multiple weight matrices have the same size (row ⁇ column), the size of the convolution feature maps extracted by the multiple weight matrices of the same size are also the same, and then the multiple extracted convolution feature maps of the same size are combined to form The output of the convolution operation.
  • weight values in these weight matrices need to be obtained through a lot of training in practical applications.
  • Each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions. .
  • the initial convolutional layer (such as 221) often extracts more general features, which can also be called low-level features; with the convolutional neural network
  • the features extracted by the subsequent convolutional layers (for example, 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
  • the 221-226 layers as illustrated by 220 in Figure 5 can be a convolutional layer followed by a layer
  • the pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers.
  • the only purpose of the pooling layer is to reduce the size of the image space.
  • the pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling the input image to obtain a smaller size image.
  • the average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling.
  • the maximum pooling operator can take the pixel with the largest value within a specific range as the result of the maximum pooling.
  • the operators in the pooling layer should also be related to the image size.
  • the size of the image output after processing by the pooling layer can be smaller than the size of the image of the input pooling layer, and each pixel in the image output by the pooling layer represents the average value or the maximum value of the corresponding sub-region of the image input to the pooling layer.
  • the convolutional neural network 200 After processing by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as mentioned above, the convolutional layer/pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (required class information or other related information), the convolutional neural network 200 needs to use the neural network layer 230 to generate one or a group of required classes of output. Therefore, the neural network layer 230 may include multiple hidden layers (231, 232 to 23n as shown in FIG. 5) and an output layer 240. The parameters contained in the multiple hidden layers can be based on specific task types. The relevant training data of the, for example, the task type can include image recognition, image classification, image super-resolution reconstruction and so on.
  • the output layer 240 After the multiple hidden layers in the neural network layer 230, that is, the final layer of the entire convolutional neural network 200 is the output layer 240.
  • the output layer 240 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error.
  • a convolutional neural network (CNN) 200 may include an input layer 110, a convolutional layer/pooling layer 120 (the pooling layer is optional), and a neural network layer 130.
  • CNN convolutional neural network
  • FIG. 5 multiple convolutional layers/pooling layers in the convolutional layer/pooling layer 120 in FIG. 6 are parallel, and the respectively extracted features are input to the full neural network layer 130 for processing.
  • the convolutional neural network shown in FIGS. 5 and 6 is only used as an example of two possible convolutional neural networks in the image processing method of the embodiment of the application.
  • the application implements
  • the convolutional neural network used in the image processing method of the example can also exist in the form of other network models.
  • the structure of the convolutional neural network obtained by the search method of the neural network structure of the embodiment of the present application may be as shown in the convolutional neural network structure in FIG. 5 and FIG. 6.
  • FIG. 7 is a hardware structure of a chip provided by an embodiment of the application.
  • the chip includes a neural network processor 50.
  • the chip may be set in the execution device 110 as shown in FIG. 1 to complete the calculation work of the calculation module 111.
  • the chip can also be set in the training device 120 as shown in FIG. 1 to complete the training work of the training device 120 and output the target model/rule 101.
  • the algorithms of each layer in the convolutional neural network as shown in FIG. 2 can be implemented in the chip as shown in FIG. 7.
  • the NPU is mounted as a co-processor to a main central processing unit (central processing unit, CPU) (host CPU), and the main CPU distributes tasks.
  • the core part of the NPU is the arithmetic circuit 50.
  • the controller 504 controls the arithmetic circuit 503 to extract data from the memory (weight memory or input memory) and perform calculations.
  • the arithmetic circuit 503 includes multiple processing units (process engines, PE). In some implementations, the arithmetic circuit 503 is a two-dimensional systolic array. The arithmetic circuit 503 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 503 is a general-purpose matrix processor.
  • the arithmetic circuit fetches the corresponding data of matrix B from the weight memory 502 and buffers it on each PE in the arithmetic circuit.
  • the arithmetic circuit fetches matrix A data and matrix B from the input memory 501 to perform matrix operations, and the partial or final result of the obtained matrix is stored in an accumulator 508.
  • the vector calculation unit 507 can perform further processing on the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison and so on.
  • the vector calculation unit 507 can be used for network calculations in the non-convolutional/non-FC layer of the neural network, such as pooling, batch normalization, local response normalization, etc. .
  • the vector calculation unit 507 can store the processed output vector in the unified buffer 506.
  • the vector calculation unit 507 may apply a nonlinear function to the output of the arithmetic circuit 503, such as a vector of accumulated values, to generate the activation value.
  • the vector calculation unit 507 generates a normalized value, a combined value, or both.
  • the processed output vector can be used as an activation input to the arithmetic circuit 503, for example for use in subsequent layers in a neural network.
  • the unified memory 506 is used to store input data and output data.
  • the weight data directly transfers the input data in the external memory to the input memory 501 and/or the unified memory 506 through the storage unit access controller 505 (direct memory access controller, DMAC), and stores the weight data in the external memory into the weight memory 502, And the data in the unified memory 506 is stored in the external memory.
  • DMAC direct memory access controller
  • the bus interface unit (BIU) 510 is used to implement interaction between the main CPU, the DMAC, and the fetch memory 509 through the bus.
  • An instruction fetch buffer 509 connected to the controller 504 is used to store instructions used by the controller 504;
  • the controller 504 is configured to call the instructions cached in the memory 509 to control the working process of the computing accelerator.
  • the unified memory 506, the input memory 501, the weight memory 502, and the instruction fetch memory 509 are all on-chip (On-Chip) memories, and the external memory is a memory external to the NPU.
  • the external memory can be a double data rate synchronous dynamic random access memory. Memory (double data rate synchronous dynamic random access memory, referred to as DDR SDRAM), high bandwidth memory (HBM) or other readable and writable memory.
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • HBM high bandwidth memory
  • each layer in the convolutional neural network shown in FIG. 2 can be executed by the arithmetic circuit 303 or the vector calculation unit 307.
  • the execution device 110 in FIG. 4 introduced above can execute the image processing method or the steps of the image processing method of the embodiment of the present application.
  • the CNN model shown in FIG. 5 and FIG. 6 and the chip shown in FIG. 7 can also be used for Perform the image processing method or each step of the image processing method in the embodiment of the application.
  • the image processing method of the embodiment of the present application and the image processing method of the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
  • an embodiment of the present application provides a system architecture 300.
  • the system architecture includes a local device 301, a local device 302, an execution device 210 and a data storage system 250, where the local device 301 and the local device 302 are connected to the execution device 210 through a communication network.
  • the execution device 210 may be implemented by one or more servers.
  • the execution device 210 can be used in conjunction with other computing devices, such as data storage, routers, load balancers and other devices.
  • the execution device 210 may be arranged on one physical site or distributed on multiple physical sites.
  • the execution device 210 may use the data in the data storage system 250 or call the program code in the data storage system 250 to implement the method for searching the neural network structure of the embodiment of the present application.
  • the execution device 210 may perform the following process: determine a search space and multiple building units; stack the multiple building units to obtain a search network, which is a neural network used to search for a neural network structure;
  • the network structure of the building units in the search network is optimized in the search space to obtain optimized building units, wherein the search space gradually decreases during the optimization process, the number of building units gradually increases, and the search space decreases
  • the increase in the number of construction units makes the video memory consumption generated in the optimization process within a preset range
  • the target neural network is built according to the optimized construction unit.
  • a target neural network can be built, and the target neural network can be used for image classification or image processing.
  • Each local device can represent any computing device, such as personal computers, computer workstations, smart phones, tablets, smart cameras, smart cars or other types of cellular phones, media consumption devices, wearable devices, set-top boxes, game consoles, etc.
  • Each user's local device can interact with the execution device 210 through a communication network of any communication mechanism/communication standard.
  • the communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof.
  • the local device 301 and the local device 302 obtain the relevant parameters of the target neural network from the execution device 210, deploy the target neural network on the local device 301 and the local device 302, and use the target neural network for image classification Or image processing and so on.
  • the target neural network can be directly deployed on the execution device 210.
  • the execution device 210 obtains the image to be processed from the local device 301 and the local device 302, and classifies the image to be processed according to the target neural network or other types of images. deal with.
  • the above-mentioned execution device 210 may also be referred to as a cloud device. At this time, the execution device 210 is generally deployed in the cloud.
  • the method for constructing a neural network in an embodiment of the present application will be described in detail below with reference to FIG. 9.
  • the method shown in FIG. 9 can be executed by a neural network construction device, which can be a computer, a server, or the like with sufficient computing power to be used for the neural network construction device.
  • the method shown in FIG. 9 includes steps 1001 to 1004, which are described in detail below.
  • the aforementioned search space is determined according to the application requirements of the target neural network to be constructed. Specifically, the aforementioned search space may be determined according to the type of processed data of the target neural network.
  • the type and number of operations contained in the above-mentioned search space should be adapted to the processing of image data; when the above-mentioned target neural network is used to process voice data, the search The type and number of operations contained in the space should be adapted to the processing of voice data.
  • the foregoing multiple construction units are determined according to the search space and the size of the video memory resources of the device that constructs the target neural network.
  • the building unit in this application is a network structure obtained by connecting multiple nodes through the basic operation of a neural network, and the building unit is a basic module for building a neural network.
  • the 3 nodes (node 0, node 1 and node 2) located in the dashed box constitute a building unit that can receive the output of nodes c_ ⁇ k-2 ⁇ and c_ ⁇ k-1 ⁇
  • the data (c_ ⁇ k-2 ⁇ and c_ ⁇ k-1 ⁇ can also be feature maps that meet the requirements.
  • c_ ⁇ k-2 ⁇ and c_ ⁇ k-1 ⁇ can be input images that have undergone certain convolution processing The feature map obtained later), and the input data will be processed by nodes 0 and 1.
  • the data output by node 0 will also be input to node 1 for processing, and the data output by node 0 and node 1 will be sent to Processing is performed in node 2, and node 2 finally outputs the data processed by the construction unit.
  • nodes c_ ⁇ k-2 ⁇ and c_ ⁇ k-1 ⁇ can be regarded as input nodes. These two nodes will input the data to be processed into the construction unit. In the construction unit, 0 and 1 are intermediate nodes. Node 2 is the output node.
  • the thick arrow in Figure 10 represents one or more basic operations. The calculation results of the basic operations that are imported into the same intermediate node are added at the intermediate node.
  • the thin arrow in Figure 10 represents the feature map connection of the channel dimension, and the output node 2
  • the output feature map is formed by connecting the outputs of two intermediate nodes (node 0 and node 1) in the channel dimension of the feature map in order.
  • the aforementioned search space may include basic operations or a combination of basic operations in a preset convolutional neural network, and these basic operations or combinations of basic operations may be collectively referred to as basic operations.
  • the above search space can contain the following 8 basic operations:
  • Zero setting operation (Zero, all neurons in the corresponding position are set to zero).
  • the above-mentioned search network is a neural network for searching the structure of a neural network.
  • the foregoing stacking of multiple building units to obtain a search network includes: stacking the multiple building units in sequence in a preset stacking manner to obtain a search network, wherein, in the search network, the search network is located The output of the building unit in front of the network is the input of the building unit located in the back of the search network.
  • the foregoing preset stacking manner may include what type of building units are stacked at which position, the number of stacks, and so on.
  • the optimization process of optimizing the network structure of the building unit in the search network can include N stages, the i-th stage and the j-th stage are any two stages of the N stages, and the search space is in the i-th stage
  • the size of is greater than the size of the search network in the j-th stage, the number of building units included in the search network in the i-th stage is less than the number of building units in the search space in the j-th stage, the search space of the search network is reduced
  • the increase in the number of building units of the small and search network makes the memory consumption of the optimization process within the preset range.
  • the difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is within a preset range.
  • the number of building units included in the above target neural network is Determined according to the application requirements of the target neural network, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j.
  • the above-mentioned video memory resource may be replaced with a cache resource.
  • the cache resource is a memory or storage unit used to store the number of calculations during the optimization process of the device used to construct the neural network.
  • the foregoing cache resources may specifically include video memory resources.
  • the number of building units included in the target neural network is determined according to the type of data to be processed by the target neural network and/or the complexity of calculation.
  • the target neural network when the above target neural network is used to process some simple text data, the target neural network only needs to contain a smaller number of building units. When the above target neural network is used to process some more complex image data, the target neural network needs Contains a large number of building units.
  • the target neural network needs to contain a larger number of building units; when the target neural network needs to process data with low complexity, the target neural network needs a smaller number
  • the building unit can be.
  • the above-mentioned size of N is preset.
  • the size of the above N can be determined according to the construction requirements of the target neural network. Specifically, when the target neural network needs to be constructed in a relatively short time, N can be set to a small value, and when the target neural network can be constructed in a relatively long time, N can be set to a Larger value.
  • the video memory resources saved by reducing the search space can be used to increase the number of building units, so that the building can be stacked as much as possible under the condition of limited video memory resources.
  • a search network whose number of units is close to that of the target neural network to be built.
  • the optimized building unit of the search network can be better adapted to the construction of the target neural network, and the target neural network built according to the optimized building unit can better meet the application requirements.
  • the application gradually reduces the size of the search space and increases the number of construction units of the search network, so as to construct a goal that can better meet the needs of the application.
  • the dependence of the video memory resources in the optimization process is reduced, so that the target neural network that satisfies the application needs can be obtained by relying on less video memory resources in the optimization process, and it also improves the memory resources to a certain extent. Utilization rate.
  • the optimized construction unit in the search network is more suitable for building the target neural network.
  • the depth of the neural network is positively correlated with the number of building units contained. Therefore, when the number of building units of the search network is close to the number of building units of the target neural network, the network depth of the search network is the same as that of the target neural network. Also relatively close.
  • the search space becomes smaller and the number of building units of the search network increases, and from the i-th stage to the j-th stage, the search space
  • the magnitude of the decrease may be the same as the magnitude of the increase in the number of building units.
  • the extent of the reduction of the search space from the i-th stage to the j-th stage can be determined according to the increase in the number of building units of the search network from the i-th stage to the j-th stage, or from the i-th stage to the j-th stage
  • the number of increase in the number of construction units of the search network in each stage can be determined according to the decrease in the search space from the i-th stage to the j-th stage.
  • the size of the video memory resources can also be combined to determine the extent of the reduction in the search space from the i-th stage to the j-th stage and the increase in the number of construction units of the search network from the i-th stage to the j-th stage.
  • the size of the search space for the i-th stage S i, S j of the above-described search space size in the j-th stage, the number of the search network construction unit included in the i-th stage is L i
  • the number of construction units included in the jth stage of the search network is L j , where the size of L j -L i is determined according to the size of S i -S j , or the size of S i -S j is Determined according to the size of L j -L i .
  • the size of S i -S j can be preset, and then the size of L j -L i can be determined according to the size of S i -S j , so that the video memory saved due to the reduced search space
  • the increase in resources and building units causes the difference between the more consumed video memory resources to be within a certain threshold (the smaller the difference, the better).
  • the size of L j -L i can also be preset, and then the size of S i -S j is determined according to the size of L j -L i , so that the increase in the building unit causes more memory resources to be consumed
  • the difference between the memory resources saved by reducing the search space and the search space is within a certain threshold (the smaller the difference, the better).
  • the second stage is compared with the first stage and the fourth stage is satisfied with the third stage: the search space is reduced, and the number of construction units of the search network is increased.
  • the search space and the number of building units contained in the search network in the second and third phases have not changed.
  • the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
  • the number of construction units increased in the i+1th stage relative to the i-th stage may be based on the aforementioned value N, the number of construction units included in the search network before optimization, and the construction of the target neural network The number of units is determined.
  • the number of building units increased by the search network in the i+1 stage relative to the i-th stage is X
  • the number of building units contained in the search network before the optimization starts is U
  • the number of building units in the target neural network is V
  • the extent of the reduction in the size of the search space and the extent of the increase in the number of search network construction units can be determined in various ways, as long as the reduction in the search space of the search network during the optimization process and the search
  • the increase in the number of building units of the network makes the memory consumption generated in the optimization process within a preset range.
  • the size of the search space can be reduced in advance, and then the amount of increase in the number of search network construction units can be determined; or the size of the search network can be preset, and then the size of the search space can be reduced.
  • This application does not limit this, and all implementations to ensure that the video memory consumption is within the preset range are within the protection scope of this application.
  • the number of the first-type operations included in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first-type operations are operations that do not include the neural network trainable parameters.
  • This application limits the number of operations of the first type to a certain range, so that the trainable parameters of the final target neural network are maintained at a relatively stable level, and the performance of the target neural network remains stable.
  • the number of operations of the first type can also be specifically limited to a certain value, so that the final target neural network includes a fixed number of operations of the first type, so that the performance of the target neural network is more stable.
  • the first type of operation mentioned above is an operation that does not contain trainable parameters. If there are too many such operations, it will result in fewer other operations containing trainable parameters, so that the overall neural network has fewer trainable parameters, and the characteristics of the neural network Decreased expression ability.
  • the number of first-type operations in the construction units obtained by each search will have a certain difference.
  • the neural network structure obtained by the search ie, the construction unit
  • Limiting the number of operations of the first type can keep the trainable parameters of the test network constructed from the neural network structure obtained by the search at a relatively stable level, thereby reducing performance fluctuations on the corresponding tasks.
  • the number of operations of the first type included in the connection relationship between the nodes of the optimized construction unit may be limited during the optimization process.
  • the number of operations of the first type is directly limited to the first number
  • the first type of operations are not changed during the optimization process
  • the number of operations of the first type in the construction unit is greater than the first number, then part of the first operations can be deleted in the optimization process so that the number of operations of the first type after the deletion is equal to the first number; if the construction The number of operations of the first type in the unit is less than the number of operations of the first type, then the number of construction units can be increased in the optimization process, so that the number of construction units after optimization is the first number.
  • the above-mentioned process of limiting the number of operations of the first type to a fixed number can be referred to as a standardized process for the number of operations of the first type.
  • the normative process for the number of operations of the first type may be based on pre-made normative rules, retaining Mc operations of the first type in a type of building unit.
  • the input construction unit structure is output directly; otherwise, the following process is executed:
  • the corresponding network structure parameters corresponding to a type of operation are sorted in descending order.
  • the first type of operation that is not in the building unit with the largest weight and conforms to the network structure generation rule is added according to the network structure generation rule Construct the unit structure, and delete the corresponding basic operations that are replaced according to the network structure generation rules and network structure parameters; if the number of the first type of operation is greater than Mc, remove the first type of operation with the smallest weight from the construction unit structure , And add corresponding other basic operations according to the network structure generation rules and network structure parameters; repeat this process until the number of the first type of operations in the construction unit is equal to Mc.
  • the first type of operation described above may specifically be a skip-connect operation or a zero-setting operation.
  • the above search network can contain multiple types of building units. The following briefly introduces the common building units included in the search network.
  • the building units in the search network include the first type of building units.
  • the first type of construction unit is a construction unit in which the number of input feature maps (specifically, the number of channels) and the size are the same as the number and size of output feature maps.
  • the input of a certain first type of construction unit is a feature map of size C ⁇ D1 ⁇ D2 (C is the number of channels, D1 and D2 are width and height respectively), and the output is processed by the first type of construction unit
  • the size of the feature map is still C ⁇ D1 ⁇ D2.
  • the above-mentioned first type of building unit may specifically be a normal cell (normal cell)
  • the building unit in the search network includes the second type of building unit.
  • the resolution of the output feature map of the second type of construction unit is 1/M of the input feature map
  • the number of output feature maps of the second type of construction unit is M times the number of input feature maps
  • M is a positive value greater than 1. Integer.
  • the value of M can generally be 2, 4, 6, and 8.
  • the input of a certain second type of construction unit is 1 size C ⁇ D1 ⁇ D2 (C is the number of channels, D1 and D2 are width and height respectively, and the product of C1 and C2 can represent the resolution of the feature map) Feature map, then, after the second type of building unit is processed, the size of 1 obtained is Characteristic map.
  • the above-mentioned second type of construction unit may specifically be a down-sampling unit (redution cell).
  • the structure of the search network may be as shown in FIG. 11.
  • the search network is formed by stacking 5 building units in turn.
  • the first type of building unit is located at the front and the last of the search network, and there is a second type of building unit between every two first building units.
  • the first building unit in the search network in Figure 11 can process the input image. After the first type of building unit processes the image, the processed feature map is input to the second type of building unit for processing, and so on. Transfer backwards until the last first-type construction unit in the search network outputs the feature map.
  • the feature map output by the last first-type construction unit of the search network is sent to the classifier for processing, and the classifier classifies the image according to the feature map.
  • the type of neural network to be constructed can be determined according to the task requirements of the neural network to be constructed (that is, the task type of the task to be processed by the neural network to be constructed).
  • the size of the search space and the number of construction units are determined, and the construction units are stacked to obtain the search network.
  • the network structure of the building unit in the search network can be optimized (training data can be used for optimization during the optimization process).
  • the optimization of the network structure of the building unit can be divided into progressive network structure search and operation Quantity specification process (that is, limit the quantity of a certain operation within a certain range, in this application, it is mainly to limit the quantity of the first type of operation within a certain range).
  • the progressive network structure search is to gradually reduce the size of the search space during the optimization process, and gradually increase the number of construction units to obtain a search network that is close to the number of construction units of the neural network to be constructed (see above for the specific process Related description in the method shown in Figure 9).
  • the operation quantity specification process can be used to ensure that the quantity of the first type operation connections in the optimized construction unit is within a certain preset range.
  • This progressive network structure search and operation quantity specification process is equivalent to the optimization process of step 1003 in the method shown in FIG. 9.
  • FIG. 13 shows the process of the neural network construction system executing the neural network structure search method of the embodiment of the application. The content shown in Figure 13 will be described in detail below.
  • the neural network construction system shown in FIG. 13 mainly includes an operation warehouse 101, a progressive network structure search module 102, and an operation quantity specification module 103.
  • the operation warehouse 101 may include a preset basic operation in the convolutional neural network.
  • the progressive network structure search module 102 is used to optimize the network structure of the construction unit of the search network.
  • the search network 1022 itself is continuously updated by increasing the stacking number of the construction unit 1021 and reducing the size of the search space. So as to realize the continuous optimization of the network structure of the building unit of the search network.
  • the operation quantity specification module 103 mainly restricts the quantity of a certain operation within a certain range.
  • the operation quantity specification module 103 mainly restricts the quantity of the first type of operation within a certain range.
  • the size of the operating warehouse 101 (equivalent to the search space above) and the initial number of construction units 103 can be determined according to the target task, and then the search network can be obtained by stacking the initial number of construction units 103 according to the initial number of construction units 103.
  • the progressive structure search module 102 can be used to optimize the search network. In the optimization process, the size of the search space is gradually reduced, the number of stacking units is increased, and the building unit is obtained.
  • the operation quantity specification module 103 restricts the first type of operations in the building units obtained by the progressive network structure search module 102 to a certain range, so as to obtain optimized building units. These optimized building units can be used for Build the final target neural network.
  • step 1003 the processes processed by the progressive network structure search module 102 and the operation quantity specification module 103 are equivalent to the optimization process in step 1003 in the method shown in FIG. 9.
  • the specific optimization process refer to the related description of step 1003.
  • FIG. 14 The specific process of the optimization operation performed by the progressive network structure search module 102 may be as shown in FIG. 14.
  • Figure 14 simplifies the actual operation to a certain extent, only showing the search process of the first type of building unit (specifically, normal cell), and the specific schematic diagram of the first type of building unit is also simplified. Show the search process, not the specific structure.
  • Each arrow line in the figure represents a basic operation, and the number of types of operations is simplified in the schematic diagram; the number boxes represent nodes, and the nodes in this example are the feature maps of the convolutional neural network.
  • connection between nodes is composed of all possible basic operations in the pre-defined search space.
  • Figure 14 uses five basic operations, which are represented by five arrowed lines.
  • the learned network structure parameters are obtained.
  • the weights of the corresponding basic operations between node 0 and node 1 of the first type of construction unit are 0.21, 0.26, 0.18, 0.03, and 0.32, respectively (the weights are shown in FIG. 14).
  • the preset basic operation deletion quantity one or more operations with the smallest weight can be deleted.
  • the arrow line with the smallest weight (as shown in the initial stage in Figure 14, the arrow line with the smallest weight is the fourth arrow line between node 0 and node 1) represents that the basic operation is deleted, and the remaining operations are in this
  • the structure of the building unit output from the stage is retained. Note that different nodes can operate according to the corresponding network structure weights, and the basic operations retained are not necessarily the same.
  • additional rules are applied to generate the network structure in addition to the same construction unit generation rules as other stages, so that the generated construction unit structure has structural characteristics that match the corresponding tasks.
  • the rule is that each node retains at most two basic input operations, that is, according to this rule and the corresponding network structure parameters, all basic operations between node 1 and node 3 are not retained.
  • the finally generated first type of construction unit is shown in the bold arrowed line and corresponding nodes in the final stage in FIG. 14.
  • the generated building unit structure and corresponding network structure parameters and their corresponding operation types are output to subsequent modules or processes together.
  • the operation quantity specification process module 103 shown in FIG. 13 is used to constrain the quantity of the first type of operation within a fixed range (specifically, the quantity of the first type of operation may be directly constrained to a certain value). The following is combined with FIG. 15 The specific process executed by the operation quantity specification flow module 103 is described.
  • FIG. 15 is a schematic diagram of the processing procedure of the operation quantity specification module of the embodiment of the present application.
  • the input is the construction unit structure output by the progressive network structure search module and the corresponding network structure parameters and their corresponding operation types
  • the output is the construction unit structure after the number of operations is standardized. It should be understood that the number of operations of the first type in the construction unit structure output after processing by the operation number specification module 103 is limited to a fixed number.
  • the specific execution process of the foregoing operation quantity specification module 103 includes:
  • Mc ⁇ M the first type of operation operation that does not belong to the construction unit structure and conforms to the network structure generation rule with the largest weight is replaced by the corresponding other types of basic operations.
  • step S3 After the building unit is generated in step S2, the building unit is sent to step S1 to continue the judgment.
  • the first type of operation may specifically be a jump connection operation.
  • Table 1 shows the neural network constructed using the neural network construction method of the embodiment of the application under similar constraints and the neural network designed or searched using other methods.
  • Table 1 also gives the search time of the contrast neural network structure.
  • CIFR10, CIFR100, ImageNetTop1, ImageNetTop5 in Table 1 respectively represent classification accuracy rates.
  • CIFAR10, CIFAR100, and ImageNet are different data sets
  • Top1 and Top5 are sub-indicators, which refer to the first 1 or 5 results.
  • NASNet-A, AmoebaNet-B, ENAS, PNAS, and DARTS (2ND) respectively represent different network structures, and the size of the search overhead can be expressed by the time required for a single GPU to run (here, the time is generally expressed in days).
  • the classification accuracy of the neural network constructed using the neural network construction method of the embodiment of the application is higher than the classification accuracy of the neural network designed or searched by other methods on the image classification data set.
  • the search cost is smaller, which can save more resources in the search process.
  • Table 2 shows the comparison of the performance of the neural network structure on the public data set before using the operation quantity specification process and after using the operation quantity specification process.
  • Run 1 represents the accuracy of the first test
  • Run 2 represents the first test.
  • Run 3 represents the accuracy of the third test.
  • the average accuracy rate in Table 2 represents the average accuracy rate from the first test to the third test
  • the standard deviation in Table 2 is the standard deviation of the accuracy rate from the first test to the third test. It can be seen from Table 2 that the performance and stability of the neural network obtained after using the standardized process of the number of operations are significantly improved compared to before use.
  • the neural network construction method of the embodiment of the application is described in detail above in conjunction with the accompanying drawings.
  • the neural network constructed by the construction method of the neural network of the embodiment of the application can be used for image processing (for example, image classification), etc. Introduce these specific applications.
  • FIG. 16 is a schematic flowchart of an image processing method according to an embodiment of the present application. The method shown in Figure 16 includes:
  • the above-mentioned target neural network may be constructed according to the method shown in FIG. 9.
  • the optimized construction unit of the search network can be better adapted to the construction of the target neural network, and a better performance target neural network can be obtained.
  • Using the target neural network for image classification can achieve better image classification results (for example, The classification result is more accurate).
  • the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
  • the above-mentioned target neural network is a neural network obtained by training through training pictures.
  • the target neural network can be trained by training pictures and the category information marked by the training pictures, and the trained neural network can be used for image classification.
  • FIG. 17 is a schematic diagram of the hardware structure of a neural network construction device provided by an embodiment of the present application.
  • the neural network construction device 3000 shown in FIG. 17 includes a memory 3001, a processor 3002, a communication interface 3003, and a bus 3004.
  • the memory 3001, the processor 3002, and the communication interface 3003 implement communication connections between each other through the bus 3004.
  • the memory 3001 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
  • the memory 3001 may store a program. When the program stored in the memory 3001 is executed by the processor 3002, the processor 3002 is configured to execute each step of the neural network construction method of the embodiment of the present application.
  • the processor 3002 may adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more
  • the integrated circuit is used to execute related programs to implement the neural network construction method of the method embodiment of the present application.
  • the processor 3002 may also be an integrated circuit chip with signal processing capabilities.
  • each step of the neural network construction method of the present application can be completed by hardware integrated logic circuits in the processor 3002 or instructions in the form of software.
  • the above-mentioned processor 3002 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, Discrete gates or transistor logic devices, discrete hardware components.
  • DSP digital signal processing
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory 3001, and the processor 3002 reads the information in the memory 3001, combines its hardware to complete the functions required by the units included in the neural network construction device, or executes the neural network construction method of the method embodiment of the application .
  • the communication interface 3003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 3000 and other devices or communication networks. For example, the information of the neural network to be constructed and the training data needed in the process of constructing the neural network can be obtained through the communication interface 3003.
  • a transceiver device such as but not limited to a transceiver to implement communication between the device 3000 and other devices or communication networks. For example, the information of the neural network to be constructed and the training data needed in the process of constructing the neural network can be obtained through the communication interface 3003.
  • the bus 3004 may include a path for transferring information between various components of the device 3000 (for example, the memory 3001, the processor 3002, and the communication interface 3003).
  • FIG. 18 is a schematic diagram of the hardware structure of an image processing apparatus according to an embodiment of the present application.
  • the image processing apparatus 4000 shown in FIG. 18 includes a memory 4001, a processor 4002, a communication interface 4003, and a bus 4004. Among them, the memory 4001, the processor 4002, and the communication interface 4003 implement communication connections between each other through the bus 4004.
  • the memory 4001 may be ROM, static storage device and RAM.
  • the memory 4001 may store a program. When the program stored in the memory 4001 is executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute each step of the image processing method of the embodiment of the present application.
  • the processor 4002 may adopt a general-purpose CPU, a microprocessor, an ASIC, a GPU, or one or more integrated circuits to execute related programs to realize the functions required by the units in the image processing apparatus of the embodiment of the present application. Or execute the image processing method in the method embodiment of this application.
  • the processor 4002 may also be an integrated circuit chip with signal processing capability.
  • each step of the image processing method of the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 4002 or instructions in the form of software.
  • the aforementioned processor 4002 may also be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component.
  • the methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and combines its hardware to complete the functions required by the units included in the image processing apparatus of the embodiment of the application, or perform the image processing of the method embodiment of the application. method.
  • the communication interface 4003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network.
  • a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network.
  • the image to be processed can be acquired through the communication interface 4003.
  • the bus 4004 may include a path for transferring information between various components of the device 4000 (for example, the memory 4001, the processor 4002, and the communication interface 4003).
  • FIG. 19 is a schematic diagram of the hardware structure of the neural network training device according to an embodiment of the present application. Similar to the aforementioned device 3000 and device 4000, the neural network training device 5000 shown in FIG. 19 includes a memory 5001, a processor 5002, a communication interface 5003, and a bus 5004. The memory 5001, the processor 5002, and the communication interface 5003 implement communication connections between each other through the bus 5004.
  • the neural network After the neural network is constructed by the neural network construction device shown in FIG. 17, the neural network can be trained by the neural network training device 5000 shown in FIG. 19, and the trained neural network can be used to implement the implementation of this application. Example image processing method.
  • the device shown in FIG. 19 can obtain training data and the neural network to be trained from the outside through the communication interface 5003, and then the processor trains the neural network to be trained according to the training data.
  • the device 3000, device 4000, and device 5000 only show a memory, a processor, and a communication interface, in a specific implementation process, those skilled in the art should understand that the device 3000, device 4000, and device 5000 may also Including other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 3000, the device 4000, and the device 5000 may also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that the device 3000, the device 4000, and the device 5000 may also only include the components necessary to implement the embodiments of the present application, and not necessarily include all the components shown in FIGS. 17, 18, and 19.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Molecular Biology (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

The present application discloses a neural network construction method, an image processing method and devices in the field of computer vision in the field of artificial intelligence. The neural network construction method comprises: determining a search space and a plurality of construction units; stacking the plurality of construction units to obtain a search network, wherein the search network is a neural network for neural architecture search; optimizing, in the search space, the architecture of the construction units within the search network, so as to obtain optimized construction units, wherein in an optimization process, the search space is gradually reduced, the number of construction units is gradually increased, and the reduction of the search space and the increase of the number of construction units enable a graphics memory consumed in the optimization process to be within a preset range; and constructing the target neural network according to the optimized construction units. The present application is able to construct a neural network which better satisfies application requirements in the case where graphics memory resources are ensured.

Description

神经网络的构建方法、图像处理方法及装置Neural network construction method, image processing method and device
本申请要求于2019年04月28日提交中国专利局、申请号为201910351894.1、申请名称为“神经网络的构建方法、图像处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on April 28, 2019, the application number is 201910351894.1, and the application name is "Neural Network Construction Method, Image Processing Method and Device", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及人工智能领域,并且更具体地,涉及一种神经网络的构建方法、图像处理方法及装置。This application relates to the field of artificial intelligence, and more specifically, to a neural network construction method, image processing method and device.
背景技术Background technique
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用***。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式作出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。人工智能领域的研究包括机器人,自然语言处理,计算机视觉,决策与推理,人机交互,推荐与搜索,AI基础理论等。Artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making. Research in the field of artificial intelligence includes robotics, natural language processing, computer vision, decision-making and reasoning, human-computer interaction, recommendation and search, and basic AI theories.
随着人工智能技术的快速发展,神经网络(例如,深度神经网络)近年来在图像、视频以及语音等多种媒体信号的处理与分析中取得了很大的成就。一个性能优良的神经网络往往拥有精妙的网络结构,而这需要具有高超技能和丰富经验的人类专家花费大量精力进行构建。为了更好地构建神经网络,人们提出了通过神经网络结构搜索(neural architecture search,NAS)的方法来搭建神经网络,通过自动化地搜索神经网络结构,从而得到性能优异的神经网络结构。With the rapid development of artificial intelligence technology, neural networks (for example, deep neural networks) have made great achievements in the processing and analysis of various media signals such as images, videos, and voices in recent years. A neural network with good performance often has a sophisticated network structure, which requires human experts with superb skills and rich experience to spend a lot of energy to construct. In order to better construct a neural network, people propose a neural network structure search (neural architecture search, NAS) method to build a neural network, and automatically search the neural network structure to obtain a neural network structure with excellent performance.
传统方案常采用可微分的神经网络结构搜索方法来搭建神经网络,该搜索方法一般是根据一定数量的构建单元搭建成一个搜索网络,然后在搜索空间内对搜索网络中构建单元的各个节点之间的连接关系进行优化,以得到优化的构建单元,最后再根据优化的构建单元搭建目标神经网络。该搜索方法在优化过程中,会将所有可能的操作都放到搜索空间中,这就导致优化过程中需要巨大的显存空间,从而只能堆叠成较浅的搜索网络。而最终要构建的目标神经网络往往层次较深,这就导致搜索网络与目标神经网络之间存在较大的深度差异,并且由于较浅的搜索网络优化得到的构建单元不是完全适用于较深的目标神经网络,从而使得最终搭建的目标神经网络可能无法很好地满足应用需求。Traditional solutions often use a differentiable neural network structure search method to build a neural network. The search method is generally based on a certain number of building units to build a search network, and then search for each node in the search network in the search space. The connection relationship of is optimized to obtain the optimized building unit, and finally the target neural network is built according to the optimized building unit. In the optimization process, the search method puts all possible operations into the search space, which leads to a huge video memory space required during the optimization process, which can only be stacked into a shallow search network. The final target neural network to be built is often deeper, which leads to a large difference in depth between the search network and the target neural network, and the construction unit obtained due to the shallower search network optimization is not completely suitable for the deeper ones. The target neural network, so that the final target neural network may not meet the application requirements well.
发明内容Summary of the invention
本申请提供一种神经网络的构建方法、图像处理方法、装置、计算机可读存储介质和芯片,以更好地构建满足需求的神经网络。This application provides a neural network construction method, image processing method, device, computer readable storage medium, and chip to better construct a neural network that meets the needs.
第一方面,提供了一种神经网络的构建方法,该方法包括:确定搜索空间和多个构建单元;堆叠多个构建单元,以得到搜索网络,该搜索网络是用于搜索神经网络结构的神经网络;在搜索空间内对搜索网络中的构建单元的网络结构进行优化,以得到优化后的构建单元;根据优化后的构建单元搭建目标神经网络。In the first aspect, a method for constructing a neural network is provided. The method includes: determining a search space and a plurality of building units; stacking the plurality of building units to obtain a search network, which is a neural network for searching the structure of a neural network Network; optimize the network structure of the building unit in the search network in the search space to obtain the optimized building unit; build the target neural network according to the optimized building unit.
其中,上述搜索空间是根据待构建的目标神经网络的应用需求确定的,上述多个构建单元是根据搜索空间以及构建目标神经网络的设备的显存资源的大小确定的,另外,构建单元是由多个节点之间通过神经网络的基本操作连接得到的一种网络结构,构建单元是用于构建神经网络的基础模块。Among them, the above search space is determined according to the application requirements of the target neural network to be constructed, and the above multiple construction units are determined according to the search space and the size of the video memory resources of the equipment that constructs the target neural network. In addition, the construction units are determined by multiple A network structure obtained by the basic operation of the neural network between nodes. The building unit is the basic module for building the neural network.
其中,对搜索网络中的构建单元的网络结构进行优化的优化过程包括N个阶段,第i个阶段和第j个阶段为N个阶段中的任意两个阶段,搜索空间在第i个阶段的大小大于搜索网络在第j个阶段的大小,搜索网络在第i个阶段时包含的构建单元的数量小于搜索空间在第j个阶段时包含的构建单元的数量,搜索网络的搜索空间的减小和搜索网络的构建单元数量的增加使得优化过程中产生的显存消耗在预设范围内,搜索网络在第N个阶段包含的构建单元的数量与目标神经网络包含的构建单元的数量的差异在预设范围内,上述目标神经网络包含的构建单元的数量是根据目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j。Among them, the optimization process for optimizing the network structure of the building unit in the search network includes N stages. The i-th and j-th stages are any two of the N stages. The search space is in the i-th stage. The size is larger than the size of the search network in the j-th stage, and the number of building units included in the search network in the i-th stage is smaller than the number of building units in the search space in the j-th stage, and the search space of the search network is reduced And the increase in the number of building units of the search network makes the video memory consumption in the optimization process within the preset range. The difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is expected Within the range, the number of building units included in the target neural network is determined according to the application requirements of the target neural network, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j .
上述搜索空间是根据待构建的目标神经网络的应用需求确定的,具体包括:上述搜索空间是根据目标神经网络的处理数据的类型确定的。The aforementioned search space is determined according to the application requirements of the target neural network to be constructed, and specifically includes: the aforementioned search space is determined according to the type of processing data of the target neural network.
具体地,当上述目标神经网络用于处理图像数据的神经网络时,上述搜索空间包含的操作的种类和数量要与图像数据的处理相适应。Specifically, when the above-mentioned target neural network is used for a neural network for processing image data, the type and number of operations included in the above-mentioned search space should be adapted to the processing of image data.
例如,当目标神经网络是用于处理图像数据的神经网络时,上述搜索空间可以包含卷积操作,池化操作,跳连接(skip-connect)操作等等。For example, when the target neural network is a neural network for processing image data, the aforementioned search space may include convolution operations, pooling operations, skip-connect operations, and so on.
当上述目标神经网络用于处理语音数据时,上述搜索空间包含的操作的种类和数量要与语音数据的处理相适应。When the above-mentioned target neural network is used to process voice data, the type and number of operations contained in the above-mentioned search space should be adapted to the processing of voice data.
例如,当目标神经网络是用于处理语音数据的神经网络时,上述搜索空间可以包含激活函数(如ReLU、Tanh)等等。For example, when the target neural network is a neural network for processing voice data, the above search space may include activation functions (such as ReLU, Tanh) and so on.
具体地,上述目标神经网络包含的构建单元的数量是根据目标神经网络的应用需求确定的,包括:上述目标神经网络包含的构建单元的数量是根据目标神经网络要处理的数据类型和/或计算的复杂度确定的。Specifically, the number of building units included in the target neural network is determined according to the application requirements of the target neural network, including: the number of building units included in the target neural network is based on the type of data and/or calculations to be processed by the target neural network The complexity is determined.
例如,当上述目标神经网络用于处理一些简单的文本数据时,目标神经网络包含较少数量的构建单元即可,当上述目标神经网络用于处理一些比较复杂的图像数据时,目标神经网络需要包含数量较多的构建单元。For example, when the above target neural network is used to process some simple text data, the target neural network only needs to contain a smaller number of building units. When the above target neural network is used to process some more complex image data, the target neural network needs Contains a large number of building units.
再如,当目标神经网络需要处理的数据复杂度较高时,目标神经网络需要包含数量较多的构建单元;当目标神经网络需要处理的数据复杂度较低时,目标神经网络需要较少数量的构建单元即可。For another example, when the target neural network needs to process data with high complexity, the target neural network needs to contain a larger number of building units; when the target neural network needs to process data with low complexity, the target neural network needs a smaller number The building unit can be.
可选地,上述显存资源可以替换为缓存资源,该缓存资源是用于构建神经网络的设备在优化过程中用于存放运算数据的内存或者存储单元。Optionally, the above-mentioned video memory resource may be replaced with a cache resource, which is a memory or storage unit used for storing operation data during the optimization process of the device used to construct the neural network.
上述缓存资源具体可以包括显存资源。The foregoing cache resources may specifically include video memory resources.
可选地,上述堆叠多个构建单元,以得到搜索网络,包括:按照预设的堆叠方式将所 述多个构建单元依次堆叠起来,以得到搜索网络,其中,在该搜索网络中,位于搜索网络前面的构建单元的输出是位于搜索网络的后面的构建单元的输入。Optionally, the foregoing stacking of multiple building units to obtain a search network includes: stacking the multiple building units in sequence in a preset stacking manner to obtain a search network, wherein, in the search network, the search network is located The output of the building unit in front of the network is the input of the building unit located in the back of the search network.
上述预设的堆叠方式可以包括在什么位置堆放什么类型的构建单元以及堆叠的数量等等。The foregoing preset stacking manner may include what type of building units are stacked at which position, the number of stacks, and so on.
本申请中,在对构建单元的网络结构进行优化的过程中,减少搜索空间节省的显存资源可以用来增加构建单元的数量,从而能够在显存资源有限的情况下,尽可能的堆叠得到构建单元数量与最终要搭建的目标神经网络的构建单元数量比较接近的搜索网络。使得优化后的构建单元能够更好地适用于目标神经网络的搭建,进而使得根据优化后的构建单元搭建成的目标神经网络能够更好地满足应用需求。In this application, in the process of optimizing the network structure of the building unit, the video memory resources saved by reducing the search space can be used to increase the number of building units, so that the building units can be stacked as much as possible when the video memory resources are limited. A search network whose number is close to the number of building units of the target neural network to be built finally. The optimized construction unit can be better adapted to the construction of the target neural network, and the target neural network built according to the optimized construction unit can better meet the application requirements.
具体地,本申请在搜索网络的构建单元的网络结构的优化过程中,通过逐渐减少搜索空间的大小,并增加搜索网络的构建单元的数量,能够在构建出能够较好满足应用需求的目标神经网络的情况下,减少优化过程显存资源的依赖,使得在优化过程中仅仅依赖较少的显存资源就能够得到较好的满足应用需求的目标神经网络,也在一定程度上提高了显存资源的利用率。Specifically, in the process of optimizing the network structure of the construction unit of the search network, this application gradually reduces the size of the search space and increases the number of construction units of the search network, so as to construct a target neural network that can better meet the needs of the application. In the case of the network, the dependence on the video memory resources in the optimization process is reduced, so that the target neural network that satisfies the application needs can be obtained by relying on less video memory resources in the optimization process, and also improves the utilization of video memory resources to a certain extent. rate.
一般地,如果搜索网络的网络深度与待构建的目标神经网络的网络深度比较接近时,搜索网络中优化得到的构建单元比较适合由于搭建目标神经网络。神经网络的深度与包含的构建单元的数量是正相关的关系,因此,当搜索网络的构建单元的数量与目标神经网络的构建单元数量比较接近时,搜索网络的网络深度与目标神经网络的网络深度也比较接近。Generally, if the network depth of the search network is relatively close to the network depth of the target neural network to be constructed, the optimized construction unit in the search network is more suitable for building the target neural network. The depth of the neural network is positively correlated with the number of building units contained. Therefore, when the number of building units of the search network is close to the number of building units of the target neural network, the network depth of the search network is the same as that of the target neural network. Also relatively close.
可选地,上述搜索空间在第i个阶段的大小为S i,上述搜索空间在第j个阶段的大小为S j,上述搜索网络在第i个阶段包含的构建单元数量为L i个,上述搜索网络在第j个阶段包含的构建单元数量为L j个,其中,上述L j-L i大小是根据S i-S j的大小确定的,或者,上述S i-S j的大小是根据L j-L i的大小确定的。 Optionally, the size of the search space for the i-th stage S i, S j of the above-described search space size in the j-th stage, the number of the search network construction unit included in the i-th stage is L i, The number of construction units included in the j-th stage of the search network is L j , where the size of L j -L i is determined according to the size of S i -S j , or the size of S i -S j is Determined according to the size of L j -L i .
具体地,在上述两个阶段中,可以预先设定S i-S j的大小,然后再根据S i-S j的大小确定L j-L i的大小,使得由于搜索空间减小节省的显存资源与构建单元增加导致多消耗的显存资源的差值在一定阈值范围内。 Specifically, in the above two stages, the size of S i -S j can be preset, and then the size of L j -L i can be determined according to the size of S i -S j , so that the video memory saved due to the reduced search space The increase in resources and building units causes the difference between the excessively consumed video memory resources to be within a certain threshold range.
在上述两个阶段中,也可以预先设定L j-L i的大小,然后再根据L j-L i的大小确定S i-S j的大小,使得由于构建单元增加导致多消耗的显存资源与搜索空间减小节省的显存资源的差值在一定阈值范围内。 In the above two stages, the size of L j -L i can also be preset, and then the size of S i -S j is determined according to the size of L j -L i , so that the increase in the building unit causes more memory resources to be consumed The difference between the video memory resources saved and the search space reduction is within a certain threshold range.
可选地,上述N的大小是预先设置的。Optionally, the above-mentioned size of N is preset.
上述N的大小可以根据目标神经网络的构建需求来确定。具体地,当目标神经网络需要在较短的时间内构建完成时,可以将N设置成一个较小的数值,当目标神经网络可以在较长的时间内构建完成时,可以将N设置成一个较大的数值。The size of the above N can be determined according to the construction requirements of the target neural network. Specifically, when the target neural network needs to be constructed in a relatively short time, N can be set to a small value, and when the target neural network can be constructed in a relatively long time, N can be set to a Larger value.
应理解,在本申请中,只要上述N个阶段中存在至少两个阶段满足搜索空间减小,构建单元数量增加即可,而不必使得每两个相邻的阶段都满足搜索空间减小,构建单元数量增加的要求。It should be understood that in this application, as long as there are at least two of the above N stages that satisfy the search space reduction and the number of construction units increase, it is not necessary to make every two adjacent stages satisfy the search space reduction and construct Requirements for increased number of units.
例如,上述N=4,第2个阶段相比于第1阶段以及第4阶段相对于第3阶段均满足:搜索空间减小,搜索网络的构建单元数量增加。而第2个阶段和第3个阶段的搜索空间以及搜索网络包含的构建单元数量均没有发生变化。For example, the above N=4, the second stage is compared with the first stage and the fourth stage is satisfied with the third stage: the search space is reduced, and the number of construction units of the search network is increased. However, the search space and the number of building units contained in the search network in the second and third phases have not changed.
结合第一方面,在第一方面的某些实现方式中,j=i+1。In combination with the first aspect, in some implementations of the first aspect, j=i+1.
当j=i+1时,在优化过程中,任意两个相邻阶段之间都会满足搜索空间逐渐减小,搜索网络的构建单元逐渐增加,使得优化过程比较平稳。When j=i+1, in the optimization process, the search space between any two adjacent stages will gradually decrease, and the construction unit of the search network will gradually increase, making the optimization process relatively stable.
可选地,上述N个阶段中,搜索网络在任意两个相邻阶段的构建单元的数量变化值相同,搜索空间在任意两个相邻阶段的大小变化值也相同。Optionally, in the above-mentioned N stages, the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
在上述优化过程中,构建单元的数量变化以及搜索空间的大小变化都是均匀的,优化的过程更加平稳。In the above optimization process, the changes in the number of construction units and the size of the search space are uniform, and the optimization process is more stable.
可选地,上述第i+1个阶段相对于第i个阶段增加的构建单元的数量可以是根据上述数值N,以及搜索网络在优化前包含的构建单元的数量,以及目标神经网络中的构建单元的数量来确定的。Optionally, the number of construction units increased in the i+1th stage relative to the i-th stage may be based on the aforementioned value N, the number of construction units included in the search network before optimization, and the construction of the target neural network The number of units is determined.
例如,搜索网络在第i+1个阶段相对于第i个阶段增加的构建单元的数量为X,优化开始前搜索网络包含的构建单元数量为U,目标神经网络中的构建单元的数量为V,那么,X可以根据公式X=(U-V)/N计算得到。For example, the number of building units increased by the search network in the i+1 stage relative to the i-th stage is X, the number of building units contained in the search network before the optimization starts is U, and the number of building units in the target neural network is V , Then, X can be calculated according to the formula X=(UV)/N.
应理解,在优化过程中,搜索空间的大小降低的幅度以及搜索网络构建单元数量的增加幅度可以根据多种方式来确定,只要能够确保优化过程中搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内即可。It should be understood that in the optimization process, the extent of the reduction in the size of the search space and the extent of the increase in the number of search network construction units can be determined in various ways, as long as the reduction in the search space of the search network during the optimization process and the search The increase in the number of building units of the network makes the memory consumption generated in the optimization process within a preset range.
在实际应用中可以先预先设定搜索空间大小降低的幅度,然后再确定搜索网络构建单元数量增加的幅度;也可以预先设定搜索网络的大小,再确定搜索空间大小降低的幅度。本申请对此不做限定,所有确保显存消耗在预设范围内的实现方式都在本申请的保护范围内。In practical applications, the size of the search space can be reduced in advance, and then the amount of increase in the number of search network construction units can be determined; or the size of the search network can be preset, and then the size of the search space can be reduced. This application does not limit this, and all implementations to ensure that the video memory consumption is within the preset range are within the protection scope of this application.
结合第一方面,在第一方面的某些实现方式中,优化后的构建单元的各个节点之间的连接关系中包含的第一类操作的数量在预设范围内,第一类操作是不包含神经网络可训练参数的操作。With reference to the first aspect, in some implementations of the first aspect, the number of the first type of operations included in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first type of operation is not Contains operations for neural network trainable parameters.
本申请通过将第一类操作的数量限制在一定范围,使得最终搭建的目标神经网络的可训练参数保持在相对稳定的水平,进而使得目标神经网络的性能保持稳定。In this application, the number of operations of the first type is limited to a certain range, so that the trainable parameters of the final target neural network are maintained at a relatively stable level, and the performance of the target neural network remains stable.
具体地,上述第一类操作是不包含可训练参数的操作,如果此类操作过多会导致包含可训练参数的其他操作较少,从而神经网络总体的可训练参数较少,神经网络的特征表达能力降低。Specifically, the first type of operation mentioned above is an operation that does not contain trainable parameters. If there are too many such operations, it will result in fewer other operations containing trainable parameters, so that the overall neural network has fewer trainable parameters, and the characteristics of the neural network Decreased expression ability.
由于在构建单元数量较多的搜索网络中进行结构搜索稳定性不足,会导致每次搜索得到的构建单元中第一类操作的数量具有一定的差异,搜索得到的神经网络结构(即构建单元)在相应任务上的性能表现波动。限制第一类操作的数量可以使得由搜索得到的神经网络结构搭建的测试网络的可训练参数保持在相对稳定的水平,从而减小在相应任务上的性能波动。Due to the insufficient stability of the structure search in the search network with a large number of construction units, the number of first-type operations in the construction units obtained by each search will have a certain difference. The neural network structure obtained by the search (ie, the construction unit) Fluctuations in performance on corresponding tasks. Limiting the number of operations of the first type can keep the trainable parameters of the test network constructed from the neural network structure obtained by the search at a relatively stable level, thereby reducing performance fluctuations on the corresponding tasks.
结合第一方面,在第一方面的某些实现方式中,搜索网络中的构建单元包括第一类构建单元,第一类构建单元是输入特征图的数量和大小分别与输出特征图的数量和大小相同的构建单元。In combination with the first aspect, in some implementations of the first aspect, the building units in the search network include the first type of building unit, and the first type of building unit is the number and size of the input feature maps and the number and the output feature maps, respectively. Building units of the same size.
结合第一方面,在第一方面的某些实现方式中,搜索网络中的构建单元包括第二类构建单元,第二类构建单元的输出特征图的分辨率是输入特征图的1/M,第二类构建单元的 输出特图的数量是输入特征图的数量的M倍,M为大于1的正整数。With reference to the first aspect, in some implementations of the first aspect, the building units in the search network include the second type of building unit, and the resolution of the output feature map of the second type of building unit is 1/M of the input feature map, The number of output feature maps of the second type of construction unit is M times the number of input feature maps, and M is a positive integer greater than 1.
第二方面,提供了一种图像处理方法,该方法包括:获取待处理图像;根据目标神经网络对所述待处理图像进行分类,得到所述待处理图像的分类结果,其中,该目标神经网络是根据第一方面中的任意一种实现方式构建得到的神经网络。In a second aspect, an image processing method is provided, the method includes: acquiring an image to be processed; classifying the image to be processed according to a target neural network to obtain a classification result of the image to be processed, wherein the target neural network It is a neural network constructed according to any one of the realization methods in the first aspect.
应理解,第二方面中的图像处理方法所采用的目标神经网络在进行图像分类之前,还需要再根据训练图像对该目标神经网络进行训练,训练得到的目标神经网络就可以对待处理图像进行分类。It should be understood that before the target neural network used in the image processing method in the second aspect performs image classification, the target neural network needs to be trained according to the training image, and the trained target neural network can then classify the image to be processed .
也就是说,可以采用第一方面中的神经网络结构搜索方法得到目标神经网络,接下来,再根据训练图像对该目标神经网络进行训练,训练完成后就可以用该目标神经网络对待处理图像进行分类了。In other words, the neural network structure search method in the first aspect can be used to obtain the target neural network. Then, the target neural network can be trained according to the training image. After the training is completed, the target neural network can be used to perform the processing of the image to be processed. Classified.
本申请中,由于目标神经网络是采用上述第一方面的方面构建得到的,比较符合或者贴近神经网络的应用需求,利用这样的神经网络进行图像分类,能够取得较好的图像分类效果(例如,分类结果更准确,等等)。In this application, since the target neural network is constructed using the above-mentioned first aspect, it is more in line with or close to the application requirements of the neural network. Using such a neural network for image classification can achieve better image classification effects (for example, The classification results are more accurate, etc.).
第三方面,提供了一种图像处理方法,该方法包括:获取待处理图像;根据目标神经网络对待处理图像进行分类,得到待处理图像的分类结果。In a third aspect, an image processing method is provided. The method includes: acquiring an image to be processed; and classifying the image to be processed according to a target neural network to obtain a classification result of the image to be processed.
其中,目标神经网络由多个优化后的构建单元搭建而成,多个优化后的构建单元是通过对搜索网络中的构建单元的网络结构进行N个阶段的优化得到的,第i个阶段和第j个阶段为N个阶段中的任意两个阶段,搜索空间在第i个阶段的大小大于搜索网络在第j个阶段的大小,搜索网络在第i个阶段时包含的构建单元的数量小于搜索空间在第j个阶段时包含的构建单元的数量,搜索网络的搜索空间的减小和搜索网络的构建单元数量的增加使得优化过程中产生的显存消耗在预设范围内,搜索网络在第N个阶段包含的构建单元的数量与目标神经网络包含的构建单元的数量的差异在预设范围内,目标神经网络包含的构建单元的数量是根据目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j。Among them, the target neural network is constructed by multiple optimized building units, and the multiple optimized building units are obtained by optimizing the network structure of the building units in the search network in N stages. The i-th stage and The j-th stage is any two of the N stages. The size of the search space in the i-th stage is greater than the size of the search network in the j-th stage, and the number of building units included in the search network in the i-th stage is less than The number of construction units included in the search space at the jth stage, the reduction of the search space of the search network and the increase of the number of construction units of the search network make the memory consumption generated during the optimization process within the preset range, and the search network is in the first The difference between the number of building units included in the N stages and the number of building units included in the target neural network is within a preset range. The number of building units included in the target neural network is determined according to the application requirements of the target neural network, and N is greater than A positive integer of 1, i and j are both positive integers less than or equal to N, and i is less than j.
本申请中,在目标神经网络构建之前的优化过程中,通过减小搜索空间的大小,增加构建单元的数量,能够尽可能的堆叠得到构建单元数量与最终要搭建的目标神经网络的构建单元数量比较接近的搜索网络。从而使得搜索网络优化后的构建单元能够更好地适用于目标神经网络的搭建,能够获得性能更好的目标神经网络,利用该目标神经网络进行图像分类能够取得较好的图像分类效果(例如,分类结果更准确,等等)。In this application, in the optimization process before the construction of the target neural network, by reducing the size of the search space and increasing the number of construction units, the number of construction units and the number of construction units of the target neural network to be built can be stacked as much as possible Relatively close search network. Therefore, the optimized construction unit of the search network can be better adapted to the construction of the target neural network, and a better performance target neural network can be obtained. Using the target neural network for image classification can achieve better image classification results (for example, The classification results are more accurate, etc.).
结合第三方面,在第三方面的某些实现方式中,j=i+1。In combination with the third aspect, in some implementations of the third aspect, j=i+1.
当j=i+1时,在优化过程中,任意两个相邻阶段之间都会满足搜索空间逐渐减小,搜索网络的构建单元逐渐增加,使得优化过程比较平稳。When j=i+1, in the optimization process, the search space between any two adjacent stages will gradually decrease, and the construction unit of the search network will gradually increase, making the optimization process relatively stable.
可选地,上述N个阶段中,搜索网络在任意两个相邻阶段的构建单元的数量变化值相同,搜索空间在任意两个相邻阶段的大小变化值也相同。Optionally, in the above-mentioned N stages, the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
在上述优化过程中,构建单元的数量变化以及搜索空间的大小变化都是均匀的,优化的过程更加平稳。In the above optimization process, the changes in the number of construction units and the size of the search space are uniform, and the optimization process is more stable.
可选地,上述目标神经网络是经过训练图片进行训练得到的神经网络。Optionally, the above-mentioned target neural network is a neural network obtained by training through training pictures.
具体地,可以通过训练图片以及训练图片标记的类别信息对目标神经网络进行训练,训练完成的神经网络就可以用于进行图像分类了。Specifically, the target neural network can be trained by training pictures and the category information marked by the training pictures, and the trained neural network can be used for image classification.
第四方面,提供了一种图像处理方法,该方法包括:获取道路画面;根据目标神经网络对道路画面进行卷积处理,得到道路画面的多个卷积特征图;根据目标神经网络对道路画面的多个卷积特征图进行反卷积处理,获得该道路画面的语义分割结果。In a fourth aspect, an image processing method is provided. The method includes: obtaining a road image; performing convolution processing on the road image according to a target neural network to obtain multiple convolution feature maps of the road image; and processing the road image according to the target neural network Deconvolution processing is performed on multiple convolution feature maps of to obtain the semantic segmentation result of the road image.
其中,上述目标神经网络是根据第一方面中的任意一种实现方式构建得到的神经网络。Among them, the above-mentioned target neural network is a neural network constructed according to any one of the implementation methods in the first aspect.
第五方面,提供了一种图像处理方法,该方法包括:获取人脸图像;根据目标神经网络对人脸图像进行卷积处理,得到人脸图像的卷积特征图;将人脸图像的卷积特征图与身份证件图像的卷积特征图进行对比,得到人脸图像的验证结果。In a fifth aspect, an image processing method is provided. The method includes: obtaining a face image; performing convolution processing on the face image according to a target neural network to obtain a convolution feature map of the face image; The product feature map is compared with the convolution feature map of the ID image to obtain the verification result of the face image.
上述身份证件图像可的卷积特征图可以是预先获取的,并存储在相应的数据库中。例如,预先对身份证件图像进行卷积处理,将得到的卷积特征图存储到数据库中。The convolution feature map of the aforementioned ID image may be obtained in advance and stored in the corresponding database. For example, perform convolution processing on the image of the ID document in advance, and store the obtained convolution feature map in the database.
另外,上述目标神经网络是根据第一方面中的任意一种实现方式构建得到的神经网络。In addition, the above-mentioned target neural network is a neural network constructed according to any one of the implementation methods in the first aspect.
应理解,在上述第一方面中对相关内容的扩展、限定、解释和说明也适用于第二方面、第三方面、第四方面和第五方面中相同的内容。It should be understood that the expansion, limitation, explanation and description of the related content in the above-mentioned first aspect are also applicable to the same content in the second, third, fourth and fifth aspects.
第六方面,提供了一种神经网络构建装置,该装置包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行第一方面中的任意一种实现方式中的方法。In a sixth aspect, a neural network construction device is provided. The device includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the The processor is configured to execute the method in any one of the implementation manners in the first aspect.
第七方面,提供了一种图像处理装置,该装置包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行第二方面至第五方面中的任意一种实现方式中的方法。In a seventh aspect, an image processing device is provided, which includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, the processing The device is used to execute the method in any one of the second aspect to the fifth aspect.
第八方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面至第五方面中的任意一种实现方式中的方法。In an eighth aspect, a computer-readable medium is provided, and the computer-readable medium stores program code for device execution, and the program code includes a method for executing any one of the first to fifth aspects. .
第九方面,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述第一方面至第五方面中的任意一种实现方式中的方法。In a ninth aspect, a computer program product containing instructions is provided. When the computer program product runs on a computer, the computer executes the method in any one of the foregoing first to fifth aspects.
第十方面,提供一种芯片,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,执行上述第一方面至第五方面中的任意一种实现方式中的方法。In a tenth aspect, a chip is provided. The chip includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface, and executes any one of the first to fifth aspects above The method in the implementation mode.
可选地,作为一种实现方式,所述芯片还可以包括存储器,所述存储器中存储有指令,所述处理器用于执行所述存储器上存储的指令,当所述指令被执行时,所述处理器用于执行第一方面至第五方面中的任意一种实现方式中的方法。Optionally, as an implementation manner, the chip may further include a memory in which instructions are stored, and the processor is configured to execute the instructions stored in the memory. When the instructions are executed, the The processor is configured to execute the method in any one of the implementation manners of the first aspect to the fifth aspect.
附图说明Description of the drawings
图1是本申请实施例提供的一种人工智能主体框架示意图;FIG. 1 is a schematic diagram of an artificial intelligence main body framework provided by an embodiment of the present application;
图2为本申请实施例提供的一种应用环境的示意图;Figure 2 is a schematic diagram of an application environment provided by an embodiment of the application;
图3为本申请实施例提供的一种卷积神经网络结构示意图;FIG. 3 is a schematic diagram of a convolutional neural network structure provided by an embodiment of the application;
图4为本申请实施例提供的一种卷积神经网络结构示意图;4 is a schematic diagram of a convolutional neural network structure provided by an embodiment of the application;
图5为本申请实施例提供的一种神经网络处理器的结构示意图;FIG. 5 is a schematic structural diagram of a neural network processor provided by an embodiment of this application;
图6为本申请实施例提供的一种处理器的结构示意图;FIG. 6 is a schematic structural diagram of a processor provided by an embodiment of the application;
图7为本申请实施例提供的一种芯片的硬件结构示意图;FIG. 7 is a schematic diagram of the hardware structure of a chip provided by an embodiment of the application;
图8为本申请实施例提供的一种***架构的示意图;FIG. 8 is a schematic diagram of a system architecture provided by an embodiment of the application;
图9是本申请实施例的神经网络的构建方法的示意性流程图;FIG. 9 is a schematic flowchart of a neural network construction method according to an embodiment of the present application;
图10是本申请实施例的构建单元的示意图;FIG. 10 is a schematic diagram of a construction unit of an embodiment of the present application;
图11是本申请实施例的搜索网络的示意图;Fig. 11 is a schematic diagram of a search network according to an embodiment of the present application;
图12是本申请实施例的神经网络的构建方法的示意图;FIG. 12 is a schematic diagram of a neural network construction method according to an embodiment of the present application;
图13是本申请实施例的神经网络构建***的示意图;FIG. 13 is a schematic diagram of a neural network construction system according to an embodiment of the present application;
图14是本申请实施例的搜索网络的构建单元的网络结构优化过程的示意图;FIG. 14 is a schematic diagram of a network structure optimization process of a construction unit of a search network according to an embodiment of the present application;
图15是本申请实施例的操作数量规范模块的处理过程的示意图;15 is a schematic diagram of the processing procedure of the operation quantity specification module of the embodiment of the present application;
图16是本申请实施例的图像处理方法的示意性流程图;FIG. 16 is a schematic flowchart of an image processing method according to an embodiment of the present application;
图17是本申请实施例的神经网络构建装置的示意性框图;FIG. 17 is a schematic block diagram of a neural network construction device according to an embodiment of the present application;
图18是本申请实施例的图像处理装置的示意性框图;FIG. 18 is a schematic block diagram of an image processing device according to an embodiment of the present application;
图19是本申请实施例的神经网络训练装置的示意性框图。Fig. 19 is a schematic block diagram of a neural network training device according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
图1示出一种人工智能主体框架示意图,该主体框架描述了人工智能***总体工作流程,适用于通用的人工智能领域需求。Figure 1 shows a schematic diagram of an artificial intelligence main framework, which describes the overall workflow of the artificial intelligence system and is suitable for general artificial intelligence field requirements.
下面从“智能信息链”(水平轴)和“信息技术(information technology,IT)价值链”(垂直轴)两个维度对上述人工智能主题框架进行详细的阐述。The following is a detailed explanation of the above-mentioned artificial intelligence theme framework from the two dimensions of "intelligent information chain" (horizontal axis) and "information technology (IT) value chain" (vertical axis).
“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。"Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has gone through the condensing process of "data-information-knowledge-wisdom".
“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到***的产业生态过程,反映人工智能为信息技术产业带来的价值。The "IT value chain" from the underlying infrastructure of human intelligence, information (providing and processing technology realization) to the system's industrial ecological process, reflects the value that artificial intelligence brings to the information technology industry.
(1)基础设施:(1) Infrastructure:
基础设施为人工智能***提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。Infrastructure provides computing power support for artificial intelligence systems, realizes communication with the outside world, and realizes support through the basic platform.
基础设施可以通过传感器与外部沟通,基础设施的计算能力可以由智能芯片提供。The infrastructure can communicate with the outside through sensors, and the computing power of the infrastructure can be provided by smart chips.
这里的智能芯片可以是中央处理器(central processing unit,CPU)、神经网络处理器(neural-network processing unit,NPU)、图形处理器(graphics processing unit,GPU)、专门应用的集成电路(application specific integrated circuit,ASIC)以及现场可编程门阵列(field programmable gate array,FPGA)等硬件加速芯片。The smart chip here can be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), and an application specific integrated circuit (application specific). Hardware acceleration chips such as integrated circuit (ASIC) and field programmable gate array (FPGA).
基础设施的基础平台可以包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。The basic platform of infrastructure can include distributed computing framework and network and other related platform guarantees and support, and can include cloud storage and computing, interconnection networks, etc.
例如,对于基础设施来说,可以通过传感器和外部沟通获取数据,然后将这些数据提供给基础平台提供的分布式计算***中的智能芯片进行计算。For example, for infrastructure facilities, data can be obtained through sensors and external communication, and then these data can be provided to the smart chip in the distributed computing system provided by the basic platform for calculation.
(2)数据:(2) Data:
基础设施的上一层的数据用于表示人工智能领域的数据来源。该数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有***的业务数据以及力、位移、液位、温度、湿度等感知数据。The data in the upper layer of the infrastructure is used to represent the data source in the field of artificial intelligence. This data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
(3)数据处理:(3) Data processing:
上述数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等处理方式。The above-mentioned data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other processing methods.
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, training, etc.
推理是指在计算机或智能***中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。Reasoning refers to the process of simulating human intelligent reasoning in a computer or intelligent system, using formal information to conduct machine thinking and solving problems based on reasoning control strategies. The typical function is search and matching.
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。Decision-making refers to the decision-making process of intelligent information after reasoning, and usually provides functions such as classification, ranking, and prediction.
(4)通用能力:(4) General ability:
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用***,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。After the above-mentioned data processing is performed on the data, some general capabilities can be formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image Recognition and so on.
(5)智能产品及行业应用:(5) Smart products and industry applications:
智能产品及行业应用指人工智能***在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能制造、智能交通、智能家居、智能医疗、智能安防、自动驾驶,平安城市,智能终端等。Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields. It is an encapsulation of the overall solution of artificial intelligence, productizing intelligent information decision-making and realizing landing applications. Its application fields mainly include: intelligent manufacturing, intelligent transportation, Smart home, smart medical, smart security, autonomous driving, safe city, smart terminal, etc.
本申请实施例可以应用在人工智能中的很多领域,例如,智能制造、智能交通、智能家居、智能医疗、智能安防、自动驾驶,平安城市等领域。The embodiments of this application can be applied to many fields in artificial intelligence, for example, smart manufacturing, smart transportation, smart home, smart medical care, smart security, automatic driving, safe cities and other fields.
具体地,本申请实施例可以具体应用在图像分类、图像检索、图像语义分割、图像超分辨率和自然语言处理等需要使用(深度)神经网络的领域。Specifically, the embodiments of the present application can be specifically applied in fields that require the use of (deep) neural networks, such as image classification, image retrieval, image semantic segmentation, image super-resolution, and natural language processing.
下面对相册图片分类和自动驾驶这两种应用场景进行简单的介绍。The following is a brief introduction to the two application scenarios of album picture classification and automatic driving.
相册图片分类:Album picture categories:
具体地,当用户在终端设备(例如,手机)或者云盘上存储了大量的图片时,通过对相册中图像进行识别可以方便用户或者***对相册进行分类管理,提升用户体验。Specifically, when a user stores a large number of pictures on a terminal device (for example, a mobile phone) or a cloud disk, recognizing the images in the album can facilitate the user or the system to classify and manage the album and improve the user experience.
利用本申请实施例的神经网络结构搜索方法能够搜索得到适用于相册分类的神经网络结构,然后再根据训练图片库中的训练图片对神经网络进行训练,就可以得到相册分类神经网络。接下来就可以利用该相册分类神经网络对图片进行分类,从而为不同的类别的图片打上标签,便于用户查看和查找。另外,这些图片的分类标签也可以提供给相册管理***进行分类管理,节省用户的管理时间,提高相册管理的效率,提升用户体验。The neural network structure search method of the embodiment of the present application can search for a neural network structure suitable for album classification, and then train the neural network according to the training pictures in the training picture library to obtain the album classification neural network. Next, the album classification neural network can be used to classify the pictures, so that different categories of pictures can be labeled for users to view and find. In addition, the classification tags of these pictures can also be provided to the album management system for classification management, saving users management time, improving the efficiency of album management, and enhancing user experience.
例如,如图2所示,可以通过神经网络构建***(对应于本申请实施例的神经网络结构搜索方法)构建得到适用于相册分类的神经网络。在构建该神经网络时,可以利用训练图片库的对搜索网络中的构建单元的网络结构进行优化,得到优化后的构建单元,然后再利用该优化后的构建单元来搭建神经网络。在获得适用于相册分类的神经网络之后,可以再根据训练图片对该神经网络进行训练,得到相册分类神经网络。接下来,就可以利用相册分类神经网络对待处理图片进行分类。如图2所示,相册分类神经网络对输入的图片进 行处理,得到图片的类别为郁金香。For example, as shown in FIG. 2, a neural network suitable for album classification can be constructed through a neural network construction system (corresponding to the neural network structure search method in the embodiment of the present application). When constructing the neural network, the network structure of the building unit in the search network can be optimized by using the training image library to obtain the optimized building unit, and then the optimized building unit can be used to build the neural network. After obtaining the neural network suitable for album classification, the neural network can be trained according to the training pictures to obtain the album classification neural network. Next, you can use the album classification neural network to classify the pictures to be processed. As shown in Figure 2, the album classification neural network processes the input pictures, and the picture category is tulip.
自动驾驶场景下的物体识别:Object recognition in autonomous driving scenarios:
自动驾驶中有大量的传感器数据需要处理,深度神经网络凭借着其强大的能力在自动驾驶中发挥着重要的作用。然而手工设计相应的数据处理网络费时费力。因此,通过采用本申请实施例的神经网络结构搜索方法,能够构建得到适用于自动驾驶场景下进行数据处理的神经网络,接下来,通过自动驾驶场景下的数据对该神经网络进行训练,能够得到传感器数据处理网络,最后就可以利用该传感器处理网络对输入的道路画面进行处理,从而识别出道路画面中的不同物体。There is a large amount of sensor data to be processed in autonomous driving, and deep neural networks play an important role in autonomous driving by virtue of their powerful capabilities. However, manually designing the corresponding data processing network takes time and effort. Therefore, by using the neural network structure search method of the embodiments of the present application, a neural network suitable for data processing in an autonomous driving scenario can be constructed, and then the neural network can be trained through the data in the autonomous driving scenario to obtain The sensor data processing network can finally use the sensor processing network to process the input road images to identify different objects in the road images.
如图3所示,神经网络构建***能够根据车辆检测任务构建出一个神经网络,在构建该神经网络时,可以利用传感器数据对搜索网络中的构建单元的网络结构进行优化,得到优化后的构建单元,然后再利用该优化后的构建单元来搭建神经网络。在得到了神经网络之后,就可以根据传感器数据对该神经网络进行训练,得到传感器数据处理网络。接下来,就可以利用该传感器数据处理网络对传感器数据进行处理。如图3所示,传感器数据处理网络对输入的道路画面进行处理,能够识别出道路画面中的车辆(如图3右下角矩形框部分所示)。As shown in Figure 3, the neural network construction system can construct a neural network according to the vehicle detection task. When constructing the neural network, the sensor data can be used to optimize the network structure of the building units in the search network to obtain the optimized construction Unit, and then use the optimized building unit to build a neural network. After the neural network is obtained, the neural network can be trained according to the sensor data to obtain the sensor data processing network. Next, you can use the sensor data processing network to process sensor data. As shown in Fig. 3, the sensor data processing network processes the input road picture, and can identify the vehicle in the road picture (as shown in the rectangular frame in the lower right corner of Fig. 3).
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例可能涉及的神经网络的相关术语和概念进行介绍。Since the embodiments of the present application involve a large number of applications of neural networks, in order to facilitate understanding, the following first introduces related terms and concepts of neural networks that may be involved in the embodiments of the present application.
(1)神经网络(1) Neural network
神经网络可以是由神经单元组成的,神经单元可以是指以x s和截距1为输入的运算单元,该运算单元的输出可以为: A neural network can be composed of neural units. A neural unit can refer to an arithmetic unit that takes x s and intercept 1 as inputs. The output of the arithmetic unit can be:
Figure PCTCN2020087222-appb-000001
Figure PCTCN2020087222-appb-000001
其中,s=1、2、……n,n为大于1的自然数,W s为x s的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。 Among them, s=1, 2,...n, n is a natural number greater than 1, W s is the weight of x s , and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected with the local receptive field of the previous layer to extract the characteristics of the local receptive field. The local receptive field can be a region composed of several neural units.
(2)深度神经网络(2) Deep neural network
深度神经网络(deep neural network,DNN),也称多层神经网络,可以理解为具有多层隐含层的神经网络。按照不同层的位置对DNN进行划分,DNN内部的神经网络可以分为三类:输入层,隐含层,输出层。一般来说第一层是输入层,最后一层是输出层,中间的层数都是隐含层。层与层之间是全连接的,也就是说,第i层的任意一个神经元一定与第i+1层的任意一个神经元相连。Deep neural network (DNN), also called multi-layer neural network, can be understood as a neural network with multiple hidden layers. DNN is divided according to the positions of different layers. The neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the number of layers in the middle are all hidden layers. The layers are fully connected, that is to say, any neuron in the i-th layer must be connected to any neuron in the i+1th layer.
虽然DNN看起来很复杂,但是就每一层的工作来说,其实并不复杂,简单来说就是如下线性关系表达式:
Figure PCTCN2020087222-appb-000002
其中,
Figure PCTCN2020087222-appb-000003
是输入向量,
Figure PCTCN2020087222-appb-000004
是输出向量,
Figure PCTCN2020087222-appb-000005
是偏移向量,W是权重矩阵(也称系数),α()是激活函数。每一层仅仅是对输入向量
Figure PCTCN2020087222-appb-000006
经过如此简单的操作得到输出向量
Figure PCTCN2020087222-appb-000007
由于DNN层数多,系数W和偏移向量
Figure PCTCN2020087222-appb-000008
的数量也比较多。这些参数在DNN中的定义如下所述:以系数W为例:假设在一个三层的DNN中,第二 层的第4个神经元到第三层的第2个神经元的线性系数定义为
Figure PCTCN2020087222-appb-000009
上标3代表系数W所在的层数,而下标对应的是输出的第三层索引2和输入的第二层索引4。
Although DNN looks complicated, it is not complicated in terms of the work of each layer. Simply put, it is the following linear relationship expression:
Figure PCTCN2020087222-appb-000002
among them,
Figure PCTCN2020087222-appb-000003
Is the input vector,
Figure PCTCN2020087222-appb-000004
Is the output vector,
Figure PCTCN2020087222-appb-000005
Is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just the input vector
Figure PCTCN2020087222-appb-000006
After such a simple operation, the output vector is obtained
Figure PCTCN2020087222-appb-000007
Due to the large number of DNN layers, the coefficient W and the offset vector
Figure PCTCN2020087222-appb-000008
The number is also relatively large. The definition of these parameters in the DNN is as follows: Take the coefficient W as an example: Suppose that in a three-layer DNN, the linear coefficients from the fourth neuron in the second layer to the second neuron in the third layer are defined as
Figure PCTCN2020087222-appb-000009
The superscript 3 represents the number of layers where the coefficient W is located, and the subscript corresponds to the output third layer index 2 and the input second layer index 4.
综上,第L-1层的第k个神经元到第L层的第j个神经元的系数定义为
Figure PCTCN2020087222-appb-000010
In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as
Figure PCTCN2020087222-appb-000010
需要注意的是,输入层是没有W参数的。在深度神经网络中,更多的隐含层让网络更能够刻画现实世界中的复杂情形。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。It should be noted that the input layer has no W parameter. In deep neural networks, more hidden layers make the network more capable of portraying complex situations in the real world. Theoretically speaking, a model with more parameters is more complex and has a greater "capacity", which means it can complete more complex learning tasks. Training a deep neural network is also a process of learning a weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (a weight matrix formed by vectors W of many layers).
(3)卷积神经网络(3) Convolutional neural network
卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取图像信息的方式与位置无关。卷积核可以以随机大小的矩阵的形式初始化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。Convolutional neural network (convolutional neuron network, CNN) is a deep neural network with convolutional structure. The convolutional neural network contains a feature extractor composed of a convolution layer and a sub-sampling layer. The feature extractor can be regarded as a filter. The convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network. In the convolutional layer of a convolutional neural network, a neuron can be connected to only part of the neighboring neurons. A convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units in the same feature plane share weights, and the shared weights here are the convolution kernels. Sharing weight can be understood as the way to extract image information has nothing to do with location. The convolution kernel can be initialized in the form of a matrix of random size. During the training of the convolutional neural network, the convolution kernel can obtain reasonable weights through learning. In addition, the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
(4)循环神经网络(recurrent neural networks,RNN)是用来处理序列数据的。在传统的神经网络模型中,是从输入层到隐含层再到输出层,层与层之间是全连接的,而对于每一层层内之间的各个节点是无连接的。这种普通的神经网络虽然解决了很多难题,但是却仍然对很多问题无能无力。例如,你要预测句子的下一个单词是什么,一般需要用到前面的单词,因为一个句子中前后单词并不是独立的。RNN之所以称为循环神经网路,即一个序列当前的输出与前面的输出也有关。具体的表现形式为网络会对前面的信息进行记忆并应用于当前输出的计算中,即隐含层本层之间的节点不再无连接而是有连接的,并且隐含层的输入不仅包括输入层的输出还包括上一时刻隐含层的输出。理论上,RNN能够对任何长度的序列数据进行处理。对于RNN的训练和对传统的CNN或DNN的训练一样。(4) Recurrent Neural Networks (RNN) are used to process sequence data. In the traditional neural network model, from the input layer to the hidden layer and then to the output layer, the layers are fully connected, and each node in each layer is disconnected. Although this ordinary neural network has solved many problems, it is still incapable of many problems. For example, if you want to predict what the next word of a sentence will be, you generally need to use the previous word, because the preceding and following words in a sentence are not independent. The reason why RNN is called recurrent neural network is that the current output of a sequence is also related to the previous output. The specific form is that the network will memorize the previous information and apply it to the calculation of the current output, that is, the nodes between the hidden layer are no longer unconnected but connected, and the input of the hidden layer includes not only The output of the input layer also includes the output of the hidden layer at the previous moment. In theory, RNN can process sequence data of any length. The training of RNN is the same as the training of traditional CNN or DNN.
既然已经有了卷积神经网络,为什么还要循环神经网络?原因很简单,在卷积神经网络中,有一个前提假设是:元素之间是相互独立的,输入与输出也是独立的,比如猫和狗。但现实世界中,很多元素都是相互连接的,比如股票随时间的变化,再比如一个人说了:我喜欢旅游,其中最喜欢的地方是云南,以后有机会一定要去。这里填空,人类应该都知道是填“云南”。因为人类会根据上下文的内容进行推断,但如何让机器做到这一步?RNN就应运而生了。RNN旨在让机器像人一样拥有记忆的能力。因此,RNN的输出就需要依赖当前的输入信息和历史的记忆信息。Now that there is already a convolutional neural network, why bother to recycle neural networks? The reason is simple. In convolutional neural networks, there is a premise that the elements are independent of each other, and the input and output are also independent, such as cats and dogs. But in the real world, many elements are connected to each other, such as the change of stocks over time, and another person said: I like traveling, and my favorite place is Yunnan, and I must go if I have a chance in the future. Filling in the blanks here, humans should all know that it is filling in "Yunnan". Because humans will make inferences based on the content of the context, but how to make the machine do this step? RNN came into being. RNN aims to make machines have memory capabilities like humans. Therefore, the output of RNN needs to rely on current input information and historical memory information.
(5)损失函数(5) Loss function
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调 整权重向量让它预测低一些,不断地调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。In the process of training a deep neural network, because it is hoped that the output of the deep neural network is as close as possible to the value that you really want to predict, you can compare the predicted value of the current network with the target value you really want, and then based on the difference between the two To update the weight vector of each layer of neural network (of course, there is usually an initialization process before the first update, that is, pre-configured parameters for each layer in the deep neural network), for example, if the predicted value of the network If it is high, adjust the weight vector to make its prediction lower, and keep adjusting until the deep neural network can predict the really wanted target value or a value very close to the really wanted target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value". This is the loss function or objective function, which is used to measure the difference between the predicted value and the target value. Important equation. Among them, take the loss function as an example. The higher the output value (loss) of the loss function, the greater the difference. Then the training of the deep neural network becomes a process of reducing this loss as much as possible.
(6)反向传播算法(6) Backpropagation algorithm
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。The neural network can use an error back propagation (BP) algorithm to modify the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, forwarding the input signal to the output will cause error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss is converged. The backpropagation algorithm is a backpropagation motion dominated by error loss, and aims to obtain the optimal neural network model parameters, such as the weight matrix.
如图4所示,本申请实施例提供了一种***架构100。在图4中,数据采集设备160用于采集训练数据。针对本申请实施例的图像处理方法来说,训练数据可以包括训练图像以及训练图像对应的分类结果,其中,训练图像的结果可以是人工预先标注的结果。As shown in FIG. 4, an embodiment of the present application provides a system architecture 100. In FIG. 4, the data collection device 160 is used to collect training data. For the image processing method of the embodiment of the present application, the training data may include training images and classification results corresponding to the training images, where the results of the training images may be manually pre-labeled results.
在采集到训练数据之后,数据采集设备160将这些训练数据存入数据库130,训练设备120基于数据库130中维护的训练数据训练得到目标模型/规则101。After the training data is collected, the data collection device 160 stores the training data in the database 130, and the training device 120 trains to obtain the target model/rule 101 based on the training data maintained in the database 130.
下面对训练设备120基于训练数据得到目标模型/规则101进行描述,训练设备120对输入的原始图像进行处理,将输出的图像与原始图像进行对比,直到训练设备120输出的图像与原始图像的差值小于一定的阈值,从而完成目标模型/规则101的训练。The following describes the target model/rule 101 obtained by the training device 120 based on the training data. The training device 120 processes the input original image and compares the output image with the original image until the output image of the training device 120 differs from the original image. The difference is less than a certain threshold, thereby completing the training of the target model/rule 101.
上述目标模型/规则101能够用于实现本申请实施例的图像处理方法或者图像处理方法。本申请实施例中的目标模型/规则101具体可以为神经网络。需要说明的是,在实际的应用中,所述数据库130中维护的训练数据不一定都来自于数据采集设备160的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备120也不一定完全基于数据库130维护的训练数据进行目标模型/规则101的训练,也有可能从云端或其他地方获取训练数据进行模型训练,上述描述不应该作为对本申请实施例的限定。The above-mentioned target model/rule 101 can be used to implement the image processing method or the image processing method of the embodiment of the present application. The target model/rule 101 in the embodiment of the present application may specifically be a neural network. It should be noted that in actual applications, the training data maintained in the database 130 may not all come from the collection of the data collection device 160, and may also be received from other devices. In addition, it should be noted that the training device 120 does not necessarily perform the training of the target model/rule 101 completely based on the training data maintained by the database 130. It may also obtain training data from the cloud or other places for model training. The above description should not be used as a reference to this application Limitations of Examples.
根据训练设备120训练得到的目标模型/规则101可以应用于不同的***或设备中,如应用于图4所示的执行设备110,所述执行设备110可以是终端,如手机终端,平板电脑,笔记本电脑,增强现实(augmented reality,AR)AR/虚拟现实(virtual reality,VR),车载终端等,还可以是服务器或者云端等。在图4中,执行设备110配置输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:客户设备输入的待处理图像。The target model/rule 101 trained according to the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. 4, which can be a terminal, such as a mobile phone terminal, a tablet computer, Notebook computers, augmented reality (AR) AR/virtual reality (VR), vehicle-mounted terminals, etc., can also be servers or clouds. In FIG. 4, the execution device 110 is configured with an input/output (input/output, I/O) interface 112 for data interaction with external devices. The user can input data to the I/O interface 112 through the client device 140. The input data in this embodiment of the application may include: the image to be processed input by the client device.
预处理模块113和预处理模块114用于根据I/O接口112接收到的输入数据(如待处理图像)进行预处理,在本申请实施例中,也可以没有预处理模块113和预处理模块114(也可以只有其中的一个预处理模块),而直接采用计算模块111对输入数据进行处理。The preprocessing module 113 and the preprocessing module 114 are used for preprocessing according to the input data (such as the image to be processed) received by the I/O interface 112. In the embodiment of the present application, the preprocessing module 113 and the preprocessing module may not be provided 114 (there may only be one preprocessing module), and the calculation module 111 is directly used to process the input data.
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模块111执行计算等相关的处理过程中,执行设备110可以调用数据存储***150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储***150中。When the execution device 110 preprocesses input data, or when the calculation module 111 of the execution device 110 performs calculations and other related processing, the execution device 110 may call data, codes, etc. in the data storage system 150 for corresponding processing , The data, instructions, etc. obtained by corresponding processing may also be stored in the data storage system 150.
最后,I/O接口112将处理结果,如上述得到的去噪处理后的图像返回给客户设备140,从而提供给用户。Finally, the I/O interface 112 returns the processing result, such as the denoising processed image obtained as described above, to the client device 140 to provide it to the user.
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练数据生成相应的目标模型/规则101,该相应的目标模型/规则101即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。It is worth noting that the training device 120 can generate corresponding target models/rules 101 based on different training data for different goals or tasks, and the corresponding target models/rules 101 can be used to achieve the above goals or complete The above tasks provide the user with the desired result.
在图4中所示情况下,用户可以手动给定输入数据,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送输入数据,如果要求客户设备140自动发送输入数据需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看执行设备110输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,采集如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果作为新的样本数据,并存入数据库130。当然,也可以不经过客户设备140进行采集,而是由I/O接口112直接将如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果,作为新的样本数据存入数据库130。In the case shown in FIG. 4, the user can manually set input data, and the manual setting can be operated through the interface provided by the I/O interface 112. In another case, the client device 140 can automatically send input data to the I/O interface 112. If the client device 140 is required to automatically send the input data and the user's authorization is required, the user can set the corresponding authority in the client device 140. The user can view the result output by the execution device 110 on the client device 140, and the specific presentation form may be a specific manner such as display, sound, and action. The client device 140 can also be used as a data collection terminal to collect the input data of the input I/O interface 112 and the output result of the output I/O interface 112 as new sample data, and store it in the database 130 as shown in the figure. Of course, it is also possible not to collect through the client device 140, but the I/O interface 112 directly uses the input data input to the I/O interface 112 and the output result of the output I/O interface 112 as a new sample as shown in the figure. The data is stored in the database 130.
值得注意的是,图4仅是本申请实施例提供的一种***架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图4中,数据存储***150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储***150置于执行设备110中。It is worth noting that FIG. 4 is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation. For example, in FIG. 4, the data The storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
如图4所示,根据训练设备120训练得到目标模型/规则101,该目标模型/规则101在本申请实施例中可以是本申请中的神经网络,具体的,本申请实施例提供的神经网络可以CNN,深度卷积神经网络(deep convolutional neural networks,DCNN),循环神经网络(recurrent neural network,RNNS)等等。As shown in FIG. 4, the target model/rule 101 is obtained by training according to the training device 120. The target model/rule 101 may be the neural network in this application in the embodiment of this application, specifically, the neural network provided in the embodiment of this application Can be CNN, deep convolutional neural networks (deep convolutional neural networks, DCNN), recurrent neural networks (recurrent neural network, RNNS) and so on.
由于CNN是一种非常常见的神经网络,下面结合图5重点对CNN的结构进行详细的介绍。如上文的基础概念介绍所述,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入其中的图像作出响应。Since CNN is a very common neural network, the structure of CNN will be introduced in detail below in conjunction with Figure 5. As mentioned in the introduction to the basic concepts above, a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture. A deep learning architecture refers to a machine learning algorithm. Multi-level learning is carried out on the abstract level of As a deep learning architecture, CNN is a feed-forward artificial neural network. Each neuron in the feed-forward artificial neural network can respond to the input image.
本申请实施例的图像处理方法具体采用的神经网络的结构可以如图5所示。在图5中,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及神经网络层230。其中,输入层210可以获取待处理图像,并将获取到的待处理图像交由卷积层/池化层220以及后面的神经网络层230进行处理,可以得到图像的处理结果。下面对图5中的CNN 200中内部的层结构进行详细的介绍。The structure of the neural network specifically adopted in the image processing method of the embodiment of the present application may be as shown in FIG. 5. In FIG. 5, a convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (where the pooling layer is optional), and a neural network layer 230. Wherein, the input layer 210 can obtain the image to be processed, and pass the obtained image to be processed to the convolutional layer/pooling layer 220 and the subsequent neural network layer 230 for processing, and the image processing result can be obtained. The following describes the internal layer structure of CNN 200 in Figure 5 in detail.
卷积层/池化层220:Convolutional layer/pooling layer 220:
卷积层:Convolutional layer:
如图5所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另一个卷 积层的输入以继续进行卷积操作。As shown in FIG. 5, the convolutional layer/pooling layer 220 may include layers 221-226, for example: in an implementation, layer 221 is a convolutional layer, layer 222 is a pooling layer, and layer 223 is a convolutional layer. Layers, 224 is the pooling layer, 225 is the convolutional layer, and 226 is the pooling layer; in another implementation, 221 and 222 are the convolutional layers, 223 is the pooling layer, and 224 and 225 are the convolutional layers. Layer, 226 is the pooling layer. That is, the output of the convolution layer can be used as the input of the subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。The following will take the convolutional layer 221 as an example to introduce the internal working principle of a convolutional layer.
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在图像处理中的作用相当于一个从输入图像矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义,在对图像进行卷积操作的过程中,权重矩阵通常在输入图像上沿着水平方向一个像素接着一个像素(或两个像素接着两个像素……这取决于步长stride的取值)的进行处理,从而完成从图像中提取特定特征的工作。该权重矩阵的大小应该与图像的大小相关,需要注意的是,权重矩阵的纵深维度(depth dimension)和输入图像的纵深维度是相同的,在进行卷积运算的过程中,权重矩阵会延伸到输入图像的整个深度。因此,和一个单一的权重矩阵进行卷积会产生一个单一纵深维度的卷积化输出,但是大多数情况下不使用单一权重矩阵,而是应用多个尺寸(行×列)相同的权重矩阵,即多个同型矩阵。每个权重矩阵的输出被堆叠起来形成卷积图像的纵深维度,这里的维度可以理解为由上面所述的“多个”来决定。不同的权重矩阵可以用来提取图像中不同的特征,例如一个权重矩阵用来提取图像边缘信息,另一个权重矩阵用来提取图像的特定颜色,又一个权重矩阵用来对图像中不需要的噪点进行模糊化等。该多个权重矩阵尺寸(行×列)相同,经过该多个尺寸相同的权重矩阵提取后的卷积特征图的尺寸也相同,再将提取到的多个尺寸相同的卷积特征图合并形成卷积运算的输出。The convolution layer 221 can include many convolution operators. The convolution operator is also called a kernel. Its function in image processing is equivalent to a filter that extracts specific information from the input image matrix. The convolution operator is essentially It can be a weight matrix. This weight matrix is usually pre-defined. In the process of convolution on the image, the weight matrix is usually one pixel after one pixel (or two pixels after two pixels) along the horizontal direction on the input image. ...It depends on the value of stride) to complete the work of extracting specific features from the image. The size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix and the depth dimension of the input image are the same. During the convolution operation, the weight matrix will extend to Enter the entire depth of the image. Therefore, convolution with a single weight matrix will produce a single depth dimension convolution output, but in most cases, a single weight matrix is not used, but multiple weight matrices of the same size (row × column) are applied. That is, multiple homogeneous matrices. The output of each weight matrix is stacked to form the depth dimension of the convolutional image, where the dimension can be understood as determined by the "multiple" mentioned above. Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract edge information of the image, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to eliminate unwanted noise in the image. Perform fuzzification, etc. The multiple weight matrices have the same size (row×column), the size of the convolution feature maps extracted by the multiple weight matrices of the same size are also the same, and then the multiple extracted convolution feature maps of the same size are combined to form The output of the convolution operation.
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入图像中提取信息,从而使得卷积神经网络200进行正确的预测。The weight values in these weight matrices need to be obtained through a lot of training in practical applications. Each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions. .
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (such as 221) often extracts more general features, which can also be called low-level features; with the convolutional neural network As the network 200 deepens, the features extracted by the subsequent convolutional layers (for example, 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
池化层:Pooling layer:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图5中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在图像处理过程中,池化层的唯一目的就是减少图像的空间大小。池化层可以包括平均池化算子和/或最大池化算子,以用于对输入图像进行采样得到较小尺寸的图像。平均池化算子可以在特定范围内对图像中的像素值进行计算产生平均值作为平均池化的结果。最大池化算子可以在特定范围内取该范围内值最大的像素作为最大池化的结果。另外,就像卷积层中用权重矩阵的大小应该与图像尺寸相关一样,池化层中的运算符也应该与图像的大小相关。通过池化层处理后输出的图像尺寸可以小于输入池化层的图像的尺寸,池化层输出的图像中每个像素点表示输入池化层的图像的对应子区域的平均值或最大值。Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolutional layer. The 221-226 layers as illustrated by 220 in Figure 5 can be a convolutional layer followed by a layer The pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers. In the image processing process, the only purpose of the pooling layer is to reduce the size of the image space. The pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling the input image to obtain a smaller size image. The average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling. The maximum pooling operator can take the pixel with the largest value within a specific range as the result of the maximum pooling. In addition, just as the size of the weight matrix used in the convolutional layer should be related to the image size, the operators in the pooling layer should also be related to the image size. The size of the image output after processing by the pooling layer can be smaller than the size of the image of the input pooling layer, and each pixel in the image output by the pooling layer represents the average value or the maximum value of the corresponding sub-region of the image input to the pooling layer.
神经网络层230:Neural network layer 230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前所述,卷积层/池化层220只会提取特征,并减少输入图像带来的参数。然而为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需 要利用神经网络层230来生成一个或者一组所需要的类的数量的输出。因此,在神经网络层230中可以包括多层隐含层(如图5所示的231、232至23n)以及输出层240,该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括图像识别,图像分类,图像超分辨率重建等等。After processing by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as mentioned above, the convolutional layer/pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (required class information or other related information), the convolutional neural network 200 needs to use the neural network layer 230 to generate one or a group of required classes of output. Therefore, the neural network layer 230 may include multiple hidden layers (231, 232 to 23n as shown in FIG. 5) and an output layer 240. The parameters contained in the multiple hidden layers can be based on specific task types. The relevant training data of the, for example, the task type can include image recognition, image classification, image super-resolution reconstruction and so on.
在神经网络层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整个卷积神经网络200的前向传播(如图5由210至240方向的传播为前向传播)完成,反向传播(如图5由240至210方向的传播为反向传播)就会开始更新前面提到的各层的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。After the multiple hidden layers in the neural network layer 230, that is, the final layer of the entire convolutional neural network 200 is the output layer 240. The output layer 240 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 200 (as shown in Figure 5, the propagation from the direction 210 to 240 is forward propagation) is completed, the back propagation (as shown in Figure 5, the propagation from the direction 240 to 210 is the back propagation) Start to update the weight values and deviations of the aforementioned layers to reduce the loss of the convolutional neural network 200 and the error between the output result of the convolutional neural network 200 through the output layer and the ideal result.
本申请实施例的图像处理方法具体采用的神经网络的结构可以如图6所示。在图6中,卷积神经网络(CNN)200可以包括输入层110,卷积层/池化层120(其中池化层为可选的),以及神经网络层130。与图5相比,图6中的卷积层/池化层120中的多个卷积层/池化层并行,将分别提取的特征均输入给全神经网络层130进行处理。The structure of the neural network specifically adopted by the image processing method of the embodiment of the present application may be as shown in FIG. 6. In FIG. 6, a convolutional neural network (CNN) 200 may include an input layer 110, a convolutional layer/pooling layer 120 (the pooling layer is optional), and a neural network layer 130. Compared with FIG. 5, multiple convolutional layers/pooling layers in the convolutional layer/pooling layer 120 in FIG. 6 are parallel, and the respectively extracted features are input to the full neural network layer 130 for processing.
需要说明的是,图5和图6所示的卷积神经网络仅作为一种本申请实施例的图像处理方法的两种可能的卷积神经网络的示例,在具体的应用中,本申请实施例的图像处理方法所采用的卷积神经网络还可以以其他网络模型的形式存在。It should be noted that the convolutional neural network shown in FIGS. 5 and 6 is only used as an example of two possible convolutional neural networks in the image processing method of the embodiment of the application. In specific applications, the application implements The convolutional neural network used in the image processing method of the example can also exist in the form of other network models.
另外,采用本申请实施例的神经网络结构的搜索方法得到的卷积神经网络的结构可以如图5和图6中的卷积神经网络结构所示。In addition, the structure of the convolutional neural network obtained by the search method of the neural network structure of the embodiment of the present application may be as shown in the convolutional neural network structure in FIG. 5 and FIG. 6.
图7为本申请实施例提供的一种芯片的硬件结构,该芯片包括神经网络处理器50。该芯片可以被设置在如图1所示的执行设备110中,用以完成计算模块111的计算工作。该芯片也可以被设置在如图1所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则101。如图2所示的卷积神经网络中各层的算法均可在如图7所示的芯片中得以实现。FIG. 7 is a hardware structure of a chip provided by an embodiment of the application. The chip includes a neural network processor 50. The chip may be set in the execution device 110 as shown in FIG. 1 to complete the calculation work of the calculation module 111. The chip can also be set in the training device 120 as shown in FIG. 1 to complete the training work of the training device 120 and output the target model/rule 101. The algorithms of each layer in the convolutional neural network as shown in FIG. 2 can be implemented in the chip as shown in FIG. 7.
神经网络处理器NPU 50 NPU作为协处理器挂载到主中央处理器(central processing unit,CPU)(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路50,控制器504控制运算电路503提取存储器(权重存储器或输入存储器)中的数据并进行运算。Neural Network Processor NPU 50 The NPU is mounted as a co-processor to a main central processing unit (central processing unit, CPU) (host CPU), and the main CPU distributes tasks. The core part of the NPU is the arithmetic circuit 50. The controller 504 controls the arithmetic circuit 503 to extract data from the memory (weight memory or input memory) and perform calculations.
在一些实现中,运算电路503内部包括多个处理单元(process engine,PE)。在一些实现中,运算电路503是二维脉动阵列。运算电路503还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路503是通用的矩阵处理器。In some implementations, the arithmetic circuit 503 includes multiple processing units (process engines, PE). In some implementations, the arithmetic circuit 503 is a two-dimensional systolic array. The arithmetic circuit 503 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 503 is a general-purpose matrix processor.
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器502中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器501中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)508中。For example, suppose there is an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit fetches the corresponding data of matrix B from the weight memory 502 and buffers it on each PE in the arithmetic circuit. The arithmetic circuit fetches matrix A data and matrix B from the input memory 501 to perform matrix operations, and the partial or final result of the obtained matrix is stored in an accumulator 508.
向量计算单元507可以对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元507可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。The vector calculation unit 507 can perform further processing on the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison and so on. For example, the vector calculation unit 507 can be used for network calculations in the non-convolutional/non-FC layer of the neural network, such as pooling, batch normalization, local response normalization, etc. .
在一些实现种,向量计算单元能507将经处理的输出的向量存储到统一缓存器506。例如,向量计算单元507可以将非线性函数应用到运算电路503的输出,例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元507生成归一化的值、合并值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路503的激活输入,例如用于在神经网络中的后续层中的使用。In some implementations, the vector calculation unit 507 can store the processed output vector in the unified buffer 506. For example, the vector calculation unit 507 may apply a nonlinear function to the output of the arithmetic circuit 503, such as a vector of accumulated values, to generate the activation value. In some implementations, the vector calculation unit 507 generates a normalized value, a combined value, or both. In some implementations, the processed output vector can be used as an activation input to the arithmetic circuit 503, for example for use in subsequent layers in a neural network.
统一存储器506用于存放输入数据以及输出数据。The unified memory 506 is used to store input data and output data.
权重数据直接通过存储单元访问控制器505(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器501和/或统一存储器506、将外部存储器中的权重数据存入权重存储器502,以及将统一存储器506中的数据存入外部存储器。The weight data directly transfers the input data in the external memory to the input memory 501 and/or the unified memory 506 through the storage unit access controller 505 (direct memory access controller, DMAC), and stores the weight data in the external memory into the weight memory 502, And the data in the unified memory 506 is stored in the external memory.
总线接口单元(bus interface unit,BIU)510,用于通过总线实现主CPU、DMAC和取指存储器509之间进行交互。The bus interface unit (BIU) 510 is used to implement interaction between the main CPU, the DMAC, and the fetch memory 509 through the bus.
与控制器504连接的取指存储器(instruction fetch buffer)509,用于存储控制器504使用的指令;An instruction fetch buffer 509 connected to the controller 504 is used to store instructions used by the controller 504;
控制器504,用于调用指存储器509中缓存的指令,实现控制该运算加速器的工作过程。The controller 504 is configured to call the instructions cached in the memory 509 to control the working process of the computing accelerator.
入口:可以根据实际发明说明这里的数据是说明数据,比如探测到车辆速度?障碍物距离等Entrance: It can be explained according to the actual invention that the data here is explanatory data, such as the detected vehicle speed? Obstacle distance etc.
一般地,统一存储器506,输入存储器501,权重存储器502以及取指存储器509均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,简称DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。Generally, the unified memory 506, the input memory 501, the weight memory 502, and the instruction fetch memory 509 are all on-chip (On-Chip) memories, and the external memory is a memory external to the NPU. The external memory can be a double data rate synchronous dynamic random access memory. Memory (double data rate synchronous dynamic random access memory, referred to as DDR SDRAM), high bandwidth memory (HBM) or other readable and writable memory.
其中,图2所示的卷积神经网络中各层的运算可以由运算电路303或向量计算单元307执行。Among them, the operations of each layer in the convolutional neural network shown in FIG. 2 can be executed by the arithmetic circuit 303 or the vector calculation unit 307.
上文中介绍的图4中的执行设备110能够执行本申请实施例的图像处理方法或者图像处理方法的各个步骤,图5和图6所示的CNN模型和图7所示的芯片也可以用于执行本申请实施例的图像处理方法或者图像处理方法的各个步骤。下面结合附图对本申请实施例的图像处理方法和本申请实施例的图像处理方法进行详细的介绍。The execution device 110 in FIG. 4 introduced above can execute the image processing method or the steps of the image processing method of the embodiment of the present application. The CNN model shown in FIG. 5 and FIG. 6 and the chip shown in FIG. 7 can also be used for Perform the image processing method or each step of the image processing method in the embodiment of the application. The image processing method of the embodiment of the present application and the image processing method of the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
如图8所示,本申请实施例提供了一种***架构300。该***架构包括本地设备301、本地设备302以及执行设备210和数据存储***250,其中,本地设备301和本地设备302通过通信网络与执行设备210连接。As shown in FIG. 8, an embodiment of the present application provides a system architecture 300. The system architecture includes a local device 301, a local device 302, an execution device 210 and a data storage system 250, where the local device 301 and the local device 302 are connected to the execution device 210 through a communication network.
执行设备210可以由一个或多个服务器实现。可选的,执行设备210可以与其它计算设备配合使用,例如:数据存储器、路由器、负载均衡器等设备。执行设备210可以布置在一个物理站点上,或者分布在多个物理站点上。执行设备210可以使用数据存储***250中的数据,或者调用数据存储***250中的程序代码来实现本申请实施例的搜索神经网络结构的方法。The execution device 210 may be implemented by one or more servers. Optionally, the execution device 210 can be used in conjunction with other computing devices, such as data storage, routers, load balancers and other devices. The execution device 210 may be arranged on one physical site or distributed on multiple physical sites. The execution device 210 may use the data in the data storage system 250 or call the program code in the data storage system 250 to implement the method for searching the neural network structure of the embodiment of the present application.
具体地,执行设备210可以执行以下过程:确定搜索空间和多个构建单元;堆叠所述多个构建单元,以得到搜索网络,所述搜索网络是用于搜索神经网络结构的神经网络;在所述搜索空间内对所述搜索网络中的构建单元的网络结构进行优化,以得到优化后的构建 单元,其中,在优化过程中搜索空间逐渐减小,构建单元数量逐渐增加,搜索空间的减小和构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内;根据所述优化后的构建单元搭建所述目标神经网络。Specifically, the execution device 210 may perform the following process: determine a search space and multiple building units; stack the multiple building units to obtain a search network, which is a neural network used to search for a neural network structure; The network structure of the building units in the search network is optimized in the search space to obtain optimized building units, wherein the search space gradually decreases during the optimization process, the number of building units gradually increases, and the search space decreases And the increase in the number of construction units makes the video memory consumption generated in the optimization process within a preset range; the target neural network is built according to the optimized construction unit.
通过上述过程执行设备210能够搭建成一个目标神经网络,该目标神经网络可以用于图像分类或者进行图像处理等等。Through the foregoing process execution device 210, a target neural network can be built, and the target neural network can be used for image classification or image processing.
用户可以操作各自的用户设备(例如本地设备301和本地设备302)与执行设备210进行交互。每个本地设备可以表示任何计算设备,例如个人计算机、计算机工作站、智能手机、平板电脑、智能摄像头、智能汽车或其他类型蜂窝电话、媒体消费设备、可穿戴设备、机顶盒、游戏机等。The user can operate respective user devices (for example, the local device 301 and the local device 302) to interact with the execution device 210. Each local device can represent any computing device, such as personal computers, computer workstations, smart phones, tablets, smart cameras, smart cars or other types of cellular phones, media consumption devices, wearable devices, set-top boxes, game consoles, etc.
每个用户的本地设备可以通过任何通信机制/通信标准的通信网络与执行设备210进行交互,通信网络可以是广域网、局域网、点对点连接等方式,或它们的任意组合。Each user's local device can interact with the execution device 210 through a communication network of any communication mechanism/communication standard. The communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof.
在一种实现方式中,本地设备301、本地设备302从执行设备210获取到目标神经网络的相关参数,将目标神经网络部署在本地设备301、本地设备302上,利用该目标神经网络进行图像分类或者图像处理等等。In one implementation, the local device 301 and the local device 302 obtain the relevant parameters of the target neural network from the execution device 210, deploy the target neural network on the local device 301 and the local device 302, and use the target neural network for image classification Or image processing and so on.
在另一种实现中,执行设备210上可以直接部署目标神经网络,执行设备210通过从本地设备301和本地设备302获取待处理图像,并根据目标神经网络对待处理图像进行分类或者其他类型的图像处理。In another implementation, the target neural network can be directly deployed on the execution device 210. The execution device 210 obtains the image to be processed from the local device 301 and the local device 302, and classifies the image to be processed according to the target neural network or other types of images. deal with.
上述执行设备210也可以称为云端设备,此时执行设备210一般部署在云端。The above-mentioned execution device 210 may also be referred to as a cloud device. At this time, the execution device 210 is generally deployed in the cloud.
下面先结合图9对本申请实施例的神经网络的构建方法进行详细的介绍。图9所示的方法可以由神经网络构建装置来执行,该神经网络构建装置可以是电脑、服务器等运算能力足以用来神经网络构建装置。The method for constructing a neural network in an embodiment of the present application will be described in detail below with reference to FIG. 9. The method shown in FIG. 9 can be executed by a neural network construction device, which can be a computer, a server, or the like with sufficient computing power to be used for the neural network construction device.
图9所示的方法包括步骤1001至1004,下面分别对这些步骤进行详细的描述。The method shown in FIG. 9 includes steps 1001 to 1004, which are described in detail below.
1001、确定搜索空间和多个构建单元。1001. Determine the search space and multiple building units.
其中,上述搜索空间是根据待构建的目标神经网络的应用需求确定的。具体地,上述搜索空间可以是根据目标神经网络的处理数据的类型确定的。Among them, the aforementioned search space is determined according to the application requirements of the target neural network to be constructed. Specifically, the aforementioned search space may be determined according to the type of processed data of the target neural network.
例如,当上述目标神经网络用于处理图像数据的神经网络时,上述搜索空间包含的操作的种类和数量要与图像数据的处理相适应;当上述目标神经网络用于处理语音数据时,述搜索空间包含的操作的种类和数量要与语音数据的处理相适应。For example, when the above-mentioned target neural network is used to process image data, the type and number of operations contained in the above-mentioned search space should be adapted to the processing of image data; when the above-mentioned target neural network is used to process voice data, the search The type and number of operations contained in the space should be adapted to the processing of voice data.
上述多个构建单元是根据搜索空间以及构建目标神经网络的设备的显存资源的大小确定的。另外,本申请中的构建单元是由多个节点之间通过神经网络的基本操作连接得到的一种网络结构,构建单元是用于构建神经网络的基础模块。The foregoing multiple construction units are determined according to the search space and the size of the video memory resources of the device that constructs the target neural network. In addition, the building unit in this application is a network structure obtained by connecting multiple nodes through the basic operation of a neural network, and the building unit is a basic module for building a neural network.
如图10所示,位于虚线框内的3个节点(节点0,节点1和节点2)构成了一个构建单元,该构建单元可以接收节点c_{k-2}和c_{k-1}输出的数据(c_{k-2}和c_{k-1}也可以是符合要求的特征图,例如,c_{k-2}和c_{k-1}可以是输入图像经过一定的卷积处理后得到的特征图),并由节点0和1分别对输入的数据进行处理,其中,节点0输出的数据还会输入到节点1中进行处理,节点0和节点1输出的数据会送入到节点2中进行处理,节点2最终输出该构建单元处理完的数据。As shown in Figure 10, the 3 nodes (node 0, node 1 and node 2) located in the dashed box constitute a building unit that can receive the output of nodes c_{k-2} and c_{k-1} The data (c_{k-2} and c_{k-1} can also be feature maps that meet the requirements. For example, c_{k-2} and c_{k-1} can be input images that have undergone certain convolution processing The feature map obtained later), and the input data will be processed by nodes 0 and 1. The data output by node 0 will also be input to node 1 for processing, and the data output by node 0 and node 1 will be sent to Processing is performed in node 2, and node 2 finally outputs the data processed by the construction unit.
另外,上述节点c_{k-2}和c_{k-1}可以视为输入节点,这两个节点会向构建单元输入待处理的数据,而在构建单元内部,0和1是中间节点,节点2是输出节点。In addition, the above-mentioned nodes c_{k-2} and c_{k-1} can be regarded as input nodes. These two nodes will input the data to be processed into the construction unit. In the construction unit, 0 and 1 are intermediate nodes. Node 2 is the output node.
图10中的粗箭头表示一个或者多个基本操作,汇入同一个中间节点的基本操作运算结果在该中间节点处相加,图10中的细箭头表示通道维度的特征图连接,输出节点2输出的特征图由2个中间节点(节点0和节点1)的输出按照顺序在特征图通道维度连接而成。The thick arrow in Figure 10 represents one or more basic operations. The calculation results of the basic operations that are imported into the same intermediate node are added at the intermediate node. The thin arrow in Figure 10 represents the feature map connection of the channel dimension, and the output node 2 The output feature map is formed by connecting the outputs of two intermediate nodes (node 0 and node 1) in the channel dimension of the feature map in order.
应理解,图10中的粗箭头和细箭头所对应的操作应是特定情况下涉及的操作,这里的相加和通道维度连接在此处都是为卷积神经网络而设计的,在其他情况下,构建单元的节点之间所对应的操作也可以是其他类型的运算或操作。It should be understood that the operations corresponding to the thick and thin arrows in Figure 10 should be operations involved in specific situations. The addition and channel dimension connections here are all designed for convolutional neural networks. In other cases Below, the operations corresponding to the nodes of the construction unit can also be other types of operations or operations.
上述搜索空间包含的可以是预先设定好的卷积神经网络中的基础运算或者基础运算的组合,这些基础运算或者基础运算的组合可以统称为基本操作。The aforementioned search space may include basic operations or a combination of basic operations in a preset convolutional neural network, and these basic operations or combinations of basic operations may be collectively referred to as basic operations.
上述搜索空间可以包含以下8种基本操作:The above search space can contain the following 8 basic operations:
(1)池化核大小为3×3的均值池化(avg_pool_3x3);(1) Average pooling with a core size of 3×3 (avg_pool_3x3);
(2)池化核大小为3×3的最大值池化(max_pool_3x3);(2) Pooling core size is 3×3 maximum pooling (max_pool_3x3);
(3)卷积核大小为3×3的分离卷积(sep_conv_3x3);(3) Separate convolution (sep_conv_3x3) with a convolution kernel size of 3×3;
(4)卷积核大小为5×5的分离卷积(sep_conv_5x5);(4) Separate convolution (sep_conv_5x5) with a convolution kernel size of 5×5;
(5)卷积核大小为3×3且空洞率为2的空洞卷积(dil_conv_3x3);(5) A hole convolution with a convolution kernel size of 3×3 and a hole rate of 2 (dil_conv_3x3);
(6)卷积核大小为5×5且空洞率为2的空洞卷积(dil_conv_5x5);(6) Hole convolution (dil_conv_5x5) with a convolution kernel size of 5×5 and a hole rate of 2;
(7)跳连接操作;(7) Jump connection operation;
(8)置零操作(Zero,相应位置所有神经元置零)。(8) Zero setting operation (Zero, all neurons in the corresponding position are set to zero).
1002、堆叠多个构建单元,以得到搜索网络。1002. Stack multiple building units to obtain a search network.
上述搜索网络是用于搜索神经网络结构的神经网络。The above-mentioned search network is a neural network for searching the structure of a neural network.
可选地,上述堆叠多个构建单元,以得到搜索网络,包括:按照预设的堆叠方式将所述多个构建单元依次堆叠起来,以得到搜索网络,其中,在该搜索网络中,位于搜索网络前面的构建单元的输出是位于搜索网络的后面的构建单元的输入。Optionally, the foregoing stacking of multiple building units to obtain a search network includes: stacking the multiple building units in sequence in a preset stacking manner to obtain a search network, wherein, in the search network, the search network is located The output of the building unit in front of the network is the input of the building unit located in the back of the search network.
上述预设的堆叠方式可以包括在什么位置堆放什么类型的构建单元以及堆叠的数量等等。The foregoing preset stacking manner may include what type of building units are stacked at which position, the number of stacks, and so on.
1003、在搜索空间内对搜索网络中的构建单元的网络结构进行优化,以得到优化后的构建单元。1003. Optimize the network structure of the construction unit in the search network in the search space to obtain an optimized construction unit.
其中,对搜索网络中的构建单元的网络结构进行优化的优化过程可以包括N个阶段,第i个阶段和第j个阶段为N个阶段中的任意两个阶段,搜索空间在第i个阶段的大小大于搜索网络在第j个阶段的大小,搜索网络在第i个阶段时包含的构建单元的数量小于搜索空间在第j个阶段时包含的构建单元的数量,搜索网络的搜索空间的减小和搜索网络的构建单元数量的增加使得优化过程中产生的显存消耗在预设范围内。Among them, the optimization process of optimizing the network structure of the building unit in the search network can include N stages, the i-th stage and the j-th stage are any two stages of the N stages, and the search space is in the i-th stage The size of is greater than the size of the search network in the j-th stage, the number of building units included in the search network in the i-th stage is less than the number of building units in the search space in the j-th stage, the search space of the search network is reduced The increase in the number of building units of the small and search network makes the memory consumption of the optimization process within the preset range.
另外,在优化过程结束后,搜索网络在第N个阶段包含的构建单元的数量与目标神经网络包含的构建单元的数量的差异在预设范围内,上述目标神经网络包含的构建单元的数量是根据目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j。In addition, after the optimization process is over, the difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is within a preset range. The number of building units included in the above target neural network is Determined according to the application requirements of the target neural network, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j.
可选地,上述显存资源可以替换为缓存资源,该缓存资源是用于构建神经网络的设备在优化过程中用于存放运算数量的内存或者存储单元。Optionally, the above-mentioned video memory resource may be replaced with a cache resource. The cache resource is a memory or storage unit used to store the number of calculations during the optimization process of the device used to construct the neural network.
上述缓存资源具体可以包括显存资源。The foregoing cache resources may specifically include video memory resources.
可选地,上述目标神经网络包含的构建单元的数量是根据目标神经网络要处理的数据类型和/或计算的复杂度确定的。Optionally, the number of building units included in the target neural network is determined according to the type of data to be processed by the target neural network and/or the complexity of calculation.
例如,当上述目标神经网络用于处理一些简单的文本数据时,目标神经网络包含较少数量的构建单元即可,当上述目标神经网络用于处理一些比较复杂的图像数据时,目标神经网络需要包含数量较多的构建单元。For example, when the above target neural network is used to process some simple text data, the target neural network only needs to contain a smaller number of building units. When the above target neural network is used to process some more complex image data, the target neural network needs Contains a large number of building units.
再如,当目标神经网络需要处理的数据复杂度较高时,目标神经网络需要包含数量较多的构建单元;当目标神经网络需要处理的数据复杂度较低时,目标神经网络需要较少数量的构建单元即可。For another example, when the target neural network needs to process data with high complexity, the target neural network needs to contain a larger number of building units; when the target neural network needs to process data with low complexity, the target neural network needs a smaller number The building unit can be.
可选地,上述N的大小是预先设置好的。Optionally, the above-mentioned size of N is preset.
上述N的大小可以根据目标神经网络的构建需求来确定。具体地,当目标神经网络需要在较短的时间内构建完成时,可以将N设置成一个较小的数值,当目标神经网络可以在较长的时间内构建完成时,可以将N设置成一个较大的数值。The size of the above N can be determined according to the construction requirements of the target neural network. Specifically, when the target neural network needs to be constructed in a relatively short time, N can be set to a small value, and when the target neural network can be constructed in a relatively long time, N can be set to a Larger value.
1004、根据优化后的构建单元搭建目标神经网络。1004. Build a target neural network according to the optimized construction unit.
本申请中,在对构建单元的网络结构进行优化的过程中,减少搜索空间节省的显存资源可以用来增加构建单元的数量,从而能够在在显存资源有限的情况下,尽可能的堆叠得到构建单元数量与最终要搭建的目标神经网络的构建单元数量比较接近的搜索网络。使得搜索网络优化后的构建单元能够更好地适用于目标神经网络的搭建,进而使得根据优化后的构建单元搭建成的目标神经网络能够更好地满足应用需求。In this application, in the process of optimizing the network structure of the building unit, the video memory resources saved by reducing the search space can be used to increase the number of building units, so that the building can be stacked as much as possible under the condition of limited video memory resources. A search network whose number of units is close to that of the target neural network to be built. The optimized building unit of the search network can be better adapted to the construction of the target neural network, and the target neural network built according to the optimized building unit can better meet the application requirements.
具体而言,本申请在搜索网络的构建单元的网络结构的优化过程中,通过逐渐减少搜索空间的大小,并增加搜索网络的构建单元的数量,能够在构建出能够较好满足应用需求的目标神经网络的情况下,减少优化过程显存资源的依赖,使得在优化过程中仅仅依赖较少的显存资源就能够得到较好的满足应用需求的目标神经网络,也在一定程度上提高了显存资源的利用率。Specifically, in the process of optimizing the network structure of the construction unit of the search network, the application gradually reduces the size of the search space and increases the number of construction units of the search network, so as to construct a goal that can better meet the needs of the application. In the case of neural network, the dependence of the video memory resources in the optimization process is reduced, so that the target neural network that satisfies the application needs can be obtained by relying on less video memory resources in the optimization process, and it also improves the memory resources to a certain extent. Utilization rate.
一般地,如果搜索网络的网络深度与待构建的目标神经网络的网络深度比较接近时,搜索网络中优化得到的构建单元比较适合由于搭建目标神经网络。神经网络的深度与包含的构建单元的数量是正相关的关系,因此,当搜索网络的构建单元的数量与目标神经网络的构建单元数量比较接近时,搜索网络的网络深度与目标神经网络的网络深度也比较接近。Generally, if the network depth of the search network is relatively close to the network depth of the target neural network to be constructed, the optimized construction unit in the search network is more suitable for building the target neural network. The depth of the neural network is positively correlated with the number of building units contained. Therefore, when the number of building units of the search network is close to the number of building units of the target neural network, the network depth of the search network is the same as that of the target neural network. Also relatively close.
应理解,在上述优化过程中,从第i个阶段到第j个阶段,搜索空间的变小,搜索网络的构建单元的数量增加,并且,从第i个阶段到第j个阶段,搜索空间减小的幅度可以是构建单元数量增加的幅度是相同的。从第i个阶段到第j个阶段搜索空间减小的幅度可以根据第i个阶段到第j个阶段搜索网络的构建单元的数量增加的数量来确定,或者,从第i个阶段到第j个阶段搜索网络的构建单元的数量增加的数量可以根据第i个阶段到第j个阶段搜索空间减小的幅度来确定。It should be understood that in the above optimization process, from the i-th stage to the j-th stage, the search space becomes smaller and the number of building units of the search network increases, and from the i-th stage to the j-th stage, the search space The magnitude of the decrease may be the same as the magnitude of the increase in the number of building units. The extent of the reduction of the search space from the i-th stage to the j-th stage can be determined according to the increase in the number of building units of the search network from the i-th stage to the j-th stage, or from the i-th stage to the j-th stage The number of increase in the number of construction units of the search network in each stage can be determined according to the decrease in the search space from the i-th stage to the j-th stage.
或者,也可以结合显存资源的大小,来一起确定第i个阶段到第j个阶段搜索空间减小的幅度以及第i个阶段到第j个阶段搜索网络的构建单元的数量增加的数量。Alternatively, the size of the video memory resources can also be combined to determine the extent of the reduction in the search space from the i-th stage to the j-th stage and the increase in the number of construction units of the search network from the i-th stage to the j-th stage.
可选地,上述搜索空间在第i个阶段的大小为S i,上述搜索空间在第j个阶段的大小为S j,上述搜索网络在第i个阶段包含的构建单元数量为L i个,上述搜索网络在第j个阶段包含的构建单元数量为L j个,其中,上述L j-L i大小是根据S i-S j的大小确定的,或者, 上述S i-S j的大小是根据L j-L i的大小确定的。 Optionally, the size of the search space for the i-th stage S i, S j of the above-described search space size in the j-th stage, the number of the search network construction unit included in the i-th stage is L i, The number of construction units included in the jth stage of the search network is L j , where the size of L j -L i is determined according to the size of S i -S j , or the size of S i -S j is Determined according to the size of L j -L i .
具体地,在上述两个阶段中,可以预先设定S i-S j的大小,然后再根据S i-S j的大小确定L j-L i的大小,使得由于搜索空间减小节省的显存资源与构建单元增加导致多消耗的显存资源的差值在一定阈值范围内(两者的差值越小越好)。 Specifically, in the above two stages, the size of S i -S j can be preset, and then the size of L j -L i can be determined according to the size of S i -S j , so that the video memory saved due to the reduced search space The increase in resources and building units causes the difference between the more consumed video memory resources to be within a certain threshold (the smaller the difference, the better).
在上述两个阶段中,也可以预先设定L j-L i的大小,然后再根据L j-L i的大小确定S i-S j的大小,使得由于构建单元增加导致多消耗的显存资源与搜索空间减小节省的显存资源的差值在一定阈值范围内(两者的差值越小越好)。 In the above two stages, the size of L j -L i can also be preset, and then the size of S i -S j is determined according to the size of L j -L i , so that the increase in the building unit causes more memory resources to be consumed The difference between the memory resources saved by reducing the search space and the search space is within a certain threshold (the smaller the difference, the better).
在本申请中,只要上述N个阶段中存在至少两个阶段满足搜索空间减小,构建单元数量增加即可,而不必使得每两个相邻的阶段都满足搜索空间减小,构建单元数量增加的要求。In this application, as long as there are at least two of the above N stages that satisfy the search space reduction and increase the number of construction units, it is not necessary to make every two adjacent stages satisfy the search space reduction and increase the number of construction units. Requirements.
例如,上述N=4,第2个阶段相比于第1阶段以及第4阶段相对于第3阶段均满足:搜索空间减小,搜索网络的构建单元数量增加。而第2个阶段和第3个阶段的搜索空间以及搜索网络包含的构建单元数量均没有发生变化。For example, the above N=4, the second stage is compared with the first stage and the fourth stage is satisfied with the third stage: the search space is reduced, and the number of construction units of the search network is increased. However, the search space and the number of building units contained in the search network in the second and third phases have not changed.
当然,如果上述N个阶段中的每两个阶段之间都满足搜索空间减小,构建单元数量增加,那么,将会使得N个阶段的优化过程中搜索空间与构建单元的数量变化更加平滑。Of course, if the search space is reduced and the number of construction units is increased between every two of the above N stages, the changes in the search space and the number of construction units in the optimization process of the N stages will be smoother.
可选地,上述i和j满足:j=i+1。Optionally, the foregoing i and j satisfy: j=i+1.
当j=i+1时,在优化过程中,任意两个相邻阶段之间都会满足搜索空间逐渐减小,搜索网络的构建单元逐渐增加,使得优化过程比较平稳。When j=i+1, in the optimization process, the search space between any two adjacent stages will gradually decrease, and the construction unit of the search network will gradually increase, making the optimization process relatively stable.
可选地,上述N个阶段中,搜索网络在任意两个相邻阶段的构建单元的数量变化值相同,搜索空间在任意两个相邻阶段的大小变化值也相同。Optionally, in the above-mentioned N stages, the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
在上述优化过程中,构建单元的数量变化以及搜索空间的大小变化都是均匀的,优化的过程更加平稳。In the above optimization process, the changes in the number of construction units and the size of the search space are uniform, and the optimization process is more stable.
可选地,上述第i+1个阶段相对于第i个阶段增加的构建单元的数量可以是根据上述数值N,以及搜索网络在优化前包含的构建单元的数量,以及目标神经网络中的构建单元的数量来确定的。Optionally, the number of construction units increased in the i+1th stage relative to the i-th stage may be based on the aforementioned value N, the number of construction units included in the search network before optimization, and the construction of the target neural network The number of units is determined.
例如,搜索网络在第i+1个阶段相对于第i个阶段增加的构建单元的数量为X,优化开始前搜索网络包含的构建单元数量为U,目标神经网络中的构建单元的数量为V,那么,X可以根据公式X=(U-V)/N计算得到。For example, the number of building units increased by the search network in the i+1 stage relative to the i-th stage is X, the number of building units contained in the search network before the optimization starts is U, and the number of building units in the target neural network is V , Then, X can be calculated according to the formula X=(UV)/N.
应理解,在优化过程中,搜索空间的大小降低的幅度以及搜索网络构建单元数量的增加幅度可以根据多种方式来确定,只要能够确保优化过程中搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内即可。It should be understood that in the optimization process, the extent of the reduction in the size of the search space and the extent of the increase in the number of search network construction units can be determined in various ways, as long as the reduction in the search space of the search network during the optimization process and the search The increase in the number of building units of the network makes the memory consumption generated in the optimization process within a preset range.
在实际应用中可以先预先设定搜索空间大小降低的幅度,然后再确定搜索网络构建单元数量增加的幅度;也可以预先设定搜索网络的大小,再确定搜索空间大小降低的幅度。本申请对此不做限定,所有确保显存消耗在预设范围内的实现方式都在本申请的保护范围内。In practical applications, the size of the search space can be reduced in advance, and then the amount of increase in the number of search network construction units can be determined; or the size of the search network can be preset, and then the size of the search space can be reduced. This application does not limit this, and all implementations to ensure that the video memory consumption is within the preset range are within the protection scope of this application.
可选地,优化后的构建单元的各个节点之间的连接关系中包含的第一类操作的数量在预设范围内,第一类操作是不包含神经网络可训练参数的操作。Optionally, the number of the first-type operations included in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first-type operations are operations that do not include the neural network trainable parameters.
本申请通过将第一类操作的数量限制在一定范围,使得最终搭建的目标神经网络的可 训练参数保持在相对稳定的水平,进而使得目标神经网络的性能保持稳定。This application limits the number of operations of the first type to a certain range, so that the trainable parameters of the final target neural network are maintained at a relatively stable level, and the performance of the target neural network remains stable.
应理解,还可以将第一类操作的数量具体限制到某一个数值,这样使得最终得到的目标神经网络中包含固定数量的第一类操作,使得目标神经网络的性能更加稳定。It should be understood that the number of operations of the first type can also be specifically limited to a certain value, so that the final target neural network includes a fixed number of operations of the first type, so that the performance of the target neural network is more stable.
具体地,上述第一类操作是不包含可训练参数的操作,如果此类操作过多会导致包含可训练参数的其他操作较少,从而神经网络总体的可训练参数较少,神经网络的特征表达能力降低。Specifically, the first type of operation mentioned above is an operation that does not contain trainable parameters. If there are too many such operations, it will result in fewer other operations containing trainable parameters, so that the overall neural network has fewer trainable parameters, and the characteristics of the neural network Decreased expression ability.
由于在构建单元数量较多的搜索网络中进行结构搜索稳定性不足,会导致每次搜索得到的构建单元中第一类操作的数量具有一定的差异,搜索得到的神经网络结构(即构建单元)在相应任务上的性能表现波动。限制第一类操作的数量可以使得由搜索得到的神经网络结构搭建的测试网络的可训练参数保持在相对稳定的水平,从而减小在相应任务上的性能波动。Due to the insufficient stability of the structure search in the search network with a large number of construction units, the number of first-type operations in the construction units obtained by each search will have a certain difference. The neural network structure obtained by the search (ie, the construction unit) Fluctuations in performance on corresponding tasks. Limiting the number of operations of the first type can keep the trainable parameters of the test network constructed from the neural network structure obtained by the search at a relatively stable level, thereby reducing performance fluctuations on the corresponding tasks.
为了使得优化后的构建单元的各个节点之间的连接关系中包含的第一类操作的数量在预设范围内,可以在优化过程中对第一类操作的数量进行限制。In order to make the number of operations of the first type included in the connection relationship between the nodes of the optimized construction unit within a preset range, the number of operations of the first type may be limited during the optimization process.
假设将第一类操作的数量直接限制为第一数量,那么,在上述优化过程中,如果构建单元中第一类操作的数量为第一数量,那么,在优化过程中不更改第一类操作的数量;而如果构建单元中第一类操作的数量大于第一数量,那么,可以在优化过程中删减掉部分第一操作使得删减后第一类操作的数量等于第一数量;如果构建单元中第一类操作的数量小于第一类操作,那么,可以在优化过程中增加构建单元的数量,使得优化后构建单元的数量为第一数量。Assuming that the number of operations of the first type is directly limited to the first number, then, in the above optimization process, if the number of operations of the first type in the construction unit is the first number, then the first type of operations are not changed during the optimization process If the number of operations of the first type in the construction unit is greater than the first number, then part of the first operations can be deleted in the optimization process so that the number of operations of the first type after the deletion is equal to the first number; if the construction The number of operations of the first type in the unit is less than the number of operations of the first type, then the number of construction units can be increased in the optimization process, so that the number of construction units after optimization is the first number.
上述将第一类操作限定在固定数量的过程可以称为第一类操作的数量的规范流程,下面对第一类操作的数量的规范流程进行详细介绍。The above-mentioned process of limiting the number of operations of the first type to a fixed number can be referred to as a standardized process for the number of operations of the first type. The following describes the standardized process for the number of operations of the first type in detail.
第一类操作的数量的规范流程可以是根据预先制定的规范规则,在一种类型的构建单元中保留Mc个第一类操作。The normative process for the number of operations of the first type may be based on pre-made normative rules, retaining Mc operations of the first type in a type of building unit.
具体地,如果该类型的构建单元中的第一类操作的数量等于Mc,则直接将输入的构建单元结构输出;否则,执行如下流程:将该类型的构建单元所对应网络结构参数中与第一类操作所对应的相应网络结构参数进行降序排序,若第一类操作的数量小于Mc则根据网络结构生成规则将不在构建单元中的权值最大且符合网络结构生成规则的第一类操作加入构建单元结构,并相应地根据网络结构生成规则以及网络结构参数删除被替换的相应基本操作;若第一类操作的数量大于Mc则从构建单元结构中移除权值最小的第一类操作的,并根据网络结构生成规则以及网络结构参数加入对应的其他基本操作;重复执行本流程直到该种构建单元中的第一类操作的数量等于Mc。Specifically, if the number of operations of the first type in the construction unit of this type is equal to Mc, the input construction unit structure is output directly; otherwise, the following process is executed: The corresponding network structure parameters corresponding to a type of operation are sorted in descending order. If the number of the first type of operation is less than Mc, the first type of operation that is not in the building unit with the largest weight and conforms to the network structure generation rule is added according to the network structure generation rule Construct the unit structure, and delete the corresponding basic operations that are replaced according to the network structure generation rules and network structure parameters; if the number of the first type of operation is greater than Mc, remove the first type of operation with the smallest weight from the construction unit structure , And add corresponding other basic operations according to the network structure generation rules and network structure parameters; repeat this process until the number of the first type of operations in the construction unit is equal to Mc.
上述第一类操作具体可以是跳连接(skip-connect)操作,也可以是置零操作。The first type of operation described above may specifically be a skip-connect operation or a zero-setting operation.
上述搜索网络可以包含多种类型的构建单元,下面简单介绍一下搜索网络包含的常见的构建单元。The above search network can contain multiple types of building units. The following briefly introduces the common building units included in the search network.
可选地,上述搜索网络中的构建单元包括第一类构建单元。Optionally, the building units in the search network include the first type of building units.
其中,第一类构建单元是输入特征图的数量(具体可以是通道数)和大小分别与输出特征图的数量和大小相同的构建单元。Among them, the first type of construction unit is a construction unit in which the number of input feature maps (specifically, the number of channels) and the size are the same as the number and size of output feature maps.
例如,某个第一类构建单元的输入的是大小为C×D1×D2(C为通道数,D1和D2分别是宽和高)的特征图,经过该第一类构建单元处理后输出的特征图的大小仍然是 C×D1×D2。For example, the input of a certain first type of construction unit is a feature map of size C×D1×D2 (C is the number of channels, D1 and D2 are width and height respectively), and the output is processed by the first type of construction unit The size of the feature map is still C×D1×D2.
上述第一类构建单元具体可以是普通单元(normal cell)The above-mentioned first type of building unit may specifically be a normal cell (normal cell)
可选地,上述搜索网络中的构建单元包括第二类构建单元。Optionally, the building unit in the search network includes the second type of building unit.
其中,第二类构建单元的输出特征图的分辨率是输入特征图的1/M,第二类构建单元的输出特图的数量是输入特征图的数量的M倍,M为大于1的正整数。Among them, the resolution of the output feature map of the second type of construction unit is 1/M of the input feature map, the number of output feature maps of the second type of construction unit is M times the number of input feature maps, and M is a positive value greater than 1. Integer.
上述M的取值一般可以是2、4、6和8等数值。The value of M can generally be 2, 4, 6, and 8.
例如,某个第二类构建单元的输入是1个大小为C×D1×D2(C为通道数,D1和D2分别是宽和高,C1和C2的乘积可以表示特征图的分辨率)的特征图,那么,经过该第二类构建单元处理后,得到的1个大小为
Figure PCTCN2020087222-appb-000011
的特征图。
For example, the input of a certain second type of construction unit is 1 size C×D1×D2 (C is the number of channels, D1 and D2 are width and height respectively, and the product of C1 and C2 can represent the resolution of the feature map) Feature map, then, after the second type of building unit is processed, the size of 1 obtained is
Figure PCTCN2020087222-appb-000011
Characteristic map.
上述第二类构建单元具体可以是下采样单元(redution cell)。The above-mentioned second type of construction unit may specifically be a down-sampling unit (redution cell).
当搜索网络由上述第一类构建单元和第二类构建单元组成时,搜索网络的结构可以如图11所示。When the search network is composed of the above-mentioned first type of construction unit and the second type of construction unit, the structure of the search network may be as shown in FIG. 11.
如图11,搜索网络由5个构建单元依次堆叠而成,其中,位于搜索网络最前端和最后端的是第一类构建单元,每两个第一构建单元之间存在一个第二类构建单元。As shown in Figure 11, the search network is formed by stacking 5 building units in turn. Among them, the first type of building unit is located at the front and the last of the search network, and there is a second type of building unit between every two first building units.
图11中的搜索网络中的第一个构建单元能够对输入的图像进行处理,第一类构建单元对图像进行处理后,将处理得到的特征图输入到第二类构建单元进行处理,这样依次向后传输,直到搜索网络中的最后一个第一类构建单元输出特征图。The first building unit in the search network in Figure 11 can process the input image. After the first type of building unit processes the image, the processed feature map is input to the second type of building unit for processing, and so on. Transfer backwards until the last first-type construction unit in the search network outputs the feature map.
搜索网络的最后一个第一类构建单元输出的特征图送入到分类器中进行处理,由分类器根据特征图对图像进行分类。The feature map output by the last first-type construction unit of the search network is sent to the classifier for processing, and the classifier classifies the image according to the feature map.
为了更好地理解本申请实施例的神经网络结构搜索方法,下面结合图12对本申请实施例的神经网络结构搜索方法的整体过程进行简单的介绍。In order to better understand the neural network structure search method of the embodiment of the present application, the following briefly introduces the overall process of the neural network structure search method of the embodiment of the present application with reference to FIG. 12.
如图12所示,可以根据待构建的神经网络的任务需求(也就是待构建的神经网络需要处理任务的任务类型)来确定构建何种类型的神经网络。接下来,再根据该神经网络处理的任务需求,确定搜索空间的大小和构建单元的数量,并对构建单元进行堆叠,得到搜索网络。在得到搜索网络之后就可以对搜索网络中的构建单元的网络结构进行优化(在优化过程中可以采用训练数据进行优化)了,对构建单元的网络结构进行优化可以分为渐进网络结构搜索和操作数量规范流程(就是将某一操作的数量限定在一定的范围内,在本申请中,主要是将第一类操作的数量限制在一定的范围内)。其中,渐进网络结构搜索就是在优化过程中逐渐减小搜索空间的大小,并逐渐增加构建单元的数量以获得与待构建的神经网络的构建单元数目比较接近的搜索网络(具体过程可以参见上文中的图9所示的方法中的相关描述)。操作数量规范流程可以用于确保优化后的构建单元中的第一类操作接的数量在一定的预设范围内。该渐进的网络结构搜索和操作数量规范流程相当于图9所示的方法中的步骤1003的优化过程。As shown in FIG. 12, the type of neural network to be constructed can be determined according to the task requirements of the neural network to be constructed (that is, the task type of the task to be processed by the neural network to be constructed). Next, according to the task requirements processed by the neural network, the size of the search space and the number of construction units are determined, and the construction units are stacked to obtain the search network. After the search network is obtained, the network structure of the building unit in the search network can be optimized (training data can be used for optimization during the optimization process). The optimization of the network structure of the building unit can be divided into progressive network structure search and operation Quantity specification process (that is, limit the quantity of a certain operation within a certain range, in this application, it is mainly to limit the quantity of the first type of operation within a certain range). Among them, the progressive network structure search is to gradually reduce the size of the search space during the optimization process, and gradually increase the number of construction units to obtain a search network that is close to the number of construction units of the neural network to be constructed (see above for the specific process Related description in the method shown in Figure 9). The operation quantity specification process can be used to ensure that the quantity of the first type operation connections in the optimized construction unit is within a certain preset range. This progressive network structure search and operation quantity specification process is equivalent to the optimization process of step 1003 in the method shown in FIG. 9.
本申请实施例的神经网络的构建方法可以由神经网络构建***来执行,图13示出了神经网络构建***执行本申请实施例的神经网络结构搜索方法的过程。下面对图13所示的内容进行详细介绍。The neural network construction method of the embodiment of the application can be executed by the neural network construction system. FIG. 13 shows the process of the neural network construction system executing the neural network structure search method of the embodiment of the application. The content shown in Figure 13 will be described in detail below.
图13所示的神经网络构建***主要包括操作仓库101、渐进网络结构搜索模块102,操作数量规范模块103构成。The neural network construction system shown in FIG. 13 mainly includes an operation warehouse 101, a progressive network structure search module 102, and an operation quantity specification module 103.
其中,操作仓库101可以包含预先设定好的卷积神经网络中的基本操作。渐进网络结构搜索模块102用于对搜索网络的构建单元的网络结构进行优化,在优化过程中,通过增加构建单元1021的堆叠数量,并减小搜索空间的大小来不断的更新搜索网络1022本身,从而实现对搜索网络的构建单元的网络结构的不断优化。Among them, the operation warehouse 101 may include a preset basic operation in the convolutional neural network. The progressive network structure search module 102 is used to optimize the network structure of the construction unit of the search network. In the optimization process, the search network 1022 itself is continuously updated by increasing the stacking number of the construction unit 1021 and reducing the size of the search space. So as to realize the continuous optimization of the network structure of the building unit of the search network.
操作数量规范模块103主要是将某一操作的数量限定在一定的范围内,在本申请中,操作数量规范模块103主要是将第一类操作的数量限制在一定的范围内。The operation quantity specification module 103 mainly restricts the quantity of a certain operation within a certain range. In this application, the operation quantity specification module 103 mainly restricts the quantity of the first type of operation within a certain range.
具体地,可以根据目标任务确定操作仓库101(相当于上文中的搜索空间)的大小和初始数量的构建单元103,然后根据初始数量的构建单元103堆叠得到搜索网络。接下来,可以采用渐进结构搜索模块102对搜索网络进行优化,在优化过程中,逐渐减小搜索空间的大小,增加堆叠单元的数量,得到构建单元。接下来,再通过操作数量规范模块103将渐进网络结构搜索模块102得到的构建单元中的第一类操作限制在一定范围内,从而得到优化后的构建单元,这些优化后构建单元就可以用于搭建最终需要的目标神经网络了。Specifically, the size of the operating warehouse 101 (equivalent to the search space above) and the initial number of construction units 103 can be determined according to the target task, and then the search network can be obtained by stacking the initial number of construction units 103 according to the initial number of construction units 103. Next, the progressive structure search module 102 can be used to optimize the search network. In the optimization process, the size of the search space is gradually reduced, the number of stacking units is increased, and the building unit is obtained. Next, the operation quantity specification module 103 restricts the first type of operations in the building units obtained by the progressive network structure search module 102 to a certain range, so as to obtain optimized building units. These optimized building units can be used for Build the final target neural network.
在图13中,渐进网络结构搜索模块102和操作数量规范模块103处理的过程相当于图9所示的方法中的步骤1003中的优化过程。具体优化过程可参见步骤1003的相关描述。In FIG. 13, the processes processed by the progressive network structure search module 102 and the operation quantity specification module 103 are equivalent to the optimization process in step 1003 in the method shown in FIG. 9. For the specific optimization process, refer to the related description of step 1003.
渐进网络结构搜索模块102进行优化操作的具体过程可以如图14所示。为了方便示意,图14对实际操作进行了一定的简化,只展示了第一类构建单元(具体可以是normal cell)的搜索过程,并且对第一类构建单元的具体示意图也进行了简化,只展示搜索过程,不代表具体结构。图中每一个箭头线代表一种基本操作,操作种类数量在示意图中做了简化;数字方框代表节点,本例中的节点为卷积神经网路的特征图。为了方便展示,我们将每一阶段的节点0和节点1及其对应的基本操作进行了特别展示,如各子图右上部分所示。The specific process of the optimization operation performed by the progressive network structure search module 102 may be as shown in FIG. 14. For ease of illustration, Figure 14 simplifies the actual operation to a certain extent, only showing the search process of the first type of building unit (specifically, normal cell), and the specific schematic diagram of the first type of building unit is also simplified. Show the search process, not the specific structure. Each arrow line in the figure represents a basic operation, and the number of types of operations is simplified in the schematic diagram; the number boxes represent nodes, and the nodes in this example are the feature maps of the convolutional neural network. In order to facilitate the display, we specially display the node 0 and node 1 and the corresponding basic operations of each stage, as shown in the upper right part of each subgraph.
在初始阶段,节点之间的连接由预先定义的搜索空间中所有可能的基本操作组成,图14中采用了5种基本操作,分别由5个带箭头线表示。由构建单元搭建而成的搜索网络拥有B1=5个构建单元,包括3个第一类构建单元和2个第二类构建单元。每种构建单元共享相同的操作和网络结构权值。经过网络参数和网络结构参数的优化,得到学习后的网络结构参数。第一类构建单元的节点0和节点1之间的相应基本操作的权值分别为0.21、0.26、0.18、0.03和0.32(图14中为示出这些权值)。根据预先设定的基本操作删除数量,可以删除权值最小的一个或多个操作。权值最小的一个箭头线(如图14中初始阶段所示,该权值最小的箭头线是节点0到节点1之间的第4个箭头线)所代表基本操作被删除,其余操作在本阶段输出的构建单元结构中被保留。注意,不同节点可以根据相应的网络结构权值进行操作,所保留的基本操作不一定相同。In the initial stage, the connection between nodes is composed of all possible basic operations in the pre-defined search space. Figure 14 uses five basic operations, which are represented by five arrowed lines. The search network built by building units has B1=5 building units, including 3 building units of the first type and 2 building units of the second type. Each construction unit shares the same operation and network structure weights. After optimization of network parameters and network structure parameters, the learned network structure parameters are obtained. The weights of the corresponding basic operations between node 0 and node 1 of the first type of construction unit are 0.21, 0.26, 0.18, 0.03, and 0.32, respectively (the weights are shown in FIG. 14). According to the preset basic operation deletion quantity, one or more operations with the smallest weight can be deleted. The arrow line with the smallest weight (as shown in the initial stage in Figure 14, the arrow line with the smallest weight is the fourth arrow line between node 0 and node 1) represents that the basic operation is deleted, and the remaining operations are in this The structure of the building unit output from the stage is retained. Note that different nodes can operate according to the corresponding network structure weights, and the basic operations retained are not necessarily the same.
本例中的中间阶段只有一个。上一阶段(初始阶段)生成的构建单元结构,每一组节点对之间删去了1种基本操作,剩余4种基本操作。本阶段的搜索网络由上一阶段输出的构建单元搭建而成,拥有更多(B2=11)构建单元。上一阶段在构建单元中删除的基本操作所减少的显存消耗提供了搭建一个构建单元数量更多的搜索网络所需要的额外显存开销,在合理设计的情况下,可以保持稳定的显存使用率。本阶段继续执行与初始阶段相似的搜索网络搭建、网络结构参数优化与构建单元结构生成流程。在本阶段中,节点0和节点1之间的第三个和第四个(按照从左到右的顺序)带箭头线所代表的基本操作在生成的构建单元结构中被删除。There is only one intermediate stage in this example. In the construction unit structure generated in the previous stage (initial stage), one basic operation is deleted between each set of node pairs, and the remaining 4 basic operations are left. The search network at this stage is built from the building units output in the previous stage, with more (B2=11) building units. The video memory consumption reduced by the basic operations deleted in the building units in the previous stage provides the additional video memory overhead required to build a search network with a larger number of building units. Under reasonable design, a stable video memory usage rate can be maintained. This stage continues to perform the search network construction, network structure parameter optimization and construction unit structure generation process similar to the initial stage. In this stage, the basic operations represented by the third and fourth (in order from left to right) with arrow lines between node 0 and node 1 are deleted in the generated building unit structure.
在最终阶段,同样执行与之前阶段相似的搜索网络搭建(B2=17,O3=2)、网络结构 参数优化与构建单元生成流程。在本阶段的构建单元生成流程中,施加除与其他阶段相同的构建单元生成规则之外的额外规则网络结构生成规则,使得生成的构建单元结构具有与相应任务所匹配的结构特点。在本例中,此规则是每一个节点至多保留两种输入基本操作,即根据这一规则以及相应的网络结构参数,节点1和节点3之间的所有基本操作均不保留。最终生成的第一类构建单元如图14中的最终阶段中加粗的带箭头线与相应节点所示。生成的构建单元结构和相应网络结构参数及其相对应的操作种类一起输出给后续模块或流程。In the final stage, the search network construction (B2=17, O3=2), network structure parameter optimization and construction unit generation process similar to the previous stage are also executed. In the construction unit generation process of this stage, additional rules are applied to generate the network structure in addition to the same construction unit generation rules as other stages, so that the generated construction unit structure has structural characteristics that match the corresponding tasks. In this example, the rule is that each node retains at most two basic input operations, that is, according to this rule and the corresponding network structure parameters, all basic operations between node 1 and node 3 are not retained. The finally generated first type of construction unit is shown in the bold arrowed line and corresponding nodes in the final stage in FIG. 14. The generated building unit structure and corresponding network structure parameters and their corresponding operation types are output to subsequent modules or processes together.
上述图13中所示的操作数量规范流程模块103用于将第一类操作的数量约束在固定范围内(具体可以是将第一类操作的数量直接约束为某个数值),下面结合图15对操作数量规范流程模块103执行的具体过程进行描述。The operation quantity specification process module 103 shown in FIG. 13 is used to constrain the quantity of the first type of operation within a fixed range (specifically, the quantity of the first type of operation may be directly constrained to a certain value). The following is combined with FIG. 15 The specific process executed by the operation quantity specification flow module 103 is described.
图15是本申请实施例的操作数量规范模块的处理过程的示意图。如图15所示,输入为渐进网络结构搜索模块输出的构建单元结构和相应网络结构参数及其对应操作种类,输出为操作数量规范后的构建单元结构。应理解,经过操作数量规范模块103处理后输出的构建单元结构中的第一类操作的数量限定在了一个固定数量。FIG. 15 is a schematic diagram of the processing procedure of the operation quantity specification module of the embodiment of the present application. As shown in Figure 15, the input is the construction unit structure output by the progressive network structure search module and the corresponding network structure parameters and their corresponding operation types, and the output is the construction unit structure after the number of operations is standardized. It should be understood that the number of operations of the first type in the construction unit structure output after processing by the operation number specification module 103 is limited to a fixed number.
上述操作数量规范模块103的具体执行过程包括:The specific execution process of the foregoing operation quantity specification module 103 includes:
S1、判断输入的构建单元结构中的第一类操作的数量Mc是否等于预先设定的固定数量M,若Mc=M,则直接输出该构建单元结构,Mc≠M,则继续执行步骤S2。S1. Determine whether the number Mc of the first type of operation in the input construction unit structure is equal to the preset fixed number M, if Mc=M, then directly output the construction unit structure, Mc≠M, then continue to perform step S2.
S2、若Mc>M,则根据相应的网络结构参数和网络结构生成规则,将该构建单元结构中权值最小的一个第一类操作替换成符合网络结构生成规则的其他基本操作;S2, if Mc>M, replace the first type of operation with the smallest weight in the construction unit structure with other basic operations that comply with the network structure generation rules according to the corresponding network structure parameters and network structure generation rules;
若Mc<M,则根据网络结构参数和网络结构生成规则,将不属于该构建单元结构的符合网络结构生成规则的权值最大的第一类操作操作替换相应的其他种类基本操作。If Mc<M, according to the network structure parameters and network structure generation rules, the first type of operation operation that does not belong to the construction unit structure and conforms to the network structure generation rule with the largest weight is replaced by the corresponding other types of basic operations.
S3、在步骤S2生成了构建单元之后,再将该构建单元送入到步骤S1中,继续进行判断。S3. After the building unit is generated in step S2, the building unit is sent to step S1 to continue the judgment.
当S1中判断得到的结果是Mc=M的话,则输出构建单元结构,否则继续执行步骤S2和S3。When the result of the judgment in S1 is Mc=M, the structure of the building unit is output, otherwise, the steps S2 and S3 are continued.
应理解,在上述图15所示的过程中,第一类操作具体可以是跳连接操作。It should be understood that, in the process shown in FIG. 15, the first type of operation may specifically be a jump connection operation.
为了与现有的神经网络的构建方法的性能进行对比,表1给出了相似约束下使用本申请实施例的神经网络的构建方法构建得到的神经网络和使用其他方法设计或搜索得到的神经网络在图像分类数据集上的分类准确率。In order to compare the performance of the existing neural network construction method, Table 1 shows the neural network constructed using the neural network construction method of the embodiment of the application under similar constraints and the neural network designed or searched using other methods. The classification accuracy rate on the image classification data set.
为了对对不同方案的搜索效率,表1中同时给出了对比的神经网络结构的搜索时间。具体地,表1中的CIFR10、CIFR100、ImageNetTop1、ImageNetTop5分别表示分类准确率,其中,CIFAR10、CIFAR100和ImageNet分别是不同的数据集,Top1和Top5是子指标,指在前1个或者5个结果中出现正确结果的比例(准确率)。NASNet-A、AmoebaNet-B、ENAS、PNAS、和DARTS(2ND)分别表示不同的网络结构,搜索开销的大小可以用在单个GPU运行时所需要的时间(这里时间一般用天表示)来表示。In order to search efficiency for different schemes, Table 1 also gives the search time of the contrast neural network structure. Specifically, CIFR10, CIFR100, ImageNetTop1, ImageNetTop5 in Table 1 respectively represent classification accuracy rates. Among them, CIFAR10, CIFAR100, and ImageNet are different data sets, and Top1 and Top5 are sub-indicators, which refer to the first 1 or 5 results. The percentage of correct results (accuracy) in. NASNet-A, AmoebaNet-B, ENAS, PNAS, and DARTS (2ND) respectively represent different network structures, and the size of the search overhead can be expressed by the time required for a single GPU to run (here, the time is generally expressed in days).
从表1中可以看出,使用本申请实施例的神经网络的构建方法构建得到的神经网络的分类准确率比其他方法设计或搜索得到的神经网络在图像分类数据集上的分类准确率更高,并且搜索开销更小,能够在搜索过程节省更多的资源。As can be seen from Table 1, the classification accuracy of the neural network constructed using the neural network construction method of the embodiment of the application is higher than the classification accuracy of the neural network designed or searched by other methods on the image classification data set. , And the search cost is smaller, which can save more resources in the search process.
表1Table 1
网络结构Network structure CIFAR10CIFAR10 CIFAR100CIFAR100 ImageNetTop1ImageNetTop1 ImageNetTop5ImageNetTop5 搜索开销Search overhead
NASNet-ANASNet-A 97.3597.35 -- 74.074.0 91.691.6 18001800
AmoebaNet-BAmoebaNet-B 97.4597.45 -- 74.074.0 91.591.5 31503150
ENASENAS 97.1197.11 -- -- -- 0.50.5
PNASPNAS 96.5996.59 -- 74.274.2 91.991.9 225225
DARTS(2ND)DARTS(2ND) 97.1797.17 82.4682.46 73.173.1 91.091.0 44
SNASSNAS 97.1597.15 -- 72.372.3 90.890.8 1.51.5
本申请This application 97.4597.45 83.4883.48 75.675.6 92.692.6 0.20.2
此外,本申请所提出的神经网络的构建方法中的操作数量规范流程能够有效地提高搜索的稳定性,提升构建得到的神经网络的性能。表2给出了使用操作数量规范流程前和使用操作数量规范流程后的得到的神经网络结构在公开数据集上的性能对比,其中,Run 1表示第一次试验的准确率,Run 2表示第二次试验的准确率,Run 3表示第三次试验的准确率。表2中的平均准确率表示的是第一次试验至第三次试验的平均准确率,表2中的标准差是第一次试验至第三次试验的准确率的标准差。从表2中可以看出,使用操作数量规范流程后得到的神经网络较使用前在性能和稳定性上有明显的提升。In addition, the standardized process of the number of operations in the neural network construction method proposed in this application can effectively improve the stability of search and improve the performance of the constructed neural network. Table 2 shows the comparison of the performance of the neural network structure on the public data set before using the operation quantity specification process and after using the operation quantity specification process. Among them, Run 1 represents the accuracy of the first test, and Run 2 represents the first test. The accuracy of the second test, Run 3 represents the accuracy of the third test. The average accuracy rate in Table 2 represents the average accuracy rate from the first test to the third test, and the standard deviation in Table 2 is the standard deviation of the accuracy rate from the first test to the third test. It can be seen from Table 2 that the performance and stability of the neural network obtained after using the standardized process of the number of operations are significantly improved compared to before use.
表2Table 2
指标index 使用前before use 使用后After use
Run 1Run 1 97.0397.03 97.3197.31
Run 2 Run 2 97.4297.42 97.4297.42
Run 3 Run 3 97.1897.18 97.3197.31
平均准确率Average accuracy 97.2197.21 97.3597.35
标准差Standard deviation 0.160.16 0.050.05
上文结合附图对本申请实施例的神经网络的构建方法进行了详细的介绍,本申请实施例的神经网络的构建方法构建得到的神经网络可以用于图像处理(例如,图像分类)等,下面对这些具体应用进行介绍。The neural network construction method of the embodiment of the application is described in detail above in conjunction with the accompanying drawings. The neural network constructed by the construction method of the neural network of the embodiment of the application can be used for image processing (for example, image classification), etc. Introduce these specific applications.
图16是本申请实施例的图像处理方法的示意性流程图。图16所示的方法包括:FIG. 16 is a schematic flowchart of an image processing method according to an embodiment of the present application. The method shown in Figure 16 includes:
2001、获取待处理图像;2001. Acquire images to be processed;
2002、根据目标神经网络对待处理图像进行分类,得到待处理图像的分类结果。2002. Classify the image to be processed according to the target neural network, and obtain the classification result of the image to be processed.
其中,上述目标神经网络可以是根据图9所示的方法构建得到的。Among them, the above-mentioned target neural network may be constructed according to the method shown in FIG. 9.
本申请中,在目标神经网络构建之前的优化过程中,通过减小搜索空间的大小,增加构建单元的数量,能够尽可能的堆叠得到构建单元数量与最终要搭建的目标神经网络的构建单元数量比较接近的搜索网络。从而使得搜索网络优化后的构建单元能够更好地适用于目标神经网络的搭建,能够获得性能更好的目标神经网络,利用该目标神经网络进行图像分类能够取得较好的图像分类效果(例如,分类结果更准确)。In this application, in the optimization process before the construction of the target neural network, by reducing the size of the search space and increasing the number of construction units, the number of construction units and the number of construction units of the target neural network to be built can be stacked as much as possible Relatively close search network. Therefore, the optimized construction unit of the search network can be better adapted to the construction of the target neural network, and a better performance target neural network can be obtained. Using the target neural network for image classification can achieve better image classification results (for example, The classification result is more accurate).
可选地,上述j=i+1。Optionally, the above j=i+1.
当j=i+1时,在优化过程中,任意两个相邻阶段之间都会满足搜索空间逐渐减小,搜索网络的构建单元逐渐增加,使得优化过程比较平稳。When j=i+1, in the optimization process, the search space between any two adjacent stages will gradually decrease, and the construction unit of the search network will gradually increase, making the optimization process relatively stable.
可选地,上述N个阶段中,搜索网络在任意两个相邻阶段的构建单元的数量变化值相同,搜索空间在任意两个相邻阶段的大小变化值也相同。Optionally, in the above-mentioned N stages, the number change value of the construction unit of the search network in any two adjacent stages is the same, and the size change value of the search space in any two adjacent stages is also the same.
在上述优化过程中,构建单元的数量变化以及搜索空间的大小变化都是均匀的,优化的过程更加平稳。In the above optimization process, the changes in the number of construction units and the size of the search space are uniform, and the optimization process is more stable.
可选地,上述目标神经网络是经过训练图片进行训练得到的神经网络。Optionally, the above-mentioned target neural network is a neural network obtained by training through training pictures.
具体地,可以通过训练图片以及训练图片标记的类别信息对目标神经网络进行训练,训练完成的神经网络就可以用于进行图像分类了。Specifically, the target neural network can be trained by training pictures and the category information marked by the training pictures, and the trained neural network can be used for image classification.
图17是本申请实施例提供的神经网络构建装置的硬件结构示意图。图17所示的神经网络构建装置3000(该装置3000具体可以是一种计算机设备)包括存储器3001、处理器3002、通信接口3003以及总线3004。其中,存储器3001、处理器3002、通信接口3003通过总线3004实现彼此之间的通信连接。FIG. 17 is a schematic diagram of the hardware structure of a neural network construction device provided by an embodiment of the present application. The neural network construction device 3000 shown in FIG. 17 (the device 3000 may specifically be a computer device) includes a memory 3001, a processor 3002, a communication interface 3003, and a bus 3004. Among them, the memory 3001, the processor 3002, and the communication interface 3003 implement communication connections between each other through the bus 3004.
存储器3001可以是只读存储器(read only memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(random access memory,RAM)。存储器3001可以存储程序,当存储器3001中存储的程序被处理器3002执行时,处理器3002用于执行本申请实施例的神经网络的构建方法的各个步骤。The memory 3001 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 3001 may store a program. When the program stored in the memory 3001 is executed by the processor 3002, the processor 3002 is configured to execute each step of the neural network construction method of the embodiment of the present application.
处理器3002可以采用通用的中央处理器(central processing unit,CPU),微处理器,应用专用集成电路(application specific integrated circuit,ASIC),图形处理器(graphics processing unit,GPU)或者一个或多个集成电路,用于执行相关程序,以实现本申请方法实施例的神经网络的构建方法。The processor 3002 may adopt a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more The integrated circuit is used to execute related programs to implement the neural network construction method of the method embodiment of the present application.
处理器3002还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请的神经网络的构建方法的各个步骤可以通过处理器3002中的硬件的集成逻辑电路或者软件形式的指令完成。The processor 3002 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the neural network construction method of the present application can be completed by hardware integrated logic circuits in the processor 3002 or instructions in the form of software.
上述处理器3002还可以是通用处理器、数字信号处理器(digital signal processing,DSP)、专用集成电路(ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器3001,处理器3002读取存储器3001中的信息,结合其硬件完成本神经网络构建装置中包括的单元所需执行的功能,或者执行本申请方法实施例的神经网络的构建方法。The above-mentioned processor 3002 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, Discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory 3001, and the processor 3002 reads the information in the memory 3001, combines its hardware to complete the functions required by the units included in the neural network construction device, or executes the neural network construction method of the method embodiment of the application .
通信接口3003使用例如但不限于收发器一类的收发装置,来实现装置3000与其他设备或通信网络之间的通信。例如,可以通过通信接口3003获取待构建的神经网络的信息以及构建神经网络过程中需要的训练数据。The communication interface 3003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 3000 and other devices or communication networks. For example, the information of the neural network to be constructed and the training data needed in the process of constructing the neural network can be obtained through the communication interface 3003.
总线3004可包括在装置3000各个部件(例如,存储器3001、处理器3002、通信接口3003)之间传送信息的通路。The bus 3004 may include a path for transferring information between various components of the device 3000 (for example, the memory 3001, the processor 3002, and the communication interface 3003).
图18是本申请实施例的图像处理装置的硬件结构示意图。图18所示的图像处理装置4000包括存储器4001、处理器4002、通信接口4003以及总线4004。其中,存储器4001、 处理器4002、通信接口4003通过总线4004实现彼此之间的通信连接。FIG. 18 is a schematic diagram of the hardware structure of an image processing apparatus according to an embodiment of the present application. The image processing apparatus 4000 shown in FIG. 18 includes a memory 4001, a processor 4002, a communication interface 4003, and a bus 4004. Among them, the memory 4001, the processor 4002, and the communication interface 4003 implement communication connections between each other through the bus 4004.
存储器4001可以是ROM,静态存储设备和RAM。存储器4001可以存储程序,当存储器4001中存储的程序被处理器4002执行时,处理器4002和通信接口4003用于执行本申请实施例的图像处理方法的各个步骤。The memory 4001 may be ROM, static storage device and RAM. The memory 4001 may store a program. When the program stored in the memory 4001 is executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute each step of the image processing method of the embodiment of the present application.
处理器4002可以采用通用的,CPU,微处理器,ASIC,GPU或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的图像处理装置中的单元所需执行的功能,或者执行本申请方法实施例的图像处理方法。The processor 4002 may adopt a general-purpose CPU, a microprocessor, an ASIC, a GPU, or one or more integrated circuits to execute related programs to realize the functions required by the units in the image processing apparatus of the embodiment of the present application. Or execute the image processing method in the method embodiment of this application.
处理器4002还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请实施例的图像处理方法的各个步骤可以通过处理器4002中的硬件的集成逻辑电路或者软件形式的指令完成。The processor 4002 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the image processing method of the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 4002 or instructions in the form of software.
上述处理器4002还可以是通用处理器、DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器4001,处理器4002读取存储器4001中的信息,结合其硬件完成本申请实施例的图像处理装置中包括的单元所需执行的功能,或者执行本申请方法实施例的图像处理方法。The aforementioned processor 4002 may also be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and combines its hardware to complete the functions required by the units included in the image processing apparatus of the embodiment of the application, or perform the image processing of the method embodiment of the application. method.
通信接口4003使用例如但不限于收发器一类的收发装置,来实现装置4000与其他设备或通信网络之间的通信。例如,可以通过通信接口4003获取待处理图像。The communication interface 4003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network. For example, the image to be processed can be acquired through the communication interface 4003.
总线4004可包括在装置4000各个部件(例如,存储器4001、处理器4002、通信接口4003)之间传送信息的通路。The bus 4004 may include a path for transferring information between various components of the device 4000 (for example, the memory 4001, the processor 4002, and the communication interface 4003).
图19是本申请实施例的神经网络训练装置的硬件结构示意图。与上述装置3000和装置4000类似,图19所示的神经网络训练装置5000包括存储器5001、处理器5002、通信接口5003以及总线5004。其中,存储器5001、处理器5002、通信接口5003通过总线5004实现彼此之间的通信连接。FIG. 19 is a schematic diagram of the hardware structure of the neural network training device according to an embodiment of the present application. Similar to the aforementioned device 3000 and device 4000, the neural network training device 5000 shown in FIG. 19 includes a memory 5001, a processor 5002, a communication interface 5003, and a bus 5004. The memory 5001, the processor 5002, and the communication interface 5003 implement communication connections between each other through the bus 5004.
在通过图17所示的神经网络构建装置构建得到了神经网络之后,可以通过图19所示的神经网络训练装置5000对该神经网络进行训练,训练得到的神经网络就可以用于执行本申请实施例的图像处理方法了。After the neural network is constructed by the neural network construction device shown in FIG. 17, the neural network can be trained by the neural network training device 5000 shown in FIG. 19, and the trained neural network can be used to implement the implementation of this application. Example image processing method.
具体地,图19所示的装置可以通过通信接口5003从外界获取训练数据以及待训练的神经网络,然后由处理器根据训练数据对待训练的神经网络进行训练。Specifically, the device shown in FIG. 19 can obtain training data and the neural network to be trained from the outside through the communication interface 5003, and then the processor trains the neural network to be trained according to the training data.
应注意,尽管上述装置3000、装置4000和装置5000仅仅示出了存储器、处理器、通信接口,但是在具体实现过程中,本领域的技术人员应当理解,装置3000、装置4000和装置5000还可以包括实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当理解,装置3000、装置4000和装置5000还可包括实现其他附加功能的硬件器件。此外,本领域的技术人员应当理解,装置3000、装置4000和装置5000也可仅仅包括实现本申请实施例所必须的器件,而不必包括图17、图18和图19中所示的全部器件。It should be noted that although the foregoing device 3000, device 4000, and device 5000 only show a memory, a processor, and a communication interface, in a specific implementation process, those skilled in the art should understand that the device 3000, device 4000, and device 5000 may also Including other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 3000, the device 4000, and the device 5000 may also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that the device 3000, the device 4000, and the device 5000 may also only include the components necessary to implement the embodiments of the present application, and not necessarily include all the components shown in FIGS. 17, 18, and 19.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may be aware that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的***、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described system, device, and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的***、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, the functional units in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program code .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application. Should be covered within the scope of protection of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (16)

  1. 一种神经网络的构建方法,其特征在于,包括:A method for constructing a neural network, which is characterized in that it includes:
    确定搜索空间和多个构建单元,其中,所述搜索空间是根据待构建的目标神经网络的应用需求确定的,所述多个构建单元是根据所述搜索空间以及构建所述目标神经网络的设备的显存资源的大小确定的,所述构建单元是由多个节点之间通过神经网络的基本操作连接得到的一种网络结构,所述构建单元是用于构建神经网络的基础模块;Determine a search space and multiple construction units, where the search space is determined according to the application requirements of the target neural network to be constructed, and the multiple construction units are based on the search space and the equipment that constructs the target neural network Is determined by the size of the video memory resources, the construction unit is a network structure obtained by connecting multiple nodes through the basic operation of a neural network, and the construction unit is a basic module for building a neural network;
    堆叠所述多个构建单元,以得到搜索网络,所述搜索网络是用于搜索神经网络结构的神经网络;Stacking the multiple building units to obtain a search network, the search network being a neural network for searching a neural network structure;
    在所述搜索空间内对所述搜索网络中的构建单元的网络结构进行优化,以得到优化后的构建单元;Optimizing the network structure of the building unit in the search network in the search space to obtain an optimized building unit;
    其中,对所述搜索网络中的构建单元的网络结构进行优化的优化过程包括N个阶段,第i个阶段和第j个阶段为所述N个阶段中的任意两个阶段,所述搜索空间在所述第i个阶段的大小大于所述搜索网络在所述第j个阶段的大小,所述搜索网络在所述第i个阶段时包含的构建单元的数量小于所述搜索空间在所述第j个阶段时包含的构建单元的数量,所述搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内,所述搜索网络在第N个阶段包含的构建单元的数量与所述目标神经网络包含的构建单元的数量的差异在预设范围内,所述目标神经网络包含的构建单元的数量是根据所述目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j;Wherein, the optimization process for optimizing the network structure of the construction unit in the search network includes N stages, the i-th stage and the j-th stage are any two stages of the N stages, and the search space When the size of the i-th stage is greater than the size of the search network in the j-th stage, the number of building units included in the search network in the i-th stage is smaller than that of the search space in the The number of construction units included in the j-th stage, the decrease in the search space of the search network and the increase in the number of construction units of the search network make the memory consumption generated during the optimization process within a preset range, so The difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is within a preset range, and the number of building units included in the target neural network is based on the target The application requirements of the neural network are determined, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j;
    根据所述优化后的构建单元搭建所述目标神经网络。Build the target neural network according to the optimized construction unit.
  2. 如权利要求1所述的方法,其特征在于,j=i+1。The method of claim 1, wherein j=i+1.
  3. 如权利要求1或2所述的方法,其特征在于,所述优化后的构建单元的各个节点之间的连接关系中包含的第一类操作的数量在预设范围内,所述第一类操作是不包含神经网络可训练参数的操作。The method according to claim 1 or 2, wherein the number of the first type of operation contained in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first type An operation is an operation that does not contain the trainable parameters of the neural network.
  4. 如权利要求1-3中任一项所述的方法,其特征在于,所述搜索网络中的构建单元包括第一类构建单元,所述第一类构建单元是输入特征图的数量和大小分别与输出特征图的数量和大小相同的构建单元。The method according to any one of claims 1 to 3, wherein the construction unit in the search network comprises a first type of construction unit, and the first type of construction unit is the number and size of the input feature maps. The same number and size of building units as the output feature map.
  5. 如权利要求1-4中任一项所述的方法,其特征在于,所述搜索网络中的构建单元包括第二类构建单元,所述第二类构建单元的输出特征图的分辨率是输入特征图的1/M,所述第二类构建单元的输出特图的数量是输入特征图的数量的M倍,M为大于1的正整数。The method according to any one of claims 1 to 4, wherein the construction unit in the search network comprises a second type of construction unit, and the resolution of the output feature map of the second type of construction unit is input 1/M of the feature map, the number of output feature maps of the second type of construction unit is M times the number of input feature maps, and M is a positive integer greater than 1.
  6. 一种图像处理方法,其特征在于,包括:An image processing method, characterized by comprising:
    获取待处理图像;Obtain the image to be processed;
    根据目标神经网络对所述待处理图像进行分类,得到所述待处理图像的分类结果;Classify the image to be processed according to the target neural network to obtain a classification result of the image to be processed;
    其中,所述目标神经网络由多个优化后的构建单元搭建而成,所述多个优化后的构建单元是通过对搜索网络中的构建单元的网络结构进行N个阶段的优化得到的,第i个阶段和第j个阶段为所述N个阶段中的任意两个阶段,所述搜索空间在所述第i个阶段的大小 大于所述搜索网络在所述第j个阶段的大小,所述搜索网络在所述第i个阶段时包含的构建单元的数量小于所述搜索空间在所述第j个阶段时包含的构建单元的数量,所述搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内,所述搜索网络在第N个阶段包含的构建单元的数量与所述目标神经网络包含的构建单元的数量的差异在预设范围内,所述目标神经网络包含的构建单元的数量是根据所述目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j。Wherein, the target neural network is constructed by a plurality of optimized construction units, and the multiple optimized construction units are obtained by optimizing the network structure of the construction units in the search network in N stages. The i-th stage and the j-th stage are any two of the N stages, the size of the search space in the i-th stage is greater than the size of the search network in the j-th stage, so The number of construction units included in the search network at the i-th stage is smaller than the number of construction units included in the search space at the j-th stage, the reduction in the search space of the search network and the The increase in the number of construction units of the search network makes the video memory consumption in the optimization process within a preset range. The number of construction units included in the search network in the Nth stage is equal to the number of construction units included in the target neural network. The difference in number is within a preset range, the number of building units included in the target neural network is determined according to the application requirements of the target neural network, N is a positive integer greater than 1, and both i and j are less than or equal to N Is a positive integer, and i is less than j.
  7. 如权利要求6所述的方法,其特征在于,j=i+1。The method of claim 6, wherein j=i+1.
  8. 一种神经网络构建装置,其特征在于,包括:A neural network construction device, characterized in that it comprises:
    存储器,用于存储程序;Memory, used to store programs;
    处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行以下过程:The processor is configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute the following process:
    确定搜索空间和多个构建单元,其中,所述搜索空间是根据待构建的目标神经网络的应用需求确定的,所述多个构建单元是根据所述搜索空间以及构建所述目标神经网络的设备的显存资源的大小确定的,所述构建单元是由多个节点之间通过神经网络的基本操作连接得到的一种网络结构,所述构建单元是用于构建神经网络的基础模块;Determine a search space and multiple construction units, where the search space is determined according to the application requirements of the target neural network to be constructed, and the multiple construction units are based on the search space and the equipment that constructs the target neural network Is determined by the size of the video memory resources, the construction unit is a network structure obtained by connecting multiple nodes through the basic operation of a neural network, and the construction unit is a basic module for building a neural network;
    堆叠所述多个构建单元,以得到搜索网络,所述搜索网络是用于搜索神经网络结构的神经网络;Stacking the multiple building units to obtain a search network, the search network being a neural network for searching a neural network structure;
    在所述搜索空间内对所述搜索网络中的构建单元的网络结构进行优化,以得到优化后的构建单元;Optimizing the network structure of the building unit in the search network in the search space to obtain an optimized building unit;
    其中,对所述搜索网络中的构建单元的网络结构进行优化的优化过程包括N个阶段,第i个阶段和第j个阶段为所述N个阶段中的任意两个阶段,所述搜索空间在所述第i个阶段的大小大于所述搜索网络在所述第j个阶段的大小,所述搜索网络在所述第i个阶段时包含的构建单元的数量小于所述搜索空间在所述第j个阶段时包含的构建单元的数量,所述搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内,所述搜索网络在第N个阶段包含的构建单元的数量与所述目标神经网络包含的构建单元的数量的差异在预设范围内,所述目标神经网络包含的构建单元的数量是根据所述目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j;Wherein, the optimization process for optimizing the network structure of the construction unit in the search network includes N stages, the i-th stage and the j-th stage are any two stages of the N stages, and the search space When the size of the i-th stage is greater than the size of the search network in the j-th stage, the number of building units included in the search network in the i-th stage is smaller than that of the search space in the The number of construction units included in the j-th stage, the decrease in the search space of the search network and the increase in the number of construction units of the search network make the memory consumption generated during the optimization process within a preset range, so The difference between the number of building units included in the search network in the Nth stage and the number of building units included in the target neural network is within a preset range, and the number of building units included in the target neural network is based on the target The application requirements of the neural network are determined, N is a positive integer greater than 1, i and j are both positive integers less than or equal to N, and i is less than j;
    根据所述优化后的构建单元搭建所述目标神经网络。Build the target neural network according to the optimized construction unit.
  9. 如权利要求8所述的装置,其特征在于,j=i+1。The apparatus of claim 8, wherein j=i+1.
  10. 如权利要求8或9所述的装置,其特征在于,所述优化后的构建单元的各个节点之间的连接关系中包含的第一类操作的数量在预设范围内,所述第一类操作是不包含神经网络可训练参数的操作。The device according to claim 8 or 9, wherein the number of the first type of operation included in the connection relationship between the nodes of the optimized construction unit is within a preset range, and the first type An operation is an operation that does not contain the trainable parameters of the neural network.
  11. 如权利要求8-10中任一项所述的装置,其特征在于,所述搜索网络中的构建单元包括第一类构建单元,所述第一类构建单元是输入特征图的数量和大小分别与输出特征图的数量和大小相同的构建单元。The device according to any one of claims 8-10, wherein the construction unit in the search network comprises a first type of construction unit, and the first type of construction unit is the number and size of the input feature maps, respectively The same number and size of building units as the output feature map.
  12. 如权利要求8-11中任一项所述的装置,其特征在于,所述搜索网络中的构建单元包括第二类构建单元,所述第二类构建单元的输出特征图的分辨率是输入特征图的 1/M,所述第二类构建单元的输出特图的数量是输入特征图的数量的M倍,M为大于1的正整数。The device according to any one of claims 8-11, wherein the construction unit in the search network comprises a second type of construction unit, and the resolution of the output feature map of the second type of construction unit is input 1/M of the feature map, the number of output feature maps of the second type of construction unit is M times the number of input feature maps, and M is a positive integer greater than 1.
  13. 一种图像处理装置,其特征在于,包括:An image processing device, characterized by comprising:
    存储器,用于存储程序;Memory, used to store programs;
    处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行以下过程:The processor is configured to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is configured to execute the following process:
    获取待处理图像;Obtain the image to be processed;
    根据目标神经网络对所述待处理图像进行分类,得到所述待处理图像的分类结果;Classify the image to be processed according to the target neural network to obtain a classification result of the image to be processed;
    其中,所述目标神经网络由多个优化后的构建单元搭建而成,所述多个优化后的构建单元是通过对搜索网络中的构建单元的网络结构进行N个阶段的优化得到的,第i个阶段和第j个阶段为所述N个阶段中的任意两个阶段,所述搜索空间在所述第i个阶段的大小大于所述搜索网络在所述第j个阶段的大小,所述搜索网络在所述第i个阶段时包含的构建单元的数量小于所述搜索空间在所述第j个阶段时包含的构建单元的数量,所述搜索网络的搜索空间的减小和所述搜索网络的构建单元数量的增加使得所述优化过程中产生的显存消耗在预设范围内,所述搜索网络在第N个阶段包含的构建单元的数量与所述目标神经网络包含的构建单元的数量的差异在预设范围内,所述目标神经网络包含的构建单元的数量是根据所述目标神经网络的应用需求确定的,N为大于1的正整数,i和j均为小于或者等于N的正整数,并且i小于j。Wherein, the target neural network is constructed by a plurality of optimized construction units, and the multiple optimized construction units are obtained by optimizing the network structure of the construction units in the search network in N stages. The i-th stage and the j-th stage are any two of the N stages, the size of the search space in the i-th stage is greater than the size of the search network in the j-th stage, so The number of construction units included in the search network at the i-th stage is smaller than the number of construction units included in the search space at the j-th stage, the reduction in the search space of the search network and the The increase in the number of construction units of the search network makes the video memory consumption in the optimization process within a preset range. The number of construction units included in the search network in the Nth stage is equal to the number of construction units included in the target neural network. The difference in number is within a preset range, the number of building units included in the target neural network is determined according to the application requirements of the target neural network, N is a positive integer greater than 1, and both i and j are less than or equal to N Is a positive integer, and i is less than j.
  14. 如权利要求13所述的装置,其特征在于,j=i+1。The apparatus of claim 13, wherein j=i+1.
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行如权利要求1-5或者6-7中任一项所述的方法。A computer-readable storage medium, wherein the computer-readable medium stores program code for device execution, and the program code includes a program code for executing any one of claims 1-5 or 6-7 Methods.
  16. 一种芯片,其特征在于,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,以执行如权利要求1-5或者6-7中任一项所述的方法。A chip, characterized in that the chip comprises a processor and a data interface, and the processor reads instructions stored on a memory through the data interface to execute any one of claims 1-5 or 6-7 The method described in the item.
PCT/CN2020/087222 2019-04-28 2020-04-27 Neural network construction method, image processing method and devices WO2020221200A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910351894.1 2019-04-28
CN201910351894.1A CN110175671B (en) 2019-04-28 2019-04-28 Neural network construction method, image processing method and device

Publications (1)

Publication Number Publication Date
WO2020221200A1 true WO2020221200A1 (en) 2020-11-05

Family

ID=67690236

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/087222 WO2020221200A1 (en) 2019-04-28 2020-04-27 Neural network construction method, image processing method and devices

Country Status (2)

Country Link
CN (1) CN110175671B (en)
WO (1) WO2020221200A1 (en)

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112784962A (en) * 2021-01-21 2021-05-11 北京百度网讯科技有限公司 Training method and device for hyper network, electronic equipment and storage medium
CN112907446A (en) * 2021-02-07 2021-06-04 电子科技大学 Image super-resolution reconstruction method based on packet connection network
CN112949827A (en) * 2021-02-25 2021-06-11 商汤集团有限公司 Neural network generation, data processing and intelligent driving control method and device
CN113033773A (en) * 2021-03-03 2021-06-25 北京航空航天大学 Efficient search method for layered multi-branch network structure for fault diagnosis of rotating machinery
CN113076938A (en) * 2021-05-06 2021-07-06 广西师范大学 Deep learning target detection method combined with embedded hardware information
CN113159115A (en) * 2021-03-10 2021-07-23 中国人民解放军陆军工程大学 Vehicle fine-grained identification method, system and device based on neural architecture search
CN114418828A (en) * 2021-12-23 2022-04-29 北京百度网讯科技有限公司 Video memory management method, device, equipment, storage medium and program product
US11403069B2 (en) 2017-07-24 2022-08-02 Tesla, Inc. Accelerated mathematical engine
US11409692B2 (en) 2017-07-24 2022-08-09 Tesla, Inc. Vector computational unit
US11487288B2 (en) 2017-03-23 2022-11-01 Tesla, Inc. Data synthesis for autonomous control systems
US11537811B2 (en) 2018-12-04 2022-12-27 Tesla, Inc. Enhanced object detection for autonomous vehicles based on field view
US11562231B2 (en) 2018-09-03 2023-01-24 Tesla, Inc. Neural networks for embedded devices
US11561791B2 (en) 2018-02-01 2023-01-24 Tesla, Inc. Vector computational unit receiving data elements in parallel from a last row of a computational array
US11567514B2 (en) 2019-02-11 2023-01-31 Tesla, Inc. Autonomous and user controlled vehicle summon to a target
US11610117B2 (en) 2018-12-27 2023-03-21 Tesla, Inc. System and method for adapting a neural network model on a hardware platform
US11636333B2 (en) 2018-07-26 2023-04-25 Tesla, Inc. Optimizing neural network structures for embedded systems
US11665108B2 (en) 2018-10-25 2023-05-30 Tesla, Inc. QoS manager for system on a chip communications
US11681649B2 (en) 2017-07-24 2023-06-20 Tesla, Inc. Computational array microprocessor system using non-consecutive data formatting
US11734562B2 (en) 2018-06-20 2023-08-22 Tesla, Inc. Data pipeline and deep learning system for autonomous driving
US11748620B2 (en) 2019-02-01 2023-09-05 Tesla, Inc. Generating ground truth for machine learning from time series elements
US11790664B2 (en) 2019-02-19 2023-10-17 Tesla, Inc. Estimating object properties using visual image data
US11816585B2 (en) 2018-12-03 2023-11-14 Tesla, Inc. Machine learning models operating at different frequencies for autonomous vehicles
US11841434B2 (en) 2018-07-20 2023-12-12 Tesla, Inc. Annotation cross-labeling for autonomous control systems
US11893774B2 (en) 2018-10-11 2024-02-06 Tesla, Inc. Systems and methods for training machine models with augmented data
US11893393B2 (en) 2017-07-24 2024-02-06 Tesla, Inc. Computational array microprocessor system with hardware arbiter managing memory requests

Families Citing this family (38)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175671B (en) * 2019-04-28 2022-12-27 华为技术有限公司 Neural network construction method, image processing method and device
CN110428046B (en) * 2019-08-28 2023-12-15 腾讯科技(深圳)有限公司 Method and device for acquiring neural network structure and storage medium
CN112445823A (en) * 2019-09-04 2021-03-05 华为技术有限公司 Searching method of neural network structure, image processing method and device
CN112465135A (en) * 2019-09-06 2021-03-09 华为技术有限公司 Data processing method, data processing device, computer readable storage medium and chip
CN110705599B (en) * 2019-09-06 2021-10-19 北京理工大学 Human body action recognition method based on online transfer learning
CN110543944B (en) * 2019-09-11 2022-08-02 北京百度网讯科技有限公司 Neural network structure searching method, apparatus, electronic device, and medium
CN110599999A (en) * 2019-09-17 2019-12-20 寇晓宇 Data interaction method and device and robot
EP4030347A4 (en) * 2019-09-24 2022-11-16 Huawei Technologies Co., Ltd. Neural network building method and device, and image processing method and device
CN112561027A (en) * 2019-09-25 2021-03-26 华为技术有限公司 Neural network architecture searching method, image processing method, device and storage medium
CN110728359B (en) * 2019-10-10 2022-04-26 北京百度网讯科技有限公司 Method, device, equipment and storage medium for searching model structure
CN112749778B (en) * 2019-10-29 2023-11-28 北京灵汐科技有限公司 Neural network mapping method and device under strong synchronization
CN110851566B (en) * 2019-11-04 2022-04-29 沈阳雅译网络技术有限公司 Differentiable network structure searching method applied to named entity recognition
CN111047563B (en) * 2019-11-26 2023-09-01 深圳度影医疗科技有限公司 Neural network construction method applied to medical ultrasonic image
CN111027714B (en) * 2019-12-11 2023-03-14 腾讯科技(深圳)有限公司 Artificial intelligence-based object recommendation model training method, recommendation method and device
CN111159542B (en) * 2019-12-12 2023-05-05 中国科学院深圳先进技术研究院 Cross-domain sequence recommendation method based on self-adaptive fine tuning strategy
CN111178316B (en) * 2020-01-06 2022-04-15 武汉大学 High-resolution remote sensing image land coverage classification method
CN112513837A (en) * 2020-01-22 2021-03-16 深圳市大疆创新科技有限公司 Network structure searching method and device
CN111382868A (en) * 2020-02-21 2020-07-07 华为技术有限公司 Neural network structure search method and neural network structure search device
CN111401516B (en) * 2020-02-21 2024-04-26 华为云计算技术有限公司 Searching method for neural network channel parameters and related equipment
CN113361680B (en) * 2020-03-05 2024-04-12 华为云计算技术有限公司 Neural network architecture searching method, device, equipment and medium
CN113469891A (en) * 2020-03-31 2021-10-01 武汉Tcl集团工业研究院有限公司 Neural network architecture searching method, training method and image completion method
CN111488971B (en) * 2020-04-09 2023-10-24 北京百度网讯科技有限公司 Neural network model searching method and device, and image processing method and device
CN111523596B (en) * 2020-04-23 2023-07-04 北京百度网讯科技有限公司 Target recognition model training method, device, equipment and storage medium
CN111612134B (en) * 2020-05-20 2024-04-12 鼎富智能科技有限公司 Neural network structure searching method and device, electronic equipment and storage medium
CN111797983A (en) * 2020-05-25 2020-10-20 华为技术有限公司 Neural network construction method and device
CN111666763A (en) * 2020-05-28 2020-09-15 平安科技(深圳)有限公司 Network structure construction method and device for multitask scene
CN111680599B (en) * 2020-05-29 2023-08-08 北京百度网讯科技有限公司 Face recognition model processing method, device, equipment and storage medium
CN113902088A (en) * 2020-06-22 2022-01-07 华为技术有限公司 Method, device and system for searching neural network structure
CN111931904A (en) * 2020-07-10 2020-11-13 华为技术有限公司 Neural network construction method and device
CN111797999A (en) * 2020-07-10 2020-10-20 深圳前海微众银行股份有限公司 Longitudinal federal modeling optimization method, device, equipment and readable storage medium
CN111898510B (en) * 2020-07-23 2023-07-28 合肥工业大学 Cross-modal pedestrian re-identification method based on progressive neural network
CN111898061B (en) * 2020-07-29 2023-11-28 抖音视界有限公司 Method, apparatus, electronic device and computer readable medium for searching network
CN111754532B (en) * 2020-08-12 2023-07-11 腾讯科技(深圳)有限公司 Image segmentation model searching method, device, computer equipment and storage medium
CN112070213A (en) * 2020-08-28 2020-12-11 Oppo广东移动通信有限公司 Neural network model optimization method, device, equipment and storage medium
CN112200223A (en) * 2020-09-22 2021-01-08 北京迈格威科技有限公司 Image recognition network construction method, device, equipment and medium
CN112381733B (en) * 2020-11-13 2022-07-01 四川大学 Image recovery-oriented multi-scale neural network structure searching method and network application
CN113052812B (en) * 2021-03-22 2022-06-24 山西三友和智慧信息技术股份有限公司 AmoebaNet-based MRI prostate cancer detection method
CN114926698B (en) * 2022-07-19 2022-10-14 深圳市南方硅谷半导体股份有限公司 Image classification method for neural network architecture search based on evolutionary game theory

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108304921A (en) * 2018-02-09 2018-07-20 北京市商汤科技开发有限公司 The training method and image processing method of convolutional neural networks, device
WO2018156942A1 (en) * 2017-02-23 2018-08-30 Google Llc Optimizing neural network architectures
CN109165720A (en) * 2018-09-05 2019-01-08 深圳灵图慧视科技有限公司 Neural network model compression method, device and computer equipment
US20190026639A1 (en) * 2017-07-21 2019-01-24 Google Llc Neural architecture search for convolutional neural networks
CN109472366A (en) * 2018-11-01 2019-03-15 郑州云海信息技术有限公司 A kind of coding-decoding method and device of machine learning model
CN110175671A (en) * 2019-04-28 2019-08-27 华为技术有限公司 Construction method, image processing method and the device of neural network

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2462380B (en) * 2007-03-14 2012-02-15 Halliburton Energy Serv Inc Neural-network based surrogate model construction methods and applications thereof
US10699186B2 (en) * 2015-12-02 2020-06-30 Google Llc Determining orders of execution of a neural network
CN109615073B (en) * 2018-12-03 2021-06-04 郑州云海信息技术有限公司 Neural network model construction method, device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018156942A1 (en) * 2017-02-23 2018-08-30 Google Llc Optimizing neural network architectures
US20190026639A1 (en) * 2017-07-21 2019-01-24 Google Llc Neural architecture search for convolutional neural networks
CN108304921A (en) * 2018-02-09 2018-07-20 北京市商汤科技开发有限公司 The training method and image processing method of convolutional neural networks, device
CN109165720A (en) * 2018-09-05 2019-01-08 深圳灵图慧视科技有限公司 Neural network model compression method, device and computer equipment
CN109472366A (en) * 2018-11-01 2019-03-15 郑州云海信息技术有限公司 A kind of coding-decoding method and device of machine learning model
CN110175671A (en) * 2019-04-28 2019-08-27 华为技术有限公司 Construction method, image processing method and the device of neural network

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
REAL, ESTEBAN ET AL.: "Regularized Evolution for Image Classifier Architecture Search", ARXIV:1802.01548V7 (CS), 16 February 2019 (2019-02-16), XP081222849, DOI: 20200723111206Y *
ZOPH, BARRET ET AL.: "Learning transferable architectures for scalable image recognition", IEEE CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION (CVPR), 22 June 2018 (2018-06-22), XP055617714, DOI: 20200723112100A *

Cited By (33)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11487288B2 (en) 2017-03-23 2022-11-01 Tesla, Inc. Data synthesis for autonomous control systems
US11681649B2 (en) 2017-07-24 2023-06-20 Tesla, Inc. Computational array microprocessor system using non-consecutive data formatting
US11893393B2 (en) 2017-07-24 2024-02-06 Tesla, Inc. Computational array microprocessor system with hardware arbiter managing memory requests
US11409692B2 (en) 2017-07-24 2022-08-09 Tesla, Inc. Vector computational unit
US11403069B2 (en) 2017-07-24 2022-08-02 Tesla, Inc. Accelerated mathematical engine
US11797304B2 (en) 2018-02-01 2023-10-24 Tesla, Inc. Instruction set architecture for a vector computational unit
US11561791B2 (en) 2018-02-01 2023-01-24 Tesla, Inc. Vector computational unit receiving data elements in parallel from a last row of a computational array
US11734562B2 (en) 2018-06-20 2023-08-22 Tesla, Inc. Data pipeline and deep learning system for autonomous driving
US11841434B2 (en) 2018-07-20 2023-12-12 Tesla, Inc. Annotation cross-labeling for autonomous control systems
US11636333B2 (en) 2018-07-26 2023-04-25 Tesla, Inc. Optimizing neural network structures for embedded systems
US11562231B2 (en) 2018-09-03 2023-01-24 Tesla, Inc. Neural networks for embedded devices
US11983630B2 (en) 2018-09-03 2024-05-14 Tesla, Inc. Neural networks for embedded devices
US11893774B2 (en) 2018-10-11 2024-02-06 Tesla, Inc. Systems and methods for training machine models with augmented data
US11665108B2 (en) 2018-10-25 2023-05-30 Tesla, Inc. QoS manager for system on a chip communications
US11816585B2 (en) 2018-12-03 2023-11-14 Tesla, Inc. Machine learning models operating at different frequencies for autonomous vehicles
US11537811B2 (en) 2018-12-04 2022-12-27 Tesla, Inc. Enhanced object detection for autonomous vehicles based on field view
US11908171B2 (en) 2018-12-04 2024-02-20 Tesla, Inc. Enhanced object detection for autonomous vehicles based on field view
US11610117B2 (en) 2018-12-27 2023-03-21 Tesla, Inc. System and method for adapting a neural network model on a hardware platform
US11748620B2 (en) 2019-02-01 2023-09-05 Tesla, Inc. Generating ground truth for machine learning from time series elements
US11567514B2 (en) 2019-02-11 2023-01-31 Tesla, Inc. Autonomous and user controlled vehicle summon to a target
US11790664B2 (en) 2019-02-19 2023-10-17 Tesla, Inc. Estimating object properties using visual image data
CN112784962A (en) * 2021-01-21 2021-05-11 北京百度网讯科技有限公司 Training method and device for hyper network, electronic equipment and storage medium
CN112907446A (en) * 2021-02-07 2021-06-04 电子科技大学 Image super-resolution reconstruction method based on packet connection network
CN112907446B (en) * 2021-02-07 2022-06-07 电子科技大学 Image super-resolution reconstruction method based on packet connection network
CN112949827A (en) * 2021-02-25 2021-06-11 商汤集团有限公司 Neural network generation, data processing and intelligent driving control method and device
CN112949827B (en) * 2021-02-25 2024-05-21 商汤集团有限公司 Neural network generation, data processing and intelligent driving control method and device
CN113033773B (en) * 2021-03-03 2023-01-06 北京航空航天大学 Efficient search method for layered multi-branch network structure for fault diagnosis of rotating machinery
CN113033773A (en) * 2021-03-03 2021-06-25 北京航空航天大学 Efficient search method for layered multi-branch network structure for fault diagnosis of rotating machinery
CN113159115A (en) * 2021-03-10 2021-07-23 中国人民解放军陆军工程大学 Vehicle fine-grained identification method, system and device based on neural architecture search
CN113159115B (en) * 2021-03-10 2023-09-19 中国人民解放军陆军工程大学 Vehicle fine granularity identification method, system and device based on neural architecture search
CN113076938A (en) * 2021-05-06 2021-07-06 广西师范大学 Deep learning target detection method combined with embedded hardware information
CN113076938B (en) * 2021-05-06 2023-07-25 广西师范大学 Deep learning target detection method combining embedded hardware information
CN114418828A (en) * 2021-12-23 2022-04-29 北京百度网讯科技有限公司 Video memory management method, device, equipment, storage medium and program product

Also Published As

Publication number Publication date
CN110175671A (en) 2019-08-27
CN110175671B (en) 2022-12-27

Similar Documents

Publication Publication Date Title
WO2020221200A1 (en) Neural network construction method, image processing method and devices
US20230028237A1 (en) Method and apparatus for training image processing model
WO2021120719A1 (en) Neural network model update method, and image processing method and device
WO2021057056A1 (en) Neural architecture search method, image processing method and device, and storage medium
WO2021043193A1 (en) Neural network structure search method and image processing method and device
WO2021008206A1 (en) Neural architecture search method, and image processing method and device
WO2020216227A1 (en) Image classification method and apparatus, and data processing method and apparatus
WO2022083536A1 (en) Neural network construction method and apparatus
WO2019228358A1 (en) Deep neural network training method and apparatus
WO2022042713A1 (en) Deep learning training method and apparatus for use in computing device
WO2021022521A1 (en) Method for processing data, and method and device for training neural network model
WO2021238366A1 (en) Neural network construction method and apparatus
WO2022001805A1 (en) Neural network distillation method and device
WO2021218517A1 (en) Method for acquiring neural network model, and image processing method and apparatus
WO2021233342A1 (en) Neural network construction method and system
WO2022052601A1 (en) Neural network model training method, and image processing method and device
WO2021244249A1 (en) Classifier training method, system and device, and data processing method, system and device
WO2021164750A1 (en) Method and apparatus for convolutional layer quantization
CN110222718B (en) Image processing method and device
WO2022007867A1 (en) Method and device for constructing neural network
WO2023231794A1 (en) Neural network parameter quantification method and apparatus
WO2023093724A1 (en) Neural network model processing method and device
WO2021227787A1 (en) Neural network predictor training method and apparatus, and image processing method and apparatus
WO2021018251A1 (en) Image classification method and device
WO2021129668A1 (en) Neural network training method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20798704

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20798704

Country of ref document: EP

Kind code of ref document: A1