CN110363297A - Neural metwork training and image processing method, device, equipment and medium - Google Patents

Neural metwork training and image processing method, device, equipment and medium Download PDF

Info

Publication number
CN110363297A
CN110363297A CN201910606138.9A CN201910606138A CN110363297A CN 110363297 A CN110363297 A CN 110363297A CN 201910606138 A CN201910606138 A CN 201910606138A CN 110363297 A CN110363297 A CN 110363297A
Authority
CN
China
Prior art keywords
parameter
network
group
convolution layer
layer parameter
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201910606138.9A
Other languages
Chinese (zh)
Inventor
俞海宝
温拓朴
孙建凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Sensetime Lingang Intelligent Technology Co Ltd
Original Assignee
Shanghai Sensetime Lingang Intelligent Technology Co Ltd
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 Shanghai Sensetime Lingang Intelligent Technology Co Ltd filed Critical Shanghai Sensetime Lingang Intelligent Technology Co Ltd
Priority to CN201910606138.9A priority Critical patent/CN110363297A/en
Publication of CN110363297A publication Critical patent/CN110363297A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Computing arrangements based on biological models using neural network models
    • G06N3/04Architectures, e.g. interconnection topology
    • G06N3/0454Architectures, e.g. interconnection topology using a combination of multiple neural nets
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Computing arrangements based on biological models using neural network models
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing

Abstract

Present embodiment discloses a kind of neural metwork training and image processing method, device, electronic equipment and computer storage mediums, the neural network training method includes: a discrete value being mapped as the parameter value of each convolution layer parameter in first nerves network in each group convolution layer parameter in the quantizing range of this group of convolution layer parameter, obtains nervus opticus network;Image procossing is carried out to first sample image using nervus opticus network;According to the annotation results and processing result of first sample image, the network parameter values of nervus opticus network are adjusted;The parameter value of each convolution layer parameter in network parameter values nervus opticus network adjusted in each group convolution layer parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, the neural network after obtaining parameter quantization.In this way, during being trained to neural network, by the quantization loss in every group of convolution layer parameter quantization to different quantizing ranges, during lower quantization.

Description

Neural metwork training and image processing method, device, equipment and medium
Technical field
This disclosure relates to computer vision processing technique more particularly to a kind of neural metwork training and image processing method, Device, electronic equipment and computer storage medium.
Background technique
With the application of deep neural network, the task processing accuracy rate of each computer vision data set is constantly being mentioned It is high;However, the intensification of neural network or widening the runing time that will definitely increase network during prediction.In recent years, in order to Deep neural network can be deployed in field programmable gate array (Field-Programmable Gate Array, FPGA) Equal low-power consumption are suitble on the resource platforms such as fixed-point calculation, and more and more researchers begin one's study will be in graphics processor Trained floating-point mould is quantized into the quantitative model of low bit in equipment such as (Graphics Processing Unit, GPU). And how to indicate model with less bit and be able to maintain the accuracy rate of model, become one, deep learning field hot spot side To.
Summary of the invention
The embodiment of the present disclosure is intended to provide the technical solution of neural metwork training and image procossing.
The embodiment of the present disclosure provides a kind of neural network training method, which comprises
This group of convolution is determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network The quantizing range of layer parameter;Wherein, the first nerves network is floating number neural network, every in the first nerves network Convolution layer parameter in a convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of each convolution layer parameter in the first nerves network in each group convolution layer parameter is mapped as this A discrete value in the quantizing range of group convolution layer parameter, obtains nervus opticus network;
Image procossing is carried out to first sample image using the nervus opticus network, obtains the first sample image Processing result;
According to the annotation results of the first sample image and the processing result of the first sample image, described in adjustment The network parameter values of nervus opticus network;
Using network parameter values nervus opticus network adjusted as first nerves network, repeat above-mentioned steps until Network parameter values nervus opticus network adjusted meets the first accuracy requirement of setting to the processing of image;
According to each group convolution layer parameter in each convolutional layer in network parameter values nervus opticus network adjusted Parameter value determines the quantizing range of this group of convolution layer parameter;Wherein, every in network parameter values nervus opticus network adjusted Convolution layer parameter in a convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer;
By each convolution layer parameter in network parameter values nervus opticus network adjusted in each group convolution layer parameter Parameter value is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, the neural network after obtaining parameter quantization.
Optionally, it is determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network Before the quantizing range of this group of convolution layer parameter, the method also includes:
The weight of this group of convolution layer parameter is determined according to the parameter value of every group of convolution layer parameter in the first nerves network Mould section;
The parameter value of every group of convolution layer parameter in the first nerves network is adjusted, to realize to this group of convolution The remodeling of the distribution of the parameter value of layer parameter;
Wherein, the parameter value of every group of convolution layer parameter after distribution is remolded in the first nerves network is rolled up in the group In the remodeling section of lamination parameter;The parameter value of every group of convolution layer parameter in distribution remodeling foregoing description first nerves network The integral of distribution curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling.
Optionally, the parameter value mapping of each convolution layer parameter in first nerves network in each group convolution layer parameter Before a discrete value in the quantizing range of this group of convolution layer parameter, the first nerves network is using following steps training It completes:
The second sample image is handled using initial neural network, obtains the processing knot of second sample image Fruit;The initial neural network is unbred floating number neural network;
According to the annotation results of second sample image and the processing result of second sample image, described in adjustment The network parameter values of initial neural network;
Determine that the group is rolled up according to the parameter value of every group of convolution layer parameter in network parameter values initial neural network adjusted The remodeling section of lamination parameter;Wherein, the convolution in each convolutional layer in network parameter values initial neural network adjusted Layer parameter is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of every group of convolution layer parameter in initial neural network adjusted to the network parameter values is adjusted It is whole, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;Wherein, the network parameter after distribution remodeling It is worth the parameter value of every group of convolution layer parameter in initial neural network adjusted in the remodeling section of this group of convolution layer parameter; Point of the parameter value of every group of convolution layer parameter in distribution remodeling foregoing description network parameter values initial neural network adjusted The integral of cloth curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling;
Image procossing is carried out to third sample image using the initial neural network after the distribution remodeling of convolution layer parameter, is obtained To the processing result of the third sample image;
According to the annotation results of the third sample image and the processing result of the third sample image, described in adjustment The network parameter values of initial neural network after the distribution remodeling of convolution layer parameter;
The distribution for repeating the convolution layer parameter in initial neural network adjusted to network parameter values is remolded The step of, and third sample image is carried out at image using the initial neural network after the distribution remodeling of convolution layer parameter Reason, and according to the annotation results of the third sample image and the processing result of the third sample image to the convolutional layer The step of network parameter values of initial neural network after the distribution remodeling of parameter are adjusted, until after network parameter values adjustment Initial neural network to image processing meet setting the second accuracy requirement, obtain first nerves network.
Optionally, using the following steps by the convolution layer parameter in each convolutional layer in the first nerves network according to Convolution kernel in the convolutional layer is divided at least two groups:
Using the adjacent convolution kernel of the first setting quantity in each convolutional layer in the first nerves network as one group;
Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
It optionally, will be in each convolutional layer in network parameter values initial neural network adjusted using the following steps Convolution layer parameter is divided at least two groups according to the convolution kernel in the convolutional layer:
By the phase of the second setting quantity in each convolutional layer in the network parameter values initial neural network adjusted Adjacent convolution kernel is as one group;
Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
Optionally, after distribution remodeling, the parameter value of every group of convolution layer parameter is in the remodeling section of this group of convolution layer parameter Inside it is evenly distributed.
Optionally, multiple discrete values in the quantizing range of every group of convolution layer parameter are equidistant discrete value.
The embodiment of the present disclosure additionally provides a kind of image processing method, which comprises
Obtain image to be processed;
The image to be processed is input to the neural network after parameter quantization, obtains the processing knot of the image to be processed Fruit, wherein the neural network after the parameter quantization is obtained according to any one of the above neural network training method.
The embodiment of the present disclosure additionally provides a kind of neural metwork training device, and described device includes first processing module and Two processing modules, wherein
First processing module, for the ginseng according to each group convolution layer parameter in each convolutional layer in first nerves network Numerical value determines the quantizing range of this group of convolution layer parameter;By each volume in the first nerves network in each group convolution layer parameter The parameter value of lamination parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, obtains nervus opticus net Network;Image procossing is carried out to first sample image using the nervus opticus network, obtains the processing of the first sample image As a result;According to the annotation results of the first sample image and the processing result of the first sample image, described the is adjusted The network parameter values of two neural networks;Using network parameter values nervus opticus network adjusted as first nerves network, first Processing module repeats its function until network parameter values nervus opticus network adjusted meets setting to the processing of image The first accuracy requirement;Wherein, the first nerves network is floating number neural network, each of described first nerves network Convolution layer parameter in convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer;
Second processing module, for according in each convolutional layer in network parameter values nervus opticus network adjusted The parameter value of each group convolution layer parameter determines the quantizing range of this group of convolution layer parameter;By network parameter values the second mind adjusted Parameter value through each convolution layer parameter in network in each group convolution layer parameter is mapped as the quantization model of this group of convolution layer parameter A discrete value in enclosing, the neural network after obtaining parameter quantization;Wherein, network parameter values nervus opticus network adjusted In each convolutional layer in convolution layer parameter at least two groups are divided into according to the convolution kernel in the convolutional layer.
Optionally, the first processing module is also used to according to each in each convolutional layer in first nerves network Before the parameter value of group convolution layer parameter determines the quantizing range of this group of convolution layer parameter, according in the first nerves network The parameter value of every group of convolution layer parameter determines the remodeling section of this group of convolution layer parameter;To every group in the first nerves network The parameter value of convolution layer parameter is adjusted, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;
Wherein, the parameter value of every group of convolution layer parameter after distribution is remolded in the first nerves network is rolled up in the group In the remodeling section of lamination parameter;The parameter value of every group of convolution layer parameter in distribution remodeling foregoing description first nerves network The integral of distribution curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling.
Optionally, the training device of neural network provided by the embodiments of the present application further includes third processing module, and described Three processing modules, the parameter value for each convolution layer parameter in first nerves network in each group convolution layer parameter map Before a discrete value in the quantizing range of this group of convolution layer parameter, initial neural network is instructed using following steps Get the first nerves network:
The second sample image is handled using the initial neural network, obtains the processing of second sample image As a result;The initial neural network is unbred floating number neural network;
According to the annotation results of second sample image and the processing result of second sample image, described in adjustment The network parameter values of initial neural network;
Determine that the group is rolled up according to the parameter value of every group of convolution layer parameter in network parameter values initial neural network adjusted The remodeling section of lamination parameter;Wherein, the convolution in each convolutional layer in network parameter values initial neural network adjusted Layer parameter is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of every group of convolution layer parameter in initial neural network adjusted to the network parameter values is adjusted It is whole, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;Wherein, the network parameter after distribution remodeling It is worth the parameter value of every group of convolution layer parameter in initial neural network adjusted in the remodeling section of this group of convolution layer parameter; Point of the parameter value of every group of convolution layer parameter in distribution remodeling foregoing description network parameter values initial neural network adjusted The integral of cloth curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling;
Image procossing is carried out to third sample image using the initial neural network after the distribution remodeling of convolution layer parameter, is obtained To the processing result of the third sample image;
According to the annotation results of the third sample image and the processing result of the third sample image, described in adjustment The network parameter values of initial neural network after the distribution remodeling of convolution layer parameter;
The distribution for repeating the convolution layer parameter in initial neural network adjusted to network parameter values is remolded The step of, and third sample image is carried out at image using the initial neural network after the distribution remodeling of convolution layer parameter Reason, and according to the annotation results of the third sample image and the processing result of the third sample image to the convolutional layer The step of network parameter values of initial neural network after the distribution remodeling of parameter are adjusted, until after network parameter values adjustment Initial neural network to image processing meet setting the second accuracy requirement, obtain first nerves network.
Optionally, the first processing module, for using the following steps by each volume in the first nerves network Convolution layer parameter in lamination is divided at least two groups according to the convolution kernel in the convolutional layer:
Using the adjacent convolution kernel of the first setting quantity in each convolutional layer in the first nerves network as one group; Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
Optionally, the third processing module, for using the following steps by network parameter values initial nerve adjusted The convolution layer parameter in each convolutional layer in network is divided at least two groups according to the convolution kernel in the convolutional layer:
By the phase of the second setting quantity in each convolutional layer in the network parameter values initial neural network adjusted Adjacent convolution kernel is as one group;Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
Optionally, after distribution remodeling, the parameter value of every group of convolution layer parameter is in the remodeling section of this group of convolution layer parameter Inside it is evenly distributed.
Optionally, multiple discrete values in the quantizing range of every group of convolution layer parameter are equidistant discrete value.
The embodiment of the present disclosure additionally provides a kind of image processing apparatus, and described device includes obtaining module and fourth process mould Block, wherein
Module is obtained, for obtaining image to be processed;
Fourth processing module obtains described for the image to be processed to be input to the neural network after parameter quantization The processing result of image to be processed, wherein the neural network after the parameter quantization is according to any one of the above neural network What training method obtained.
The embodiment of the present disclosure also proposed a kind of electronic equipment, including processor and can transport on a processor for storing The memory of capable computer program;Wherein,
The processor for run the computer program with execute any one of the above neural network training method or Any one of the above image processing method.
The embodiment of the present disclosure also proposed a kind of computer storage medium, be stored thereon with computer program, the computer Any one of the above neural network training method or any one of the above image processing method are realized when program is executed by processor.
The neural metwork training and image processing method, device, electronic equipment and computer that the embodiment of the present disclosure proposes are deposited In storage media, this group of convolution is determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network The quantizing range of layer parameter;Wherein, the first nerves network is floating number neural network, every in the first nerves network Convolution layer parameter in a convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer;It will be in the first nerves network The parameter value of each convolution layer parameter in each group convolution layer parameter is mapped as one in the quantizing range of this group of convolution layer parameter A discrete value obtains nervus opticus network;Image procossing is carried out to first sample image using the nervus opticus network, is obtained The processing result of the first sample image;According to the annotation results of the first sample image and the first sample image Processing result, adjust the network parameter values of the nervus opticus network;By network parameter values nervus opticus network adjusted As first nerves network, above-mentioned steps are repeated up to network parameter values nervus opticus network adjusted is to the place of image Reason meets the first accuracy requirement of setting;According in each convolutional layer in network parameter values nervus opticus network adjusted The parameter value of each group convolution layer parameter determines the quantizing range of this group of convolution layer parameter;Wherein, network parameter values adjusted The convolution layer parameter in each convolutional layer in two neural networks is divided at least two groups according to the convolution kernel in the convolutional layer;By net The parameter value of each convolution layer parameter in network parameter value nervus opticus network adjusted in each group convolution layer parameter is mapped as A discrete value in the quantizing range of this group of convolution layer parameter, the neural network after obtaining parameter quantization.In this way, in the disclosure In embodiment, during being trained to neural network, when convolution layer parameter is quantified as fixed-point number from floating number, not It is by the quantization of each convolution layer parameter in the same quantizing range, but by every group of convolution layer parameter group quantization to different In quantizing range, so that the quantization during lower quantization is lost, and by training come trim network parameter, thus meeting portion In the case where affixing one's name to environment, the precision and accuracy when neural network carries out image procossing are promoted as far as possible.
It should be understood that above general description and following detailed description is only exemplary and explanatory, rather than Limit the disclosure.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and those figures show meet this public affairs The embodiment opened, and together with specification it is used to illustrate the technical solution of the disclosure.
Fig. 1 is a kind of flow chart of the training method of neural network of the embodiment of the present disclosure;
Fig. 2 is the schematic diagram that the convolution layer parameter of the embodiment of the present disclosure is grouped;
Fig. 3 is the schematic diagram of the network parameter quantization and trim process of the neural network of the embodiment of the present disclosure;
Fig. 4 is the flow chart of another neural network training method of the embodiment of the present disclosure;
Fig. 5 is the flow chart of the training method of the first nerves network of the embodiment of the present disclosure;
Fig. 6 is the flow chart of the image processing method of the embodiment of the present disclosure;
Fig. 7 a is the signal quantified in disclosure Application Example to the convolution layer parameter with laplacian distribution Figure;
Fig. 7 b is the schematic diagram quantified in disclosure Application Example to the convolution layer parameter with Gaussian Profile;
Fig. 7 c is in disclosure Application Example to the schematic diagram quantified with equally distributed convolution layer parameter;
Fig. 8 a is the schematic diagram of the packet-based distribution remodeling quantization frame of disclosure Application Example;
Fig. 8 b is the signal of the test phase of the network of the packet-based distribution remodeling quantization of disclosure Application Example Figure;
Fig. 9 is influence schematic diagram of the remodeling distribution to quantization in disclosure Application Example;
Figure 10 is all convolution layer parameters and every group of convolution of trained ResNet-18 in disclosure Application Example The schematic diagram of the optimal α of layer parameter;
Figure 11 a is that first convolution of five floating-point moulds in different quantizing bit numbers is directed in disclosure Application Example Schematic diagram is lost in the quantization of layer weight coefficient;
Figure 11 b is that five floating-point moulds are directed in disclosure Application Example in different quantizing bit numbers 50 stages The schematic diagram of the accuracy rate of low bit model after fine tuning;
Figure 12 is the composed structure schematic diagram of the neural metwork training device of the embodiment of the present disclosure;
Figure 13 is the structural schematic diagram of a kind of electronic equipment of the embodiment of the present disclosure;
Figure 14 is the composed structure schematic diagram of the image processing apparatus of the embodiment of the present disclosure;
Figure 15 is the structural schematic diagram of another electronic equipment of the embodiment of the present disclosure.
Specific embodiment
With reference to the accompanying drawings and embodiments, the disclosure is further elaborated.It should be appreciated that mentioned herein Embodiment is only used to explain the disclosure, is not used to limit the disclosure.In addition, embodiment provided below is for implementing The section Example of the disclosure, rather than the whole embodiments for implementing the disclosure are provided, in the absence of conflict, the disclosure is implemented Example record technical solution can mode in any combination implement.
It should be noted that in the embodiments of the present disclosure, the terms "include", "comprise" or its any other variant are intended to Cover non-exclusive inclusion, so that including the method for a series of elements or device not only includes wanting of being expressly recited Element, but also including other elements that are not explicitly listed, or further include for implementation method or device intrinsic want Element.In the absence of more restrictions, the element limited by sentence " including one ... ", it is not excluded that wanted including this In the method or device of element there is also other relevant factor (such as the step in method or the unit in device, such as Unit can be partial circuit, segment processor, subprogram or software etc.).
For example, neural network training method and image processing method that the embodiment of the present disclosure provides contain a series of step Suddenly, but the neural network training method and image processing method of embodiment of the present disclosure offer are not limited to documented step, together Sample, the neural metwork training device and image processing apparatus that the embodiment of the present disclosure provides include a series of modules, but this The device that open embodiment provides is not limited to include module be expressly recited, and can also include to obtain relevant information or base The module of required setting when information is handled.
The terms "and/or", only a kind of incidence relation for describing affiliated partner, indicates that there may be three kinds of passes System, for example, A and/or B, can indicate: individualism A exists simultaneously A and B, these three situations of individualism B.In addition, herein Middle term "at least one" indicate a variety of in any one or more at least two any combination, it may for example comprise A, B, at least one of C can indicate to include any one or more elements selected from the set that A, B and C are constituted.
The embodiment of the present disclosure can be applied to terminal and server composition computer system in, and can with it is numerous other General or specialized computing system environment or configuration operate together.Here, terminal can be thin client, thick client computer, it is hand-held or Laptop devices, microprocessor-based system, set-top box, programmable consumer electronics, NetPC Network PC, minicomputer System, etc., server can be server computer system little type Ji and calculate machine Xi Tong ﹑ large computer system and including above-mentioned Distributed cloud computing technology environment of any system, etc..
The electronic equipments such as terminal, server can be (all in the computer system executable instruction executed by computer system Such as program module) describe under context.In general, program module may include routine, program, target program, component, patrol Volume, data structure etc., they execute specific tasks or realize specific abstract data type.Computer system/service Device can be implemented in distributed cloud computing environment, and in distributed cloud computing environment, task is by being linked through a communication network What remote processing devices executed.In distributed cloud computing environment, program module can be located at include storage equipment local or On remote computing system storage medium.
Based on the application scenarios of above-mentioned record, in some embodiments of the present disclosure, a kind of neural metwork training is proposed Method, the embodiment of the present disclosure can be applied to neural network compression and quantization scene, low-power consumption and low computing resource platform, image Classification and the relevant Computer Vision Task for needing to carry out network acceleration.
Fig. 1 is a kind of flow chart of neural network training method of the embodiment of the present disclosure, as shown in Figure 1, the process can be with Include:
Step 101: being determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network The quantizing range of this group of convolution layer parameter.
Wherein, first nerves network is floating number neural network, the convolution in each convolutional layer in first nerves network Layer parameter is divided at least two groups according to the convolution kernel in the convolutional layer.
Here, first nerves network includes multiple convolutional layers, before the first quantizing range for determining convolution layer parameter First nerves network, which can be, has completed trained floating number neural network;In the embodiment of the present disclosure, not to first nerves The packet mode of convolution layer parameter in each convolutional layer of network is defined, and illustrates the volume of first nerves network separately below Two kinds of embodiments of lamination parameter grouping: in the first embodiment, in each convolutional layer of first nerves network Convolution layer parameter, the mode that convolution kernel can be randomly selected carries out the grouping of convolution layer parameter, random to select in a convolutional layer Several convolution kernels are selected as one group, the corresponding convolution layer parameter of one group of convolution kernel is as one group of convolution layer parameter;It is real at second It applies in mode, it can be using the adjacent convolution kernel of the first setting quantity in each convolutional layer in first nerves network as one Group;Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter, pass through actual neural metwork training mistake For journey it is found that compared with using the first embodiment, the training speed ratio using neural network when second of embodiment is very fast, And the image of the neural network and the neural network obtained using the first embodiment that are obtained using second of embodiment The effect and precision of processing are essentially identical.
In the embodiment of the present disclosure, the first setting quantity can be imitated the processing of image according to the neural network after the completion of training Fruit determines;It is alternatively possible to using 8 adjacent convolution kernels as one group, neural network that training can in this way completed into Precision and accuracy when row image procossing is higher.
Fig. 2 is the schematic diagram that the convolution layer parameter of the embodiment of the present disclosure is grouped, as shown in Fig. 2, input parameter is some volume The convolution layer parameter of lamination, in a convolutional layer, convolution layer parameter includes n convolution kernel, in actual implementation, this n volume Product core is denoted as W respectively1、W2…Wn-1、Wn, this n convolution kernel can be grouped, in one example, when n is even number, One group can be divided into every two convolution kernel, available n/2 group.
Step 102: the parameter value of each convolution layer parameter in first nerves network in each group convolution layer parameter is mapped For a discrete value in the quantizing range of this group of convolution layer parameter, nervus opticus network is obtained.
Here, the parameter value of each convolution layer parameter in each group convolution layer parameter of first nerves network was mapped Journey, it is believed that be the quantizing process to each group convolution layer parameter of first nerves network;By to every group of convolution layer parameter Quantization, available corresponding discrete value.In the related art, in training neural network, usually to entire convolutional layer Convolution layer parameter carries out unified quantization;And in the embodiments of the present disclosure, each group convolution layer parameter can be quantified respectively, because And the ability to express of the discrete value after each group convolution layer parameter can be made full use of to map is conducive to reduce quantization loss The precision and accuracy rate of neural network are promoted, and then the precision for carrying out image procossing using neural network can be improved.
According to theory analysis, floating number parameter is after quantization, if quantization loss is smaller, illustrates essence caused by quantization Degree loss is smaller, and quantization loss can be obtained according to formula (1).
||S-quantize(S)|| (1)
Wherein, | | | | indicate p norm, p is positive integer, and S indicates floating number parameter, and quantize (S) indicates that S is quantified The discrete value obtained afterwards.
It, illustratively, can be adaptive according to formula (1) for the implementation quantified to every group of convolution layer parameter Ground determines the optimum quantization spacing of every group of convolution layer parameter, and then is grouped quantization.By experimental verification, this quantization method Quantization loss it is smaller.
Optionally, multiple discrete values in the quantizing range of every group of convolution layer parameter are equidistant discrete value;Namely It says, uniform quantization can be carried out to every group of convolution layer parameter;Uniform quantization in the embodiment of the present disclosure, to every group of convolution layer parameter It can be indicated with formula (2).
Wherein, w indicates the parameter for needing to quantify, and α indicates that the cutoff value for being greater than 0 of setting, clamp (w, α) are indicated w's Value is limited between [- α, α], specifically, when w is less than or equal to-α, clamp (w, α)=- α, when w is greater than or equal to α When, clamp (w, α)=α, as-α < w < α, clamp (w, α)=w;[] indicates that floor operation, s indicate quantizing factor;nw Indicate the bit number of quantization.
In the specific implementation, it can be directed to every group of suitable quantizing factor of convolutional layer parameter search, then according to formula (2) Carry out uniform quantization.The scheme of quantization is gone using unified quantizing factor compared to the convolution layer parameter relatively to each convolutional layer, it is right The scheme that each group convolution layer parameter is quantified respectively can make full use of the table of the discrete value after the mapping of each group convolution layer parameter Danone power, therefore, it is possible to reduce quantization loss.
Step 103: image procossing being carried out to first sample image using nervus opticus network, obtains first sample image Processing result.
Here, first sample image can be preset, and illustratively, the can be obtained from local storage region or network One sample image, the format of first sample image can be Joint Photographic Experts Group (Joint Photographic Experts GROUP, JPEG), bitmap (Bitmap, BMP), portable network figure (Portable Network Graphics, PNG) or extended formatting;It should be noted that being here only to be carried out to the format of first sample image and source For example, the embodiment of the present disclosure is not defined the format and source of first sample image.
Step 104: according to the annotation results of first sample image and the processing result of first sample image, adjustment second The network parameter values of neural network.
Here, the annotation results of first sample image are predetermined;It, can be according to first sample figure in practical application The difference of the annotation results of the processing result and first sample image of picture adjusts the network parameter values of nervus opticus network.
Wherein, the network parameter values of nervus opticus network include the convolution layer parameter of each convolutional layer of nervus opticus network Value.
Step 1051: judging whether network parameter values nervus opticus network adjusted meets setting to the processing of image First accuracy requirement, if not, step 1052 is executed, if so, executing step 106;
Step 1052: using network parameter values nervus opticus network adjusted as first nerves network;Then step is executed Rapid 101.
Here, the first accuracy requirement of setting can be the processing result of first sample image and the mark of first sample image The difference of result is infused in the first preset range.
In practical applications, the training process of neural network includes propagated forward process and back-propagation process, and forward direction passes Procedural representation is broadcast from input image data to the process for obtaining processing result image;Back-propagation process is indicated to neural network The process that parameter is adjusted;In neural network training process, need repeatedly to be alternately performed propagated forward process and reversed biography Process is broadcast, after each propagated forward process, needs the processing result image according to first sample image, judges that network is joined Whether numerical value nervus opticus network adjusted meets the first accuracy requirement of setting to the processing of image, if conditions are not met, then Back-propagation process is executed, first sample image is then re-entered to network parameter values neural network adjusted, holds again Row propagated forward process;If it is satisfied, then step 106 can be executed.
As can be seen that in order to make network parameter values nervus opticus network adjusted meet the of setting to the processing of image One accuracy requirement needs to repeat above-mentioned steps 101 to step 1052;It is above-mentioned executing every time as a kind of implementation When step 101 to step 1052, convolution layer parameter in each convolutional layer in first nerves network is grouped, then, Quantification treatment is carried out based on the convolution layer parameter after grouping;As another implementation, no matter execute how many times step 101 to Step 1052, it is once grouped just for convolution layer parameter in each convolutional layer in first nerves network, it is subsequent each It is realized on the basis of convolution layer parameter of the quantizing process after this grouping.
Step 106: according to each group convolution in each convolutional layer in network parameter values nervus opticus network adjusted The parameter value of layer parameter determines the quantizing range of this group of convolution layer parameter.
Wherein, the convolution layer parameter in each convolutional layer in network parameter values nervus opticus network adjusted is according to this Convolution kernel in convolutional layer is divided at least two groups.
Here, network parameter values nervus opticus network adjusted includes multiple convolutional layers;In the embodiment of the present disclosure, not The packet mode of convolution layer parameter in each convolutional layer of nervus opticus network is defined, each of nervus opticus network The packet mode of convolution layer parameter in convolutional layer can be with the convolution layer parameter in each convolutional layer of first nerves network Packet mode is identical, can also be different from the packet mode of convolution layer parameter in each convolutional layer of first nerves network.? The packet mode of convolution layer parameter in each convolutional layer of nervus opticus network can be with each convolution of first nerves network It, can be just in each convolutional layer in first nerves network in the identical situation of packet mode of convolution layer parameter in layer Convolution layer parameter is once grouped, and the subsequent quantization for first nerves network convolution layer parameter can be in this grouping On the basis of realize, the subsequent quantization for nervus opticus network convolution layer parameter can continue to use this packet mode.
Step 107: by each convolution in network parameter values nervus opticus network adjusted in each group convolution layer parameter The parameter value of layer parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, the mind after obtaining parameter quantization Through network.
Here, each convolutional layer in each group convolution layer parameter of network parameter values nervus opticus network adjusted is joined Several parameter value mapping process, it is believed that be each group convolution layer parameter to network parameter values nervus opticus network adjusted Quantizing process;By the quantization to every group of convolution layer parameter, available corresponding discrete value.In the related art, it is instructing When practicing neural network, unified quantization usually is carried out to the convolution layer parameter of entire convolutional layer;And in the embodiments of the present disclosure, it can To quantify respectively to each group convolution layer parameter, therefore, it is possible to the discrete value after making full use of each group convolution layer parameter to map Ability to express, therefore, it is possible to reduce quantization loss, be conducive to promoted network parameter values nervus opticus network adjusted essence Degree and accuracy rate, and then the precision that image procossing is carried out using network parameter values nervus opticus network adjusted can be improved.
In the embodiment of the present disclosure, it can be known as finely tuning (fine with the adjustment process of each group convolution layer parameter of neural network Tune), that is, after quantifying every time to each group convolution layer parameter, quantization loss is compensated by fine tuning (fine tune); Here convolution layer parameter can be weight coefficient, activation value etc..
Fig. 3 is the schematic diagram of the network parameter quantization and trim process of the neural network of the embodiment of the present disclosure, such as Fig. 3 institute Show, w indicates floating number parameter, and w' indicates that the fixed-point number that w is obtained after the processes such as being grouped, quantifying, w' are expressed as network parameter The parameter value of nervus opticus network before value adjustment, xlIndicate input, ylIndicate output, Δ w is indicated according to the ginseng in backpropagation The amount that number gradient is finely adjusted w', obtains new w after fine tuning;Propagated forward and backpropagation belong to trim process;Having It,, can be by repeating hold after obtaining fixed-point number w' after the processes such as being grouped, quantifying for floating number parameter w when body is implemented Row above-mentioned steps 101 are realized the execution of propagated forward and backpropagation, in turn, are realized to the micro- of fixed-point number w' to step 1052 It adjusts, new w is obtained after fine tuning;Nervus opticus network after fine tuning meets the first accuracy requirement of setting to the processing of image In the case where, fixed-point number w' can be updated by quantizing process, for example, (stochastic can be rounded with random number Sampling) mode updates fixed-point number w';
In practical applications, step 101 to step 107 can use the realization of the processor in electronic equipment, above-mentioned processing Device can be application-specific IC (Application Specific Integrated Circuit, ASIC), number letter Number processor (Digital Signal Processor, DSP), digital signal processing device (Digital Signal Processing Device, DSPD), programmable logic device (Programmable Logic Device, PLD), FPGA, in At least one of central processor (Central Processing Unit, CPU), controller, microcontroller, microprocessor.
As can be seen that in the embodiments of the present disclosure, during being trained to neural network, by convolution layer parameter from It is not by the quantization of each convolution layer parameter in the same quantizing range when floating number is quantified as fixed-point number, but by every group In the quantization to different quantizing ranges of convolution layer parameter, so that the quantization during lower quantization is lost, and by training come micro- Network parameter is adjusted, thus in the case where meeting deployed environment, for example, being promoted as far as possible in the limited deployed environment of resource Neural network carries out the precision and accuracy when image procossing.
On the basis of a kind of neural network training method shown in Fig. 1, the embodiment of the present disclosure also proposed another mind Through network training method.
Fig. 4 is the flow chart of another neural network training method of the embodiment of the present disclosure, as shown in figure 4, the process can To include:
Step 100: this group of convolution layer parameter is determined according to the parameter value of every group of convolution layer parameter in first nerves network Remodeling section;The parameter value of every group of convolution layer parameter in first nerves network is adjusted, to realize to this group of convolution The remodeling of the distribution of the parameter value of layer parameter.
Wherein, the parameter value of every group of convolution layer parameter after distribution is remolded in first nerves network is in this group of convolutional layer In the remodeling section of parameter;The distribution curve of the parameter value of every group of convolution layer parameter before distribution remodeling in first nerves network Integral with distribution remold after the integral of distribution curve of parameter value of this group of convolution layer parameter it is equal.
In practical applications, (Scale-Clip) method can be cut using scale, realized to the every of first nerves network The remodeling of the distribution of the parameter value of group convolution layer parameter.It, can be to use Scale-Clip method to every in specific example Every group of convolution layer parameter of a convolutional layer is cut such as weight coefficient or activation value.
In the embodiment of the present disclosure, the detailed process of Scale-Clip method are as follows: first calculate every group of parameter under 1 norm Average energy value E, then calculates the thresholding of corresponding parameter, and utilizes [- k*E, k*E] that parameter is truncated, and wherein k is positive whole Number, k are generally set to 2.
In one example, for the convolution layer parameter of each convolutional layer of first nerves network, quantified and be distributed Different convolution layer parameter packet modes can be used when remodeling;In another example, for each of first nerves network The convolution layer parameter of convolutional layer, can be using identical convolution layer parameter packet mode, specifically when being quantified and being distributed remodeling Ground, can be subsequent to be directed to first nerves network first against being once grouped in each convolutional layer in first nerves network Each convolutional layer convolution layer parameter distribution remodeling and quantization can be realized on the basis of this grouping.
Step 101: being determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network The quantizing range of this group of convolution layer parameter;Wherein, first nerves network is floating number neural network, every in first nerves network Convolution layer parameter in a convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer.
Step 102: the parameter value of each convolution layer parameter in first nerves network in each group convolution layer parameter is mapped For a discrete value in the quantizing range of this group of convolution layer parameter, nervus opticus network is obtained.
Step 103: image procossing being carried out to first sample image using nervus opticus network, obtains first sample image Processing result.
Step 104: according to the annotation results of first sample image and the processing result of first sample image, adjustment second The network parameter values of neural network.
Step 1051: judging whether network parameter values nervus opticus network adjusted meets setting to the processing of image First accuracy requirement, if not, step 1052 is executed, if so, executing step 106;
Step 1052: using network parameter values nervus opticus network adjusted as first nerves network;Then step is executed Rapid 101;
Step 106: according to each group convolution in each convolutional layer in network parameter values nervus opticus network adjusted The parameter value of layer parameter determines the quantizing range of this group of convolution layer parameter;Wherein, network parameter values nervus opticus net adjusted The convolution layer parameter in each convolutional layer in network is divided at least two groups according to the convolution kernel in the convolutional layer.
Step 107: by each convolution in network parameter values nervus opticus network adjusted in each group convolution layer parameter The parameter value of layer parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, the mind after obtaining parameter quantization Through network.
The implementation of step 101 to step 107 has been made an explanation in the content of foregoing description, no longer superfluous here It states.
In practical applications, step 100 to step 107 can use the realization of the processor in electronic equipment, above-mentioned processing Device can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, microprocessor.
As can be seen that being not to each layer of convolutional layer when being trained to neural network in the embodiments of the present disclosure Parameter carries out univesral distribution remodeling, but executes packet-based distribution remodeling, that is, it can be directed to each group convolution layer parameter, it is real Now neatly distribution remodeling so that the parameter after distribution remodeling is more conducive to quantify, and then is distributed weight to each group convenient for subsequent Convolution layer parameter after modeling is grouped quantization, in this way, can make subsequent quantization process quantization lose be maintained at one compared with Low-level is conducive to the precision and accuracy rate that promote neural network, and then can be improved and carry out image procossing using neural network Precision.
Optionally, after realizing the remodeling of distribution of the parameter value to every group of convolution layer parameter of first nerves network, often The parameter value of group convolution layer parameter is evenly distributed in the remodeling section of this group of convolution layer parameter, that is to say, that every group of convolution It is distributed as being uniformly distributed after the remodeling of layer parameter;It is demonstrated experimentally that the distribution remodeling of every group of convolution layer parameter is had to be uniformly distributed It is lost conducive to the quantization for reducing subsequent quantization process, and improves the precision of the image procossing of parameter nervus opticus network adjusted And accuracy rate.
In the embodiment of the present disclosure, it can train in several ways and obtain first nerves network, it is exemplary below by Fig. 5 Ground illustrates a kind of training method of first nerves network.
As shown in figure 5, the process of the training method of first nerves network may include:
Step 501: the second sample image being handled using initial neural network, obtains the processing of the second sample image As a result;Initial neural network is unbred floating number neural network.
Here, the second sample image can be preset, and illustratively, the can be obtained from local storage region or network Two sample images, the format of the second sample image can be JPEG, BMP, PNG or extended formatting;It should be noted that here only It is only to have been carried out to the format of the second sample image and source for example, the embodiment of the present disclosure is not to the second sample image Format and source are defined.
In the embodiment of the present disclosure, the second sample image can be identical as first sample image, can also be with first sample figure As different.Wherein, initial neural network is a unbred floating number neural network.
Step 502: according to the annotation results of the second sample image and the processing result of the second sample image, adjustment is initial The network parameter values of neural network.
Here, the annotation results of the second sample image are predetermined;It, can be according to the second sample graph in practical application The difference of the processing result of picture and the annotation results of the second sample image, adjusts the network parameter values of initial neural network.
Wherein, the network parameter values of initial neural network include the convolution layer parameter of each convolutional layer of initial neural network Value.
Step 503: the parameter value according to every group of convolution layer parameter in network parameter values initial neural network adjusted is true The remodeling section of fixed this group of convolution layer parameter.
Wherein, the convolution layer parameter in each convolutional layer in network parameter values initial neural network adjusted is according to this Convolution kernel in convolutional layer is divided at least two groups.
Volume in the embodiment of the present disclosure, in each convolutional layer of initial neural network not adjusted to network parameter values The packet mode of lamination parameter is defined, and illustrates the convolutional layer of network parameter values initial neural network adjusted separately below Two kinds of embodiments of parameter grouping: in the first embodiment, for the convolution in each convolutional layer of initial neural network Layer parameter, the mode that convolution kernel can be randomly selected carry out the grouping of convolution layer parameter, if randomly choosing in a convolutional layer Dry convolution kernel is as one group, and using the corresponding convolution layer parameter of one group of convolution kernel as one group of convolution layer parameter;It is real at second It applies in mode, it can be using the adjacent convolution kernel of the second setting quantity in each convolutional layer in initial neural network as one Group;Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter, instructed by actual initial neural network Practice process it is found that the training of initial neural network is fast when using second of embodiment compared with using the first embodiment Degree is than very fast, and the first nerves network that is obtained using second of embodiment and obtained using the first embodiment the The effect and precision of the image procossing of one neural network are essentially identical.
In the embodiment of the present disclosure, third sets quantity can be according to the first nerves network after the completion of training to the place of image Effect is managed to determine;It is alternatively possible to which the nerve net of training completion can be made in this way using 8 adjacent convolution kernels as one group Precision and accuracy when network progress image procossing is higher.
It should be noted that in each convolutional layer of initial neural network and first nerves network and nervus opticus network The packet mode of convolution layer parameter may be the same or different;In initial neural network, first nerves network and nervus opticus It, can be just in initial neural network in the identical situation of packet mode of convolution layer parameter in each convolutional layer of network Each convolutional layer in convolution layer parameter be once grouped, the subsequent distribution remodeling for initial neural network can be at this It is realized on the basis of grouping, the subsequent distribution for first nerves network convolution layer parameter is remolded and quantization can continue to use this Packet mode, the subsequent quantization for nervus opticus network convolution layer parameter can continue to use this packet mode.
Step 504: the parameter value of every group of convolution layer parameter in initial neural network adjusted to network parameter values into Row adjustment, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter.
Wherein, every group of convolution layer parameter after distribution remodeling in network parameter values initial neural network adjusted Parameter value is in the remodeling section of this group of convolution layer parameter;Network parameter values initial neural network adjusted before distribution remodeling In every group of convolution layer parameter parameter value distribution curve integral with distribution remodeling after this group of convolution layer parameter parameter The integral of the distribution curve of value is equal;
In practical applications, above-mentioned Scale-Clip method can be used, is realized adjusted to network parameter values initial The remodeling of the distribution of the parameter value of every group of convolution layer parameter of neural network.
Step 505: figure being carried out to third sample image using the initial neural network after the distribution remodeling of convolution layer parameter As processing, the processing result of third sample image is obtained.
Here, third sample image can be preset, and illustratively, the can be obtained from local storage region or network Three sample images, the format of third sample image can be JPEG, BMP, PNG or extended formatting;It should be noted that here only It is only to have been carried out to the format of third sample image and source for example, the embodiment of the present disclosure is not to third sample image Format and source are defined.
In the embodiment of the present disclosure, third sample image can be identical as first sample image or the second sample image, can also With different from first sample image or the second sample image.
Step 506: according to the annotation results of third sample image and the processing result of third sample image, adjusting convolution The network parameter values of initial neural network after the distribution remodeling of layer parameter.
Here, the annotation results of third sample image are predetermined;It, can be according to third sample graph in practical application The difference of the processing result of picture and the annotation results of the second sample image, the initial mind after the distribution remodeling of adjustment convolution layer parameter Network parameter values through network.
Step 507: judging whether network parameter values initial neural network adjusted meets setting to the processing of image Second accuracy requirement, if network parameter values initial neural network adjusted is unsatisfactory for the second essence of setting to the processing of image Degree demand then repeats step 503 to step 507;If network parameter values initial neural network adjusted is to image Processing meets the second accuracy requirement of setting, thens follow the steps 508.
Here, the second accuracy requirement of setting can be the processing result of third sample image and the mark of third sample image The difference of result is infused in the second preset range;Second preset range can be identical as the first preset range, can also be with first Preset range is different.
Step 508: using network parameter values initial neural network adjusted as first nerves network.
In practical applications, the training process of initial neural network includes propagated forward process and back-propagation process, preceding It indicates to communication process from input image data to the process for obtaining processing result image;Back-propagation process is indicated to initial mind The process that parameter through network is adjusted;In initial neural network training process, need repeatedly to be alternately performed propagated forward Process and back-propagation process need the image procossing knot according to third sample image after each propagated forward process Fruit, judges whether network parameter values initial neural network adjusted meets the second accuracy requirement of setting to the processing of image, If conditions are not met, back-propagation process is then executed, the initial neural network after inputting third sample image to adjusting parameter, again Execute propagated forward process;If it is satisfied, then first nerves network can be immediately arrived at.
In practical applications, step 501 to step 508 can use the realization of the processor in electronic equipment, above-mentioned processing Device can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, microprocessor.
As can be seen that in order to make network parameter values initial neural network adjusted meet the of setting to the processing of image Two accuracy requirements need to repeat above-mentioned steps 503 to step 507;As a kind of implementation, above-mentioned step is being executed every time Rapid 503 to step 507 when, convolution layer parameter in each convolutional layer in initial neural network is grouped, then, is based on Convolution layer parameter after grouping carries out quantification treatment;As another implementation, how many times step 503 no matter is executed to step 507, it is once grouped just for convolution layer parameter in each convolutional layer in initial neural network, subsequent each distribution weight It is realized on the basis of convolution layer parameter of the modeling process after this grouping.
Optionally, after realizing the remodeling of distribution of the parameter value to every group of convolution layer parameter of initial neural network, often The parameter value of group convolution layer parameter is evenly distributed in the remodeling section of this group of convolution layer parameter, that is to say, that every group of convolution It is distributed as being uniformly distributed after the remodeling of layer parameter;It is demonstrated experimentally that the distribution remodeling of every group of convolution layer parameter is had to be uniformly distributed It is lost conducive to the quantization for reducing subsequent quantization process, and then the image procossing of parameter nervus opticus network adjusted can be improved Precision and accuracy rate.
In the embodiments of the present disclosure, a whole set of training frame is proposed for floating number neural network, including is based on convolution Distribution remodeling, packet-based quantization and the fine tuning of layer parameter grouping, can reduce quantization loss, and then can reduce fine tuning Required time and consumption resource, so that promotion neural network as far as possible carries out image procossing in the case where meeting deployed environment When precision and accuracy.
Based on the training method of neural network set forth above, the embodiment of the present disclosure also proposed a kind of image processing method Method.
Fig. 6 is the flow chart of the image processing method of the embodiment of the present disclosure, as shown in fig. 6, the process may include:
Step 601: obtaining image to be processed.
Here, image to be processed is the image for needing to be handled by computer vision task, calculating here Machine visual task can be image classification, target detection, semantic segmentation etc..
Illustratively, image to be processed can be obtained from local storage region or network, the format of image to be processed can be with JPEG, BMP, PNG or extended formatting;It should be noted that being here only to be carried out to the format of image to be processed and source For example, the embodiment of the present invention is not defined the format and source of image to be processed.
Step 602: image to be processed being input to the neural network after parameter quantization, obtains the processing knot of image to be processed Fruit, wherein the neural network after parameter quantization is obtained according to any one of the above neural network training method.
In practical applications, step 601 to step 602 can use the realization of the processor in electronic equipment, above-mentioned processing Device can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, microprocessor.
As can be seen that in the embodiments of the present disclosure, during being trained to neural network, by convolution layer parameter from It is not by the quantization of each convolution layer parameter in the same quantizing range when floating number is quantified as fixed-point number, but by every group In the quantization to different quantizing ranges of convolution layer parameter, so that the quantization during lower quantization is lost, and by training come micro- Network parameter is adjusted, to promote precision when neural network carries out image procossing as far as possible in the case where meeting deployed environment And accuracy.
The disclosure is further described below by a specific Application Example.
Disclosure Application Example proposes Scale-Clip technology, that is, one kind can be in a dynamic way by weight system The remodeling of several or activation value is equally distributed distributed remodeling technology.Furthermore, it is also proposed that a kind of new packet-based quantization Convolution layer parameter can be divided into multiple groups by method.Different quantization parameters can be set in different groups.This law is disclosed using real It applies in example, Scale-Clip technology can also be combined with packet-based quantization method, propose a kind of neural metwork training Method can be applied in various Computer Vision Tasks.
Quantization involved in neural network training method to disclosure Application Example below and distribution remodeling process into Row exemplary illustration.
Fig. 7 a is the signal quantified in disclosure Application Example to the convolution layer parameter with laplacian distribution Figure, Fig. 7 b are the schematic diagram quantified in disclosure Application Example to the convolution layer parameter with Gaussian Profile, and Fig. 7 c is To with the convolution layer parameter amount of progress for being uniformly distributed (Uniform-like distribution) in disclosure Application Example The schematic diagram of change, in Fig. 7 a to Fig. 7 c, the vertical line of black indicates that quantization divides (bins), that is, indicates the discrete value of setting quantity, Concrete meaning is that continuum is divided into several mutually disjoint sections;Stair-stepping graphical representation convolution layer parameter.
Referring to Fig. 7 a to Fig. 7 c, the convolution layer parameter for following following distribution can be quantified: Gaussian Profile, La Pula This is distributed and is uniformly distributed;Wherein, p- norm is 1- norm, nω=4, nωIndicate that the bit number of quantization in practical applications can To calculate quantization loss;Pass through analysis quantization loss calculated result, it can be seen that compared with being uniformly distributed, Gaussian Profile or Laplacian distribution can generate more quantization losses, that is, by the distribution remodeling of convolutional layer to be uniformly distributed, can relatively drop The quantization of low subsequent quantization process is lost.
Distribution remodeling procedure can also be realized based on the convolution layer parameter after grouping.
Fig. 8 a is the schematic diagram of the packet-based distribution remodeling quantization frame of disclosure Application Example, in Fig. 8 a, W table Show the convolution layer parameter that needs are grouped, Wgs1、Wgs2、Wgs3And Wgs4It is illustrated respectively in each group for needing to quantify in quantizing process Parameter, S1、S2、S3And S4Parameter after respectively indicating quantization, Chn1, Chn2, Chn3 and Chn4 respectively indicate batch and normalize (BN) parameter in layer.
Referring to Fig. 8 a, convolution layer parameter, such as weight coefficient can be divided into several groups, respectively with different threshold values to weight The distribution of coefficient is cut, then the distribution of weight coefficient is remolded to be uniformly distributed.On the basis of every group of remodeling distribution Carry out uniform quantization.
Fig. 8 b is the signal of the test phase of the network of the packet-based distribution remodeling quantization of disclosure Application Example Scheme, in Fig. 8 b, Wgs1、Wgs2、Wgs3And Wgs4Respectively indicate first group, second group, third group and the 4th group of parameter, s1, s2, s3 W is respectively indicated with s4gs1、Wgs2、Wgs3And Wgs4Corresponding scale factor, BN layers of Merged indicate the BN layer after merging.
In disclosure Application Example, the quantification manner of uniform quantization can be used, every group of convolution layer parameter is mapped To discrete value, here, each group convolution layer parameter in each convolutional layer not necessarily uses identical quantification manner;For different groups Convolution layer parameter, flexible quantification manner can be used.
For the implementation of uniform quantization;Illustratively, convolution weight coefficient can be expressed as to W={ Wi| i= 1 ..., n }, for weight atom (weight atom) w ∈ Wi, by uniform quantization that it is linearly discrete according to formula (2) Change.
In addition, for activation value, when being quantified, can will value by range [0, α] because activation value is linear It is nonnegative value after rectification function (Rectified Linear Unit, ReLU) layer;It indicates for simplicity, it can be respectively by weight Coefficient quantization and activation value quantization means are Q (w;α) and Q (A;α).
In some embodiments, quantization ginseng can be determined using the method for directly optimizing quantization loss according to formula (3) Number.
Wherein, Q (W;α) indicate the parameter after W is quantified, QL (W, Q (W;α)) indicate the quantization loss of W;||·||pTable Show p- norm, can take p- norm is 1- norm.It note that formula (3) also definition of the part similar to KL distance.Here, may be used To show that α *, α * indicate optimal α according to formula (4).
Content based on foregoing description optimizes entire QL (W, Q (W;α)) be disclosure Application Example an emphasis; However, due to Q (;Indifference α) is anisotropic, and formula (3) cannot directly optimize in the training process.It needs in the same of retention property When search for which kind of W be suitble to uniform quantization.Since most of weight coefficient in convolutional layer is distributed in the region (near close to zero Zero areas), for example, laplacian distribution or Gaussian Profile;However, these distributions often generate compared with being uniformly distributed Larger quantization loss;In Fig. 7 a to Fig. 7 c, three data distribution example (Fig. 7 a being made of 1000 samples are generated respectively Corresponding laplacian distribution, Fig. 7 b correspond to Gaussian Profile, and Fig. 7 c correspondence is uniformly distributed).For Fig. 7 a to Fig. 7 c, optimal α points It is not expressed asWithAccording to formula (4),It is equally distributed Corresponding quantization loss is 0.059, and the quantization of laplacian distribution loss is then up to 0.133.It may be seen that the distribution of W is more flat It is smooth, then quantify to lose smaller.This conclusion can be further verified by experiment, it is demonstrated experimentally that remodeling is equally distributed volume Product weight coefficient does not influence the performance of floating number neural network.
As a result, in disclosure Application Example, as shown in figure 9, the distribution of floating-point mould can be remolded uniformly to divide Cloth;In Fig. 9, the distribution of the floating-point mould before remodeling is difficult to quantify, and after remodeling distribution, it is easy to be quantified.
For weight coefficient W, max (| W |) and mean (| W |) are two kinds of statistics being widely used of W, max (| W |) it indicates | W | maximum value, mean (| W |) indicates the average value of W;Here, it has inquired into first between two kinds of statistics under being uniformly distributed Relationship, the density function of weight atom w can be defined according to formula (5) in W.
Wherein, p (w) indicates that the density function of w, C=1/2T, T are the positive number for being greater than 0 of setting.Assuming that W [- T, T] it Between follow and be uniformly distributed, then have max (| W |)=T.Mean (| W |) approximate calculation can be carried out according to formula (6).
Here it is possible to indicate T according to formula (7).
T=max (| W |) ≈ 2mean (| W |) (7)
According to formula (6) to formula (7), in disclosure Application Example, proposes a kind of simple and be effectively distributed remodeling Method, in the training stage by floating-point mould distribution remodeling to be uniformly distributed, the formula of remodeling process is formula (8).
Wherein,
Tw=kmean (| W |) (9)
By following intuitive analysis it can be concluded that the advantages of above-mentioned distribution remodeling procedure: when k is close to 2, in order to compensate for sanction Energy loss caused by exceptional value is cut, the more multivalue near zero often becomes much larger, and finally, W reaches capacity situation, i.e. W's Distribution tends to be uniform;However, when k < < 2 when, when no enough values (being properly termed as shift value (shifted values)) are mended When filling energy loss, more exceptional values will be cut, and converge to zero so as to cause W;When k > > 2 when, the distribution of above-mentioned remodeling by Gaussian Profile is faded to, final this method (the distribution remodeling procedure that disclosure Application Example proposes) there almost is not distribution remodeling Have an impact.
It, can also be using distribution remodeling strategy for activation value A.However, the statistic of A is dependent on data and is training It is in journey and unstable, it is thus impossible to directly be quantified according to formula (9) Lai Jinhang activation value.It is asked to solve the quantization of activation value Topic, it should the biggish k of numerical value is selected, to adapt to variable statistic mean (A).In addition, in order to realize stable quantization, with For the purpose of dynamic meets formula (11), the new more new strategy of training stage is introduced according to formula (10).
Wherein, | | | |2Indicate 2- norm, λ indicates the training hyper parameter of manual setting.
In disclosure Application Example, a kind of packet-based quantization method is proposed, convolution layer parameter can be drawn It is divided into several groups, then, the convolution layer parameter after grouping is quantified using different α.The process of packet-based quantization As shown in Figure 8 a.
The Inspiration Sources of packet-based quantization in quantization weight coefficient value can only be fromThe limited value taken out.However, since ability to express is limited, all convolutional layers The optimal α of the optimal α of parameter and every group of convolution layer parameter is distinct.In fact, in order to obtain better performance, intuition Solution be that different convolution layer parameters should take different α and quantizing factor s (α) in quantizing process;For example, point It will not join for the trained weight coefficient of the first convolutional layer of the network structure ResNet-18 of CIFAR-100 data set Number is divided into 8 groups, calculates separately the optimal α of every group of convolution layer parameter.
Figure 10 is all convolution layer parameters and every group of convolution of trained ResNet-18 in disclosure Application Example The schematic diagram of the optimal α of layer parameter, as shown in Figure 10, the optimal α (dotted line frame) of all convolution layer parameters be not always with The optimal α (solid line boxes) of every group of convolution layer parameter is consistent.
Illustratively, it is as follows to execute details for packet-based quantization: firstly, weight coefficient is grouped according to following formula:Wherein, GlIndicate that l group convolution layer parameter, n indicate one layer of convolutional layer The number of parameter, the size (i.e. the number for the convolution layer parameter that every group of convolution layer parameter is included) of gs expression group.
Secondly, being calculated by formula (12)And then to GlQuantified.
The method of grouping, distribution remodeling and quantization in the embodiment of the present disclosure, carries out real on CIFAR-100 data set When testing, different k values can be used in formula (9), for example, k ∈ { 2,2.5,3,4, ∞ }, and remodeling procedure application will be distributed In on weight coefficient, with 5 floating-point mould ResNet-18 of training, each floating-point mould indicates floating number neural network, wherein When k is equal to ∞, expression is not remolded.
All convolutional layer weight coefficients of above-mentioned five floating-point mould ResNet-18 are quantized to nωA bit is (from 2 bits To 8 bits), and the quantization of the first convolutional layer weight coefficient loss is calculated by formula (3).
Figure 11 a is that first convolution of five floating-point moulds in different quantizing bit numbers is directed in disclosure Application Example Schematic diagram is lost in the quantization of layer weight coefficient;In Figure 11 a, horizontal axis indicates quantizing bit number (Quantization Bit Number), the longitudinal axis indicates that quantization loss late (Quantization Loss Ratio, QLR), ordinary curve expression do not carry out It is distributed the quantization loss late curve of the first layer weight coefficient of remodeling;It can be seen that from Figure 11 a when bit wide (i.e. quantizing bit number) When increase, quantization loss tends to reduce, and for identical bit wide, biggish k value corresponds to larger quantization loss, when k is equal to 2 For quantization loss curve lower than other curves (k is greater than 2 or conventional), this shows that uniform quantization can reduce quantization loss really.
Figure 11 b is that five floating-point moulds are directed in disclosure Application Example in different quantizing bit numbers 50 stages The schematic diagram of the accuracy rate of neural network after fine tuning;In Figure 11 b, horizontal axis indicates that quantizing bit number, the longitudinal axis indicate previous precision (Top-1accuracy);It can be seen that from Figure 11 b and set 2 for k, the neural network after can promoting training is preferably final Performance;Therefore, it can be deduced that draw a conclusion: by weight coefficient remold for equally distributed performance be better than by weight coefficient remodeling be Gaussian Profile or laplacian distribution.
It will be understood by those skilled in the art that each step writes sequence simultaneously in the above method of specific embodiment It does not mean that stringent execution sequence and any restriction is constituted to implementation process, the specific execution sequence of each step should be with its function It can be determined with possible internal logic
On the basis of the neural network training method that previous embodiment proposes, the embodiment of the present disclosure proposes a kind of nerve Network training device.
Figure 12 is the composed structure schematic diagram of the neural metwork training device of the embodiment of the present disclosure, as shown in figure 12, described Device includes: first processing module 121 and Second processing module 122, wherein
First processing module 121, for according to each group convolution layer parameter in each convolutional layer in first nerves network Parameter value determine the quantizing range of this group of convolution layer parameter;It will be each in each group convolution layer parameter in the first nerves network The parameter value of a convolution layer parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, obtains nervus opticus Network;Image procossing is carried out to first sample image using the nervus opticus network, obtains the place of the first sample image Manage result;According to the annotation results of the first sample image and the processing result of the first sample image, described in adjustment The network parameter values of nervus opticus network;Using network parameter values nervus opticus network adjusted as first nerves network, One processing module 121 repeats its function until network parameter values nervus opticus network adjusted meets the processing of image First accuracy requirement of setting;Wherein, the first nerves network is floating number neural network, in the first nerves network Convolution layer parameter in each convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer;
Second processing module 122, for according to each convolutional layer in network parameter values nervus opticus network adjusted In the parameter value of each group convolution layer parameter determine the quantizing range of this group of convolution layer parameter;By network parameter values adjusted The parameter value of each convolution layer parameter in two neural networks in each group convolution layer parameter is mapped as the amount of this group of convolution layer parameter Change a discrete value in range, the neural network after obtaining parameter quantization;Wherein, network parameter values nervus opticus adjusted The convolution layer parameter in each convolutional layer in network is divided at least two groups according to the convolution kernel in the convolutional layer.
Optionally, the first processing module 121 is also used to according in each convolutional layer in first nerves network Before the parameter value of each group convolution layer parameter determines the quantizing range of this group of convolution layer parameter, according in the first nerves network The parameter value of every group of convolution layer parameter determine the remodeling section of this group of convolution layer parameter;To every in the first nerves network The parameter value of group convolution layer parameter is adjusted, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;
Wherein, the parameter value of every group of convolution layer parameter after distribution is remolded in the first nerves network is rolled up in the group In the remodeling section of lamination parameter;The parameter value of every group of convolution layer parameter in distribution remodeling foregoing description first nerves network The integral of distribution curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling.
Optionally, the neural metwork training device that the embodiment of the present disclosure provides further includes third processing module 123, at third Parameter value of the reason module 123 for each convolution layer parameter in first nerves network in each group convolution layer parameter is mapped as Before a discrete value in the quantizing range of this group of convolution layer parameter, initial neural network is trained using following steps Obtain the first nerves network:
The second sample image is handled using the initial neural network, obtains the processing of second sample image As a result;The initial neural network is unbred floating number neural network;
According to the annotation results of second sample image and the processing result of second sample image, described in adjustment The network parameter values of initial neural network;
Determine that the group is rolled up according to the parameter value of every group of convolution layer parameter in network parameter values initial neural network adjusted The remodeling section of lamination parameter;Wherein, the convolution in each convolutional layer in network parameter values initial neural network adjusted Layer parameter is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of every group of convolution layer parameter in initial neural network adjusted to the network parameter values is adjusted It is whole, to realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;Wherein, the network parameter after distribution remodeling It is worth the parameter value of every group of convolution layer parameter in initial neural network adjusted in the remodeling section of this group of convolution layer parameter; Point of the parameter value of every group of convolution layer parameter in distribution remodeling foregoing description network parameter values initial neural network adjusted The integral of cloth curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling;
Image procossing is carried out to third sample image using the initial neural network after the distribution remodeling of convolution layer parameter, is obtained To the processing result of the third sample image;
According to the annotation results of the third sample image and the processing result of the third sample image, described in adjustment The network parameter values of initial neural network after the distribution remodeling of convolution layer parameter;
The distribution for repeating the convolution layer parameter in initial neural network adjusted to network parameter values is remolded The step of, and third sample image is carried out at image using the initial neural network after the distribution remodeling of convolution layer parameter Reason, and according to the annotation results of the third sample image and the processing result of the third sample image to the convolutional layer The step of network parameter values of initial neural network after the distribution remodeling of parameter are adjusted, until after network parameter values adjustment Initial neural network to image processing meet setting the second accuracy requirement, obtain first nerves network.
Optionally, the first processing module 121, for using the following steps by each of described first nerves network Convolution layer parameter in convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer:
Using the adjacent convolution kernel of the first setting quantity in each convolutional layer in the first nerves network as one group; Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
Optionally, the third processing module 123, for using the following steps by network parameter values initial mind adjusted At least two groups are divided into according to the convolution kernel in the convolutional layer through the convolution layer parameter in each convolutional layer in network:
By the phase of the second setting quantity in each convolutional layer in the network parameter values initial neural network adjusted Adjacent convolution kernel is as one group;Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
Optionally, after distribution remodeling, the parameter value of every group of convolution layer parameter is in the remodeling section of this group of convolution layer parameter Inside it is evenly distributed.
Optionally, multiple discrete values in the quantizing range of every group of convolution layer parameter are equidistant discrete value.
In practical application, first processing module 121, Second processing module 122 and third processing module 123 be can use Processor in electronic equipment realizes that above-mentioned processor can be ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, micro-control At least one of device processed, microprocessor.
In addition, each functional module in the present embodiment can integrate in one processing unit, it is also possible to each list Member physically exists alone, and can also be integrated in one unit with two or more units.Above-mentioned integrated unit both can be with Using formal implementation of hardware, can also be realized in the form of software function module.
If the integrated unit realizes that being not intended as independent product is sold in the form of software function module Or in use, can store in a computer readable storage medium, based on this understanding, the technical side of the present embodiment Substantially all or part of the part that contributes to existing technology or the technical solution can be produced case in other words with software The form of product embodies, which is stored in a storage medium, including some instructions are used so that one Platform computer equipment (can be personal computer, server or the network equipment etc.) or processor (processor) execute sheet The all or part of the steps of embodiment the method.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic or disk Etc. the various media that can store program code.
Specifically, the corresponding computer program instructions of one of the present embodiment neural network training method can be deposited It stores up on CD, hard disk, the storage mediums such as USB flash disk, when the calculating corresponding with a kind of neural network training method in storage medium Machine program instruction is read or is performed by an electronic equipment, realizes any one neural metwork training side of previous embodiment Method.
Based on the identical technical concept of previous embodiment, referring to Figure 13, it illustrates one kind that the embodiment of the present disclosure provides Electronic equipment 130 may include: memory 131 and processor 132;Wherein,
The memory 131, for storing computer program and data;
The processor 132, for executing the computer program stored in the memory, to realize previous embodiment Any one neural network training method.
In practical applications, above-mentioned memory 131 can be volatile memory (volatile memory), such as RAM;Or nonvolatile memory (non-volatile memory), such as ROM, flash memory (flash memory), Hard disk (Hard Disk Drive, HDD) or solid state hard disk (Solid-State Drive, SSD);Or the storage of mentioned kind The combination of device, and instruction and data is provided to processor 132.
Above-mentioned processor 132 can be ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, micro process At least one of device.It is to be appreciated that the electronic device for realizing above-mentioned processor function may be used also for different equipment Think other, the embodiment of the present disclosure is not especially limited.
On the basis of the neural network training method that previous embodiment proposes, the embodiment of the present disclosure proposes a kind of image Processing unit.
Figure 14 is the composed structure schematic diagram of the image processing apparatus of the embodiment of the present disclosure, as shown in figure 14, described device It include: to obtain module 141 and fourth processing module 142, wherein
Module 141 is obtained, for obtaining image to be processed;
Fourth processing module 142 obtains institute for the image to be processed to be input to the neural network after parameter quantization State the processing result of image to be processed, wherein the neural network after parameter quantization be according to foregoing description any one What neural network training method obtained.
In practical applications, it obtains module 141 and third processing module 142 can use the processor in electronic equipment It realizes, above-mentioned processor can be in ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, microprocessor It is at least one.
In addition, each functional module in the present embodiment can integrate in one processing unit, it is also possible to each list Member physically exists alone, and can also be integrated in one unit with two or more units.Above-mentioned integrated unit both can be with Using formal implementation of hardware, can also be realized in the form of software function module.
If the integrated unit realizes that being not intended as independent product is sold in the form of software function module Or in use, can store in a computer readable storage medium, based on this understanding, the technical side of the present embodiment Substantially all or part of the part that contributes to existing technology or the technical solution can be produced case in other words with software The form of product embodies, which is stored in a storage medium, including some instructions are used so that one Platform computer equipment (can be personal computer, server or the network equipment etc.) or processor (processor) execute sheet The all or part of the steps of embodiment the method.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic or disk Etc. the various media that can store program code.
Specifically, the corresponding computer program instructions of one of the present embodiment image processing method can be stored in CD, hard disk, on the storage mediums such as USB flash disk, when the computer program corresponding with a kind of image processing method in storage medium refers to It enables and is read or be performed by an electronic equipment, realize any one image processing method of previous embodiment.
Based on the identical technical concept of previous embodiment, referring to Figure 15, it illustrates the another of embodiment of the present disclosure offer Kind electronic equipment 150, may include: memory 151 and processor 152;Wherein,
The memory 151, for storing computer program and data;
The processor 152, for executing the computer program stored in the memory, to realize previous embodiment Any one image processing method.
In practical applications, above-mentioned memory 151 can be volatile memory (volatile memory), such as RAM;Or nonvolatile memory (non-volatile memory), such as ROM, flash memory (flash memory), Hard disk (Hard Disk Drive, HDD) or solid state hard disk (Solid-State Drive, SSD);Or the storage of mentioned kind The combination of device, and instruction and data is provided to processor 152.
Above-mentioned processor 152 can be ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, micro process At least one of device.It is to be appreciated that the electronic device for realizing above-mentioned processor function may be used also for different equipment Think other, the embodiment of the present disclosure is not especially limited.
In some embodiments, the embodiment of the present disclosure provides the function that has of device or comprising module can be used for holding The method of row embodiment of the method description above, specific implementation are referred to the description of embodiment of the method above, for sake of simplicity, this In repeat no more.
Above the description of each embodiment is tended to emphasize the difference between each embodiment, it is same or similar Place can refer to mutually, for sake of simplicity, repeats no more herein
Disclosed method in each method embodiment provided herein, in the absence of conflict can be any group It closes, obtains new embodiment of the method.
Disclosed feature in each product embodiments provided herein, in the absence of conflict can be any group It closes, obtains new product embodiments.
Disclosed feature, can appoint in the absence of conflict in each method or apparatus embodiments provided herein Meaning combination, obtains new embodiment of the method or apparatus embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a storage medium In (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal (can be mobile phone, computer, service Device, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much Form, all of these belong to the protection of the present invention.

Claims (10)

1. a kind of neural network training method, which is characterized in that the described method includes:
This group of convolutional layer ginseng is determined according to the parameter value of each group convolution layer parameter in each convolutional layer in first nerves network Several quantizing ranges;Wherein, the first nerves network is floating number neural network, each volume in the first nerves network Convolution layer parameter in lamination is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of each convolution layer parameter in the first nerves network in each group convolution layer parameter is mapped as group volume A discrete value in the quantizing range of lamination parameter, obtains nervus opticus network;
Image procossing is carried out to first sample image using the nervus opticus network, obtains the processing of the first sample image As a result;
According to the annotation results of the first sample image and the processing result of the first sample image, adjustment described second The network parameter values of neural network;
Using network parameter values nervus opticus network adjusted as first nerves network, above-mentioned steps are repeated until network Parameter value nervus opticus network adjusted meets the first accuracy requirement of setting to the processing of image;
According to the parameter of each group convolution layer parameter in each convolutional layer in network parameter values nervus opticus network adjusted It is worth the quantizing range for determining this group of convolution layer parameter;Wherein, each volume in network parameter values nervus opticus network adjusted Convolution layer parameter in lamination is divided at least two groups according to the convolution kernel in the convolutional layer;
By the parameter of each convolution layer parameter in network parameter values nervus opticus network adjusted in each group convolution layer parameter Value is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, the neural network after obtaining parameter quantization.
2. the method according to claim 1, wherein according in each convolutional layer in first nerves network Before the parameter value of each group convolution layer parameter determines the quantizing range of this group of convolution layer parameter, the method also includes:
The remodeling area of this group of convolution layer parameter is determined according to the parameter value of every group of convolution layer parameter in the first nerves network Between;
The parameter value of every group of convolution layer parameter in the first nerves network is adjusted, this group of convolutional layer is joined with realizing The remodeling of the distribution of several parameter values;
Wherein, the parameter value of every group of convolution layer parameter after distribution is remolded in the first nerves network is in this group of convolutional layer In the remodeling section of parameter;The distribution of the parameter value of every group of convolution layer parameter in distribution remodeling foregoing description first nerves network The integral of curve is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling.
3. method according to claim 1 or 2, which is characterized in that each group convolution layer parameter in first nerves network In the parameter value of each convolution layer parameter be mapped as before a discrete value in the quantizing range of this group of convolution layer parameter, institute First nerves network is stated to complete using following steps training:
The second sample image is handled using initial neural network, obtains the processing result of second sample image;Institute Stating initial neural network is unbred floating number neural network;
According to the annotation results of second sample image and the processing result of second sample image, adjust described initial The network parameter values of neural network;
This group of convolutional layer is determined according to the parameter value of every group of convolution layer parameter in network parameter values initial neural network adjusted The remodeling section of parameter;Wherein, the convolutional layer ginseng in each convolutional layer in network parameter values initial neural network adjusted Number is divided at least two groups according to the convolution kernel in the convolutional layer;
The parameter value of every group of convolution layer parameter in initial neural network adjusted to the network parameter values is adjusted, with Realize the remodeling of the distribution to the parameter value of this group of convolution layer parameter;Wherein, the network parameter values tune after distribution remodeling The parameter value of every group of convolution layer parameter in initial neural network after whole is in the remodeling section of this group of convolution layer parameter;Distribution The distribution for remolding the parameter value of every group of convolution layer parameter in foregoing description network parameter values initial neural network adjusted is bent The integral of line is equal with the integral of distribution curve of parameter value of this group of convolution layer parameter after distribution remodeling;
Image procossing is carried out to third sample image using the initial neural network after the distribution remodeling of convolution layer parameter, obtains institute State the processing result of third sample image;
According to the annotation results of the third sample image and the processing result of the third sample image, the convolution is adjusted The network parameter values of initial neural network after the distribution remodeling of layer parameter;
Repeat the step that the distribution of the convolution layer parameter in initial neural network adjusted to network parameter values is remolded Suddenly, image procossing and using the initial neural network after the distribution remodeling of convolution layer parameter is carried out to third sample image, and According to the annotation results of the third sample image and the processing result of the third sample image to the convolution layer parameter Distribution remodeling after the network parameter values of initial neural network the step of being adjusted, until network parameter values are adjusted just Beginning neural network meets the second accuracy requirement of setting to the processing of image, obtains first nerves network.
4. method according to claim 1-3, which is characterized in that use the following steps by the first nerves net The convolution layer parameter in each convolutional layer in network is divided at least two groups according to the convolution kernel in the convolutional layer:
Using the adjacent convolution kernel of the first setting quantity in each convolutional layer in the first nerves network as one group;
Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
5. according to the method described in claim 3, it is characterized in that, using the following steps that network parameter values are adjusted initial The convolution layer parameter in each convolutional layer in neural network is divided at least two groups according to the convolution kernel in the convolutional layer:
The adjacent of quantity is set by each convolutional layer in the network parameter values initial neural network adjusted second Convolution kernel is as one group;
Using the corresponding convolution layer parameter of each group of convolution kernel as one group of convolution layer parameter.
6. a kind of image processing method, which is characterized in that the described method includes:
Obtain image to be processed;
The image to be processed is input to the neural network after parameter quantization, obtains the processing result of the image to be processed, Wherein, the neural network after the parameter quantization is that neural network training method according to any one of claims 1 to 5 obtains It arrives.
7. a kind of neural metwork training device, which is characterized in that described device includes first processing module and Second processing module, Wherein,
First processing module, for the parameter value according to each group convolution layer parameter in each convolutional layer in first nerves network Determine the quantizing range of this group of convolution layer parameter;By each convolutional layer in the first nerves network in each group convolution layer parameter The parameter value of parameter is mapped as a discrete value in the quantizing range of this group of convolution layer parameter, obtains nervus opticus network;Benefit Image procossing is carried out to first sample image with the nervus opticus network, obtains the processing result of the first sample image; According to the annotation results of the first sample image and the processing result of the first sample image, the nervus opticus is adjusted The network parameter values of network;Using network parameter values nervus opticus network adjusted as first nerves network;First processing mould Block repeats to hold its function until network parameter values nervus opticus network adjusted meets the first essence of setting to the processing of image Degree demand;Wherein, the first nerves network is floating number neural network, in each convolutional layer in the first nerves network Convolution layer parameter at least two groups are divided into according to the convolution kernel in the convolutional layer;
Second processing module, for according to each group in each convolutional layer in network parameter values nervus opticus network adjusted The parameter value of convolution layer parameter determines the quantizing range of this group of convolution layer parameter;By network parameter values nervus opticus net adjusted The parameter value of each convolution layer parameter in network in each group convolution layer parameter is mapped as in the quantizing range of this group of convolution layer parameter A discrete value, obtain parameter quantization after neural network;Wherein, in network parameter values nervus opticus network adjusted Convolution layer parameter in each convolutional layer is divided at least two groups according to the convolution kernel in the convolutional layer.
8. a kind of image processing apparatus, which is characterized in that described device includes obtaining module and fourth processing module, wherein
Module is obtained, for obtaining image to be processed;
Fourth processing module obtains described wait locate for the image to be processed to be input to the neural network after parameter quantization Manage the processing result of image, wherein the neural network after the parameter quantization is according to any one of claims 1 to 5 What neural network training method obtained.
9. a kind of electronic equipment, which is characterized in that including processor and for storing the computer that can be run on a processor The memory of program;Wherein,
The processor requires 1 to 5 described in any item neural network instructions for running the computer program with perform claim Practice method or image processing method as claimed in claim 6.
10. a kind of computer storage medium, is stored thereon with computer program, which is characterized in that the computer program is processed Device realizes neural network training method described in any one of claim 1 to 5 or image procossing as claimed in claim 6 when executing Method.
CN201910606138.9A 2019-07-05 2019-07-05 Neural metwork training and image processing method, device, equipment and medium Pending CN110363297A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910606138.9A CN110363297A (en) 2019-07-05 2019-07-05 Neural metwork training and image processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910606138.9A CN110363297A (en) 2019-07-05 2019-07-05 Neural metwork training and image processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN110363297A true CN110363297A (en) 2019-10-22

Family

ID=68218403

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910606138.9A Pending CN110363297A (en) 2019-07-05 2019-07-05 Neural metwork training and image processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN110363297A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111144511A (en) * 2019-12-31 2020-05-12 上海云从汇临人工智能科技有限公司 Image processing method, system, medium and electronic terminal based on neural network
WO2021147362A1 (en) * 2020-01-21 2021-07-29 苏州浪潮智能科技有限公司 Hardware environment-based data quantization method and apparatus, and readable storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111144511A (en) * 2019-12-31 2020-05-12 上海云从汇临人工智能科技有限公司 Image processing method, system, medium and electronic terminal based on neural network
CN111144511B (en) * 2019-12-31 2020-10-20 上海云从汇临人工智能科技有限公司 Image processing method, system, medium and electronic terminal based on neural network
WO2021147362A1 (en) * 2020-01-21 2021-07-29 苏州浪潮智能科技有限公司 Hardware environment-based data quantization method and apparatus, and readable storage medium

Similar Documents

Publication Publication Date Title
Dai et al. Compressing neural networks using the variational information bottleneck
US10552737B2 (en) Artificial neural network class-based pruning
CN110363297A (en) Neural metwork training and image processing method, device, equipment and medium
CN109002889B (en) Adaptive iterative convolution neural network model compression method
CN109344893B (en) Image classification method based on mobile terminal
EP3732631A1 (en) Neural architecture search for dense image prediction tasks
WO2019155064A1 (en) Data compression using jointly trained encoder, decoder, and prior neural networks
WO2021238262A1 (en) Vehicle recognition method and apparatus, device, and storage medium
CN111178491A (en) Method, device, system and storage medium for training and applying neural network model
CN110956202A (en) Image training method, system, medium and intelligent device based on distributed learning
KR102153192B1 (en) Effective Network Compression using Simulation-guided Iterative Pruning
CN113424200A (en) Methods, apparatuses and computer program products for video encoding and video decoding
CN109388779A (en) A kind of neural network weight quantization method and neural network weight quantization device
CN108694414A (en) Digital evidence obtaining file fragmentation sorting technique based on digital picture conversion and deep learning
CN113011581A (en) Neural network model compression method and device, electronic equipment and readable storage medium
CN112861996A (en) Deep neural network model compression method and device, electronic equipment and storage medium
CN112150497A (en) Local activation method and system based on binary neural network
CN112488304A (en) Heuristic filter pruning method and system in convolutional neural network
US20190392311A1 (en) Method for quantizing a histogram of an image, method for training a neural network and neural network training system
JP6935868B2 (en) Image recognition device, image recognition method, and program
US20200285956A1 (en) Training Artificial Neural Networks with Reduced Computational Complexity
KR20210088656A (en) Methods, devices, devices and media for image generation and neural network training
CN111199507A (en) Image steganography analysis method, intelligent terminal and storage medium
CN110659561A (en) Optimization method and device of internet riot and terrorist video identification model
EP4007173A1 (en) Data storage method, and data acquisition method and apparatus therefor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination