CN106855952A - Computational methods and device based on neutral net - Google Patents
Computational methods and device based on neutral net Download PDFInfo
- Publication number
- CN106855952A CN106855952A CN201611244827.2A CN201611244827A CN106855952A CN 106855952 A CN106855952 A CN 106855952A CN 201611244827 A CN201611244827 A CN 201611244827A CN 106855952 A CN106855952 A CN 106855952A
- Authority
- CN
- China
- Prior art keywords
- point
- fixed point
- fixed
- result
- floating
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2415—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Biophysics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Probability & Statistics with Applications (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Evolutionary Biology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
A kind of computational methods based on neutral net are the embodiment of the invention provides, including:Obtain the original image of tensor form;Original image to the tensor form carries out fixed-point computation;Based on the output data of the fixed-point computation, image thermodynamic chart is produced;And the original image is labeled based on described image thermodynamic chart.The method that the use fixed point method that the embodiment of the present invention is proposed realizes the calculating of neutral net, as a result of fixed-point computation, amount of calculation is small, and occupancy resource is few, so as to the requirement to hardware is relatively low.
Description
Technical field
The present invention relates to image processing field, relate more specifically to a kind of computational methods based on neutral net and device.
Background technology
Neutral net (Neural Networks, NNs) is also referred to as artificial neural network (Artificial Neural
Networks, ANNs) or link model (Connection Model), it is a kind of imitation animal nerve network behavior feature, enter
The algorithm mathematics model of row distributed parallel information processing.Neutral net relies on the complexity of system, internal big by adjusting
The relation being connected with each other between gauge operator node, so as to reach the purpose of processing information.
Neutral net has had extensively in many fields such as speech recognition, Text region and image/video identification
And successfully apply.Traditional neutral net multiplies/adds calculating as basic computational ele- ment using double precision or single precision floating datum,
However, the algorithm framework of traditional neutral net can cause intensive demand, internal memory high (or video memory) to take and high bandwidth
It is required that the problems such as, not only the requirement to hardware is higher, can also cause the increase of cost.
The content of the invention
The present invention is proposed in view of above mentioned problem.The invention provides a kind of computational methods based on neutral net,
Requirement of the method to hardware is relatively low such that it is able to cost-effective.
According to the first aspect of the invention, there is provided a kind of computational methods based on neutral net, including:
Obtain the original image of tensor form;
Original image to the tensor form carries out fixed-point computation;
Based on the output data of the fixed-point computation, image thermodynamic chart is produced;And
The original image is labeled based on described image thermodynamic chart.
Exemplarily, the original image to the tensor form carries out fixed-point computation, including:
Each calculate node in the neutral net performs following operation:
Convolution operation is carried out to input data;
Convolution output to the convolution operation is linearly calculated;
Result to the linear calculating carries out low-bit width fixed point;
Wherein, the input data of first calculate node in the neutral net is the original graph of the tensor form
Picture, the input data of other calculate nodes in addition to first calculate node in the neutral net is previous meter
The result of the low-bit width fixed point of operator node.
Exemplarily, it is described linear to be calculated as floating-point and linearly calculate.
Exemplarily, the floating-point is linearly calculated and is expressed as:Y=k × X+b,
Wherein, X is fixed-point number, and k, b and y are floating number, and X represents the convolution output, and y represents that the floating-point is linearly calculated
Result, k and b is the good floating point parameters of training in advance.
Exemplarily, the result to the linear calculating carries out low-bit width fixed point, including:
Magnitude relationship between the result linearly calculated according to the floating-point and the first fixed point decision threshold, determines described low
The result of bit wide fixed point,
Wherein, the first fixed point decision threshold is the good floating point parameters of training in advance, and first fixed point adjudicates threshold
Value is more than 0.
Exemplarily, it is described to be linearly calculated as pinpointing linear calculating.
Exemplarily, the linear calculating of the fixed point is expressed as:Y '=X '+B,
Wherein, X '=N × X, X, X ', Y ', B and N be fixed-point number, N is default positive integer, and X represents that the convolution is defeated
Go out, Y ' represents the linear result for calculating of the fixed point, B represents fixed point displacement parameter.
Exemplarily, the result to the linear calculating carries out low-bit width fixed point, including:
According to the magnitude relationship between the linear result for calculating of the fixed point and the second fixed point decision threshold, determine described low
The result of bit wide fixed point.
Exemplarily, before the convolution output to the convolution operation is linearly calculated, also include:
According to the good floating point parameters of training in advance, the fixed point displacement parameter and the second fixed point decision threshold are determined.
Exemplarily, it is described to carry out convolution operation to input data, including:
The input data is carried out by the convolution operation of low-bit width fixed point unit based on multiply-add.
Exemplarily, the output data of the fixed-point computation is that last calculate node in the neutral net is carried out
The result of the low-bit width fixed point obtained by fixed-point computation.
According to the second aspect of the invention, there is provided a kind of computing device based on neutral net, including:
Acquisition module, the original image for obtaining tensor form;
Computing module, fixed-point computation is carried out for the original image to the tensor form;
Thermodynamic chart generation module, for the output data based on the fixed-point computation, produces image thermodynamic chart;And
Image labeling module, for being labeled to the original image based on described image thermodynamic chart.
Exemplarily, the computing module includes convolution submodule, linear calculating sub module and fixed point module,
For each calculate node in the neutral net:
The convolution submodule, for carrying out convolution operation to input data;
The linear calculating sub module, is linearly calculated for the convolution output to the convolution operation;
The fixed point module, low-bit width fixed point is carried out for the result to the linear calculating;
Wherein, the input data of first calculate node in the neutral net is the original graph of the tensor form
Picture, the input data of other calculate nodes in addition to first calculate node in the neutral net is previous meter
The result of the low-bit width fixed point of operator node.
Exemplarily, it is described linear to be calculated as floating-point and linearly calculate.
Exemplarily, the floating-point is linearly calculated and is expressed as:Y=k × X+b,
Wherein, X is fixed-point number, and k, b and y are floating number, and X represents the convolution output, and y represents that the floating-point is linearly calculated
Result, k and b is the good floating point parameters of training in advance.
Exemplarily, the fixed point module, is used for:
Magnitude relationship between the result linearly calculated according to the floating-point and the first fixed point decision threshold, determines described low
The result of bit wide fixed point,
Wherein, the first fixed point decision threshold is the good floating point parameters of training in advance, and first fixed point adjudicates threshold
Value is more than 0.
Exemplarily, it is described to be linearly calculated as pinpointing linear calculating.
Exemplarily, the linear calculating of the fixed point is expressed as:Y '=X '+B,
Wherein, X '=N × X, X, X ', Y ', B and N be fixed-point number, N is default positive integer, and X represents that the convolution is defeated
Go out, Y ' represents the linear result for calculating of the fixed point, B represents fixed point displacement parameter.
Exemplarily, the fixed point submodule, is used for:
According to the magnitude relationship between the linear result for calculating of the fixed point and the second fixed point decision threshold, determine described low
The result of bit wide fixed point.
Exemplarily, the linear calculating sub module, is additionally operable to:
Before the convolution output to the convolution operation is linearly calculated, according to the good floating point parameters of training in advance,
Determine the fixed point displacement parameter and the second fixed point decision threshold.
Exemplarily, the convolution submodule, is used for:
The input data is carried out by the convolution operation of low-bit width fixed point unit based on multiply-add.
Exemplarily, the output data of the fixed-point computation is that last calculate node in the neutral net is carried out
The result of the low-bit width fixed point obtained by fixed-point computation.
The device described in second aspect is implemented for the computational methods based on neutral net of aforementioned first aspect.
According to the third aspect of the invention we, there is provided a kind of computer chip, the computer chip includes processor and deposits
Reservoir.The memory storage has instruction code, and the processor is used to perform the instruction code, and when the processor is held
During row instruction code, the computational methods based on neutral net described in aforementioned first aspect can be realized.
The method that the use fixed point method that the embodiment of the present invention is proposed realizes the calculating of neutral net, as a result of fixed
Point is calculated, and amount of calculation is small, and occupancy resource is few, so as to the requirement to hardware is relatively low.
Brief description of the drawings
The embodiment of the present invention is described in more detail by with reference to accompanying drawing, of the invention above-mentioned and other purposes,
Feature and advantage will be apparent.Accompanying drawing is used for providing further understanding the embodiment of the present invention, and constitutes explanation
A part for book, is used to explain the present invention together with the embodiment of the present invention, is not construed as limiting the invention.In the accompanying drawings,
Identical reference number typically represents same parts or step.
Fig. 1 is a schematic block diagram of the electronic equipment of the embodiment of the present invention;
Fig. 2 is an indicative flowchart of the computational methods based on neutral net of the embodiment of the present invention;
Fig. 3 is another indicative flowchart of the computational methods based on neutral net of the embodiment of the present invention;
Fig. 4 is another indicative flowchart of the computational methods based on neutral net of the embodiment of the present invention;
Fig. 5 is a schematic block diagram of the computing device based on neutral net of the embodiment of the present invention;
Fig. 6 is another schematic block diagram of the computing device based on neutral net of the embodiment of the present invention.
Specific embodiment
In order that obtain the object, technical solutions and advantages of the present invention becoming apparent, root is described in detail below with reference to accompanying drawings
According to example embodiment of the invention.Obviously, described embodiment is only a part of embodiment of the invention, rather than this hair
Bright whole embodiments, it should be appreciated that the present invention is not limited by example embodiment described herein.Described in the present invention
The embodiment of the present invention, those skilled in the art's all other embodiment resulting in the case where creative work is not paid
Should all fall under the scope of the present invention.
The general algorithm framework of traditional neutral net is as follows:(1) picture will be input into and is extracted into the form of tensor, it is incoming
Trained good Floating-point Computation neutral net.(2) each calculate node in Floating-point Computation neutral net, by with floating multiplication
The convolution operation of base unit is added as, and floating point calculations are sent to next layer of calculate node.(3) by the calculating of multilayer
After node computing, the output layer of final neutral net produces image segmentation thermodynamic chart (heatmap), then on its basis to original
Figure carries out related mark.However, such framework often leads to intensive demand, internal memory high (or video memory) occupancy, Yi Jigao
The problems such as bandwidth requirement, so as to realize that Large Scale Neural Networks propose requirement very high to hardware.
The embodiment of the present invention proposes a kind of method that use fixed point method realizes the calculating of neutral net, due to using
Fixed-point computation, amount of calculation is small, takes that resource is few, so as to the requirement to hardware is relatively low.
The embodiment of the present invention can apply to electronic equipment, and Fig. 1 show of the electronic equipment of the embodiment of the present invention
Schematic block diagram.Electronic equipment 10 shown in Fig. 1 include one or more processors 102, one or more storage devices 104,
Input unit 106, output device 108, imageing sensor 110 and one or more non-image sensors 114, these components lead to
Cross bus system 112 and/or other forms interconnection.It should be noted that the component and structure of electronic equipment 10 shown in Fig. 1 are to show
Example property, and it is nonrestrictive, and as needed, the electronic equipment can also have other assemblies and structure.
The processor 102 can include CPU (Central Processing Unit, CPU) 1021 and/
Or graphics processing unit (Graphics Processing Unit, GPU) 1022, or including with data-handling capacity and/
Or the processing unit of the other forms of instruction execution capability, such as field programmable gate array (Field-Programmable
Gate Array, FPGA) or advanced reduced instruction set machine (Advanced RISC (Reduced Instruction Set
Computer) Machine, ARM) etc., and processor 102 can control other components in the electronic equipment 10 to perform
Desired function.
The storage device 104 can include one or more computer program products, and the computer program product can
With including various forms of computer-readable recording mediums, such as volatile memory 1041 and/or nonvolatile memory
1042.The volatile memory 1041 can for example include random access memory (Random Access Memory, RAM)
And/or cache memory (cache) etc..The nonvolatile memory 1042 can for example include read-only storage
(Read-Only Memory, ROM), hard disk, flash memory etc..One or many can be stored on the computer-readable recording medium
Individual computer program instructions, processor 102 can run described program instruction, to realize various desired functions.In the meter
Various application programs and various data can also be stored in calculation machine readable storage medium storing program for executing, such as application program use and/or
Various data for producing etc..
The input unit 106 can be device of the user for input instruction, and can include keyboard, mouse, wheat
One or more in gram wind and touch-screen etc..
The output device 108 can export various information (such as image or sound) to outside (such as user), and
Can be including one or more in display, loudspeaker etc..
Described image sensor 110 can shoot the desired image of user (such as photo, video etc.), and will be captured
Image store in the storage device 104 so that other components are used.
Work as attention, the component and structure of the electronic equipment 10 shown in Fig. 1 are exemplary, although the electronics shown in Fig. 1
Equipment 20 includes multiple different devices, but as needed, some of which device can not be necessary, some of which
The quantity of device can be of the invention that this is not limited with more etc..
Fig. 2 is an indicative flowchart of the computational methods based on neutral net of the embodiment of the present invention, shown in Fig. 2
Method includes:
S101, obtains the original image of tensor form.
Specifically, the original image of tensor form, can by common RGB image (such as from optical pickocff
RGB image) on extract characteristic tensor obtain.Wherein, after the original image for obtaining tensor form, then by the original of the tensor form
The incoming fixed-point computation neutral net for having trained of beginning image is processed.Wherein, original image is referred to as input figure
Picture.Image can be picture (such as frame of video) or continuous video.
That is, S101 refers to:The fixed-point computation neutral net for having trained obtains the original image of tensor form.
In the embodiment of the present invention, the fixed-point computation neutral net for having trained includes the good floating-point ginseng of training in advance
Parameter needed for number and convolution operation etc..Wherein, the good floating point parameters of training in advance include follow-up involved k, b, t0,
T1 ... etc..
S102, the original image to the tensor form carries out fixed-point computation.
Neutral net includes multiple (referred at least two) calculate nodes.
Specifically, in S102, each calculate node in the neutral net performs following operation:Input data is entered
Row convolution operation;Convolution output to the convolution operation is linearly calculated;Result to the linear calculating carries out low level
Fixed point wide.Wherein, the input data of first calculate node in the neutral net is the original graph of the tensor form
Picture, the input data of other calculate nodes in addition to first calculate node in the neutral net is previous meter
The result of the low-bit width fixed point of operator node.
That is, each calculate node is performed both by:Convolution operation, linear calculating operate and fixed point operation.
Here it is possible to the output data of the result referred to as calculate node of the low-bit width fixed point that calculate node is obtained.
So as to the input data of other calculate nodes in addition to first calculate node in the neutral net is previous
The output data of calculate node.
All calculate nodes in neutral net (can be referred to as initial calculation section including first calculate node
Point), intermediary computing node and last calculate node.Wherein, first input data of calculate node is the tensor shape
The data of the original image of formula.The input data of intermediary computing node and last calculate node is previous calculate node
Output data.Wherein, first calculate node and intermediary computing node output data to next calculate node by what is obtained.
Wherein, convolution operation is carried out to input data, can be included:Input data is carried out multiply-add be with low-bit width fixed point
The convolution operation of base unit.So, amount of calculation can be reduced using fixed point is multiply-add, resource occupation is reduced, and uses low-bit width
Fixed point is multiply-add can further to reduce amount of calculation, and further reduces resource occupation.
Wherein, the convolution output to the convolution operation is linearly calculated, including:Floating-point is carried out to convolution output linear
Calculate or the linear calculating of fixed point.
Exemplarily, as a example by being linearly calculated as floating-point and linearly calculate, in S102, each meter in the neutral net
Operator node performs following operation:Convolution operation is carried out to input data;Convolution output to the convolution operation carries out floating-point line
Property calculate;Low-bit width fixed point is carried out to the result that the floating-point is linearly calculated;Using the result of the low-bit width fixed point as
Output data.Wherein, the input data of first calculate node in the neutral net is the original graph of the tensor form
Picture, the input data of other calculate nodes in addition to first calculate node in the neutral net is previous meter
The output data of operator node.
Wherein, carry out floating-point to the output of the convolution of the convolution operation linearly to calculate, can include:According to y=k × X+b
Calculate the result that floating-point is linearly calculated.
That is, floating-point is linearly calculated can be expressed as:Y=k × X+b.Wherein, X is fixed-point number, and k, b and y are floating-point
Number, X represents the convolution output, and y represents the result that the floating-point is linearly calculated, and k and b is the good floating point parameters of training in advance.
That is, k therein and b are the parameters of the fixed-point computation neutral net for having trained, the fixed point that can be trained from this
Obtained in calculating neutral net.As can be seen here, so just floating-point can be calculated according to convolution output X linearly to calculate
Result y.
Wherein, low-bit width fixed point is carried out to the result that the floating-point is linearly calculated, can be included:According to the floating-point line
Property calculate result and first fixed point decision threshold between magnitude relationship, determine the result of the low-bit width fixed point.Wherein,
The first fixed point decision threshold is the good floating point parameters of training in advance, and the first fixed point decision threshold is more than 0.Wherein,
As k and b, the first fixed point decision threshold is also the parameter of the fixed-point computation neutral net for having trained, can be from this
Trained good fixed-point computation neutral net is directly obtained.
First fixed point decision threshold can be expressed as t0, t1, t2 ....The quantity of the first fixed point decision threshold can be by fixed
The digit revealed is determined.For example, if fixed point is to 2 bits (bit), the quantity of the first fixed point decision threshold is 1, can
To be expressed as t0.
For example, the result of low-bit width fixed point can be expressed as Y.If fixed point is to 2 bits (bit), and first
Fixed point decision threshold can be expressed as t0.Then determining the method for the result Y of low-bit width fixed point can be:
If y meets y≤- t0, it is determined that Y=0;If y satisfactions-t0<y<0, it is determined that Y=1;If y meets 0≤y<T0, then
Determine Y=2;If y meets y >=t0, it is determined that Y=3.
If it is understood that the result of a low-bit width fixed point for calculate node to be expressed as the output of Y, the i.e. calculate node
Data are Y, then Y is also simultaneously the input data X of next calculate node.
The process can be schematically as shown in Figure 3.Also, fixed point conventional part therein can be calculated with fixed-point integer
Module is realized;K × X+b parts therein and fixed point part can be realized with floating number computing module.
Exemplarily, as a example by being linearly calculated as pinpointing linear calculating, in S102, each meter in the neutral net
Operator node performs following operation:Convolution operation is carried out to input data;Convolution output to the convolution operation carries out fixed point line
Property calculate;Low-bit width fixed point is carried out to the linear result for calculating of the fixed point;Using the result of the low-bit width fixed point as
Output data.Wherein, the input data of first calculate node in the neutral net is the original graph of the tensor form
Picture, the input data of other calculate nodes in addition to first calculate node in the neutral net is previous meter
The output data of operator node.
Wherein, the convolution output to the convolution operation carries out pinpointing linear calculating, can include:According to Y '=X '+B meters
Calculate the result that floating-point is linearly calculated.
That is, linear calculating of fixed point can be expressed as:Y '=X '+B.Wherein, X '=N × X, X, X ', Y ', B and N it is equal
It is fixed-point number, N is default positive integer, and X represents the convolution output, and Y ' represents the linear result for calculating of the fixed point, and B is represented
Fixed point displacement parameter.
Wherein, low-bit width fixed point is carried out to the linear result for calculating of the fixed point, can be included:According to the fixed point line
Property calculate result and second fixed point decision threshold between magnitude relationship, determine the result of the low-bit width fixed point.
Fixed point displacement parameter and the second fixed point decision threshold used in the calculating process can be according to instruction in advance
What the floating point parameters perfected were determined.It can be seen that, carry out pinpointing linear calculating in the convolution output to the convolution operation
Before, can also include:According to the good floating point parameters of training in advance, determine that the fixed point displacement parameter and second fixed point are sentenced
Certainly threshold value.In one example, by enumerative technique according to the good floating point parameters of training in advance determine it is described fixed point displacement parameter and
The second fixed point decision threshold.Enumerative technique is simpler relative to other method easy, can save programming time.
By the good floating point parameters of training in advance be expressed as k, b, t0, t1, t2 ..., wherein, the physical meaning of parameters is such as
It is preceding described.Will fixed point displacement parameter be expressed as B, by second fixed point decision threshold be expressed as T0, T1 ....Then can based on k, b,
T0, t1, t2 ..., according to certain algorithm obtain suitable B, T0, T1, T2 ....For example, can be enumerated or be traveled through,
So that it is determined that suitable B, T0, T1, T2 ....
As a example by with N=4, and fixed point to 2 bits, now the good floating point parameters of training in advance are expressed as k, b, t0, as follows
Show a kind of calculation procedure that B and T0 are determined by enumerative technique:
So, fixed point decision thresholds T0, T1 ... of fixed point displacement parameter B and second can just be obtained.For example, can be by
The result of low-bit width fixed point is expressed as Y.If fixed point is to 2 bits (bit), and the second fixed point decision threshold can be expressed as
T0.Then determining the method for the result Y of low-bit width fixed point can be:
If Y ' meets Y '≤- T0, it is determined that Y=0;If Y ' satisfactions-T0<Y’<0, it is determined that Y=1;If Y ' meets 0≤Y '<
T0, it is determined that Y=2;If Y ' meets Y ' >=T0, it is determined that Y=3.
That is, if X '+B≤- T0, it is determined that Y=0;If-T0<X’+B<0, it is determined that Y=1;If 0≤X '+B<T0, it is determined that
Y=2;If X '+B >=T0, it is determined that Y=3.
If it is understood that the result of a low-bit width fixed point for calculate node to be expressed as the output of Y, the i.e. calculate node
Data are Y, then Y is also simultaneously the input data X of next calculate node.
The process can be schematically as shown in Figure 4.Also, fixed point conventional part therein, X '+part B and fixed point
Part can be realized with fixed-point integer computing module.It can be seen that, in the embodiment, it is only necessary to by n numeric parameter (i.e. B,
T0, T1 ...), it is possible to calculated by fixed-point integer realize that floating-point is linearly calculated and 2 × n values and log completely2(2 × n) position
The function of fixed point wide.It is possible thereby to realize that whole low-bit width neural computing node can calculate mould using fixed-point integer
Block is realized.
It should be noted that in the embodiment of the present invention, the output way (output channel) of calculate node can for all the way or
Multichannel.If output way is multichannel, it is directed to each of which road and is performed both by being carried out simultaneously between above-mentioned operation, i.e. multichannel
Row operation.Also, it is to be understood that, when it is multichannel to export way, linearly calculated using floating-point than calculating institute using fixed point is linear
Need the hardware resource for taking many.
It should be noted that capital X, Y, X in the embodiment of the present invention ', Y ', B, T0, T1 ... represent fixed-point number, lowercase
X, y, k, b, t0, t1 ... represent floating number.In addition, N and n represent positive integer.
S103, based on the output data of the fixed-point computation, produces image thermodynamic chart.
Wherein, the output data of fixed-point computation is that last calculate node in the neutral net carries out fixed-point computation
The result of resulting low-bit width fixed point.The output data Y of last calculate node in as described neutral net.
Specifically, in by S102 after the computing of multilayer calculate node, can be according to last calculate node
Output data Y, image thermodynamic chart is produced in the output layer of neutral net.
S104, is labeled based on described image thermodynamic chart to the original image.
As can be seen here, the embodiment of the present invention proposes a kind of parameter to neutral net, intermediate representation and basic calculating
The method that unit carries out low-bit width fixed point, requirement of the method to hardware is relatively low.
The computational methods based on neutral net shown in the embodiment of the present invention can be by the field programmable gate of electronic equipment
Array (Field-Programmable Gate Array, FPGA) is performed.
Fig. 5 is a schematic block diagram of the computing device based on neutral net of the embodiment of the present invention.Dress shown in Fig. 5
Putting 50 includes acquisition module 501, computing module 502, thermodynamic chart generation module 503 and image labeling module 504.
Acquisition module 501, the original image for obtaining tensor form.
Computing module 502, fixed-point computation is carried out for the original image to the tensor form.
Thermodynamic chart generation module 503, for the output data based on the fixed-point computation, produces image thermodynamic chart.And
Image labeling module 504, for being labeled to the original image based on described image thermodynamic chart.
Exemplarily, as shown in fig. 6, computing module includes convolution submodule 5021, linear calculating sub module 5022 and fixed
Reveal module 5023.For each calculate node in the neutral net:Convolution submodule 5021, for input data
Carry out convolution operation;Linear calculating sub module 5022, is linearly calculated for the convolution output to the convolution operation;Fixed point
Change module 5023, low-bit width fixed point is carried out for the result to the linear calculating.Wherein, first in the neutral net
The input data of individual calculate node is the original image of the tensor form, in the neutral net except described first calculating
The input data of other calculate nodes outside node is the result of the low-bit width fixed point of previous calculate node.
Alternatively, it is described linear to be calculated as floating-point and linearly calculate as a kind of implementation.
Exemplarily, the floating-point is linearly calculated and can be expressed as:Y=k × X+b.Wherein, X is fixed-point number, and k, b and y are
Floating number, X represents the convolution output, and y represents the result that the floating-point is linearly calculated, and k and b is the good floating-point ginseng of training in advance
Number.
Exemplarily, fixed point module 5023, can be used for:According to result and the first fixed point that the floating-point is linearly calculated
Magnitude relationship between decision threshold, determines the result of the low-bit width fixed point.Wherein, the first fixed point decision threshold is
The good floating point parameters of training in advance, and the first fixed point decision threshold is more than 0.
Alternatively, it is described to be linearly calculated as pinpointing linear calculating as another implementation.
Exemplarily, the linear calculating of the fixed point can be expressed as:Y '=X '+B.Wherein, X '=N × X, X, X ', Y ', B
Fixed-point number is with N, N is default positive integer, and X represents the convolution output, and Y ' represents the linear result for calculating of the fixed point,
B represents fixed point displacement parameter.
Exemplarily, fixed point submodule 5023, can be used for:Determined with second according to the linear result for calculating of the fixed point
Magnitude relationship between point decision threshold, determines the result of the low-bit width fixed point.
Exemplarily, linear calculating sub module 5022, can be also used for:Carried out in the convolution output to the convolution operation
Before linear calculating, according to the good floating point parameters of training in advance, the fixed point displacement parameter and the second fixed point judgement are determined
Threshold value.
Exemplarily, convolution submodule 5021, can be used for:The input data is carried out multiply-add be with low-bit width fixed point
The convolution operation of base unit.
Exemplarily, the output data of the fixed-point computation is that last calculate node in the neutral net is carried out
The result of the low-bit width fixed point obtained by fixed-point computation.
Device 50 shown in Fig. 5 and Fig. 6 is implemented for calculating based on neutral net of the earlier figures 2 shown in Fig. 4
Method.Exemplarily, device 50 can be FPGA.
In addition, the embodiment of the present invention additionally provides another computing device based on neutral net, the device can include
Processor and memory, wherein, memory is used for store instruction code, during the computing device instruction code, it is possible to achieve preceding
State the computational methods based on neutral net shown in Fig. 2 to Fig. 4.
In addition, the embodiment of the present invention additionally provides a kind of electronic equipment, the electronic equipment can be included shown in Fig. 5 or Fig. 6
Device 50.
The method that the use fixed point method that the embodiment of the present invention is proposed realizes the calculating of neutral net, the i.e. present invention are implemented
Example proposes neutral net fixed point method, and the method is as a result of fixed-point computation, and amount of calculation is small, and occupancy resource is few, so that
Requirement to hardware is relatively low.
Although the example embodiment by reference to Description of Drawings here, it should be understood that above-mentioned example embodiment is merely exemplary
, and be not intended to limit the scope of the invention to this.Those of ordinary skill in the art can wherein carry out various changes
And modification, it is made without departing from the scope of the present invention and spirit.All such changes and modifications are intended to be included in appended claims
Within required the scope of the present invention.
Those of ordinary skill in the art are it is to be appreciated that the list of each example described with reference to the embodiments described herein
Unit and algorithm steps, can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
Performed with hardware or software mode, depending on the application-specific and design constraint of technical scheme.Professional and technical personnel
Described function, but this realization can be realized it is not considered that exceeding using distinct methods to each specific application
The scope of the present invention.
In several embodiments provided herein, it should be understood that disclosed apparatus and method, can be by it
Its mode is realized.For example, apparatus embodiments described above are only schematical, for example, the division of the unit, only
Only a kind of division of logic function, can there is other dividing mode when actually realizing, such as multiple units or component can be tied
Another equipment is closed or is desirably integrated into, or some features can be ignored, or do not perform.
In specification mentioned herein, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention
Example can be put into practice in the case of without these details.In some instances, known method, structure is not been shown in detail
And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the present invention and help to understand one or more in each inventive aspect, exist
In to the description of exemplary embodiment of the invention, each feature of the invention be grouped together into sometimes single embodiment, figure,
Or in descriptions thereof.However, the method for the present invention should be construed to reflect following intention:It is i.e. required for protection
Application claims features more more than the feature being expressly recited in each claim.More precisely, such as corresponding power
As sharp claim reflects, its inventive point is that can use the spy of all features less than certain disclosed single embodiment
Levy to solve corresponding technical problem.Therefore, it then follows it is specific that thus claims of specific embodiment are expressly incorporated in this
Implementation method, wherein each claim are in itself as separate embodiments of the invention.
It will be understood to those skilled in the art that in addition to mutually exclusive between feature, any combinations pair can be used
All features and so disclosed any method disclosed in this specification (including adjoint claim, summary and accompanying drawing)
Or all processes or unit of equipment are combined.Unless expressly stated otherwise, this specification (including adjoint right will
Ask, make a summary and accompanying drawing) disclosed in each feature can the alternative features of or similar purpose identical, equivalent by offer replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include other embodiments
In included some features rather than further feature, but the combination of the feature of different embodiments means in of the invention
Within the scope of and form different embodiments.For example, in detail in the claims, embodiment required for protection it is one of any
Mode can use in any combination.
All parts embodiment of the invention can be realized with hardware, or be run with one or more processor
Software module realize, or with combinations thereof realize.It will be understood by those of skill in the art that can use in practice
Microprocessor or digital signal processor (DSP) realize some moulds in article analytical equipment according to embodiments of the present invention
The some or all functions of block.The present invention is also implemented as the part or complete for performing method as described herein
The program of device (for example, computer program and computer program product) in portion.It is such to realize that program of the invention be stored
On a computer-readable medium, or can have one or more signal form.Such signal can be from internet
Downloaded on website and obtained, or provided on carrier signal, or provided in any other form.
It should be noted that above-described embodiment the present invention will be described rather than limiting the invention, and ability
Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims,
Any reference symbol being located between bracket should not be configured to limitations on claims.Word "comprising" is not excluded the presence of not
Element listed in the claims or step.Word "a" or "an" before element is not excluded the presence of as multiple
Element.The present invention can come real by means of the hardware for including some different elements and by means of properly programmed computer
It is existing.If in the unit claim for listing equipment for drying, several in these devices can be by same hardware branch
To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame
Claim.
The above, specific embodiment only of the invention or the explanation to specific embodiment, protection of the invention
Scope is not limited thereto, any one skilled in the art the invention discloses technical scope in, can be easily
Expect change or replacement, should all be included within the scope of the present invention.Protection scope of the present invention should be with claim
Protection domain is defined.
Claims (22)
1. a kind of computational methods based on neutral net, it is characterised in that including:
Obtain the original image of tensor form;
Original image to the tensor form carries out fixed-point computation;
Based on the output data of the fixed-point computation, image thermodynamic chart is produced;And
The original image is labeled based on described image thermodynamic chart.
2. the method for claim 1, it is characterised in that the original image to the tensor form carries out fixed point meter
Calculate, including:
Each calculate node in the neutral net performs following operation:
Convolution operation is carried out to input data;
Convolution output to the convolution operation is linearly calculated;
Result to the linear calculating carries out low-bit width fixed point;
Wherein, the input data of first calculate node in the neutral net is the original image of the tensor form, institute
State the input data of other calculate nodes in addition to first calculate node in neutral net and calculate section for previous
The result of the low-bit width fixed point of point.
3. method as claimed in claim 2, it is characterised in that described linear to be calculated as floating-point and linearly calculate.
4. method as claimed in claim 3, it is characterised in that
The floating-point is linearly calculated and is expressed as:Y=k × X+b,
Wherein, X is fixed-point number, and k, b and y are floating number, and X represents the convolution output, and y represents the knot that the floating-point is linearly calculated
Really, k and b is the good floating point parameters of training in advance.
5. the method as described in claim 3 or 4, it is characterised in that the result to the linear calculating carries out low-bit width
Fixed point, including:
Magnitude relationship between the result linearly calculated according to the floating-point and the first fixed point decision threshold, determines the low-bit width
The result of fixed point,
Wherein, the first fixed point decision threshold is the good floating point parameters of training in advance, and the first fixed point decision threshold is big
In 0.
6. method as claimed in claim 2, it is characterised in that described linear to be calculated as pinpointing linear calculating.
7. method as claimed in claim 6, it is characterised in that
The linear calculating of the fixed point is expressed as:Y '=X '+B,
Wherein, X '=N × X, X, X ', Y ', B and N be fixed-point number, N is default positive integer, and X represents the convolution output, Y '
The linear result for calculating of the fixed point is represented, B represents fixed point displacement parameter.
8. method as claimed in claim 7, it is characterised in that the result to the linear calculating carries out low-bit width fixed point
Change, including:
According to the magnitude relationship between the linear result for calculating of the fixed point and the second fixed point decision threshold, the low-bit width is determined
The result of fixed point.
9. method as claimed in claim 8, it is characterised in that carried out in the convolution output to the convolution operation linear
Before calculating, also include:
According to the good floating point parameters of training in advance, the fixed point displacement parameter and the second fixed point decision threshold are determined.
10. the method as described in any one of claim 2 to 9, it is characterised in that described that convolution operation is carried out to input data,
Including:
The input data is carried out by the convolution operation of low-bit width fixed point unit based on multiply-add.
11. method as described in any one of claim 1 to 10, it is characterised in that the output data of the fixed-point computation is institute
Stating last calculate node in neutral net carries out the result of the low-bit width fixed point obtained by fixed-point computation.
A kind of 12. computing devices based on neutral net, it is characterised in that including:
Acquisition module, the original image for obtaining tensor form;
Computing module, fixed-point computation is carried out for the original image to the tensor form;
Thermodynamic chart generation module, for the output data based on the fixed-point computation, produces image thermodynamic chart;And
Image labeling module, for being labeled to the original image based on described image thermodynamic chart.
13. devices as claimed in claim 12, it is characterised in that the computing module includes convolution submodule, linear to calculate
Submodule and fixed point module,
For each calculate node in the neutral net:
The convolution submodule, for carrying out convolution operation to input data;
The linear calculating sub module, is linearly calculated for the convolution output to the convolution operation;
The fixed point module, low-bit width fixed point is carried out for the result to the linear calculating;
Wherein, the input data of first calculate node in the neutral net is the original image of the tensor form, institute
State the input data of other calculate nodes in addition to first calculate node in neutral net and calculate section for previous
The result of the low-bit width fixed point of point.
14. devices as claimed in claim 13, it is characterised in that described linear to be calculated as floating-point and linearly calculate.
15. devices as claimed in claim 14, it is characterised in that
The floating-point is linearly calculated and is expressed as:Y=k × X+b,
Wherein, X is fixed-point number, and k, b and y are floating number, and X represents the convolution output, and y represents the knot that the floating-point is linearly calculated
Really, k and b is the good floating point parameters of training in advance.
16. device as described in claims 14 or 15, it is characterised in that the fixed point module, is used for:
Magnitude relationship between the result linearly calculated according to the floating-point and the first fixed point decision threshold, determines the low-bit width
The result of fixed point,
Wherein, the first fixed point decision threshold is the good floating point parameters of training in advance, and the first fixed point decision threshold is big
In 0.
17. devices as claimed in claim 13, it is characterised in that described to be linearly calculated as pinpointing linear calculating.
18. devices as claimed in claim 17, it is characterised in that
The linear calculating of the fixed point is expressed as:Y '=X '+B,
Wherein, X '=N × X, X, X ', Y ', B and N be fixed-point number, N is default positive integer, and X represents the convolution output, Y '
The linear result for calculating of the fixed point is represented, B represents fixed point displacement parameter.
19. devices as claimed in claim 18, it is characterised in that the fixed point submodule, are used for:
According to the magnitude relationship between the linear result for calculating of the fixed point and the second fixed point decision threshold, the low-bit width is determined
The result of fixed point.
20. devices as claimed in claim 19, it is characterised in that the linear calculating sub module, are additionally operable to:
Before the convolution output to the convolution operation is linearly calculated, according to the good floating point parameters of training in advance, it is determined that
The fixed point displacement parameter and the second fixed point decision threshold.
21. device as described in any one of claim 13 to 20, it is characterised in that the convolution submodule, is used for:
The input data is carried out by the convolution operation of low-bit width fixed point unit based on multiply-add.
22. device as described in any one of claim 12 to 21, it is characterised in that the output data of the fixed-point computation is institute
Stating last calculate node in neutral net carries out the result of the low-bit width fixed point obtained by fixed-point computation.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611244827.2A CN106855952B (en) | 2016-12-29 | 2016-12-29 | Neural network-based computing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611244827.2A CN106855952B (en) | 2016-12-29 | 2016-12-29 | Neural network-based computing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106855952A true CN106855952A (en) | 2017-06-16 |
CN106855952B CN106855952B (en) | 2020-08-18 |
Family
ID=59126554
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611244827.2A Active CN106855952B (en) | 2016-12-29 | 2016-12-29 | Neural network-based computing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106855952B (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107562694A (en) * | 2017-08-23 | 2018-01-09 | 维沃移动通信有限公司 | A kind of data processing method and mobile terminal |
CN107766939A (en) * | 2017-11-07 | 2018-03-06 | 维沃移动通信有限公司 | A kind of data processing method, device and mobile terminal |
CN108053028A (en) * | 2017-12-21 | 2018-05-18 | 深圳云天励飞技术有限公司 | Data fixed point processing method, device, electronic equipment and computer storage media |
CN108875519A (en) * | 2017-12-19 | 2018-11-23 | 北京旷视科技有限公司 | Method for checking object, device and system and storage medium |
CN108876790A (en) * | 2017-09-14 | 2018-11-23 | 北京旷视科技有限公司 | Image, semantic dividing method and device, neural network training method and device |
WO2020098368A1 (en) * | 2018-11-15 | 2020-05-22 | 北京嘉楠捷思信息技术有限公司 | Adaptive quantization method and apparatus, device and medium |
CN111383237A (en) * | 2018-12-29 | 2020-07-07 | Tcl集团股份有限公司 | Image analysis method and device and terminal equipment |
CN111448050A (en) * | 2017-12-13 | 2020-07-24 | 惠普发展公司,有限责任合伙企业 | Thermal behavior prediction from continuous tone maps |
CN112912232A (en) * | 2018-10-29 | 2021-06-04 | 惠普发展公司,有限责任合伙企业 | Heat mapping |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102981854A (en) * | 2012-11-16 | 2013-03-20 | 天津市天祥世联网络科技有限公司 | Neural network optimization method based on floating number operation inline function library |
US20150170020A1 (en) * | 2013-12-13 | 2015-06-18 | Amazon Technologies, Inc. | Reducing dynamic range of low-rank decomposition matrices |
CN105654176A (en) * | 2014-11-14 | 2016-06-08 | 富士通株式会社 | Nerve network system, and training device and training method for training nerve network system |
CN105760933A (en) * | 2016-02-18 | 2016-07-13 | 清华大学 | Method and apparatus for fixed-pointing layer-wise variable precision in convolutional neural network |
CN106066783A (en) * | 2016-06-02 | 2016-11-02 | 华为技术有限公司 | The neutral net forward direction arithmetic hardware structure quantified based on power weight |
CN106251338A (en) * | 2016-07-20 | 2016-12-21 | 北京旷视科技有限公司 | Target integrity detection method and device |
-
2016
- 2016-12-29 CN CN201611244827.2A patent/CN106855952B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102981854A (en) * | 2012-11-16 | 2013-03-20 | 天津市天祥世联网络科技有限公司 | Neural network optimization method based on floating number operation inline function library |
US20150170020A1 (en) * | 2013-12-13 | 2015-06-18 | Amazon Technologies, Inc. | Reducing dynamic range of low-rank decomposition matrices |
CN105654176A (en) * | 2014-11-14 | 2016-06-08 | 富士通株式会社 | Nerve network system, and training device and training method for training nerve network system |
CN105760933A (en) * | 2016-02-18 | 2016-07-13 | 清华大学 | Method and apparatus for fixed-pointing layer-wise variable precision in convolutional neural network |
CN106066783A (en) * | 2016-06-02 | 2016-11-02 | 华为技术有限公司 | The neutral net forward direction arithmetic hardware structure quantified based on power weight |
CN106251338A (en) * | 2016-07-20 | 2016-12-21 | 北京旷视科技有限公司 | Target integrity detection method and device |
Non-Patent Citations (1)
Title |
---|
SAJID ANWAR 等: "FIXED POINT OPTIMIZATION OF DEEP CONVOLUTIONAL NEURAL NETWORKS FOR OBJECT RECOGNITION", 《2015 IEEE INTERNATIONAL CONFERENCE ON ACOUSTICS, SPEECH AND SIGNAL PROCESSING (ICASSP)》 * |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107562694A (en) * | 2017-08-23 | 2018-01-09 | 维沃移动通信有限公司 | A kind of data processing method and mobile terminal |
CN108876790A (en) * | 2017-09-14 | 2018-11-23 | 北京旷视科技有限公司 | Image, semantic dividing method and device, neural network training method and device |
CN107766939A (en) * | 2017-11-07 | 2018-03-06 | 维沃移动通信有限公司 | A kind of data processing method, device and mobile terminal |
CN111448050A (en) * | 2017-12-13 | 2020-07-24 | 惠普发展公司,有限责任合伙企业 | Thermal behavior prediction from continuous tone maps |
US11669057B2 (en) | 2017-12-13 | 2023-06-06 | Hewlett-Packard Development Company, L.P. | Neural network thermal behavior predictions |
CN111448050B (en) * | 2017-12-13 | 2022-10-11 | 惠普发展公司,有限责任合伙企业 | Thermal behavior prediction from continuous tone maps |
CN108875519A (en) * | 2017-12-19 | 2018-11-23 | 北京旷视科技有限公司 | Method for checking object, device and system and storage medium |
CN108053028B (en) * | 2017-12-21 | 2021-09-14 | 深圳励飞科技有限公司 | Data fixed-point processing method and device, electronic equipment and computer storage medium |
CN108053028A (en) * | 2017-12-21 | 2018-05-18 | 深圳云天励飞技术有限公司 | Data fixed point processing method, device, electronic equipment and computer storage media |
CN112912232A (en) * | 2018-10-29 | 2021-06-04 | 惠普发展公司,有限责任合伙企业 | Heat mapping |
CN112912232B (en) * | 2018-10-29 | 2023-03-10 | 惠普发展公司,有限责任合伙企业 | Heat mapping |
US11971699B2 (en) | 2018-10-29 | 2024-04-30 | Hewlett-Packard Development Company, L.P. | Thermal mapping |
WO2020098368A1 (en) * | 2018-11-15 | 2020-05-22 | 北京嘉楠捷思信息技术有限公司 | Adaptive quantization method and apparatus, device and medium |
CN111383237A (en) * | 2018-12-29 | 2020-07-07 | Tcl集团股份有限公司 | Image analysis method and device and terminal equipment |
Also Published As
Publication number | Publication date |
---|---|
CN106855952B (en) | 2020-08-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106855952A (en) | Computational methods and device based on neutral net | |
CN106611216A (en) | Computing method and device based on neural network | |
CN108701250B (en) | Data fixed-point method and device | |
CN109697510B (en) | Method and device with neural network | |
CN109685198A (en) | Method and apparatus for quantifying the parameter of neural network | |
KR20190073303A (en) | Method and electronic device for convolution calculation in neutral network | |
KR20190052893A (en) | Method and apparatus for preprocessing an operation of neural network | |
CN108053028A (en) | Data fixed point processing method, device, electronic equipment and computer storage media | |
JP6991983B2 (en) | How and systems to train machine learning systems | |
WO2021097442A1 (en) | Guided training of machine learning models with convolution layer feature data fusion | |
CN112508190A (en) | Method, device and equipment for processing structured sparse parameters and storage medium | |
CN111476719A (en) | Image processing method, image processing device, computer equipment and storage medium | |
CN106779057A (en) | The method and device of the calculating binary neural network convolution based on GPU | |
CN111401339A (en) | Method and device for identifying age of person in face image and electronic equipment | |
CN107402905A (en) | Computational methods and device based on neutral net | |
CN110637306A (en) | Conditional graph execution based on previous reduced graph execution | |
CN112966818A (en) | Directional guide model pruning method, system, equipment and storage medium | |
CN114386590A (en) | Method and apparatus for compressing artificial neural networks | |
CN110647718A (en) | Data processing method, device, equipment and computer readable storage medium | |
CN112561050B (en) | Neural network model training method and device | |
CN110503600A (en) | Feature point detecting method, device, electronic equipment and readable storage medium storing program for executing | |
CN109359542B (en) | Vehicle damage level determining method based on neural network and terminal equipment | |
CN109389215B (en) | Network structure determination method and device of deep learning network | |
CN114819159A (en) | Inference method, device, equipment and storage medium of deep learning model | |
CN111815510B (en) | Image processing method based on improved convolutional neural network model and related equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 100190 Beijing, Haidian District Academy of Sciences, South Road, No. 2, block A, No. 313 Applicant after: MEGVII INC. Applicant after: Beijing maigewei Technology Co., Ltd. Address before: 100190 Beijing, Haidian District Academy of Sciences, South Road, No. 2, block A, No. 313 Applicant before: MEGVII INC. Applicant before: Beijing aperture Science and Technology Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |