WO2018068421A1 - Method and device for optimizing neural network - Google Patents

Method and device for optimizing neural network Download PDF

Info

Publication number
WO2018068421A1
WO2018068421A1 PCT/CN2016/113271 CN2016113271W WO2018068421A1 WO 2018068421 A1 WO2018068421 A1 WO 2018068421A1 CN 2016113271 W CN2016113271 W CN 2016113271W WO 2018068421 A1 WO2018068421 A1 WO 2018068421A1
Authority
WO
WIPO (PCT)
Prior art keywords
neural network
weight parameter
parameter matrix
target
deleted
Prior art date
Application number
PCT/CN2016/113271
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 WO2018068421A1 publication Critical patent/WO2018068421A1/en

Links

Images

Classifications

    • 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/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections

Definitions

  • Embodiments of the present invention relate to the field of artificial neural network technologies, and in particular, to a method and an apparatus for optimizing a neural network.
  • the existing optimization method of neural network model can not completely solve the above problems.
  • the optimization in the form of Huffman coding can ensure the processing accuracy of the optimized neural network model and effectively reduce the deep nerve.
  • the storage space of the network model can not reduce the complexity of processing operations, shorten the running time, and can not reduce the space occupied by memory or video memory during processing.
  • the embodiment of the invention provides a method and a device for optimizing a neural network, which can optimize the neural network, achieve the purpose of shortening the running time and reducing the space occupied by the device resources.
  • an embodiment of the present invention provides a method for optimizing a neural network, including:
  • Deleting the unit nodes forms an optimized target neural network.
  • an embodiment of the present invention provides an apparatus for optimizing a neural network, including:
  • a parameter matrix determining module configured to acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
  • a node determining module to be deleted configured to process the weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network
  • the target network determining module is configured to delete the unit node to form an optimized target neural network.
  • a method and a device for optimizing a neural network are provided.
  • the method first obtains an initial neural network that meets a set precision condition, and determines a weight parameter matrix between adjacent two nodes in the initial neural network;
  • the set deletion threshold is in the determined weight parameter matrix, thereby determining the unit node to be deleted in the initial neural network; finally deleting the determined unit node in the initial neural network to form the optimized target neural network.
  • the neural network can be compressed simply and efficiently, and the neural network can be optimized. Therefore, when the face recognition based on the optimized post-neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage can be reduced. Run memory and the purpose of space occupied by video memory.
  • FIG. 1 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 2 of the present invention
  • FIG. 2b is a structural diagram of a trained initial neural network according to Embodiment 2 of the present invention.
  • 2c is a structural diagram of a target neural network formed by optimizing an initial neural network according to Embodiment 2 of the present invention
  • FIG. 3 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 3 of the present invention.
  • FIG. 3b is a structural diagram of a target neural network formed by depth optimization of a target neural network according to Embodiment 3 of the present invention.
  • FIG. 4 is a structural block diagram of an apparatus for optimizing a neural network according to Embodiment 4 of the present invention.
  • FIG. 1 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 1 of the present invention.
  • the method is applicable to a compression optimization of a neural network after training and learning, and the method may be performed by an optimization device of a neural network, where The device can be implemented by software and/or hardware and is typically integrated on a terminal device or server platform on which the neural network model is located.
  • the neural network mainly refers to the artificial neural network, which can be regarded as an algorithm mathematical model that simulates the behavior characteristics of animal neural networks and performs distributed parallel information processing.
  • the unit nodes in the neural network are divided into at least three layers, including an input layer, a hidden layer, and an output layer, wherein the input layer and the output layer each include only one layer of unit nodes, and the hidden layer includes at least one layer of unit nodes.
  • the number of unit nodes included in each layer can be set according to different application conditions.
  • the input layer of the neural network is responsible for receiving the input data and distributing it to the hidden layer
  • the hidden layer is responsible for calculating the received data and passing the calculation result to the output layer
  • the output layer is responsible for the output of the calculation result, which is understandable.
  • the data transmission and processing in the neural network is mainly based on the connection between the adjacent two-level unit nodes and the weight parameter values corresponding to the connection.
  • pattern recognition such as face recognition
  • processing can be performed based on a neural network, and the created neural network needs to be trained and learned before performing pattern recognition, and only when it is determined that the processing precision of the neural network satisfies the application requirement.
  • Perform pattern recognition it should be noted that in the actual pattern recognition process, the trained neural network has a large scale, which not only affects the running time of the recognition process, but also occupies more storage space and runs memory. And the memory space, so the trained neural network can be optimized based on the neural network optimization method provided by the embodiment to solve the above problem.
  • a method for optimizing a neural network according to Embodiment 1 of the present invention includes the following operations:
  • the setting precision condition can be specifically understood as a range of processing precision that the neural network needs to reach when the neural network is trained and learned.
  • the setting precision condition may be a system default range or an artificially set range.
  • the trained neural network can determine the current processing precision by processing the sample data included in the standard test set, and consider the neural network when the currently determined processing precision meets the set precision condition.
  • the actual application processing can be performed, and the neural network can be referred to as an initial neural network.
  • the training learning of the neural network is mainly implemented by a set training learning algorithm. Since the training learning algorithm is already a mature technology, it will not be described in detail here. It can be understood that the training learning process of the neural network is actually a process in which the value of the weight parameter corresponding to the connection of two adjacent unit nodes in the neural network is continuously changed and finally determined.
  • the weight parameter matrix between the adjacent two layer unit nodes may be determined according to the weight parameter values corresponding to the connection of the adjacent two layer unit nodes.
  • a weight parameter value if there is only one connection between any one of the cell nodes of one layer to any of the cell nodes of the other layer, it can be considered that only between the two cell nodes
  • a weight parameter value if there is at least two connections between any one of the unit nodes of one layer to any one of the other nodes of the other layer, Or the connection relationship between the two unit nodes needs to be represented by a function, then it can be considered that there is a weight parameter array (may be a one-dimensional array or a two-dimensional array) between the two unit nodes, and the adjacent two layer unit nodes can be determined at this time.
  • a multidimensional weight parameter matrix may be a one-dimensional array or a two-dimensional array
  • S102 Process a weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network.
  • the optimization of the initial neural network may be implemented by deleting the unit nodes in the initial neural network, thereby determining the unit nodes to be deleted in the initial neural network.
  • the set deletion threshold is first obtained, and then the relationship between the absolute value of each element value in the weight parameter matrix and the deletion threshold is determined; finally, the initial neural network may be determined according to the relationship between the absolute value of the element value and the deletion threshold.
  • the cell node to be deleted is first obtained, and then the relationship between the absolute value of each element value in the weight parameter matrix and the deletion threshold is determined; finally, the initial neural network may be determined according to the relationship between the absolute value of the element value and the deletion threshold.
  • the deletion threshold may be set based on the basic distribution rule of the element values in the weight parameter matrix, and the set deletion threshold is a real number greater than 0.
  • the element values in the weight parameter matrix are basically distributed on the left and right sides of the value 0, and the range of the range is generally (-0.05, 0.05), and it is preferable to set the deletion threshold to 0.001.
  • the setting of the deletion threshold is only needed when the neural network optimization is performed for the first time.
  • the set deletion threshold may be kept unchanged or the deletion threshold may be automatically changed based on other rules.
  • the setting of the deletion threshold is different, and thus the deletion threshold needs to be specifically set based on the specific situation.
  • the unit node may be deleted in the initial neural network, and in addition, when the unit node is deleted, the relationship or connection existing with the unit node is also deleted.
  • the resulting neural network is finally formed, called the target neural network.
  • a method for optimizing a neural network according to Embodiment 1 of the present invention first obtains an initial neural network that meets a set accuracy condition, and determines a weight parameter matrix between adjacent two nodes in the initial neural network; The threshold is in the determined weight parameter matrix, thereby determining the unit node to be deleted in the initial neural network; finally deleting the determined unit node in the initial neural network to form an optimized target neural network.
  • the neural network can be compressed simply and efficiently, and the neural network can be optimized. Therefore, when the face recognition based on the optimized post-neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage can be reduced. Run memory and the purpose of space occupied by video memory.
  • FIG. 2 is a schematic flowchart diagram of a method for optimizing a neural network according to Embodiment 2 of the present invention.
  • the embodiment of the present invention is optimized based on the above embodiment, and in this embodiment, the initial god is determined
  • the weight parameter matrix between two adjacent unit nodes in the network is further optimized to: if the connection between two adjacent unit nodes in the initial neural network is fully connected, the weight parameter corresponding to the connection between the unit nodes is based on The value forms a two-dimensional weight parameter matrix; if the connection between two adjacent unit nodes in the initial neural network is a convolution connection, the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes.
  • the weight parameter matrix is processed according to the set deletion threshold, and the unit node to be deleted in the initial neural network is determined, and the specific optimization is: if the weight parameter matrix is a two-dimensional weight parameter matrix, based on The column vector in the two-dimensional weight parameter matrix determines a unit node to be deleted in the initial neural network; if the weight parameter matrix is a multi-dimensional weight parameter matrix, determining the initial nerve based on the dimension-reduced multi-dimensional weight parameter matrix The cell node to be deleted in the network.
  • a method for optimizing a neural network according to Embodiment 2 of the present invention specifically includes the following operations:
  • the neural network may be determined as the initial neural network to be acquired.
  • step S202 If the connection between two adjacent unit nodes in the initial neural network is a full connection, the two-dimensional weight parameter matrix is formed based on the weight parameter values corresponding to the connection between the unit nodes, and then step S204 is performed.
  • connection between adjacent two layer unit nodes when the connection between adjacent two layer unit nodes is only a single line connection, the connection between the adjacent two layer unit nodes may be referred to as a full connection, and at this time, any unit node of one layer of the layer There is only one weight parameter value between any one of the unit nodes of another layer, so that the two-dimensional weight parameter matrix can be constructed according to the weight parameter value corresponding to the connection between the adjacent two layer unit nodes.
  • FIG. 2b is a structural diagram of a trained initial neural network according to Embodiment 2 of the present invention.
  • the initial neural network has four layers of unit nodes, wherein the first layer serves as an input layer. Layers 2 and 3 act as hidden layers, and layer 4 acts as an output layer, and it can be determined that the connections between adjacent two-layer unit nodes in the initial neural network are fully connected.
  • the weight parameter value corresponding to the connection between the mth unit node in the first layer and the nth unit node in the second layer is represented by w mn .
  • 1 ⁇ m ⁇ 5, 1 ⁇ n ⁇ 4; then a 5 ⁇ 4 order two-dimensional weight parameter matrix can be formed between the unit nodes in the first layer and the second layer, and the two-dimensional weight parameter matrix W 5 ⁇ 4 It can be expressed as:
  • connection between two adjacent unit nodes in the initial neural network is a convolution connection
  • the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes, and then step S205 is performed.
  • connection between two adjacent unit nodes is a multi-line connection (at least two connections exist) or a connection relationship is represented by a function
  • the connection between the adjacent two-layer unit nodes may be referred to as Convolution connection.
  • there may be an array of weight parameters (generally a one-dimensional array or a two-dimensional array) between any one of the unit nodes of one layer to any of the unit nodes of the other layer, thereby being able to be based on the adjacent two-level unit nodes.
  • the multi-weight weight parameter matrix is constructed by connecting the weight parameter array corresponding to the line, wherein when the weight parameter array is a one-dimensional array, a three-dimensional weight parameter matrix can be formed, and when the weight parameter array is a two-dimensional array, a four-dimensional weight parameter can be formed. matrix.
  • determining the unit node to be deleted in the initial neural network based on the column vector in the two-dimensional weight parameter matrix includes: acquiring a column vector of the i-th column in the two-dimensional weight parameter matrix; If the weight parameter values included in the column vector of the column are all smaller than the set first deletion threshold, the i-th unit node of the second layer in the adjacent two layers is determined as the unit node to be deleted in the initial neural network.
  • the formed two-dimensional weight parameter matrix is g ⁇ h order, it may be determined that the two-dimensional weight parameter matrix has a column vector of the h column. And determining that the weight parameter values in the i-th column of the two-dimensional weight parameter matrix are related to the i-th unit node of the second layer in the adjacent two layers.
  • the determining process of the unit node to be deleted may be expressed as: acquiring the set first deletion threshold, selecting a column vector of the i-th column in the two-dimensional weight parameter matrix, and determining the ith column column vector Whether the included g weight parameter values are all smaller than the first set threshold, and if all are smaller than the first set threshold, the i-th unit node of the second layer of the adjacent two layers may be determined as the initial neural network.
  • the cell node to be deleted may be expressed as: acquiring the set first deletion threshold, selecting a column vector of the i-th column in the two-dimensional weight parameter matrix, and determining the ith column column vector Whether the included g weight parameter values are all smaller than the first set threshold, and if all are smaller than the first set threshold, the i-th unit node of the second layer of the adjacent two layers may be determined as the initial neural network.
  • the cell node to be deleted may be expressed as: acquiring the set first deletion threshold, selecting a column vector of the i-th column in
  • the weight parameter value in the two-dimensional weight parameter matrix of g ⁇ h order is represented as w ai
  • the obtained first deletion threshold is t 1 , where 1 ⁇ a ⁇ g, 1 ⁇ i ⁇ h
  • the process of determining whether the g weight parameter values included in the i-th column column vector are all smaller than the first set threshold t 1 may be specifically described as: if the weight parameter value w ai in the i-th column column vector is smaller than the first
  • the first deletion threshold when the first deletion threshold is set for the first time, the first deletion threshold may be preferably set based on a basic distribution rule of the weight parameter values in the two-dimensional weight parameter matrix.
  • a multi-dimensional weight parameter matrix may be formed for a convoluted adjacent two-layer unit node.
  • the multi-dimensional weight parameter matrix needs to be subjected to dimensionality reduction processing, and is formed after the dimensionality reduction processing.
  • a two-dimensional target weight parameter matrix, after which the cell node to be deleted can be determined according to the target weight parameter matrix.
  • determining the unit node to be deleted in the initial neural network based on the dimension-reduced multi-dimensional weight parameter matrix comprises: performing dimension reduction processing on the multi-dimensional weight parameter matrix to form a two-dimensional target weight parameter matrix; a column vector of the jth column in the target weight parameter matrix; if the element values included in the column vector of the jth column are all smaller than the set second deletion threshold, the jth of the second layer in the adjacent two layers
  • the unit node is determined to be a unit node to be deleted in the initial neural network.
  • the process of reducing the dimensionality of the multi-dimensional weight parameter matrix to form a two-dimensional target weight parameter matrix may be described as: determining the dimension of the multi-dimensional weight parameter matrix and the element value in the matrix, if the multi-dimensional weight parameter matrix is The three-dimensional weight parameter matrix, the value of each element in the matrix is usually a one-dimensional array, in this case, the data in the one-dimensional array can be directly summed, and finally the calculated data and or the average of the data sum can be used as The element value corresponding to the target weight parameter matrix after dimension reduction; if the multi-dimensional weight parameter matrix is a four-dimensional weight parameter matrix, each element value in the matrix is usually a two-dimensional array, and the column data of each column in the two-dimensional array is first used. The summation calculation is performed to obtain the corresponding column data sum, and then the column data is summed and calculated. Finally, the calculated data and the average value of the data sum may be used as the element values corresponding to the dimension-reduced target weight parameter matrix
  • the determination of the unit node to be deleted may be performed in the formed target weight parameter matrix,
  • the operation process of determining the unit node to be deleted is the same as the operation process determined by the unit node based on step S204, and details are not described herein again.
  • the second deletion threshold when the second deletion threshold is set for the first time, the second deletion threshold may be preferably set based on a basic distribution rule of the element values in the target weight parameter matrix.
  • all the unit nodes to be deleted in the initial neural network may be determined, thereby deleting all the determined unit nodes in the initial neural network, and simultaneously deleting and The unit node has a connection to the relationship.
  • FIG. 2c is a structural diagram of a target neural network formed by optimizing an initial neural network according to Embodiment 2 of the present invention.
  • step S202 as shown in FIG. 2c, compared with the initial neural network in FIG. 2b, one unit node is reduced in the second layer, and thus, the neural network provided according to the second embodiment of the present invention is known.
  • the optimization method realizes the optimization of deleting the second unit node of the second layer of the initial neural network in Fig. 2b.
  • a method for optimizing a neural network according to Embodiment 2 of the present invention specifically describes a process for determining a weight matrix of corresponding weights when different adjacent nodes of a neural network have different connection modes; and specifically describing different weight parameter matrices The process of determining the cell node to be deleted.
  • the neural network with different unit node connection modes can be compressed and optimized, so that when the face recognition based on the optimized back neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage and operation can be reduced.
  • the purpose of memory and space occupied by video memory is used.
  • FIG. 3a is a schematic flowchart diagram of a method for optimizing a neural network according to Embodiment 3 of the present invention.
  • Ben The embodiment of the present invention is optimized based on the foregoing embodiment.
  • the optimization is further increased: determining whether the current processing precision of the target neural network meets the set precision condition, and determining the target neural network based on the determination result.
  • the network conducts training learning or deep optimization.
  • the training learning or depth optimization of the target neural network based on the determination result is further optimized to: if the current processing precision does not meet the set precision condition, then the target neural network is Performing training learning until the set accuracy condition is met or the set training number is reached; otherwise, the deletion threshold is self-incremented, and the target neural network is used as a new initial neural network to re-execute the neural network optimization.
  • the operation, wherein the deletion threshold is a first deletion threshold or a second deletion threshold.
  • the operation including another case is also optimized, that is, if the target neural network after the training learning meets the set precision condition and the number of training times is not greater than the set training number, then
  • the deletion threshold is performed by a self-incrementing operation, and the target neural network is used as a new initial neural network to re-execute the optimization operation of the neural network.
  • a method for optimizing a neural network according to Embodiment 3 of the present invention specifically includes the following operations:
  • the acquired initial neural network is specifically used for face recognition
  • the setting precision condition can be considered as the processing precision required by the neural network in face recognition
  • the optimized target neural network is also specifically used for face recognition. Therefore, it is also required to test whether the current processing accuracy of the target neural network meets the set accuracy condition.
  • the testing process of the current processing accuracy of the target neural network may be described as follows: first, the sample image required for the target neural network test is selected according to the rules of the international standard face verification test set, and preferably, 3000 pairs of positive samples may be selected. Image (a pair of positive sample images are two images with the same face) and 3000 pairs of negative sample images (a pair of negative sample images are two images with different faces); then, the positive sample images are paired and negative, respectively The sample image pair is input data of the target neural network; finally, the current processing accuracy of the target neural network can be determined according to the value of the output result X of the face recognition and the calculation formula of the current processing precision.
  • the output result X when the target neural network determines two images in the positive sample image pair as the same person, the output result X has a value of 1, otherwise the output result X has a value of 0; when the target neural network will have a negative sample image pair When the two images in the determination are not the same person, the value of the output result X is 1, otherwise the value of the output result X is 0.
  • the calculation formula of the current processing precision can be expressed as:
  • step S307 may be directly performed; otherwise, the operation of step S305 needs to be performed.
  • step S305 Perform training learning on the target neural network, and then perform step S306.
  • the target neural network when the determined current processing accuracy does not meet the set accuracy condition, the target neural network may be trained and learned based on the set training learning method.
  • the training learning method used in training learning is not detailed here.
  • step S306. Determine whether the number of trainings for training the target neural network reaches the set training number. If not, return to step S304; if yes, execute step S308.
  • step S307. Perform a self-increment operation on the deletion threshold, and use the target neural network as a new initial neural network, and return to step S301.
  • the current target neural network may continue to perform depth optimization based on steps S301 to S303.
  • the deletion threshold Before performing deep optimization on the target neural network, the deletion threshold may be self-incremented, and then the target neural network is used as the initial neural network, and then returning to step S301 to restart the optimization of the neural network.
  • the deletion threshold is the first deletion threshold or the second deletion threshold in this embodiment, the incremental value according to the deletion threshold self-increment operation is mainly set based on a specific situation. It can be understood that when the neural network optimization is performed based on the added deletion threshold, more unit nodes to be deleted can be determined, so that the target neural network that is finally suitable for face recognition can be determined more quickly.
  • FIG. 3b is a structural diagram of a target neural network formed by depth optimization of an original target neural network according to Embodiment 3 of the present invention.
  • the target shown in FIG. 3b can be considered.
  • the neural network is a further depth optimization of the target neural network shown in Figure 2c, as shown in Figure 3b, compared to the target neural network provided in Figure 2c, there is a reduction of one unit node in the third layer, thus knowing
  • the depth optimization of deleting the second unit node of the third layer of the target neural network provided in FIG. 2c is implemented.
  • the training of the target neural network may be ended.
  • the target neural network that was last optimized as the initial neural network is the neural network required for face recognition.
  • a method for optimizing a neural network according to Embodiment 3 of the present invention further increases the operation of training learning or deep optimization for the optimized neural network, thereby maintaining the processing precision of the optimized neural network and the existing optimization.
  • the compression optimization of the neural network can be realized without reducing the computational accuracy of the neural network processing, so as to speed up the face recognition processing and shorten the face recognition when performing face recognition based on the optimized back neural network. Processing time, reducing the purpose of storage, running memory, and space occupied by video memory.
  • FIG. 4 is a structural block diagram of an apparatus for optimizing a neural network according to Embodiment 4 of the present invention.
  • the device is suitable for compression optimization of a neural network after training and learning, wherein the device can be implemented by software and/or hardware, and is generally integrated on a terminal device or a server platform where the neural network model is located.
  • the optimization apparatus includes a parameter matrix determination module 41, a node determination module 42 to be deleted, and a target network determination module 43.
  • the parameter matrix determining module 41 is configured to acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
  • the to-be-deleted node determining module 42 is configured to process the weight parameter matrix according to the set deletion threshold to determine a unit node to be deleted in the initial neural network;
  • the target network determining module 43 is configured to delete the unit node to form an optimized target neural network.
  • the optimization device first obtains an initial neural network that meets the set precision condition by the parameter matrix determination module 41, and determines a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
  • the node determining module 42 processes the weight parameter matrix according to the set deletion threshold to determine a unit node to be deleted in the initial neural network; finally, the target network determining module 43 deletes the unit node to form an optimized target neural network.
  • the neural network optimization device provided in Embodiment 4 of the present invention can compress the neural network simply and efficiently, and realize the optimization of the neural network, thereby achieving accelerated recognition when performing face recognition based on the optimized back neural network. Processing speed, shorten recognition processing time, and reduce the space occupied by storage, running memory and video memory.
  • parameter matrix determining module 41 is specifically configured to:
  • the two-dimensional weight parameter is formed based on the weight parameter values corresponding to the connection between the unit nodes.
  • a matrix if the connection between two adjacent unit nodes in the initial neural network is a convolution connection, the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes.
  • node to be deleted module 42 includes:
  • a first determining unit configured to: when the weight parameter matrix is a two-dimensional weight parameter matrix, determine a cell node to be deleted in the initial neural network based on a column vector in the two-dimensional weight parameter matrix;
  • a second determining unit configured to: when the weight parameter matrix is a multi-dimensional weight parameter matrix, determine a cell node to be deleted in the initial neural network based on the dimension-reduced multi-dimensional weight parameter matrix.
  • the first determining unit is specifically configured to:
  • the first deletion threshold determines the i-th unit node of the second layer in the adjacent two layers as the unit node to be deleted in the initial neural network.
  • the second determining unit is specifically configured to:
  • the multi-dimensional weight parameter matrix is subjected to dimensionality reduction processing to form a two-dimensional target weight parameter matrix; and the column vector of the j-th column in the target weight parameter matrix is obtained; If the element values included in the column vector of the jth column are both smaller than the set second deletion threshold, determining the jth unit node of the second layer of the adjacent two layers as the to-be-deleted in the initial neural network Unit node.
  • the optimization apparatus further includes: a target network processing module 44, configured to determine whether a current processing precision of the target neural network meets the set precision condition, and perform training learning or depth on the target neural network based on the determination result. optimization.
  • the target network processing module 44 is specifically configured to:
  • the deletion threshold is self-incremented, and the target neural network is used as a new initial neural network to re-execute the optimization operation of the neural network, wherein the deletion threshold is The first deletion threshold or the second deletion threshold.
  • the self-increase operation is performed on the deletion threshold, and the target neural network is used as a new
  • the initial neural network re-executes the optimization of the neural network.

Abstract

Disclosed are a method and device for optimizing a neural network. The method comprises: obtaining an initial neural network meeting a set precision condition, and determining a weight parameter matrix between two adjacent layers of unit nodes in the initial neural network; processing the weight parameter matrix according to a set deletion threshold and determining a unit node to be deleted in the initial neural network; and deleting the unit node to form an optimized target neural network. The method can easily and efficiently compress a neural network, thereby implementing the optimization of the neural network. Therefore, during human face recognition based on an optimized neural network, the recognition processing speed can be increased, the recognition processing time can be shortened, and the occupation of spaces, such as storage, a running memory, and a display memory, can be reduced.

Description

一种神经网络的优化方法及装置Neural network optimization method and device 技术领域Technical field
本发明实施例涉及人工神经网络技术领域,尤其涉及一种神经网络的优化方法及装置。Embodiments of the present invention relate to the field of artificial neural network technologies, and in particular, to a method and an apparatus for optimizing a neural network.
背景技术Background technique
目前,通常基于训练好的神经网络模型(如深度卷积神经网络模型)进行人脸识别。在使用神经网络模型进行人脸识别时,存在的问题如下:1、对图像数据处理计算的复杂度较高,影响运算时间(如,在配置有酷睿i7处理器的电子设备上处理人脸图像时往往要耗费1秒以上的时间);2、在处理过程中需要占用较大的内存空间或显卡显存空间;3、还需要占用较大存储空间来存放整个神经网络模型。Currently, face recognition is usually performed based on a trained neural network model such as a deep convolutional neural network model. When using neural network model for face recognition, the problems are as follows: 1. The computational complexity of image data processing is high, which affects the computing time (for example, processing face images on electronic devices equipped with Core i7 processor) It usually takes more than 1 second); 2. It takes a large memory space or graphics memory space during processing; 3. It also needs to occupy a large storage space to store the entire neural network model.
现有的神经网络模型的优化方法,并不能完全解决上述存在的问题,如,采用霍夫曼编码的形式进行的优化,能够保证优化后神经网络模型的处理计算精度,并有效的降低深度神经网络模型的存储空间,但不能降低处理运算的复杂度,缩短运行时间,同时也不能降低处理过程中对内存或显存的空间占用。The existing optimization method of neural network model can not completely solve the above problems. For example, the optimization in the form of Huffman coding can ensure the processing accuracy of the optimized neural network model and effectively reduce the deep nerve. The storage space of the network model, but can not reduce the complexity of processing operations, shorten the running time, and can not reduce the space occupied by memory or video memory during processing.
发明内容Summary of the invention
本发明实施例提供了一种神经网络的优化方法及装置,能够实现神经网络的优化,达到缩短运行时间、降低装置资源空间占用的目的。The embodiment of the invention provides a method and a device for optimizing a neural network, which can optimize the neural network, achieve the purpose of shortening the running time and reducing the space occupied by the device resources.
一方面,本发明实施例提供了一种神经网络的优化方法,包括:In one aspect, an embodiment of the present invention provides a method for optimizing a neural network, including:
获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两 层单元节点间的权重参数矩阵;Obtain an initial neural network that meets the set accuracy condition, and determine two adjacent ones in the initial neural network a weight parameter matrix between layer unit nodes;
根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点;Processing the weight parameter matrix according to the set deletion threshold, and determining a unit node to be deleted in the initial neural network;
删除所述单元节点形成优化后的目标神经网络。Deleting the unit nodes forms an optimized target neural network.
另一方面,本发明实施例提供了一种神经网络的优化装置,包括:In another aspect, an embodiment of the present invention provides an apparatus for optimizing a neural network, including:
参数矩阵确定模块,用于获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵;a parameter matrix determining module, configured to acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
待删除节点确定模块,用于根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点;a node determining module to be deleted, configured to process the weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network;
目标网络确定模块,用于删除所述单元节点形成优化后的目标神经网络。The target network determining module is configured to delete the unit node to form an optimized target neural network.
本发明实施例中提供了一种神经网络的优化方法及装置,该方法首先获取符合设定精度条件的初始神经网络,并确定初始神经网络中相邻两层节点间的权重参数矩阵;之后根据设定的删除阈值处于所确定的权重参数矩阵,由此确定初始神经网络中待删除的单元节点;最终在初始神经网络中删除所确定的单元节点形成优化后的目标神经网络。利用该方法,能够简单高效的对神经网络进行压缩,实现神经网络的优化,由此在基于优化的后神经网络进行人脸识别时,能够达到加快识别处理速度,缩短识别处理时间,降低存储、运行内存以及显存等空间占用的目的。In the embodiment of the present invention, a method and a device for optimizing a neural network are provided. The method first obtains an initial neural network that meets a set precision condition, and determines a weight parameter matrix between adjacent two nodes in the initial neural network; The set deletion threshold is in the determined weight parameter matrix, thereby determining the unit node to be deleted in the initial neural network; finally deleting the determined unit node in the initial neural network to form the optimized target neural network. By using this method, the neural network can be compressed simply and efficiently, and the neural network can be optimized. Therefore, when the face recognition based on the optimized post-neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage can be reduced. Run memory and the purpose of space occupied by video memory.
附图说明DRAWINGS
图1为本发明实施例一提供的一种神经网络的优化方法的流程示意图;1 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 1 of the present invention;
图2a为本发明实施例二提供的一种神经网络的优化方法的流程示意图; FIG. 2 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 2 of the present invention; FIG.
图2b为本发明实施例二提供的一个训练后的初始神经网络的结构图;2b is a structural diagram of a trained initial neural network according to Embodiment 2 of the present invention;
图2c为本发明实施例二中对初始神经网络优化后所形成目标神经网络的结构图;2c is a structural diagram of a target neural network formed by optimizing an initial neural network according to Embodiment 2 of the present invention;
图3a为本发明实施例三提供的一种神经网络的优化方法的流程示意图;FIG. 3 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 3 of the present invention; FIG.
图3b为本发明实施例三中对原目标神经网络深度优化形成的目标神经网络的结构图;FIG. 3b is a structural diagram of a target neural network formed by depth optimization of a target neural network according to Embodiment 3 of the present invention; FIG.
图4为本发明实施例四提供的一种神经网络的优化装置的结构框图。FIG. 4 is a structural block diagram of an apparatus for optimizing a neural network according to Embodiment 4 of the present invention.
具体实施方式detailed description
下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部结构。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. It should also be noted that, for ease of description, only some, but not all, of the structures related to the present invention are shown in the drawings.
实施例一 Embodiment 1
图1为本发明实施例一提供的一种神经网络的优化方法的流程示意图,该方法适用于对训练学习后的神经网络进行压缩优化的情况,该方法可以由神经网络的优化装置执行,其中该装置可由软件和/或硬件实现,并一般集成在神经网络模型所在的终端设备或服务器平台上。FIG. 1 is a schematic flowchart of a method for optimizing a neural network according to Embodiment 1 of the present invention. The method is applicable to a compression optimization of a neural network after training and learning, and the method may be performed by an optimization device of a neural network, where The device can be implemented by software and/or hardware and is typically integrated on a terminal device or server platform on which the neural network model is located.
一般地,神经网络主要指人工神经网络,具体可看作一种模仿动物神经网络行为特征,进行分布式并行信息处理的算法数学模型。神经网络中所具有的单元节点至少分为三层,包括了输入层、隐藏层以及输出层,其中,输入层以及输出层均只包含一层单元节点,而隐藏层则至少包含一层单元节点,此外, 各层所包含单元节点的个数都可根据不同应用情况设定。具体而言,神经网络的输入层负责接收输入的数据并分发到隐藏层,隐藏层负责对所接收的数据进行计算并将计算结果传递给输出层,输出层负责计算结果的输出,可以理解的是,神经网络中数据的传递及处理主要基于相邻两层单元节点间的连线及连线对应的权重参数值实现。Generally, the neural network mainly refers to the artificial neural network, which can be regarded as an algorithm mathematical model that simulates the behavior characteristics of animal neural networks and performs distributed parallel information processing. The unit nodes in the neural network are divided into at least three layers, including an input layer, a hidden layer, and an output layer, wherein the input layer and the output layer each include only one layer of unit nodes, and the hidden layer includes at least one layer of unit nodes. In addition, The number of unit nodes included in each layer can be set according to different application conditions. Specifically, the input layer of the neural network is responsible for receiving the input data and distributing it to the hidden layer, the hidden layer is responsible for calculating the received data and passing the calculation result to the output layer, and the output layer is responsible for the output of the calculation result, which is understandable. Yes, the data transmission and processing in the neural network is mainly based on the connection between the adjacent two-level unit nodes and the weight parameter values corresponding to the connection.
目前,可以基于神经网络进行模式识别(如人脸识别)处理,而在进行模式识别前需要对所创建的神经网络进行训练学习,只有确定神经网络所具有的处理精度满足应用需求时,才可以进行模式识别。需要说明的是,在实际的模式识别处理中,所采用的训练好的神经网络所具有规模一般都很大,由此不仅影响识别处理的运行时间,还占用了更多的存储空间、运行内存以及显存空间,因此可以基于本实施例提供的神经网络的优化方法对训练好的神经网络进行优化,来解决上述问题。At present, pattern recognition (such as face recognition) processing can be performed based on a neural network, and the created neural network needs to be trained and learned before performing pattern recognition, and only when it is determined that the processing precision of the neural network satisfies the application requirement. Perform pattern recognition. It should be noted that in the actual pattern recognition process, the trained neural network has a large scale, which not only affects the running time of the recognition process, but also occupies more storage space and runs memory. And the memory space, so the trained neural network can be optimized based on the neural network optimization method provided by the embodiment to solve the above problem.
如图1所示,本发明实施例一提供的一种神经网络的优化方法,包括如下操作:As shown in FIG. 1 , a method for optimizing a neural network according to Embodiment 1 of the present invention includes the following operations:
S101、获取符合设定精度条件的初始神经网络,确定初始神经网络中相邻两层单元节点间的权重参数矩阵。S101. Acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network.
在本实施例中,设定精度条件具体可理解为对神经网络进行训练学习后,实际进行应用处理时,神经网络需要达到的处理精度范围。一般地,该设定精度条件可以是系统默认的范围,也可以是人为设置的范围。在本实施例中,被训练学习的神经网络可以通过对标准测试集中所包含样本数据的处理来确定当前能够达到的处理精度,并在当前确定的处理精度符合设定精度条件时,认为神经网络可以进行实际应用处理,同时可将该神经网络称为初始神经网络。 In this embodiment, the setting precision condition can be specifically understood as a range of processing precision that the neural network needs to reach when the neural network is trained and learned. Generally, the setting precision condition may be a system default range or an artificially set range. In this embodiment, the trained neural network can determine the current processing precision by processing the sample data included in the standard test set, and consider the neural network when the currently determined processing precision meets the set precision condition. The actual application processing can be performed, and the neural network can be referred to as an initial neural network.
一般地,对神经网络的训练学习主要通过设定的训练学习算法实现,由于训练学习算法已经是成熟的技术,这里不再详述。可以理解的是,神经网络的训练学习过程,实际就是神经网络中相邻两层单元节点连线对应的权重参数值不断变更并最终确定的过程。在本实施例中,在获取初始神经网络后,可以根据相邻两层单元节点连线对应的权重参数值来确定相邻两层单元节点间的权重参数矩阵。Generally, the training learning of the neural network is mainly implemented by a set training learning algorithm. Since the training learning algorithm is already a mature technology, it will not be described in detail here. It can be understood that the training learning process of the neural network is actually a process in which the value of the weight parameter corresponding to the connection of two adjacent unit nodes in the neural network is continuously changed and finally determined. In this embodiment, after acquiring the initial neural network, the weight parameter matrix between the adjacent two layer unit nodes may be determined according to the weight parameter values corresponding to the connection of the adjacent two layer unit nodes.
在本实施例中,对于相邻两层的单元节点而言,如果其中一层的任一单元节点到另一层的任一单元节点间只存在一条连线,则可认为两单元节点间只存在一个权重参数值,此时相邻两层单元节点间可以确定一个二维权重参数矩阵;如果其中一层的任一单元节点到另一层的任一单元节点间至少存在两条连线,或两单元节点间的连线关系需要用函数表示,则可认为两单元节点间对应存在一个权重参数数组(可能是一维数组或二维数组),此时相邻两层单元节点间可以确定一个多维权重参数矩阵。In this embodiment, for a cell node of two adjacent layers, if there is only one connection between any one of the cell nodes of one layer to any of the cell nodes of the other layer, it can be considered that only between the two cell nodes There is a weight parameter value, and a two-dimensional weight parameter matrix can be determined between adjacent two-level unit nodes; if there is at least two connections between any one of the unit nodes of one layer to any one of the other nodes of the other layer, Or the connection relationship between the two unit nodes needs to be represented by a function, then it can be considered that there is a weight parameter array (may be a one-dimensional array or a two-dimensional array) between the two unit nodes, and the adjacent two layer unit nodes can be determined at this time. A multidimensional weight parameter matrix.
S102、根据设定的删除阈值处理权重参数矩阵,确定初始神经网络中待删除的单元节点。S102. Process a weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network.
在本实施例中,可以采用删除初始神经网络中单元节点的方式来实现初始神经网络的优化,由此需要确定初始神经网络中待删除的单元节点。具体地,首先获取设定的删除阈值,然后确定权重参数矩阵中各元素值的绝对值与删除阈值的大小关系;最终可根据元素值的绝对值与删除阈值的大小关系来确定初始神经网络中待删除的单元节点。In this embodiment, the optimization of the initial neural network may be implemented by deleting the unit nodes in the initial neural network, thereby determining the unit nodes to be deleted in the initial neural network. Specifically, the set deletion threshold is first obtained, and then the relationship between the absolute value of each element value in the weight parameter matrix and the deletion threshold is determined; finally, the initial neural network may be determined according to the relationship between the absolute value of the element value and the deletion threshold. The cell node to be deleted.
在本实施例中,可以基于权重参数矩阵中元素值的基本分布规律来设定删除阈值,且所设定的删除阈值为大于0的实数。示例性地,经实际分析发现, 权重参数矩阵中的元素值基本分布在数值0的左右两侧,并且值域范围一般为(-0.05,0.05),此时可优选的将删除阈值设置为0.001。需要说明的是,本实施例只需在首次进行神经网络优化时进行删除阈值的设定,当循环进行神经网络优化时,可保持设定的删除阈值不变或基于其他规则自动变更删除阈值的值;此外,对于不同维度的权重参数矩阵而言,其删除阈值的设定存在不同,由此删除阈值还需基于具体情况进行具体设定。In this embodiment, the deletion threshold may be set based on the basic distribution rule of the element values in the weight parameter matrix, and the set deletion threshold is a real number greater than 0. Exemplarily, through actual analysis, The element values in the weight parameter matrix are basically distributed on the left and right sides of the value 0, and the range of the range is generally (-0.05, 0.05), and it is preferable to set the deletion threshold to 0.001. It should be noted that, in this embodiment, the setting of the deletion threshold is only needed when the neural network optimization is performed for the first time. When the neural network optimization is performed cyclically, the set deletion threshold may be kept unchanged or the deletion threshold may be automatically changed based on other rules. In addition, for the weight parameter matrix of different dimensions, the setting of the deletion threshold is different, and thus the deletion threshold needs to be specifically set based on the specific situation.
S103、删除所述单元节点形成优化后的目标神经网络。S103. Delete the unit node to form an optimized target neural network.
在本实施例中,确定待删除的单元节点后,可以在初始神经网络中删除该单元节点,此外,在删除该单元节点的同时,与该单元节点存在的关系或连线也一并删除,最终形成优化后的神经网络,称为目标神经网络。In this embodiment, after determining the unit node to be deleted, the unit node may be deleted in the initial neural network, and in addition, when the unit node is deleted, the relationship or connection existing with the unit node is also deleted. The resulting neural network is finally formed, called the target neural network.
本发明实施例一提供的一种神经网络的优化方法,首先获取符合设定精度条件的初始神经网络,并确定初始神经网络中相邻两层节点间的权重参数矩阵;之后根据设定的删除阈值处于所确定的权重参数矩阵,由此确定初始神经网络中待删除的单元节点;最终在初始神经网络中删除所确定的单元节点形成优化后的目标神经网络。利用该方法,能够简单高效的对神经网络进行压缩,实现神经网络的优化,由此在基于优化的后神经网络进行人脸识别时,能够达到加快识别处理速度,缩短识别处理时间,降低存储、运行内存以及显存等空间占用的目的。A method for optimizing a neural network according to Embodiment 1 of the present invention first obtains an initial neural network that meets a set accuracy condition, and determines a weight parameter matrix between adjacent two nodes in the initial neural network; The threshold is in the determined weight parameter matrix, thereby determining the unit node to be deleted in the initial neural network; finally deleting the determined unit node in the initial neural network to form an optimized target neural network. By using this method, the neural network can be compressed simply and efficiently, and the neural network can be optimized. Therefore, when the face recognition based on the optimized post-neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage can be reduced. Run memory and the purpose of space occupied by video memory.
实施例二 Embodiment 2
图2为本发明实施例二提供的一种神经网络的优化方法的流程示意图。本发明实施例以上述实施例为基础进行优化,在本实施例中,将确定所述初始神 经网络中相邻两层单元节点间的权重参数矩阵,进一步优化为:如果所述初始神经网络中相邻两层单元节点间的连接为全连接,则基于单元节点间连线对应的权重参数值形成二维权重参数矩阵;如果所述初始神经网络中相邻两层单元节点间的连接为卷积连接,则基于单元节点间连线对应的权重参数数组形成多维权重参数矩阵。FIG. 2 is a schematic flowchart diagram of a method for optimizing a neural network according to Embodiment 2 of the present invention. The embodiment of the present invention is optimized based on the above embodiment, and in this embodiment, the initial god is determined The weight parameter matrix between two adjacent unit nodes in the network is further optimized to: if the connection between two adjacent unit nodes in the initial neural network is fully connected, the weight parameter corresponding to the connection between the unit nodes is based on The value forms a two-dimensional weight parameter matrix; if the connection between two adjacent unit nodes in the initial neural network is a convolution connection, the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes.
进一步地,将根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点,具体优化为:如果所述权重参数矩阵为二维权重参数矩阵,则基于所述二维权重参数矩阵中的列向量确定所述初始神经网络中待删除的单元节点;如果所述权重参数矩阵为多维权重参数矩阵,则基于降维后的多维权重参数矩阵确定所述初始神经网络中待删除的单元节点。Further, the weight parameter matrix is processed according to the set deletion threshold, and the unit node to be deleted in the initial neural network is determined, and the specific optimization is: if the weight parameter matrix is a two-dimensional weight parameter matrix, based on The column vector in the two-dimensional weight parameter matrix determines a unit node to be deleted in the initial neural network; if the weight parameter matrix is a multi-dimensional weight parameter matrix, determining the initial nerve based on the dimension-reduced multi-dimensional weight parameter matrix The cell node to be deleted in the network.
如图2a所示,本发明实施例二提供的一种神经网络的优化方法,具体包括如下操作:As shown in FIG. 2a, a method for optimizing a neural network according to Embodiment 2 of the present invention specifically includes the following operations:
S201、获取符合设定精度条件的初始神经网络。S201. Acquire an initial neural network that meets a condition of setting accuracy.
示例性地,在对所创建的神经网络进行训练学习后,如果神经网络的当前处理精度符合设定精度条件,则可将该神经网络确定为待获取的初始神经网络。Illustratively, after training learning of the created neural network, if the current processing accuracy of the neural network meets the set accuracy condition, the neural network may be determined as the initial neural network to be acquired.
S202、如果初始神经网络中相邻两层单元节点间的连接为全连接,则基于单元节点间连线对应的权重参数值形成二维权重参数矩阵,之后执行步骤S204。S202. If the connection between two adjacent unit nodes in the initial neural network is a full connection, the two-dimensional weight parameter matrix is formed based on the weight parameter values corresponding to the connection between the unit nodes, and then step S204 is performed.
在本实施例中,当相邻两层单元节点间的连接仅为单线连接时,可将该相邻两层单元节点间的连接称为全连接,此时,其中一层的任一单元节点到另一层的任一单元节点间只存在一个权重参数值,由此可以根据相邻两层单元节点间连线对应的权重参数值来构建二维权重参数矩阵。In this embodiment, when the connection between adjacent two layer unit nodes is only a single line connection, the connection between the adjacent two layer unit nodes may be referred to as a full connection, and at this time, any unit node of one layer of the layer There is only one weight parameter value between any one of the unit nodes of another layer, so that the two-dimensional weight parameter matrix can be constructed according to the weight parameter value corresponding to the connection between the adjacent two layer unit nodes.
示例性地,图2b为本发明实施例二提供的一个训练后的初始神经网络的结 构图,如图2b所示,该初始神经网络共有4层单元节点,其中,第1层作为输入层,第2层和第3层作为隐藏层,第4层作为输出层,同时可以确定该初始神经网络中相邻两层单元节点间的连接为全连接。以第1层和第2层单元节点间的连接为例,首先将第1层中第m个单元节点与第2层中第n个单元节点的连线对应的权重参数值用wmn表示,其中,1≤m≤5,1≤n≤4;则第1层和第2层中单元节点间可以形成一个5×4阶的二维权重参数矩阵,该二维权重参数矩阵W5×4可以表示为:Illustratively, FIG. 2b is a structural diagram of a trained initial neural network according to Embodiment 2 of the present invention. As shown in FIG. 2b, the initial neural network has four layers of unit nodes, wherein the first layer serves as an input layer. Layers 2 and 3 act as hidden layers, and layer 4 acts as an output layer, and it can be determined that the connections between adjacent two-layer unit nodes in the initial neural network are fully connected. Taking the connection between the first layer and the second layer unit node as an example, first, the weight parameter value corresponding to the connection between the mth unit node in the first layer and the nth unit node in the second layer is represented by w mn . Wherein, 1≤m≤5, 1≤n≤4; then a 5×4 order two-dimensional weight parameter matrix can be formed between the unit nodes in the first layer and the second layer, and the two-dimensional weight parameter matrix W 5×4 It can be expressed as:
Figure PCTCN2016113271-appb-000001
Figure PCTCN2016113271-appb-000001
S203、如果初始神经网络中相邻两层单元节点间的连接为卷积连接,则基于单元节点间连线对应的权重参数数组形成多维权重参数矩阵,之后执行步骤S205。S203. If the connection between two adjacent unit nodes in the initial neural network is a convolution connection, the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes, and then step S205 is performed.
在本实施例中,当相邻两层单元节点间的连接为多线连接(至少存在两条连线)或用函数表示连接关系时,可将该相邻两层单元节点间的连接称为卷积连接。此时,其中一层的任一单元节点到另一层的任一单元节点间可能存在一个权重参数数组(一般为一维数组或二维数组),由此可以根据相邻两层单元节点间连线对应的权重参数数组来构建多维权重参数矩阵,其中,当权重参数数组为一维数组时,可以形成一个三维权重参数矩阵,当权重参数数组为二维数组时,可以形成一个四维权重参数矩阵。In this embodiment, when the connection between two adjacent unit nodes is a multi-line connection (at least two connections exist) or a connection relationship is represented by a function, the connection between the adjacent two-layer unit nodes may be referred to as Convolution connection. At this time, there may be an array of weight parameters (generally a one-dimensional array or a two-dimensional array) between any one of the unit nodes of one layer to any of the unit nodes of the other layer, thereby being able to be based on the adjacent two-level unit nodes. The multi-weight weight parameter matrix is constructed by connecting the weight parameter array corresponding to the line, wherein when the weight parameter array is a one-dimensional array, a three-dimensional weight parameter matrix can be formed, and when the weight parameter array is a two-dimensional array, a four-dimensional weight parameter can be formed. matrix.
S204、基于二维权重参数矩阵中的列向量确定初始神经网络中待删除的单 元节点。S204. Determine, according to a column vector in the two-dimensional weight parameter matrix, the to-be-deleted list in the initial neural network. Meta node.
具体地,基于所述二维权重参数矩阵中的列向量确定所述初始神经网络中待删除的单元节点包括:获取所述二维权重参数矩阵中第i列的列向量;如果所述第i列的列向量中包括的权重参数值均小于设定的第一删除阈值,则将相邻两层中第二层的第i个单元节点确定为所述初始神经网络中待删除的单元节点。Specifically, determining the unit node to be deleted in the initial neural network based on the column vector in the two-dimensional weight parameter matrix includes: acquiring a column vector of the i-th column in the two-dimensional weight parameter matrix; If the weight parameter values included in the column vector of the column are all smaller than the set first deletion threshold, the i-th unit node of the second layer in the adjacent two layers is determined as the unit node to be deleted in the initial neural network.
在本实施例中,对于全连接的相邻两层单元节点而言,假设所形成的二维权重参数矩阵为g×h阶,则可确定该二维权重参数矩阵共有h列的列向量,且可确定该二维权重参数矩阵中的第i列中的权重参数值均与该相邻两层中第二层的第i个单元节点相关。具体地,待删除的单元节点的确定过程可表述为:获取所设定的第一删除阈值,在该二维权重参数矩阵中选取第i列的列向量,并确定第i列列向量中所包含的g个权重参数值是否均小于第一设定阈值,如果全部小于第一设定阈值,则可以将相邻两层中第二层的第i个单元节点确定为所述初始神经网络中待删除的单元节点。In this embodiment, for the fully connected adjacent two-layer unit nodes, if the formed two-dimensional weight parameter matrix is g×h order, it may be determined that the two-dimensional weight parameter matrix has a column vector of the h column. And determining that the weight parameter values in the i-th column of the two-dimensional weight parameter matrix are related to the i-th unit node of the second layer in the adjacent two layers. Specifically, the determining process of the unit node to be deleted may be expressed as: acquiring the set first deletion threshold, selecting a column vector of the i-th column in the two-dimensional weight parameter matrix, and determining the ith column column vector Whether the included g weight parameter values are all smaller than the first set threshold, and if all are smaller than the first set threshold, the i-th unit node of the second layer of the adjacent two layers may be determined as the initial neural network. The cell node to be deleted.
在本实施例中,假设g×h阶的二维权重参数矩阵中的权重参数值表示为wai,所获取的第一删除阈值为t1,其中,1≤a≤g,1≤i≤h,则判定第i列列向量中所包含的g个权重参数值是否均小于第一设定阈值t1的过程可以具体描述为:如果第i列列向量中的权重参数值wai小于第一删除阈值t1,则确定函数f(wai)=0,否则,确定函数f(wai)=1,之后判定
Figure PCTCN2016113271-appb-000002
的值是否等于0,如果等于0,则可认为第i列列向量中所包含的g个权重参数值均小于第一设定阈值t1。需要说明的是,在首次设定第一删除阈值时,该第一删除阈值可以优选的基于二维权重参数矩阵中权重参数值的基本分布规律设定。
In this embodiment, it is assumed that the weight parameter value in the two-dimensional weight parameter matrix of g×h order is represented as w ai , and the obtained first deletion threshold is t 1 , where 1≤a≤g, 1≤i≤ h, the process of determining whether the g weight parameter values included in the i-th column column vector are all smaller than the first set threshold t 1 may be specifically described as: if the weight parameter value w ai in the i-th column column vector is smaller than the first Once the threshold t 1 is deleted, the function f(w ai )=0 is determined. Otherwise, the function f(w ai )=1 is determined, and then determined.
Figure PCTCN2016113271-appb-000002
Whether the value is equal to 0, if equal to 0, it can be considered that the g weight parameter values included in the i-th column column vector are all smaller than the first set threshold t 1 . It should be noted that, when the first deletion threshold is set for the first time, the first deletion threshold may be preferably set based on a basic distribution rule of the weight parameter values in the two-dimensional weight parameter matrix.
S205、基于降维后的多维权重参数矩阵确定初始神经网络中待删除的单元节点。S205. Determine, according to the dimension reduction multidimensional weight parameter matrix, the unit node to be deleted in the initial neural network.
在本实施例中,对于卷积连接的相邻两层单元节点而言,则可以形成一个多维权重参数矩阵,此时需要对该多维权重参数矩阵进行降维处理,且在降维处理后形成一个二维的目标权重参数矩阵,之后可以根据该目标权重参数矩阵来确定待删除的单元节点。In this embodiment, for a convoluted adjacent two-layer unit node, a multi-dimensional weight parameter matrix may be formed. In this case, the multi-dimensional weight parameter matrix needs to be subjected to dimensionality reduction processing, and is formed after the dimensionality reduction processing. A two-dimensional target weight parameter matrix, after which the cell node to be deleted can be determined according to the target weight parameter matrix.
进一步地,基于降维后的多维权重参数矩阵确定所述初始神经网络中待删除的单元节点包括:对所述多维权重参数矩阵进行降维处理,形成二维的目标权重参数矩阵;获取所述目标权重参数矩阵中第j列的列向量;如果所述第j列的列向量中包括的元素值均小于设定的第二删除阈值,则将相邻两层中第二层的第j个单元节点确定为所述初始神经网络中待删除的单元节点。Further, determining the unit node to be deleted in the initial neural network based on the dimension-reduced multi-dimensional weight parameter matrix comprises: performing dimension reduction processing on the multi-dimensional weight parameter matrix to form a two-dimensional target weight parameter matrix; a column vector of the jth column in the target weight parameter matrix; if the element values included in the column vector of the jth column are all smaller than the set second deletion threshold, the jth of the second layer in the adjacent two layers The unit node is determined to be a unit node to be deleted in the initial neural network.
在本实施例中,对多维权重参数矩阵进行降维处理,形成二维的目标权重参数矩阵的过程可描述为:确定多维权重参数矩阵的维度以及矩阵中的元素值,如果多维权重参数矩阵为三维权重参数矩阵,则该矩阵中每个元素值通常为一维数组,此时可直接对一维数组中的数据进行求和计算,最终可以将计算所得的数据和或数据和的平均值作为降维后目标权重参数矩阵对应的元素值;如果多维权重参数矩阵为四维权重参数矩阵,则该矩阵中每个元素值通常为二维数组,此时先对二维数组中各列的列数据进行求和计算,得到相应的列数据和,然后再对列数据和进行求和计算,最终可以将计算所得的数据和或数据和的平均值作为降维后目标权重参数矩阵对应的元素值。In this embodiment, the process of reducing the dimensionality of the multi-dimensional weight parameter matrix to form a two-dimensional target weight parameter matrix may be described as: determining the dimension of the multi-dimensional weight parameter matrix and the element value in the matrix, if the multi-dimensional weight parameter matrix is The three-dimensional weight parameter matrix, the value of each element in the matrix is usually a one-dimensional array, in this case, the data in the one-dimensional array can be directly summed, and finally the calculated data and or the average of the data sum can be used as The element value corresponding to the target weight parameter matrix after dimension reduction; if the multi-dimensional weight parameter matrix is a four-dimensional weight parameter matrix, each element value in the matrix is usually a two-dimensional array, and the column data of each column in the two-dimensional array is first used. The summation calculation is performed to obtain the corresponding column data sum, and then the column data is summed and calculated. Finally, the calculated data and the average value of the data sum may be used as the element values corresponding to the dimension-reduced target weight parameter matrix.
在本实施例中,对多维权重参数矩阵进行降维处理获得目标权重参数矩阵后,可以在所形成目标权重参数矩阵中进行待删除的单元节点的确定,由于后 续确定待删除的单元节点的操作过程与基于步骤S204进行单元节点确定的操作过程相同,这里不再赘述。需要说明的是,在首次设定第二删除阈值时,该第二删除阈值可以优选的基于目标权重参数矩阵中元素值的基本分布规律设定。In this embodiment, after performing the dimensionality reduction processing on the multi-dimensional weight parameter matrix to obtain the target weight parameter matrix, the determination of the unit node to be deleted may be performed in the formed target weight parameter matrix, The operation process of determining the unit node to be deleted is the same as the operation process determined by the unit node based on step S204, and details are not described herein again. It should be noted that, when the second deletion threshold is set for the first time, the second deletion threshold may be preferably set based on a basic distribution rule of the element values in the target weight parameter matrix.
S206、删除神经网络中确定的单元节点,形成优化后的目标神经网络。S206. Delete the unit nodes determined in the neural network to form an optimized target neural network.
在本实施例中,基于上述步骤S201至步骤S205的操作,可以确定出初始神经网络中所有待删除的单元节点,由此可以在初始神经网络中删除所有确定出的单元节点,并同时删除与该单元节点存在关系的连线。In this embodiment, based on the operations of step S201 to step S205 described above, all the unit nodes to be deleted in the initial neural network may be determined, thereby deleting all the determined unit nodes in the initial neural network, and simultaneously deleting and The unit node has a connection to the relationship.
示例性地,图2c为本发明实施例二中对初始神经网络优化后所形成目标神经网络的结构图。接上述步骤S202中的示例,如图2c所示,与图2b中的初始神经网络相比,在第2层中减少了一个单元节点,由此可知,基于本发明实施例二提供的神经网络的优化方法,实现了对图2b中初始神经网络第2层的第2个单元节点进行删除的优化。Illustratively, FIG. 2c is a structural diagram of a target neural network formed by optimizing an initial neural network according to Embodiment 2 of the present invention. Following the example in the above step S202, as shown in FIG. 2c, compared with the initial neural network in FIG. 2b, one unit node is reduced in the second layer, and thus, the neural network provided according to the second embodiment of the present invention is known. The optimization method realizes the optimization of deleting the second unit node of the second layer of the initial neural network in Fig. 2b.
本发明实施例二提供的一种神经网络的优化方法,具体描述了神经网络中相邻两层单元节点间具有不同连接方式时所对应权重参数矩阵的确定过程;还具体描述了不同权重参数矩阵下对待删除的单元节点的确定过程。利用该方法,能够对具有不同单元节点连接方式的神经网络进行压缩优化,由此在基于优化的后神经网络进行人脸识别时,能够达到加快识别处理速度,缩短识别处理时间,降低存储、运行内存以及显存等空间占用的目的。A method for optimizing a neural network according to Embodiment 2 of the present invention specifically describes a process for determining a weight matrix of corresponding weights when different adjacent nodes of a neural network have different connection modes; and specifically describing different weight parameter matrices The process of determining the cell node to be deleted. By using this method, the neural network with different unit node connection modes can be compressed and optimized, so that when the face recognition based on the optimized back neural network is used, the recognition processing speed can be accelerated, the recognition processing time can be shortened, and the storage and operation can be reduced. The purpose of memory and space occupied by video memory.
实施例三 Embodiment 3
图3a为本发明实施例三提供的一种神经网络的优化方法的流程示意图。本 发明实施例以上述实施例为基础进行优化,在本实施例中,还优化增加了:确定所述目标神经网络的当前处理精度是否符合所述设定精度条件,基于确定结果对所述目标神经网络进行训练学习或深度优化。FIG. 3a is a schematic flowchart diagram of a method for optimizing a neural network according to Embodiment 3 of the present invention. Ben The embodiment of the present invention is optimized based on the foregoing embodiment. In this embodiment, the optimization is further increased: determining whether the current processing precision of the target neural network meets the set precision condition, and determining the target neural network based on the determination result. The network conducts training learning or deep optimization.
在上述优化的基础上,将基于确定结果对所述目标神经网络进行训练学习或深度优化,进一步优化为:如果所述当前处理精度不符合所述设定精度条件,则对所述目标神经网络进行训练学习直至符合所述设定精度条件或达到设定训练次数;否则,对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新执行神经网络的优化操作,其中,所述删除阈值为第一删除阈值或第二删除阈值。On the basis of the above optimization, the training learning or depth optimization of the target neural network based on the determination result is further optimized to: if the current processing precision does not meet the set precision condition, then the target neural network is Performing training learning until the set accuracy condition is met or the set training number is reached; otherwise, the deletion threshold is self-incremented, and the target neural network is used as a new initial neural network to re-execute the neural network optimization. The operation, wherein the deletion threshold is a first deletion threshold or a second deletion threshold.
在上述优化的基础上,还优化包括了另一种情况的操作,即,如果训练学习后的目标神经网络符合所述设定精度条件且训练次数不大于所述设定训练次数,则对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新执行神经网络的优化操作。On the basis of the above optimization, the operation including another case is also optimized, that is, if the target neural network after the training learning meets the set precision condition and the number of training times is not greater than the set training number, then The deletion threshold is performed by a self-incrementing operation, and the target neural network is used as a new initial neural network to re-execute the optimization operation of the neural network.
如图3所示,本发明实施例三提供的一种神经网络的优化方法,具体包括如下操作:As shown in FIG. 3, a method for optimizing a neural network according to Embodiment 3 of the present invention specifically includes the following operations:
S301、获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵。S301. Acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network.
在本实施例中,可以认为所获取的初始神经网络具体用来进行人脸识别,则设定精度条件就可认为是人脸识别时神经网络所要求达到的处理精度。In this embodiment, it can be considered that the acquired initial neural network is specifically used for face recognition, and the setting precision condition can be considered as the processing precision required by the neural network in face recognition.
S302、根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点。S302. Process the weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network.
S303、删除所述单元节点形成优化后的目标神经网络。 S303. Delete the unit node to form an optimized target neural network.
S304、确定目标神经网络的当前处理精度是否符合设定精度条件,若否,则执行步骤S305;若是,则执行步骤S307。S304. Determine whether the current processing precision of the target neural network meets the set precision condition. If not, execute step S305; if yes, execute step S307.
在本实施例中,还可以认为优化后的目标神经网络也具体用于进行人脸识别,因此,也需要测试目标神经网络的当前处理精度是否符合设定精度条件。In this embodiment, it can also be considered that the optimized target neural network is also specifically used for face recognition. Therefore, it is also required to test whether the current processing accuracy of the target neural network meets the set accuracy condition.
具体地,对目标神经网络的当前处理精度的测试过程可描述为:首先依据国际标准人脸验证测试集的规则来选取目标神经网络测试所需的样本图像,优选地,可选取3000对正样本图像(一对正样本图像为两张具有相同人脸的图像)和3000对负样本图像(一对负样本图像为两张具有不同人脸的图像);然后,分别将正样本图像对和负样本图像对作为目标神经网络的输入数据;最终,可根据人脸识别的输出结果X的值以及当前处理精度的计算公式,来确定目标神经网络的当前处理精度。Specifically, the testing process of the current processing accuracy of the target neural network may be described as follows: first, the sample image required for the target neural network test is selected according to the rules of the international standard face verification test set, and preferably, 3000 pairs of positive samples may be selected. Image (a pair of positive sample images are two images with the same face) and 3000 pairs of negative sample images (a pair of negative sample images are two images with different faces); then, the positive sample images are paired and negative, respectively The sample image pair is input data of the target neural network; finally, the current processing accuracy of the target neural network can be determined according to the value of the output result X of the face recognition and the calculation formula of the current processing precision.
示例性地,当目标神经网络将正样本图像对中的两个图像判定为同一人时,输出结果X的值为1,否则输出结果X的值为0;当目标神经网络将负样本图像对中的两个图像判定为非同一人时,输出结果X的值为1,否则输出结果X的值为0。其中,当前处理精度的计算公式可表示为:
Figure PCTCN2016113271-appb-000003
Illustratively, when the target neural network determines two images in the positive sample image pair as the same person, the output result X has a value of 1, otherwise the output result X has a value of 0; when the target neural network will have a negative sample image pair When the two images in the determination are not the same person, the value of the output result X is 1, otherwise the value of the output result X is 0. Among them, the calculation formula of the current processing precision can be expressed as:
Figure PCTCN2016113271-appb-000003
在本实施例中,如果所确定的当前处理精度符合了设定精度条件,则可直接执行步骤S307的操作,否则,需要执行步骤S305的操作。In this embodiment, if the determined current processing precision meets the set precision condition, the operation of step S307 may be directly performed; otherwise, the operation of step S305 needs to be performed.
S305、对目标神经网络进行训练学习,之后执行步骤S306。S305. Perform training learning on the target neural network, and then perform step S306.
在本实施例中,当所确定的当前处理精度不符合设定精度条件,可以基于设定的训练学习方法对目标神经网络进行训练学习。这里不再详述训练学习所采用的训练学习方法。 In this embodiment, when the determined current processing accuracy does not meet the set accuracy condition, the target neural network may be trained and learned based on the set training learning method. The training learning method used in training learning is not detailed here.
S306、确定对目标神经网络进行训练学习的训练次数是否达到设定训练次数,若否,则返回执行步骤S304;若是,则执行步骤S308。S306. Determine whether the number of trainings for training the target neural network reaches the set training number. If not, return to step S304; if yes, execute step S308.
在本实施例中,对目标神经网络进行训练学习后,需要判定对其进行训练学习的训练次数是否达到设定训练次数,然后基于判定结果执行不同的操作步骤。In this embodiment, after training the target neural network, it is necessary to determine whether the number of trainings for which the training is performed reaches the set training number, and then perform different operation steps based on the determination result.
S307、对删除阈值进行自增加操作,并将目标神经网络作为新的初始神经网络,返回执行步骤S301。S307. Perform a self-increment operation on the deletion threshold, and use the target neural network as a new initial neural network, and return to step S301.
在本实施例中,如果目标神经网络的当前处理精度符合了设定精度条件,则可对当前的目标神经网络继续基于步骤S301至步骤S303进行深度优化。In this embodiment, if the current processing accuracy of the target neural network meets the set accuracy condition, the current target neural network may continue to perform depth optimization based on steps S301 to S303.
在对目标神经网络进行深度优化之前,可以对删除阈值进行自增加操作,然后再将目标神经网络作为初始神经网络,之后返回步骤S301重新开始进行神经网络的优化。需要说明的是,由于本实施例中删除阈值为为第一删除阈值或第二删除阈值,因此,删除阈值自增加操作所依据的增量值主要基于具体情况设定。可以理解的是,基于增加后的删除阈值进行神经网络优化时,可以确定出更多的待删除的单元节点,从而可以更快的确定出最终适合人脸识别的目标神经网络。Before performing deep optimization on the target neural network, the deletion threshold may be self-incremented, and then the target neural network is used as the initial neural network, and then returning to step S301 to restart the optimization of the neural network. It should be noted that, since the deletion threshold is the first deletion threshold or the second deletion threshold in this embodiment, the incremental value according to the deletion threshold self-increment operation is mainly set based on a specific situation. It can be understood that when the neural network optimization is performed based on the added deletion threshold, more unit nodes to be deleted can be determined, so that the target neural network that is finally suitable for face recognition can be determined more quickly.
示例性地,图3b为本发明实施例三中对原目标神经网络深度优化形成的目标神经网络的结构图,接上述实施例二中步骤S206中的示例,可以认为图3b中所示的目标神经网络是对图2c中所示目标神经网络的进一步深度优化,如图3b所示,与图2c中提供的目标神经网络相比,在第3层中有减少了一个单元节点,由此可知,基于本发明实施例三提供的神经网络的优化方法,实现了对图2c中提供的目标神经网络第3层的第2个单元节点进行删除的深度优化。 Illustratively, FIG. 3b is a structural diagram of a target neural network formed by depth optimization of an original target neural network according to Embodiment 3 of the present invention. According to the example in step S206 in the second embodiment, the target shown in FIG. 3b can be considered. The neural network is a further depth optimization of the target neural network shown in Figure 2c, as shown in Figure 3b, compared to the target neural network provided in Figure 2c, there is a reduction of one unit node in the third layer, thus knowing Based on the optimization method of the neural network provided by the third embodiment of the present invention, the depth optimization of deleting the second unit node of the third layer of the target neural network provided in FIG. 2c is implemented.
S308、结束对目标神经网络的训练学习。S308. End training learning on the target neural network.
在本实施例中,如果对目标神经网络进行训练学习的训练次数达到了设定训练次数,且此时对应的当前处理精度仍不符合设定精度条件,则可以结束对目标神经网络的训练学习,同时,可以优选的确定上一次作为初始神经网络进行深度优化的目标神经网络为人脸识别所需的神经网络。In this embodiment, if the number of trainings for training the target neural network reaches the set training number, and the current processing accuracy corresponding to the current processing does not meet the set precision condition, the training of the target neural network may be ended. At the same time, it can be preferably determined that the target neural network that was last optimized as the initial neural network is the neural network required for face recognition.
本发明实施例三提供的一种神经网络的优化方法,进一步增加了对优化后神经网络再次进行训练学习或深度优化的操作,由此来保持优化后神经网络的处理计算精度,与现有优化方法相比,能够在不降低神经网络处理计算精度的情况下,实现神经网络的压缩优化,从而在基于优化的后神经网络进行人脸识别时,达到加快人脸识别处理速度,缩短人脸识别处理时间,降低存储、运行内存以及显存等空间占用的目的。A method for optimizing a neural network according to Embodiment 3 of the present invention further increases the operation of training learning or deep optimization for the optimized neural network, thereby maintaining the processing precision of the optimized neural network and the existing optimization. Compared with the method, the compression optimization of the neural network can be realized without reducing the computational accuracy of the neural network processing, so as to speed up the face recognition processing and shorten the face recognition when performing face recognition based on the optimized back neural network. Processing time, reducing the purpose of storage, running memory, and space occupied by video memory.
实施例四 Embodiment 4
图4为本发明实施例四提供的一种神经网络的优化装置的结构框图。该装置适用于对训练学习后的神经网络进行压缩优化的情况,其中该装置可由软件和/或硬件实现,并一般集成在神经网络模型所在的终端设备或服务器平台上。如图4所示,该优化装置包括:参数矩阵确定模块41、待删除节点确定模块42以及目标网络确定模块43。FIG. 4 is a structural block diagram of an apparatus for optimizing a neural network according to Embodiment 4 of the present invention. The device is suitable for compression optimization of a neural network after training and learning, wherein the device can be implemented by software and/or hardware, and is generally integrated on a terminal device or a server platform where the neural network model is located. As shown in FIG. 4, the optimization apparatus includes a parameter matrix determination module 41, a node determination module 42 to be deleted, and a target network determination module 43.
其中,参数矩阵确定模块41,用于获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵;The parameter matrix determining module 41 is configured to acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
待删除节点确定模块42,用于根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点; The to-be-deleted node determining module 42 is configured to process the weight parameter matrix according to the set deletion threshold to determine a unit node to be deleted in the initial neural network;
目标网络确定模块43,用于删除所述单元节点形成优化后的目标神经网络。The target network determining module 43 is configured to delete the unit node to form an optimized target neural network.
在本实施例中,该优化装置首先通过参数矩阵确定模块41获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵;然后通过待删除节点确定模块42根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点;最终通过目标网络确定模块43删除所述单元节点形成优化后的目标神经网络。In this embodiment, the optimization device first obtains an initial neural network that meets the set precision condition by the parameter matrix determination module 41, and determines a weight parameter matrix between adjacent two layer unit nodes in the initial neural network; The node determining module 42 processes the weight parameter matrix according to the set deletion threshold to determine a unit node to be deleted in the initial neural network; finally, the target network determining module 43 deletes the unit node to form an optimized target neural network.
本发明实施例四提供的一种神经网络的优化装置,能够简单高效的对神经网络进行压缩,实现神经网络的优化,由此在基于优化的后神经网络进行人脸识别时,能够达到加快识别处理速度,缩短识别处理时间,降低存储、运行内存以及显存等空间占用的目的。The neural network optimization device provided in Embodiment 4 of the present invention can compress the neural network simply and efficiently, and realize the optimization of the neural network, thereby achieving accelerated recognition when performing face recognition based on the optimized back neural network. Processing speed, shorten recognition processing time, and reduce the space occupied by storage, running memory and video memory.
进一步地,参数矩阵确定模块41具体用于:Further, the parameter matrix determining module 41 is specifically configured to:
在获取符合设定精度条件的初始神经网络后,如果所述初始神经网络中相邻两层单元节点间的连接为全连接,则基于单元节点间连线对应的权重参数值形成二维权重参数矩阵;如果所述初始神经网络中相邻两层单元节点间的连接为卷积连接,则基于单元节点间连线对应的权重参数数组形成多维权重参数矩阵。After obtaining the initial neural network that meets the set precision condition, if the connection between two adjacent unit nodes in the initial neural network is fully connected, the two-dimensional weight parameter is formed based on the weight parameter values corresponding to the connection between the unit nodes. a matrix; if the connection between two adjacent unit nodes in the initial neural network is a convolution connection, the multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes.
进一步地,待删除节点确定模块42包括:Further, the node to be deleted module 42 includes:
第一确定单元,用于当所述权重参数矩阵为二维权重参数矩阵时,基于所述二维权重参数矩阵中的列向量确定所述初始神经网络中待删除的单元节点;a first determining unit, configured to: when the weight parameter matrix is a two-dimensional weight parameter matrix, determine a cell node to be deleted in the initial neural network based on a column vector in the two-dimensional weight parameter matrix;
第二确定单元,用于当所述权重参数矩阵为多维权重参数矩阵时,基于降维后的多维权重参数矩阵确定所述初始神经网络中待删除的单元节点。And a second determining unit, configured to: when the weight parameter matrix is a multi-dimensional weight parameter matrix, determine a cell node to be deleted in the initial neural network based on the dimension-reduced multi-dimensional weight parameter matrix.
在上述优化的基础上,第一确定单元具体用于: Based on the above optimization, the first determining unit is specifically configured to:
当所述权重参数矩阵为二维权重参数矩阵时,获取所述二维权重参数矩阵中第i列的列向量;如果所述第i列的列向量中包括的权重参数值均小于设定的第一删除阈值,则将相邻两层中第二层的第i个单元节点确定为所述初始神经网络中待删除的单元节点。When the weight parameter matrix is a two-dimensional weight parameter matrix, acquiring a column vector of the i-th column in the two-dimensional weight parameter matrix; if the weight parameter values included in the column vector of the i-th column are smaller than the set value The first deletion threshold determines the i-th unit node of the second layer in the adjacent two layers as the unit node to be deleted in the initial neural network.
进一步地,第二确定单元具体用于:Further, the second determining unit is specifically configured to:
当所述权重参数矩阵为二维权重参数矩阵时,对所述多维权重参数矩阵进行降维处理,形成二维的目标权重参数矩阵;获取所述目标权重参数矩阵中第j列的列向量;如果所述第j列的列向量中包括的元素值均小于设定的第二删除阈值,则将相邻两层中第二层的第j个单元节点确定为所述初始神经网络中待删除的单元节点。When the weight parameter matrix is a two-dimensional weight parameter matrix, the multi-dimensional weight parameter matrix is subjected to dimensionality reduction processing to form a two-dimensional target weight parameter matrix; and the column vector of the j-th column in the target weight parameter matrix is obtained; If the element values included in the column vector of the jth column are both smaller than the set second deletion threshold, determining the jth unit node of the second layer of the adjacent two layers as the to-be-deleted in the initial neural network Unit node.
进一步地,该优化装置还包括:目标网络处理模块44,用于确定所述目标神经网络的当前处理精度是否符合所述设定精度条件,基于确定结果对所述目标神经网络进行训练学习或深度优化。Further, the optimization apparatus further includes: a target network processing module 44, configured to determine whether a current processing precision of the target neural network meets the set precision condition, and perform training learning or depth on the target neural network based on the determination result. optimization.
在上述优化的基础上,目标网络处理模块44具体用于:Based on the above optimization, the target network processing module 44 is specifically configured to:
确定所述目标神经网络的当前处理精度是否符合所述设定精度条件;如果所述当前处理精度不符合所述设定精度条件,则对所述目标神经网络进行训练学习直至符合所述设定精度条件或达到设定训练次数;否则,对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新执行神经网络的优化操作,其中,所述删除阈值为第一删除阈值或第二删除阈值。Determining whether the current processing precision of the target neural network meets the set precision condition; if the current processing accuracy does not meet the set accuracy condition, performing training learning on the target neural network until the setting is met The precision condition or the set training number is reached; otherwise, the deletion threshold is self-incremented, and the target neural network is used as a new initial neural network to re-execute the optimization operation of the neural network, wherein the deletion threshold is The first deletion threshold or the second deletion threshold.
进一步地,如果训练学习后的目标神经网络符合所述设定精度条件且训练次数不大于所述设定训练次数,则对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新执行神经网络的优化操作。 Further, if the target neural network after the training learning meets the set precision condition and the number of training times is not greater than the set training number, the self-increase operation is performed on the deletion threshold, and the target neural network is used as a new The initial neural network re-executes the optimization of the neural network.
注意,上述仅为本发明的较佳实施例及所运用技术原理。本领域技术人员会理解,本发明不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本发明的保护范围。因此,虽然通过以上实施例对本发明进行了较为详细的说明,但是本发明不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本发明的范围由所附的权利要求范围决定。 Note that the above are only the preferred embodiments of the present invention and the technical principles applied thereto. Those skilled in the art will appreciate that the invention is not limited to the specific embodiments described herein, and that various modifications, changes and substitutions may be made without departing from the scope of the invention. Therefore, the present invention has been described in detail by the above embodiments, but the present invention is not limited to the above embodiments, and other equivalent embodiments may be included without departing from the inventive concept. The scope is determined by the scope of the appended claims.

Claims (10)

  1. 一种神经网络的优化方法,其特征在于,包括:A method for optimizing a neural network, comprising:
    获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵;Obtaining an initial neural network that meets a set precision condition, and determining a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
    根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点;Processing the weight parameter matrix according to the set deletion threshold, and determining a unit node to be deleted in the initial neural network;
    删除所述单元节点形成优化后的目标神经网络。Deleting the unit nodes forms an optimized target neural network.
  2. 根据权利要求1所述的方法,其特征在于,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵包括:The method according to claim 1, wherein determining a weight parameter matrix between adjacent two-layer unit nodes in the initial neural network comprises:
    如果所述初始神经网络中相邻两层单元节点间的连接为全连接,则基于单元节点间连线对应的权重参数值形成二维权重参数矩阵;If the connection between two adjacent unit nodes in the initial neural network is a full connection, forming a two-dimensional weight parameter matrix based on the weight parameter values corresponding to the connection between the unit nodes;
    如果所述初始神经网络中相邻两层单元节点间的连接为卷积连接,则基于单元节点间连线对应的权重参数数组形成多维权重参数矩阵。If the connection between two adjacent unit nodes in the initial neural network is a convolution connection, a multi-dimensional weight parameter matrix is formed based on the weight parameter array corresponding to the connection between the unit nodes.
  3. 根据权利要求2所述的方法,其特征在于,根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点包括:The method according to claim 2, wherein the determining the weight parameter matrix according to the set deletion threshold, determining the unit node to be deleted in the initial neural network comprises:
    如果所述权重参数矩阵为二维权重参数矩阵,则基于所述二维权重参数矩阵中的列向量确定所述初始神经网络中待删除的单元节点;If the weight parameter matrix is a two-dimensional weight parameter matrix, determining a cell node to be deleted in the initial neural network based on a column vector in the two-dimensional weight parameter matrix;
    如果所述权重参数矩阵为多维权重参数矩阵,则基于降维后的多维权重参数矩阵确定所述初始神经网络中待删除的单元节点。If the weight parameter matrix is a multi-dimensional weight parameter matrix, the unit node to be deleted in the initial neural network is determined based on the dimension-reduced multi-dimensional weight parameter matrix.
  4. 根据权利要求3所述的方法,其特征在于,基于所述二维权重参数矩阵中的列向量确定所述初始神经网络中待删除的单元节点包括:The method according to claim 3, wherein determining the unit node to be deleted in the initial neural network based on the column vector in the two-dimensional weight parameter matrix comprises:
    获取所述二维权重参数矩阵中第i列的列向量;Obtaining a column vector of the i-th column in the two-dimensional weight parameter matrix;
    如果所述第i列的列向量中包括的权重参数值均小于设定的第一删除阈值, 则将相邻两层中第二层的第i个单元节点确定为所述初始神经网络中待删除的单元节点。If the value of the weight parameter included in the column vector of the i-th column is less than the set first deletion threshold, Then, the i-th unit node of the second layer in the adjacent two layers is determined as the unit node to be deleted in the initial neural network.
  5. 根据权利要求3所述的方法,其特征在于,基于降维后的多维权重参数矩阵确定所述初始神经网络中待删除的单元节点包括:The method according to claim 3, wherein determining the unit node to be deleted in the initial neural network based on the dimension-reduced multi-dimensional weight parameter matrix comprises:
    对所述多维权重参数矩阵进行降维处理,形成二维的目标权重参数矩阵;Performing dimensionality reduction processing on the multi-dimensional weight parameter matrix to form a two-dimensional target weight parameter matrix;
    获取所述目标权重参数矩阵中第j列的列向量;Obtaining a column vector of the jth column in the target weight parameter matrix;
    如果所述第j列的列向量中包括的元素值均小于设定的第二删除阈值,则将相邻两层中第二层的第j个单元节点确定为所述初始神经网络中待删除的单元节点。If the element values included in the column vector of the jth column are both smaller than the set second deletion threshold, determining the jth unit node of the second layer of the adjacent two layers as the to-be-deleted in the initial neural network Unit node.
  6. 根据权利要求1-5任一所述的方法,其特征在于,还包括:The method of any of claims 1-5, further comprising:
    确定所述目标神经网络的当前处理精度是否符合所述设定精度条件,基于确定结果对所述目标神经网络进行训练学习或深度优化。Determining whether the current processing precision of the target neural network meets the set accuracy condition, and performing training learning or depth optimization on the target neural network based on the determination result.
  7. 根据权利要求6所述的方法,其特征在于,基于确定结果对所述目标神经网络进行训练学习或深度优化包括:The method according to claim 6, wherein the training learning or depth optimization of the target neural network based on the determination result comprises:
    如果所述当前处理精度不符合所述设定精度条件,则对所述目标神经网络进行训练学习直至符合所述设定精度条件或达到设定训练次数;否则,If the current processing precision does not meet the set accuracy condition, performing training learning on the target neural network until the set accuracy condition is met or the set training number is reached; otherwise,
    对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新执行神经网络的优化操作,其中,所述删除阈值为第一删除阈值或第二删除阈值。Performing a self-incrementing operation on the deletion threshold, and using the target neural network as a new initial neural network to re-execute the optimization operation of the neural network, wherein the deletion threshold is a first deletion threshold or a second deletion threshold.
  8. 根据权利要求7所述的方法,其特征在于,如果训练学习后的目标神经网络符合所述设定精度条件且训练次数不大于所述设定训练次数,则对所述删除阈值进行自增加操作,并将所述目标神经网络作为新的初始神经网络,重新 执行神经网络的优化操作。The method according to claim 7, wherein if the target neural network after the training learning meets the set precision condition and the number of training times is not greater than the set training number, the deletion threshold is self-incremented. And the target neural network as a new initial neural network, re Perform optimization of the neural network.
  9. 一种神经网络的优化装置,其特征在于,包括:An apparatus for optimizing a neural network, comprising:
    参数矩阵确定模块,用于获取符合设定精度条件的初始神经网络,确定所述初始神经网络中相邻两层单元节点间的权重参数矩阵;a parameter matrix determining module, configured to acquire an initial neural network that meets a set precision condition, and determine a weight parameter matrix between adjacent two layer unit nodes in the initial neural network;
    待删除节点确定模块,用于根据设定的删除阈值处理所述权重参数矩阵,确定所述初始神经网络中待删除的单元节点;a node determining module to be deleted, configured to process the weight parameter matrix according to the set deletion threshold, and determine a unit node to be deleted in the initial neural network;
    目标网络确定模块,用于删除所述单元节点形成优化后的目标神经网络。The target network determining module is configured to delete the unit node to form an optimized target neural network.
  10. 根据权利要求9所述的装置,其特征在于,还包括:The device according to claim 9, further comprising:
    目标网络处理模块,用于确定所述目标神经网络的当前处理精度是否符合所述设定精度条件,基于确定结果对所述目标神经网络进行训练学习或深度优化。 The target network processing module is configured to determine whether the current processing precision of the target neural network meets the set precision condition, and perform training learning or depth optimization on the target neural network based on the determination result.
PCT/CN2016/113271 2016-10-11 2016-12-29 Method and device for optimizing neural network WO2018068421A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610887709.7 2016-10-11
CN201610887709.7A CN106650928A (en) 2016-10-11 2016-10-11 Method and device for optimizing neural network

Publications (1)

Publication Number Publication Date
WO2018068421A1 true WO2018068421A1 (en) 2018-04-19

Family

ID=58855232

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/113271 WO2018068421A1 (en) 2016-10-11 2016-12-29 Method and device for optimizing neural network

Country Status (2)

Country Link
CN (1) CN106650928A (en)
WO (1) WO2018068421A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3649582A4 (en) * 2017-07-07 2021-07-21 Darwinai Corporation System and method for automatic building of learning machines using learning machines

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109102074B (en) * 2017-06-21 2021-06-01 上海寒武纪信息科技有限公司 Training device
CN107247991A (en) * 2017-06-15 2017-10-13 北京图森未来科技有限公司 A kind of method and device for building neutral net
CN109492762A (en) * 2017-09-11 2019-03-19 北京博越世纪科技有限公司 A kind of technology of Optimal Neural Network Architectures
CN107862380A (en) * 2017-10-19 2018-03-30 珠海格力电器股份有限公司 Artificial neural network computing circuit
CN107807387B (en) * 2017-10-31 2019-08-27 中国科学技术大学 Acquisition methods when seismic first break neural network based is walked
CN109754077B (en) * 2017-11-08 2022-05-06 杭州海康威视数字技术股份有限公司 Network model compression method and device of deep neural network and computer equipment
CN112836792A (en) * 2017-12-29 2021-05-25 华为技术有限公司 Training method and device of neural network model
CN109791628B (en) * 2017-12-29 2022-12-27 清华大学 Neural network model block compression method, training method, computing device and system
CN108038546B (en) * 2017-12-29 2021-02-09 百度在线网络技术(北京)有限公司 Method and apparatus for compressing neural networks
CN108510058B (en) * 2018-02-28 2021-07-20 中国科学院计算技术研究所 Weight storage method in neural network and processor based on method
CN109472359B (en) * 2018-10-23 2021-06-04 深圳和而泰数据资源与云技术有限公司 Network structure processing method of deep neural network and related product
CN110991659B (en) * 2019-12-09 2024-03-08 北京奇艺世纪科技有限公司 Abnormal node identification method, device, electronic equipment and storage medium
CN111324860B (en) * 2020-02-11 2024-01-23 无锡北邮感知技术产业研究院有限公司 Lightweight CNN calculation method and device based on random matrix approximation
TWI778822B (en) * 2021-09-30 2022-09-21 鴻海精密工業股份有限公司 Image processing method based on neural network model, electronic equipment, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017351A1 (en) * 2008-07-17 2010-01-21 Hench John J Neural network based hermite interpolator for scatterometry parameter estimation
CN104504442A (en) * 2014-12-30 2015-04-08 湖南强智科技发展有限公司 Neural network optimization method
CN104751228A (en) * 2013-12-31 2015-07-01 安徽科大讯飞信息科技股份有限公司 Method and system for constructing deep neural network
CN105160396A (en) * 2015-07-06 2015-12-16 东南大学 Method utilizing field data to establish nerve network model
CN105373830A (en) * 2015-12-11 2016-03-02 中国科学院上海高等研究院 Prediction method and system for error back propagation neural network and server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017351A1 (en) * 2008-07-17 2010-01-21 Hench John J Neural network based hermite interpolator for scatterometry parameter estimation
CN104751228A (en) * 2013-12-31 2015-07-01 安徽科大讯飞信息科技股份有限公司 Method and system for constructing deep neural network
CN104504442A (en) * 2014-12-30 2015-04-08 湖南强智科技发展有限公司 Neural network optimization method
CN105160396A (en) * 2015-07-06 2015-12-16 东南大学 Method utilizing field data to establish nerve network model
CN105373830A (en) * 2015-12-11 2016-03-02 中国科学院上海高等研究院 Prediction method and system for error back propagation neural network and server

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3649582A4 (en) * 2017-07-07 2021-07-21 Darwinai Corporation System and method for automatic building of learning machines using learning machines

Also Published As

Publication number Publication date
CN106650928A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
WO2018068421A1 (en) Method and device for optimizing neural network
CN111369681B (en) Three-dimensional model reconstruction method, device, equipment and storage medium
CN108171663B (en) Image filling system of convolutional neural network based on feature map nearest neighbor replacement
KR20190031318A (en) Domain Separation Neural Networks
CN111695415A (en) Construction method and identification method of image identification model and related equipment
US20210312261A1 (en) Neural network search method and related apparatus
EP4322056A1 (en) Model training method and apparatus
CN111832437A (en) Building drawing identification method, electronic equipment and related product
CN111008631B (en) Image association method and device, storage medium and electronic device
CN109344893B (en) Image classification method based on mobile terminal
JP6811736B2 (en) Information processing equipment, information processing methods, and programs
JP2023523029A (en) Image recognition model generation method, apparatus, computer equipment and storage medium
CN112163601A (en) Image classification method, system, computer device and storage medium
CN111428854A (en) Structure searching method and structure searching device
CN112861659A (en) Image model training method and device, electronic equipment and storage medium
Mozejko et al. Superkernel neural architecture search for image denoising
CN115115924A (en) Concrete image crack type rapid intelligent identification method based on IR7-EC network
TW202001701A (en) Method for quantizing an image and method for training a neural network
CN110135428A (en) Image segmentation processing method and device
TWI758223B (en) Computing method with dynamic minibatch sizes and computing system and computer-readable storage media for performing the same
CN111079930A (en) Method and device for determining quality parameters of data set and electronic equipment
CN114638823B (en) Full-slice image classification method and device based on attention mechanism sequence model
CN110610140A (en) Training method, device and equipment of face recognition model and readable storage medium
CN112784967B (en) Information processing method and device and electronic equipment
WO2021179117A1 (en) Method and apparatus for searching number of neural network channels

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: 16918498

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: 16918498

Country of ref document: EP

Kind code of ref document: A1