WO2019075604A1 - 数据定点化方法和装置 - Google Patents

数据定点化方法和装置 Download PDF

Info

Publication number
WO2019075604A1
WO2019075604A1 PCT/CN2017/106333 CN2017106333W WO2019075604A1 WO 2019075604 A1 WO2019075604 A1 WO 2019075604A1 CN 2017106333 W CN2017106333 W CN 2017106333W WO 2019075604 A1 WO2019075604 A1 WO 2019075604A1
Authority
WO
WIPO (PCT)
Prior art keywords
bit width
layer
output value
target layer
data
Prior art date
Application number
PCT/CN2017/106333
Other languages
English (en)
French (fr)
Inventor
李似锦
杨康
林蔓虹
颜钊
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2017/106333 priority Critical patent/WO2019075604A1/zh
Priority to CN201780008940.7A priority patent/CN108701250B/zh
Publication of WO2019075604A1 publication Critical patent/WO2019075604A1/zh
Priority to US16/842,145 priority patent/US20200234133A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present application relates to the field of data processing, and in particular, to a data point method and apparatus.
  • the current mainstream neural network computing framework it is basically calculated using floating point numbers.
  • the calculation of the gradient needs to be based on the floating point number representation to ensure sufficient accuracy; the layers of the forward propagation process of the neural network, especially the weight coefficients of the convolutional layer and the fully connected layer
  • the output values of each layer are also expressed in floating point numbers.
  • the floating point number based operation is more complicated than the fixed point number based logic design, which consumes more hardware resources and consumes more power.
  • Fixed-point based hardware logic design is more friendly than floating point number based hardware logic design.
  • the application provides a data fixed point method and device, so that the network can be transmitted after the fixed point Deliver more useful information while maintaining high accuracy, thereby improving the expressiveness and accuracy of the network.
  • a data staging method comprising: calculating a maximum output value of each of the plurality of input samples in a first target layer of a neural network; selecting from a plurality of the maximum output values Determining at least two of the maximum output values as fixed-point reference values; determining a reference integer portion bit width according to each of the fixed-point reference values; performing accuracy based on a preset output value total bit width and each of the reference integer portion bit widths The test will determine the reference integer portion with the highest accuracy as the integer partial bit width used by the first target layer when the output value is fixed.
  • the data pointing method of the first aspect determines a bit width of a reference integer part corresponding to each fixed point reference value by selecting a plurality of values from a plurality of maximum output values of the first target layer as a fixed point reference value, and determining based on the accuracy test
  • the optimal integer part bit width according to the optimal integer part bit width, enables the fixed-point network to deliver more useful information while maintaining high precision, which can improve the expressiveness and accuracy of the network.
  • a data pointing method comprising: calculating a reference output value of an input sample in a first target layer of a neural network; determining a total bit width of the output value preset for the output value and a preset first symbol Bit width; determining an integer part bit width of the output value according to the size of the reference output value; determining a fractional part of the output value according to the total bit width of the output value, the first sign bit width, and the integer part bit width of the output value a bit width, wherein the first symbol bit width, the output value integer portion bit width, and the output value fractional portion bit width are used as a symbol bit width, an integer used by the first target layer when the output value is fixed. Partial bit width and fractional part bit width.
  • the data fixed-point method of the second aspect considers the sign bit when the output value is fixed, so that the determined fixed-point solution is better, and the possibility of increasing the network accuracy is improved.
  • a data processing method comprising: performing a combined preprocessing on at least two layers of a neural network; and performing a neural network operation based on the combined preprocessed neural network.
  • At least two layers of the neural network are combined and preprocessed, and the operation is performed based on the neural network after the pre-processing, which can save computing resources and improve system efficiency.
  • a data alignment method including: determining a plurality of layers that need data alignment from a neural network; and determining an integer part width according to an output value of each of the plurality of layers The plurality of layer output values are fixed to use the integer portion bit width of the final use, wherein any two of the plurality of layers are fixed in the integer value of the final use.
  • the fourth aspect of the data alignment method can solve the problem that some layers have input data alignment requirements when determining the fixed point scheme, can reduce the use of hardware resources, and improve system efficiency.
  • a fifth aspect provides a data pointing device, comprising: a forward propagation calculation module, configured to calculate a maximum output value of each of the plurality of input samples in a first target layer of the neural network; a selection module, configured to select at least two of the maximum output values from the plurality of maximum output values obtained by the forward propagation calculation module as a fixed point reference value; a reference bit width determining module, configured to refer to the fixed point reference Determining a reference integer part bit width for each of the fixed point reference values selected by the module; an accuracy test module, configured to determine each of the reference integers determined by the module based on a preset output value total bit width and the reference bit width determining module The partial bit width is tested for accuracy, and the reference integer portion with the highest accuracy is determined as the integer partial bit width used by the first target layer when the output value is fixed.
  • a sixth aspect provides a data pointing device, including: a forward propagation calculation module, configured to calculate a reference output value of an input sample in a first target layer of a neural network; and a determining module configured to determine a preset value for the output value The output value total bit width and the preset first symbol bit width; the output value bit width determining module, configured to determine an integer part bit width of the output value according to the size of the reference output value obtained by the forward propagation calculation module; Determining, according to the total value bit width of the output value, the first symbol bit width, and the integer part bit width of the output value determined by the determining module, determining a bit width of the output value, wherein the first symbol bit width, The output value integer part bit width and the output value fractional part bit width are used as a symbol bit width, an integer part bit width, and a fractional part bit width used by the first target layer when the output value is fixed.
  • a data processing apparatus including: a pre-processing module, configured to perform pre-processing on at least two layers of a neural network; and an operation module, configured to combine the pre-processed neural network based on the pre-processing module Perform neural network operations.
  • a data aligning apparatus including: a first determining module, configured to determine, from a neural network, a plurality of layers that need data alignment; and a second determining module, configured to use each of the plurality of layers
  • the output value is fixed to the integer part of the bit width to be used, and the integer part width of the plurality of layer output values is determined to be finalized, wherein any two of the plurality of layers are fixed to the final integer part of the output value.
  • the bit width is equal.
  • a ninth aspect provides a data pointing method, comprising: calculating a maximum output value of each of the plurality of input samples in a first target layer of a neural network; and selecting from the plurality of the maximum output values One of the maximum output values as a fixed point reference; according to the fixed point reference The value determines the reference integer portion bit width as the integer partial bit width used by the first target layer when the output value is fixed.
  • a tenth aspect provides a data pointing device, comprising: a forward propagation calculation module, configured to calculate a maximum output value of each of the plurality of input samples in a first target layer of the neural network; a selection module, configured to select one of the plurality of maximum output values obtained from the forward propagation calculation module as a fixed point reference value; a bit width determination module, configured to select according to the fixed point reference selection module The fixed point reference value determines a reference integer portion bit width as an integer partial bit width used by the first target layer when the output value is fixed.
  • Figure 1 is a schematic diagram of the framework of a deep convolutional neural network.
  • FIG. 2 is a schematic flowchart of a data fixed point method according to an embodiment of the present application.
  • FIG. 3A, FIG. 3B and FIG. 3C are schematic diagrams of several cases of merge preprocessing according to an embodiment of the present application;
  • FIG. 3D is a schematic diagram of a layer connection manner of the BN layer after the convolution layer.
  • FIG. 4 is a schematic diagram of selecting a fixed point reference value according to an embodiment of the present application.
  • Figure 5 is a schematic diagram of the working principle of the Concatenation layer.
  • Figure 6 is a schematic illustration of post processing of one embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a data fixed point method according to an embodiment of the present application.
  • FIG. 8 is a schematic flowchart of a data fixed point method according to an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of a data processing method according to an embodiment of the present application.
  • FIG. 10 is a schematic flowchart of a data alignment method according to an embodiment of the present application.
  • FIG. 11 is a schematic block diagram of a data pointing device of an embodiment of the present application.
  • FIG. 12 is a schematic block diagram of a data pointing device of an embodiment of the present application.
  • FIG. 13 is a schematic block diagram of a data processing apparatus according to an embodiment of the present application.
  • Figure 14 is a schematic block diagram of a data alignment device of one embodiment of the present application.
  • Figure 1 is a schematic diagram of the framework of a deep convolutional neural network.
  • the input value of the deep convolutional neural network (input by the input layer), convolution, transposed convolution or deconvolution, normalization (BN), scaling (Scale) through the hidden layer
  • the output values (output by the output layer) are obtained after operations such as fully connected, concatenation, pooling, element-wise addition, and activation.
  • the operations that may be involved in the hidden layer of the neural network of the embodiment of the present application are not limited to the above operations.
  • the hidden layer of the deep convolutional neural network may include multiple layers of cascades.
  • the input of each layer is the output of the upper layer, which is a feature map, and each layer performs at least one operation of the above described one or more sets of feature maps to obtain the output of the layer.
  • the output of each layer is also a feature map.
  • each layer is named after the implemented function, for example, a layer that implements a convolution operation is called a convolutional layer.
  • the hidden layer may further include a transposed convolution layer, a BN layer, a Scale layer, a pooling layer, a fully connected layer, a Concatenation layer, an element intelligent addition layer, an activation layer, and the like, which are not enumerated here.
  • the specific operation flow of each layer can refer to the existing technology, and will not be described in detail herein.
  • each layer may have one input and/or one output, or multiple inputs and/or multiple outputs.
  • the width and height of the feature map are often decremented layer by layer (for example, the input, feature map #1, feature map #2, feature map #3, and output width and height shown in FIG. 1 are
  • the semantic segmentation task after the width and height of the feature graph are decremented to a certain depth, it may be incremented by a transposition convolution operation or an upsampling operation.
  • the convolution layer is followed by an activation layer.
  • Common activation layers include a Rectified Linear Unit (ReLU) layer, a S-type (sigmoid) layer, and a hyperbolic tangent (tanh) layer.
  • layers that require more weight parameters for operations are: convolutional layer, fully connected layer, transposed convolutional layer, and BN layer.
  • Floating point numbers include single-precision floating-point numbers (32-bit) and double-precision floating-point numbers (64-bit).
  • the floating point number is represented by a sign bit, an integer part, and a fractional part.
  • Bw is the total bit width of the fixed point number
  • s is the sign bit (usually placed in the leftmost bit)
  • fl is the fractional part bit width
  • x i is the value of each bit (also called the mantissa bit).
  • the real value of a fixed-point number can be expressed as:
  • a fixed point number is 01000101
  • a bit width is 8 bits
  • a highest bit (0) is a sign bit
  • a decimal part bit width fl is 3.
  • the fixed point of data mainly includes the fixed point of the weight coefficient and the fixed point of the output value of the convolutional layer or the fully connected layer.
  • a fixed-point method is achieved by minimizing numerical errors.
  • the optimization objective function of the weight coefficient is to find the decimal place width when the error between the number obtained by the fixed-point truncation of the weight coefficient and the floating-point number is the smallest, given the total bit width.
  • the position of the fixed point is determined by minimizing the error of the optimized objective function, and the obtained fixed-point result may be poor. Still taking the output value as an example, the main reason is that the most important information in the output value is often determined by the larger value of the output value, and its proportion is usually smaller.
  • the fixed-point position obtained by the fixed-point method is fixed, although the truncation rate is relatively low, the most useful high-order information is often removed, resulting in a decrease in the accuracy of the network.
  • the existing fixed-point methods do not consider the fixed-point processing of layers other than the convolutional layer and the fully-connected layer, especially the active layer, the pooled layer, and the BN layer, all of which may involve floating-point operations, so Need to consider the fixed point processing.
  • the existing fixed-point method does not consider the problem of data point alignment of the input of the element-wise addition layer and the Concatenation layer. This will cause the data to be shifted during the operation after the data is fixed, making the operation more complicated.
  • Method 100 includes:
  • S140 Perform an accuracy test based on a preset total output bit width and a bit width of each reference integer part, and determine a reference integer part with the highest accuracy as an integer part bit used by the first target layer when the output value is fixed. width.
  • the embodiment of the present application determines a reference integer partial bit width corresponding to each fixed point reference value by selecting a plurality of values from a plurality of maximum output values of the first target layer as a fixed point reference value, and determining an optimal integer based on the accuracy test. Partial bit width, according to the optimal integer part bit width, enables the network to deliver more useful information while maintaining high accuracy and improve the expressiveness and accuracy of the network.
  • the embodiment of the present application can obtain the reference fractional part bit width based on the preset output value total bit width. Or, in other embodiments, the reference decimal portion bit width may be obtained first, and then the reference integer portion bit width is obtained, which is not limited by the embodiment of the present application.
  • the bit width of the sign bit is the first sign bit width.
  • the sum of the first symbol bit width, the reference integer portion bit width, and the reference fraction portion bit width is equal to the preset output value total bit width.
  • the first sign bit is determined according to the positive and negative of the data to be determined; the integer part and the decimal part of the fixed point are determined according to the value (size) of the data to be determined.
  • the first target layer of the embodiment of the present application may include a convolution layer, a transposed convolution layer, a BN layer, a Scale layer, a pooling layer, a fully connected layer, a Concatenation layer, an element-wise addition layer, and a layer in the active layer. Or at least two layers of the combined layer. That is, the data pointing method of the embodiment of the present application can be applied to any layer or layers of the hidden layer of the neural network.
  • the data delimiting method 100 may further include: combining pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining. This process can be considered as a pre-processing part of the data fixed-point method.
  • the parameters of the convolutional layer, the BN layer, and the Scale layer of the inference phase are fixed.
  • the parameters of the BN layer and the Scale layer can be merged into the parameters of the convolution layer, so that the intellectual property core (IP core) of the neural network does not need to be specifically for the BN layer and the Scale layer.
  • IP core intellectual property core
  • the convolutional layer was followed by the active layer.
  • the BN layer can be introduced before the layer is activated after the convolution layer.
  • x i is the output of the convolutional layer, let X be the input of the convolutional layer, W be the weight coefficient matrix, and b be the offset value:
  • the output of the BN layer is Therefore, based on the neural network designed by Caffe framework, the Scale layer is usually added after the BN layer to achieve complete normalization.
  • combining the pre-processing of at least two layers of the neural network to obtain the first target layer formed by combining may include: performing pre-processing on the convolution layer and the BN layer of the neural network to obtain the first target layer; or The convolutional layer and the Scale layer of the neural network are combined and preprocessed to obtain a first target layer; or, the convolutional layer, the BN layer and the Scale layer of the neural network are combined and preprocessed to obtain a first target layer.
  • FIGS. 3A, 3B, and 3C are schematic diagrams of several cases of merge preprocessing in the embodiment of the present application.
  • Figure 3D is a layer connection of the BN layer followed by the simplest convolutional layer.
  • the convolution layer is followed by the BN layer, followed by the active layer, and the convolution layer and the BN layer are merged into the first target layer, followed by the active layer, which is similar.
  • the two-layer structure of Figure 3D is similar.
  • IP cores support the processing of the Scale layer
  • the combination of the convolutional layer and the BN layer in the merge preprocessing can be replaced by the convolution layer and the Scale layer.
  • FIG. 3B before the merge preprocessing is performed, the convolution layer is followed by the Scale layer, and then the active layer, and the convolution layer and the Scale layer are merged into the first target layer, followed by the active layer, which is similar.
  • the two-layer structure of Figure 3D The two-layer structure of Figure 3D.
  • the convolution layer is followed by a BN layer, followed by a Scale layer, and then an active layer, and the convolutional layer, the BN layer, and the Scale layer are merged into a first target layer.
  • a two-layer structure similar to that of Figure 3D is obtained.
  • the maximum output value in S110 is the maximum output value of the first target layer formed after the merge of each of the plurality of input samples.
  • the fixed-point position of the output value of the first target layer can be determined.
  • S110 Calculate a maximum output value of each of the plurality of input samples in the first target layer of the neural network.
  • a plurality of input samples constitute an input data set.
  • a forward propagation calculation is performed on a plurality of input data sets, for example, M samples, and a maximum output value for each sample is recorded in the first target layer to be fixed, and M maximum values are obtained.
  • M is a positive integer greater than or equal to 2. It should be noted that in the forward propagation calculation, in order to ensure the calculation accuracy, the weight coefficient can still use floating point numbers.
  • Selecting at least two maximum output values from the plurality of maximum output values as the fixed point reference value may include: sorting the plurality of maximum output values, and selecting at least two of the plurality of maximum output values according to the preset selection parameter.
  • the maximum output value is used as a fixed point reference. It should be understood that the selection parameters may be within a preset range.
  • a plurality of maximum output values are sorted, for example, in ascending order or descending order, or sorted according to a certain preset rule.
  • the N maximum output values are selected from the M maximum output values according to the preset selection parameters (for example, the selection parameter is the value of the specific position after the sorting is selected).
  • the selection parameter is the value of the specific position after the sorting is selected.
  • the parameter is a(j)
  • the maximum output value of the a(j) ⁇ M is selected as the fixed reference value, wherein the value of j is 1, ..., N, a(j) is greater than or equal to 0 and less than or equal to 1.
  • N can be equal to 10
  • a(1), ..., a(10) are 0.5, 0.6, 0.7, 0.8, 0.9, 0.92, 0.94, 0.96, 0.98, 1, respectively.
  • the selection parameter a(j) may be a selected maximum value and a second largest value.
  • the value of the parameter a(j) may be a uniform value, for example, 0.1, 0.2, 0.3, ..., 1, etc., and the method for selecting the fixed point reference value is not limited herein.
  • Determining a reference integer part bit width according to each fixed point reference value may include: determining a reference integer part bit width according to a size of the fixed point reference value.
  • the method 100 may further include: determining a preset first symbol bit width and an output value total bit width; determining a reference decimal according to the first symbol bit width, the output value total bit width, and the reference integer portion bit width Partially wide.
  • the first sign bit and the reference integer part may be considered as reference non-decimal parts.
  • the reference non-fractional portion bit width includes the first symbol bit width (generally the first symbol bit width is 1) and the reference integer portion bit width.
  • the jth fixed point reference value among the N fixed point reference values is Oj.
  • Determining a reference integer part bit width according to each fixed point reference value may include: determining a reference integer part bit width according to a size of the fixed point reference value.
  • the jth fixed point reference value among the N fixed point reference values is Oj.
  • Bwo is the total bit width of the output value preset for the output value.
  • S140 Perform an accuracy test based on a preset total output bit width and a bit width of each reference integer part, and determine a reference integer part with the highest accuracy as an integer part bit used by the first target layer when the output value is fixed. width.
  • the first target layer has N possible fixed-point solutions, and a fixed-point solution with the least prediction accuracy loss.
  • the fixed-point reference value is 127.
  • the prediction accuracy rate is the least lost.
  • the data fixed-pointing method may further include a process of determining a weighting coefficient fixed-pointing scheme, the method comprising: determining a weight-fixed total bit width preset for the weighting coefficient and a preset second symbol Bit width; determining a weight integer partial bit width according to the size of the maximum weight coefficient in the first target layer; determining a weight fractional part width according to the weight fixed point total bit width, the second symbol bit width, and the weight integer part bit width, wherein The second sign bit width, the weight integer part bit width, and the weight fraction part bit width are determined as the sign bit width, the integer part bit width, and the fractional part bit width used by the first target layer in the weight coefficient denomination.
  • the process of determining the weighting factor fixed-pointing scheme is similar to the process of determining the output value fixed-pointing scheme.
  • the maximum weight coefficient is directly found from the first target layer, and the weight of the non-fractional portion is determined according to the size of the maximum weight coefficient.
  • the weighted fixed point width for the weight coefficient may be bww.
  • Calculating a weight non-fractional portion bit width iww ceil(log 2 (w)+1) corresponding to the maximum weight coefficient w in the first target layer, wherein the second symbol bit width and the weight integer portion bit width are included.
  • the second symbol bit width (usually 1 bit), the weight integer part bit width iww-1, and the weight fraction part bit width fww as the symbol bit width and the integer part bit width used by the first target layer in the weight coefficient fixed point. And the decimal part is wide.
  • the maximum weight coefficient is the maximum value of the weight coefficient of the first target layer formed by combining the pre-processing of at least two layers of the neural network.
  • the embodiments of the present application may include post-processing to solve the problem that some layers have decimal point alignment requirements of input data. Therefore, the output value of the at least two layers (for example, including the first target layer and the second target layer) is required to be aligned, and the data pointing method 100 may further include: determining that the second target layer of the neural network is at the output value fixed point
  • the integer part of the bit width used in the morphing is such that the integer part bit width used by the second target layer when the output value is fixed is equal to the integer part bit width used by the first target layer when the output value is fixed.
  • the integer part bit width used by the second target layer when the output value is fixed is equal to the integer part width used when the first target layer is fixed at the output value.
  • the fractional portion width used by the second target layer when the output value is fixed is equal to the fractional portion width used by the first target layer when the output value is fixed.
  • the integer part bit width includes: a maximum value of the integer part bit width that should be used to fix the first target layer and the second target layer output value, and is determined to be the first target layer and the second target layer output value fixed point final use
  • the integer part of the bit width For example, according to the respective output value pointing scheme, the non-fractional portion of the first target layer has a bit width of 7 (the first symbol bit width is 1, the integer portion has a bit width of 6), and the non-fractional portion of the second target layer has a bit width.
  • the non-fractional part of the final used bit width may be 7.
  • the non-fractional portion has a bit width of 7 and may include a 1-bit sign bit 6 as an integer bit. If the preset output value has a total bit width of 16, the fractional portion has a bit width of 9.
  • the output value of the first target layer and the output value of the second target layer are subsequently processed in the concatenated Concatenation layer and/or the element-wise addition layer.
  • the output values after the decimal point alignment may be further processed in other layers, which is not limited in the embodiment of the present application.
  • the post-processing is mainly for the Concatenation layer and the element-wise addition layer, so that the decimal point positions of the input values of the two layers (ie, the input feature map) are aligned.
  • the function implemented by the Concatenation layer is to combine the two sets of input feature maps to achieve the effect of merging features.
  • Figure 5 shows a schematic diagram of the working principle of the Concatenation layer.
  • the function implemented by the element-wise addition layer is to add points to the two sets of input feature maps and calculate the residual feature map.
  • the two layers need to perform the decimal point alignment processing on the values of the two sets of input feature maps.
  • the decimal point alignment of the values of the input feature map can be implemented by hardware by shifting, doing so wastes certain hardware resources.
  • the two sets of feature maps input by the Concatenation layer or the element-wise addition layer are feature maps outputted by two layers (for example, including the first target layer and the second target layer), and a fixed point processing is performed when the two layers are outputted. Therefore, it is only necessary to keep the output values of the two layers at the decimal point alignment.
  • the post-processing of the embodiment of the present application can reduce the use of hardware resources and improve system efficiency.
  • Figure 6 is a schematic illustration of post processing of one embodiment of the present application.
  • the feature graph with the data format of Q4.11 is obtained; the feature graph with the data format of Q4.11 is convoluted to obtain the data.
  • the feature map of the format Q6.9; the obtained data format is the character map of Q4.11, and the data format is converted into the data format after being shifted.
  • Q6.9, and the obtained feature map with the data format of Q6.9 is used as the input of the Concatenation layer, and the feature map of the data format of Q6.9 (the output of the Concatenation layer) is obtained by the Concatenation layer operation.
  • the feature map of the data format of Q6.9 (the output of the Concatenation layer) is obtained by the Concatenation layer operation.
  • the solution of one embodiment of the present application is a convolution operation and a post-combination process (determining the data format should be Q6.9) for the feature map with the data format Q5.10, and the data format is Q6.
  • the input of the layer is obtained by the Concatenation layer to obtain the feature map of the data format Q6.9 (the output of the Concatenation layer).
  • the post-processing may be performed by aligning with the data format Q4.11, that is, to ensure that the decimal place width is the largest as the standard alignment; or other embodiments may select the aligned bits by other standards.
  • the embodiment of the present application does not limit this.
  • FIG. 7 is a schematic flowchart of a data fixed point method according to an embodiment of the present application.
  • determining the data fixed-point solution requires obtaining the structure of the neural network, the weighting coefficients of each layer, and the input data set used to determine the fixed-pointing scheme.
  • the structure of a neural network refers to the type of layer that the neural network includes.
  • the merge preprocessing of S210 is performed.
  • S220 may be performed to determine a fixed-point scheme of the weight coefficients of the layers.
  • the output values of each layer are obtained, and the fixed-point output of each layer of S230 is performed, and the result of the S240 accuracy test is combined to determine the fixed-point scheme of the weight coefficients of each layer.
  • S250 post processing can be performed.
  • the fixed-point parameters of the weight coefficient and the output value of each layer are output, for example, the non-fractional portion bit width, or the non-fractional portion bit width and the fractional portion bit width, or the integer portion bit width and the fractional portion bit width. , or the sign bit width, the integer part bit width, and the fractional part bit width, and so on.
  • FIG. 8 is a schematic flowchart of a data de-pointing method 300 according to an embodiment of the present application.
  • the data staging method 300 can include:
  • S340 Determine, according to the total bit width of the output value, the first symbol bit width, and the integer part bit width of the output value, the bit width of the output value fraction, wherein the first symbol bit width, the output value integer part bit width, and the output value fractional part bit
  • the width is used as the first target layer to use the sign bit width, the integer part bit width, and the fractional part bit width when the output value is fixed.
  • the data fixed-point method of the embodiment of the present application considers the sign bit when the output value is fixed, so that the determined fixed-point solution is better, and the possibility of increasing the network accuracy is improved.
  • the reference output value of the embodiment of the present application may be one value, or may be multiple reference output values generated by multiple input samples.
  • the reference output value may be the maximum output value of the input sample at the first target layer, or may be the next largest output value or a value other than the maximum output value.
  • an optimal fixed-point solution is determined from a fixed-point solution corresponding to a plurality of reference output values (for example, a plurality of maximum output values).
  • the reference non-fractional portion bit width may include a first symbol bit width (generally the first symbol bit width is 1) and an integer portion bit width iwo-1; the reference non-fractional portion bit width may also have no sign bit, Only the integer part of the bit width iwo is included.
  • the data delimiting method 300 may further include: determining a weight fixed point total bit width preset for the weight coefficient and a preset second symbol bit width; according to the maximum weight coefficient in the first target layer The size determines the weight of the integer part of the bit width; according to the weight fixed point total bit width, the second symbol bit width and the weight integer part bit width, the weight fraction part width is determined, wherein the second symbol bit width, the weight integer part width and the weight The fractional partial bit width is determined as the symbol bit width, the integer partial bit width, and the fractional partial bit width used by the first target layer when the weight coefficient is fixed.
  • the data delimiting method 300 may further include: combining pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining.
  • the reference output value is a reference output value of the first target layer formed after the merge of each of the plurality of input samples.
  • the maximum weight coefficient is a maximum value of a weight coefficient of the first target layer formed by combining pre-processing on at least two layers of the neural network.
  • combining the pre-processing of at least two layers of the neural network to obtain the first target layer formed by combining may include: performing pre-processing on the convolution layer and the normalization layer of the neural network. Obtaining a first target layer; or, combining the convolutional layer and the scaling layer of the neural network to obtain a first target layer; or, combining the convolutional layer, the normalized layer, and the scaling layer of the neural network Processing to obtain the first target layer.
  • the first target layer may include a convolution layer, a transposed convolution layer, One of the normalized layer, the zoomed layer, the pooled layer, the fully connected layer, the stitched layer, the elemental smart additive layer, and the active layer or at least two combined layers.
  • the data delimiting method 300 may further include: determining an integer partial bit width used by the second target layer of the neural network when the output value is fixed, so that the second target layer is fixed at the output value.
  • the integer part bit width used is equal to the integer part width used by the first target layer when the output value is fixed.
  • the fractional portion width used by the second target layer when the output value is fixed is equal to the fractional portion width used by the first target layer when the output value is fixed.
  • the output value of the first target layer and the output value of the second target layer are subsequently processed at the stitching layer and/or the element smart additive layer.
  • FIG. 9 is a schematic flowchart of a data processing method 400 according to an embodiment of the present application.
  • Data processing method 400 can include:
  • At least two layers of the neural network are combined and preprocessed, and the operation is performed based on the neural network after the pre-processing, which can save computing resources and improve system efficiency.
  • S410 performs combined preprocessing on at least two layers of the neural network, and may include: performing pre-processing on the convolution layer and the normalization layer of the neural network; or convolution on the neural network.
  • the layer and the zoom layer are combined and preprocessed; or, the convolution layer, the normalization layer, and the zoom layer of the neural network are combined and preprocessed.
  • the data processing method 400 may further include: determining a weight coefficient of the first target layer formed by combining the at least two layers.
  • the S420 performs a neural network operation based on the combined pre-processed neural network, and includes: performing a fixed-point calculation on the first target layer formed by combining the at least two layers.
  • performing a fixed-point calculation on the first target layer formed by performing the pre-processing on the at least two layers may include: determining the first target layer fixed-point according to the data fixed-pointing method 100 or 200 described above. The integer part of the bit width used.
  • FIG. 10 is a schematic flowchart of a data alignment method 500 according to an embodiment of the present application.
  • the data alignment method 500 can include:
  • S520 Determine an integer part bit width to be used according to an output value of each layer in each of the plurality of layers, and determine an integer part width of the final use of the plurality of layer output values, wherein any two of the plurality of layers are fixed in the output value.
  • the integer parts used in the end are equal in width.
  • the data alignment method in the embodiment of the present application can solve the problem that some layers have the input data decimal point alignment requirement when determining the fixed point scheme, can reduce the use of hardware resources, and improve system efficiency.
  • the data alignment method 500 may further include: determining, according to the data delimiting method 100 or 200 described above, an integer partial bit width that should be used for each layer of the output value of each of the plurality of layers.
  • any two of the plurality of layers are outputted, and the fractional portions of the last used fractional bits are equal.
  • S520 determines a plurality of layer output values to be fixed to use an integer part bit width, which may include: determining a maximum value of all integer part bit widths to be used in a plurality of layers, determining The integer part bit width of the final use is fixed for multiple layer output values.
  • S520 determines the integer part bit width of the final use of the plurality of layer output values, and may also include: determining a minimum of all the integer part widths that should be used in the plurality of layers.
  • the value of the integer part of the bit length is used for the finalization; or the integer part of the bit width is determined according to other standards or preset rules, which is not limited by the embodiment of the present application.
  • the embodiment of the present application also provides a data pointing method.
  • the data staging method includes calculating a maximum output value of each of the plurality of input samples at a first target layer of the neural network. Select one of the multiple maximum output values as the fixed point reference.
  • the reference integer part bit width is determined according to the fixed point reference value as the integer part bit width used by the first target layer when the output value is fixed.
  • selecting one of the plurality of maximum output values as the fixed point reference value may be selected according to a preset rule. For example, one of the maximum output values is selected as the fixed point reference value; or one of the plurality of maximum output values is selected as the fixed point reference value; or from multiple The maximum output value is selected as a fixed point reference value at a position in the middle; or a plurality of maximum output values are sorted, and a maximum output value is selected from the plurality of maximum output values according to a preset selection parameter.
  • Fixed point The value of the test, and so on, the specific selection method is not limited in the embodiment of the present application.
  • determining a reference integer part bit width according to the fixed point reference value, as an integer part bit width used by the first target layer when the output value is fixed comprising: determining a reference integer part bit width according to the fixed point reference value.
  • the accuracy test is performed based on the preset total output bit width and the reference integer part bit width. When the accuracy is not less than the preset threshold, the reference integer part bit width is used as the first target layer when the output value is fixed. The integer part of the bit width.
  • the preset threshold is 85%, and when the maximum output value of the next largest value is selected from the plurality of maximum output values, the reference integer partial bit width corresponding to the fixed point reference value is such that the accuracy is not less than 85%.
  • the reference integer part bit width is used as the integer part bit width used when the first target layer is fixed at the output value; when the maximum output value of the next largest value is selected from the plurality of maximum output values as the fixed point reference value
  • the reference integer part bit width is such that when the accuracy is less than 85%, the maximum output value with the largest value is used as the fixed point reference value to recalculate the reference integer part bit width, and when the reference integer part bit width is such that the accuracy is not less than 85%
  • the reference integer partial bit width is used as an integer partial bit width used when the first target layer is fixed at the output value. It should be understood that this is only a specific example of determining the integer partial bit width used by the first target layer in the output value to be fixed, and is not limited to the embodiment of the present application.
  • FIG. 11 is a schematic block diagram of a data pointing device 600 in accordance with an embodiment of the present application.
  • the data pointing device 600 includes:
  • the forward propagation calculation module 610 is configured to calculate a maximum output value of each of the plurality of input samples in the first target layer of the neural network.
  • the fixed point reference selection module 620 is configured to select at least two maximum output values from the plurality of maximum output values obtained by the forward propagation calculation module 610 as the fixed point reference value.
  • the reference bit width determining module 630 is configured to determine a reference integer part bit width according to each fixed point reference value selected by the fixed point reference selecting module 620.
  • the accuracy test module 640 is configured to perform an accuracy test based on the preset output value total bit width and the reference bit width determination width determined by the reference bit width determination module 630, and determine the reference integer portion with the highest accuracy as the first The integer part of the bit width used by a target layer when the output value is fixed.
  • the data pointing device 600 of the embodiment of the present application determines a reference integer part corresponding to each fixed point reference value by selecting a plurality of values from a plurality of maximum output values of the first target layer as fixed point reference values. Bit width, and based on the accuracy test to determine the optimal integer part bit width, according to the optimal integer part bit width, the network can deliver more useful information while maintaining higher accuracy and improve the network's expressive ability. And accuracy.
  • the fixed point reference selection module 620 selects at least two maximum output values from the plurality of maximum output values as the fixed point reference value, and may include: the fixed point reference selection module 620 sorts the plurality of maximum output values, At least two maximum output values are selected from the plurality of maximum output values as fixed point reference values according to preset selection parameters.
  • the reference bit width determining module 630 determines the reference integer part bit width according to each fixed point reference value, including: the reference bit width determining module 630 determines the reference integer part bit width according to the size of the fixed point reference value;
  • the bit width determining module 630 is further configured to: determine a preset first symbol bit width and an output value total bit width; determine a reference fractional part bit width according to the first symbol bit width, the output value total bit width, and the reference integer part bit width .
  • the data delimiting device 600 may further include a weight bit width determining module, configured to: determine a weight fixed point total bit width preset for the weight coefficient and a preset second symbol bit width; Determining the weight of the maximum weight coefficient in a target layer; determining the bit width of the weight fraction according to the weight total point width, the second symbol bit width, and the weight integer part width, wherein the second symbol bit width is determined.
  • the weight integer partial bit width and the weight fractional partial bit width are determined as a symbol bit width, an integer partial bit width, and a fractional partial bit width used by the first target layer when the weight coefficient is fixed.
  • the data delimiting device 600 may further include a pre-processing module, configured to perform a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining.
  • a pre-processing module configured to perform a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining.
  • the maximum output value is a maximum output value of the first target layer formed by combining each of the plurality of input samples.
  • the maximum weight coefficient is a maximum value of a weight coefficient of the first target layer formed by combining pre-processing on at least two layers of the neural network.
  • the pre-processing module performs a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining, including: a convolution layer and a normalization of the pre-processing module on the neural network.
  • the layer is combined and preprocessed to obtain a first target layer; or, the preprocessing module combines the convolution layer and the zoom layer of the neural network to obtain a first target layer; or, the preprocessing module convolves on the neural network
  • the normalization layer and the scaling layer are combined and preprocessed to obtain a first target layer.
  • the first target layer is a convolution layer, a transposed convolution layer, a normalization layer, a scaling layer, a pooling layer, a fully connected layer, a mosaic layer, an element intelligent addition layer, and an activation layer.
  • a convolution layer a convolution layer
  • a transposed convolution layer a normalization layer
  • a scaling layer a scaling layer
  • a pooling layer a fully connected layer
  • a mosaic layer a mosaic layer
  • an element intelligent addition layer an activation layer.
  • an activation layer One of the layers or at least two of the combined layers.
  • the data delimiting device 600 further includes an alignment module, configured to: determine an integer partial bit width used by the second target layer of the neural network when the output value is fixed, so that the second target layer is output
  • the integer part bit width used when the value is fixed is equal to the integer part bit width used by the first target layer when the output value is fixed.
  • the fractional portion width used by the second target layer when the output value is fixed is equal to the fractional portion width used by the first target layer when the output value is fixed.
  • the alignment module determines an integer partial bit width used by the second target layer of the neural network when the output value is fixed, including: the alignment module fixes the first target layer and the second target layer output value.
  • the maximum value in the integer partial bit width that should be used is determined as the integer partial bit width of the final use of the first target layer and the second target layer output value.
  • the output value of the first target layer and the output value of the second target layer are subsequently processed at the stitching layer and/or the element smart additive layer.
  • FIG. 12 is a schematic block diagram of a data pointing device 700 in accordance with an embodiment of the present application.
  • the data pointing device 700 includes:
  • the forward propagation calculation module 710 is configured to calculate a reference output value of the input sample in the first target layer of the neural network.
  • the determining module 720 is configured to determine an output value total bit width preset for the output value and a preset first symbol bit width.
  • the output value bit width determining module 730 is configured to determine an integer value bit width of the output value according to the size of the reference output value obtained by the forward propagation calculation module 710; the total bit width, the first symbol bit width, and the output value determined according to the determining module 720
  • the value of the integer part of the output value determines the bit width of the fractional part of the output value, wherein the first sign bit width, the output value integer part bit width, and the output value fractional part bit width are used as symbols used by the first target layer when the output value is fixed. Bit width, integer part bit width, and fractional part bit width.
  • the data pointing device of the embodiment of the present application considers the sign bit when the output value is fixed, so that the determined fixed point solution is better, and the possibility of increasing the network accuracy is improved.
  • the reference output value may be a maximum output value of the input sample at the first target layer.
  • the data pointing device 700 may further include a weight bit width.
  • a determining module configured to: determine a weight fixed point total bit width preset for the weight coefficient and a preset second symbol bit width; determine a weight integer part bit width according to a size of a maximum weight coefficient in the first target layer; The bit width, the second symbol bit width, and the weight integer part bit width are determined, and the weight fraction part width is determined, wherein the second symbol bit width, the weight integer part bit width, and the weight fraction partial width are determined as the first target layer in the weight The symbol bit width, the integer part bit width, and the fractional part bit width used when the coefficient is fixed.
  • the data delimiting device 700 may further include a pre-processing module, configured to: perform a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining.
  • a pre-processing module configured to: perform a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining.
  • the reference output value is a reference output value of the first target layer formed after the merge of each of the plurality of input samples.
  • the maximum weight coefficient is a maximum value of a weight coefficient of the first target layer formed by combining pre-processing on at least two layers of the neural network.
  • the pre-processing module performs a combined pre-processing on at least two layers of the neural network to obtain a first target layer formed by combining, including: a pre-processing module pairing the convolution layer of the neural network and returning The first layer is merged and preprocessed to obtain a first target layer; or, the preprocessing module combines the convolution layer and the zoom layer of the neural network to obtain a first target layer; or, the preprocessing module pairs the neural network The convolutional layer, the normalization layer, and the scaling layer are combined and preprocessed to obtain a first target layer.
  • the first target layer is a convolution layer, a transposed convolution layer, a normalization layer, a scaling layer, a pooling layer, a fully connected layer, a mosaic layer, an element intelligent addition layer, and an activation layer.
  • a convolution layer a convolution layer
  • a transposed convolution layer a normalization layer
  • a scaling layer a scaling layer
  • a pooling layer a fully connected layer
  • a mosaic layer a mosaic layer
  • an element intelligent addition layer an activation layer.
  • an activation layer One of the layers or at least two of the combined layers.
  • the data pointing device 700 may further include an alignment module, configured to: determine, by the alignment module, an integer partial bit width used by the second target layer of the neural network when the output value is fixed, to make the second target
  • the integer part bit width used by the layer when the output value is fixed is equal to the integer part bit width used by the first target layer when the output value is fixed.
  • the fractional portion width used by the second target layer when the output value is fixed is equal to the fractional portion width used by the first target layer when the output value is fixed.
  • the output value of the first target layer and the output value of the second target layer are subsequently processed at the stitching layer and/or the element smart additive layer.
  • FIG. 13 is a schematic block diagram of a data processing apparatus 800 in accordance with an embodiment of the present application.
  • the data Processing device 800 includes:
  • a pre-processing module 810 configured to perform a combined pre-processing on at least two layers of the neural network
  • the operation module 820 is configured to perform a neural network operation based on the pre-processing module 810 combining the pre-processed neural network.
  • the data processing apparatus of the embodiment of the present application performs combined pre-processing on at least two layers of the neural network, and performs computation based on the neural network after the pre-processing, which can save computing resources and improve system efficiency.
  • the pre-processing module 810 performs a combination pre-processing on at least two layers of the neural network, and may include: the pre-processing module performs a combined pre-processing on the convolution layer and the normalization layer of the neural network; or The preprocessing module performs combined preprocessing on the convolutional layer and the scaling layer of the neural network; or, the preprocessing module performs combined preprocessing on the convolutional layer, the normalized layer and the scaling layer of the neural network.
  • the data processing apparatus 800 may further include: a determining module, configured to: determine a weight coefficient of the first target layer formed by combining the at least two layers after the pre-processing.
  • the operation module 820 performs a neural network operation based on the merged preprocessed neural network, and may include: the operation module 820 performs a fixed point calculation on the first target layer formed by combining and preprocessing at least two layers. .
  • the operation module 820 performs a fixed-point calculation on the first target layer formed by performing the pre-processing on the at least two layers, and may include: the operation module 820 determines the data according to the data delimiting method 100 or 200 described above.
  • the first target layer is fixed to use the integer part of the bit width.
  • the data alignment device 900 includes:
  • the first determining module 910 is configured to determine, from the neural network, multiple layers that require data alignment.
  • a second determining module 920 configured to determine an integer part bit width to be used according to an output value of each layer in each of the plurality of layers, and determine an integer part bit width of the final use of the plurality of layer output values, wherein any of the plurality of layers The two-layer output value is fixed and the final integer part width is equal.
  • the data aligning apparatus of the embodiment of the present application can solve the problem that some layers have input data alignment requirements when determining the fixed point scheme, can reduce the use of hardware resources, and improve system efficiency.
  • the data aligning apparatus 900 may further include a third determining module, configured to determine, according to the data staging method 100 or 200 described above, an integer that should be used for each layer of output values in each of the multiple layers. Partially wide.
  • any two of the plurality of layers are outputted and fixed.
  • the fractional part has the same width.
  • the second determining module 920 determines a plurality of layer output values to be fixed to use the integer part bit width, including: the second determining module determines all integer part bits to be used in the plurality of layers.
  • the maximum value of the width is determined as the integer part width of the final use of the multiple layer output values.
  • the embodiment of the present application also provides a data pointing device.
  • the data pointing device includes: a forward propagation calculation module, configured to calculate a maximum output value of each input sample of the plurality of input samples in a first target layer of the neural network; and a fixed point reference selection module for using the forward propagation calculation module One of the plurality of maximum output values obtained is selected as a fixed point reference value; and a bit width determining module is configured to determine a reference integer partial bit width according to the fixed point reference value selected by the fixed point reference selection module, as the first target layer is outputted The integer part of the bit width used when the value is fixed.
  • the bit width determining module determines the reference integer part bit width according to the fixed point reference value, and the integer part bit width used by the first target layer when the output value is fixed, may include: the bit width determining module is configured according to The fixed point reference value determines the reference integer part bit width; the bit width determining module performs an accuracy test based on the preset output value total bit width and the reference integer part bit width, and when the accuracy rate is not less than the preset threshold, the integer part bit width is referred to The integer partial bit width used as the first target layer when the output value is fixed.
  • the apparatus of the embodiments of the present application may be implemented based on a memory and a processor, each memory is configured to store instructions for executing the method of the embodiments of the present application, and the processor executes the instructions, so that the apparatus performs the embodiments of the present application. Methods.
  • processors mentioned in the embodiment of the present application may be a central processing unit (CPU), and may also be other general-purpose processors, digital signal processors (DSPs), and application specific integrated circuits ( Application Specific Integrated Circuit (ASIC), Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the memory referred to in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory may be a read-only memory (ROM), a programmable read only memory (PROM), an erasable programmable read only memory (Erasable PROM, EPROM), or an electric Erase programmable read only memory (Electrically EPROM, EEPROM) Or flash memory.
  • the volatile memory can be a Random Access Memory (RAM) that acts as an external cache.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • Synchronous DRAM synchronous dynamic random access memory
  • SDRAM Double Data Rate SDRAM
  • ESDRAM Enhanced Synchronous Dynamic Random Access Memory
  • SLDRAM Synchronous Connection Dynamic Random Access Memory
  • DR RAM direct memory bus random access memory
  • processor is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, the memory (storage module) is integrated in the processor.
  • memories described herein are intended to comprise, without being limited to, these and any other suitable types of memory.
  • the embodiment of the present application further provides a computer readable storage medium having stored thereon instructions for causing a computer to execute the methods of the foregoing method embodiments when the instructions are run on a computer.
  • the embodiment of the present application further provides a computing device, which includes the above computer readable storage medium.
  • Embodiments of the present application can be applied to the field of aircraft, especially drones.
  • circuits, sub-circuits, and sub-units of various embodiments of the present application is merely illustrative. Those of ordinary skill in the art will appreciate that the circuits, sub-circuits, and sub-units of the various examples described in the embodiments disclosed herein can be further separated or combined.
  • a computer program product includes one or more computer instructions.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, computer instructions can be wired from a website site, computer, server or data center (eg Coaxial cable, fiber, Digital Subscriber Line (DSL) or wireless (eg infrared, no) Line, microwave, etc.) transfer to another website site, computer, server or data center.
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a high-density digital video disc (DVD)), or a semiconductor medium (for example, a solid state disk (SSD)). )Wait.
  • a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape
  • an optical medium for example, a high-density digital video disc (DVD)
  • DVD high-density digital video disc
  • SSD solid state disk
  • the size of the sequence numbers of the foregoing processes does not mean the order of execution sequence, and the order of execution of each process should be determined by its function and internal logic, and should not be applied to the embodiment of the present application.
  • the implementation process constitutes any limitation.
  • B corresponding to A means that B is associated with A, and B can be determined according to A.
  • determining B from A does not mean that B is only determined based on A, and that B can also be determined based on A and/or other information.
  • the disclosed systems, devices, and methods may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

Landscapes

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

Abstract

一种数据定点化方法和装置、数据处理方法和装置以及数据对齐方法和装置,其中数据定点化方法包括:计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值(S110);从多个最大输出值中选取至少两个最大输出值作为定点参考值(S120);根据每个定点参考值确定参考整数部分位宽(S130);基于预设的输出值总位宽和每个参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为第一目标层在输出值定点化时使用的整数部分位宽(S140)。该方法通过从第一目标层的多个最大输出值中选取多个值作为定点参考值,确定每个定点参考值对应的参考整数部分位宽,并基于准确率测试确定最优的整数部分位宽,根据最优的整数部分位宽使得定点化后网络可以在传递更多的有用信息同时保持较高的精度,提高网络的表达能力和准确率。

Description

数据定点化方法和装置
版权申明
本专利文件披露的内容包含受版权保护的材料。该版权为版权所有人所有。版权所有人不反对任何人复制专利与商标局的官方记录和档案中所存在的该专利文件或者该专利披露。
技术领域
本申请涉及数据处理领域,尤其涉及数据定点化方法和装置。
背景技术
当前主流的神经网络计算框架中,基本都是利用浮点数进行训练计算的。其中,神经网络的反向传播过程中,梯度的计算需要基于浮点数表示,以保证足够的精度;神经网络的前向传播过程的各层,尤其是卷积层和全连接层的权重系数和各层的输出值也均以浮点数表示。但是,前向传播过程中,基于浮点数的运算相比基于定点数的运算的逻辑设计更复杂,会消耗更多的硬件资源,功耗也更高。基于定点数的硬件逻辑设计相较于基于浮点数的硬件逻辑设计更友好。
业界的相关公司通常通过最小化数值误差将训练时用浮点数表示的各层输出值和权重系数转换为定点数表示。即,为输出值设置优化目标函数,根据优化目标函数,在给定位宽的条件下,找到使得输出值定点截断后得到的数与浮点数误差最小时的小数位位宽。权重系数的定点化也以类似的原理实现。然而,以优化目标函数的误差最小确定定点位置,得到的定点化结果可能很糟糕。仍以输出值为例,其主要原因在于,输出值中最重要的信息往往是由数值比较大的输出值决定的,而其占比通常比较小。以该定点化方法得到的定点位置进行定点化时,虽然截断率比较低,但往往会把最有用的高位信息剔除掉,从而影响网络的表达能力,造成网络的准确率下降。
发明内容
本申请提供了一种数据定点化方法和装置,使得定点化后网络可以在传 递更多的有用信息同时保持较高的精度,从而提高网络的表达能力和准确率。
第一方面,提供了一种数据定点化方法,包括:计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;从多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值;根据每个所述定点参考值确定参考整数部分位宽;基于预设的输出值总位宽和每个所述参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为所述第一目标层在输出值定点化时使用的整数部分位宽。
第一方面的数据定点化方法通过从第一目标层的多个最大输出值中选取多个值作为定点参考值,确定每个定点参考值对应的参考整数部分位宽,并基于准确率测试确定最优的整数部分位宽,根据最优的整数部分位宽使得定点化后网络可以在传递更多的有用信息同时保持较高的精度,可以提高网络的表达能力和准确率。
第二方面,提供了一种数据定点化方法,包括:计算输入样本在神经网络的第一目标层的参考输出值;确定为输出值预设的输出值总位宽和预设的第一符号位宽;根据所述参考输出值的大小确定输出值整数部分位宽;根据所述输出值总位宽、所述第一符号位宽和所述输出值整数部分位宽,确定输出值小数部分位宽,其中,所述第一符号位宽、所述输出值整数部分位宽和所述输出值小数部分位宽作为所述第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
第二方面的数据定点化方法在输出值定点化时考虑符号位,这样使得确定的定点化方案更优,提高增加网络准确率的可能性。
第三方面,提供了一种数据处理方法,包括:对神经网络的至少两层进行合并预处理;基于合并预处理后的神经网络进行神经网络运算。
第三方面的数据处理方法,对神经网络的至少两层进行合并预处理,基于合并预处理后的神经网络进行运算,可以节省计算资源,提高系统效率。
第四方面,提供了一种数据对齐方法,包括:从神经网络中确定需数据对齐的多个层;根据所述多个层中每层输出值定点化应使用的整数部分位宽,确定所述多个层输出值定点化最终使用的整数部分位宽,其中,所述多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
第四方面的数据对齐方法可以在确定定点化方案时解决一些层有输入数据对齐需求的问题,可以减少硬件资源的使用,提高系统效率。
第五方面,提供了一种数据定点化装置,包括:前向传播计算模块,用于计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;定点参考选取模块,用于从所述前向传播计算模块得到的多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值;参考位宽确定模块,用于根据所述定点参考选取模块选取的每个所述定点参考值确定参考整数部分位宽;准确率测试模块,用于基于预设的输出值总位宽和所述参考位宽确定模块确定的每个所述参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为所述第一目标层在输出值定点化时使用的整数部分位宽。
第六方面,提供了一种数据定点化装置,包括:前向传播计算模块,用于计算输入样本在神经网络的第一目标层的参考输出值;确定模块,用于确定为输出值预设的输出值总位宽和预设的第一符号位宽;输出值位宽确定模块,用于根据所述前向传播计算模块得到的所述参考输出值的大小确定输出值整数部分位宽;根据所述确定模块确定的所述输出值总位宽、所述第一符号位宽和所述输出值整数部分位宽,确定输出值小数部分位宽,其中,所述第一符号位宽、所述输出值整数部分位宽和所述输出值小数部分位宽作为所述第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
第七方面,提供了一种数据处理装置,包括:预处理模块,用于对神经网络的至少两层进行合并预处理;运算模块,用于基于所述预处理模块合并预处理后的神经网络进行神经网络运算。
第八方面,提供了一种数据对齐装置,包括:第一确定模块,用于从神经网络中确定需数据对齐的多个层;第二确定模块,用于根据所述多个层中每层输出值定点化应使用的整数部分位宽,确定所述多个层输出值定点化最终使用的整数部分位宽,其中,所述多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
第九方面,提供了一种数据定点化方法,包括:计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;从多个所述最大输出值中选取一个所述最大输出值作为定点参考值;根据所述定点参考 值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽。
第十方面,提供了一种数据定点化装置,包括:前向传播计算模块,用于计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;定点参考选取模块,用于从所述前向传播计算模块得到的多个所述最大输出值中选取一个所述最大输出值作为定点参考值;位宽确定模块,用于根据所述定点参考选取模块选取的所述定点参考值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽。
附图说明
图1是深度卷积神经网络的框架示意图。
图2是本申请一个实施例的数据定点化方法的示意性流程图。
图3A、图3B和图3C是本申请实施例的合并预处理的几种情况的示意图;图3D是卷积层之后是BN层的一种层连接方式的示意图。
图4是本申请一个实施例的选取定点参考值的示意图。
图5是Concatenation层的工作原理的示意图。
图6是本申请一个实施例的后处理的示意图。
图7是本申请一个实施例的数据定点化方法的示意性流程图。
图8是本申请一个实施例的数据定点化方法的示意性流程图。
图9是本申请一个实施例的数据处理方法的示意性流程图。
图10是本申请一个实施例的数据对齐方法的示意性流程图。
图11是本申请一个实施例的数据定点化装置的示意性框图。
图12是本申请一个实施例的数据定点化装置的示意性框图。
图13是本申请一个实施例的数据处理装置的示意性框图。
图14是本申请一个实施例的数据对齐装置的示意性框图。
具体实施方式
下面将结合附图,对本申请实施例中的技术方案进行描述。
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请。
首先介绍本申请实施例涉及的相关技术及概念。
神经网络(以深度卷积神经网络(Deep Convolutional Neural Network,DCNN)为例):
图1是深度卷积神经网络的框架示意图。深度卷积神经网络的输入值(由输入层输入),经隐藏层进行卷积(convolution)、转置卷积(transposed convolution or deconvolution)、归一化(Batch Normalization,BN)、缩放(Scale)、全连接(fully connected)、拼接(Concatenation)、池化(pooling)、元素智能加法(element-wise addition)和激活(activation)等运算后,得到输出值(由输出层输出)。本申请实施例的神经网络的隐藏层可能涉及的运算不仅限于上述运算。
深度卷积神经网络的隐藏层可以包括级联的多层。每层的输入为上层的输出,为特征图(feature map),每层对输入的一组或多组特征图进行前述描述的至少一种运算,得到该层的输出。每层的输出也是特征图。一般情况下,各层以实现的功能命名,例如实现卷积运算的层称作卷积层。此外,隐藏层还可以包括转置卷积层、BN层、Scale层、池化层、全连接层、Concatenation层、元素智能加法层和激活层等等,此处不进行一一列举。各层的具体运算流程可以参考现有的技术,本文不进行赘述。
应理解,每层(包括输入层和输出层)可以有一个输入和/或一个输出,也可以有多个输入和/或多个输出。在视觉领域的分类和检测任务中,特征图的宽高往往是逐层递减的(例如图1所示的输入、特征图#1、特征图#2、特征图#3和输出的宽高是逐层递减的);而在语义分割任务中,特征图的宽高在递减到一定深度后,有可能会通过转置卷积运算或上采样(upsampling)运算,再逐层递增。
通常情况下,卷积层的后面会紧接着一层激活层,常见的激活层有线性整流函数(Rectified Linear Unit,ReLU)层、S型(sigmoid)层和双曲正切(tanh)层等。在BN层被提出以后,越来越多的神经网络在卷积之后会先进行BN处理,然后再进行激活计算。
当前,需要较多权重参数用于运算的层有:卷积层、全连接层、转置卷积层和BN层。
浮点数和定点数:
浮点数包括单精度浮点数(32位)和双精度浮点数(64位)。浮点数表 达为符号位、整数部分和小数部分。bw为定点数总位宽,s为符号位(通常置于最左位),fl为小数部分位宽,xi是各位(也称为尾数(mantissa)位)的数值。一个定点数的实值可以表示为:
Figure PCTCN2017106333-appb-000001
例如,一个定点数为01000101,位宽为8位,最高位(0)为符号位,小数部分位宽fl为3。那么这个定点数代表的实值为:
x=(-1)0×2-3×(20+22+26)=8.625。
一种现有的定点化方法:
数据的定点化主要包括权重系数的定点化,以及卷积层或全连接层输出值的定点化。一种定点化方法是通过最小化数值误差实现的。
对于每层的权重系数定点化,可以有一个优化目标函数。权重系数的该优化目标函数是在给定总位宽的条件下,找到使得权重系数定点截断后得到的数与浮点数误差最小时的小数位位宽。
对于卷积层或全连接层的输出值定点化,也可以有一个优化目标函数。其定点化的原理同权重系数的定点化原理类似。
以优化目标函数的误差最小确定定点位置,得到的定点化结果可能很差。仍以输出值为例,其主要原因在于,输出值中最重要的信息往往是由数值比较大的输出值决定的,而其占比通常比较小。以该定点化方法得到的定点位置进行定点化时,虽然截断率比较低,但往往会把最有用的高位信息剔除掉,从而造成网络的准确率下降。
现有的定点化方法都没有考虑除卷积层和全连接层以外其他层的定点化处理,特别是激活层、池化层和BN层,这些层中都有可能涉及浮点运算,因此都需要考虑定点化处理。
现有的定点化方法没有考虑element-wise addition层和Concatenation层等层输入的数据小数点对齐的问题。这会造成在数据定点化之后运算的过程中,需对数据进行移位操作,使得操作过程较为复杂。
针对上述问题,本申请实施例提供了一种数据定点化方法100,图2是该数据定点化方法100的示意性流程图。方法100包括:
S110,计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值。
S120,从多个最大输出值中选取至少两个最大输出值作为定点参考值。
S130,根据每个定点参考值确定参考整数部分位宽。
S140,基于预设的输出值总位宽和每个参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为第一目标层在输出值定点化时使用的整数部分位宽。
本申请实施例通过从第一目标层的多个最大输出值中选取多个值作为定点参考值,确定每个定点参考值对应的参考整数部分位宽,并基于准确率测试确定最优的整数部分位宽,根据最优的整数部分位宽使得定点化后网络可以在传递更多的有用信息同时保持较高的精度,提高网络的表达能力和准确率。
应理解,本申请实施例确定参考整数部分位宽之后,基于预设的输出值总位宽就能够得到参考小数部分位宽。或者在其他实施例中,可以先得到参考小数部分位宽,再得到参考整数部分位宽,本申请实施例对此不作限定。
在一些实施例中,数据定点化后可以存在符号位(例如,符号位的位宽为第一符号位宽)。第一符号位宽、参考整数部分位宽和参考小数部分位宽的和等于预设的输出值总位宽。
还应理解,确定定点化方案后在定点化时,根据待定点化数据的正负确定第一符号位;根据待定点化数据的数值(大小)确定定点化后的整数部分和小数部分,本申请实施例在此不进行赘述。
本申请实施例的第一目标层可以包括卷积层、转置卷积层、BN层、Scale层、池化层、全连接层、Concatenation层、element-wise addition层和激活层中的一层或至少两层合并后的层。即,本申请实施例的数据定点化方法可以应用于神经网络的隐藏层的任一层或多层。
对应于第一目标层为至少两层合并后的层的情况,数据定点化方法100还可以包括:对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层。该处理可以认为是数据定点化方法的预处理部分。
神经网络的训练阶段完成后,推理(inference)阶段的卷积层、BN层和Scale层的参数是固定的。通过计算推导可以知道,其实BN层和Scale层的参数是可以合并到卷积层的参数里,这样神经网络的知识产权核(Intellectual Property core,IP核)就不需要专门为BN层和Scale层设计专用电路了。
早期的神经网络中,卷积层之后为激活层。为了防止网络过拟合、加快收敛速度、增强网络泛化能力等,在卷积层之后激活层之前可以引入BN层。BN层的输入包括Β={x1,...,xm}={xi}以及参数γ和β,其中,xi既是卷积层的输出又是BN层的输入,参数γ和β在训练阶段进行计算,在推理阶段均为常数。BN层的输出为{yi=BNγ,β(xi)}。
其中,
Figure PCTCN2017106333-appb-000002
Figure PCTCN2017106333-appb-000003
Figure PCTCN2017106333-appb-000004
Figure PCTCN2017106333-appb-000005
因此
Figure PCTCN2017106333-appb-000006
和yi的计算可以化简为:
Figure PCTCN2017106333-appb-000007
Figure PCTCN2017106333-appb-000008
xi是卷积层的输出,令X为卷积层的输入,W为权重系数矩阵,b为偏置值则有:
Figure PCTCN2017106333-appb-000009
Figure PCTCN2017106333-appb-000010
由此,卷积层和BN层的合并完成。
Scale层本身就是要计算yi=axi+b,参考BN层与卷积层的合并,也可将Scale层和卷积层合并。在Caffe框架下,BN层的输出是
Figure PCTCN2017106333-appb-000011
因此基于Caffe框架设计的神经网络,通常会在BN层后加入Scale层以实现完整的归一化。
由此,对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层,可以包括:对神经网络的卷积层和BN层进行合并预处理,得到第一目标层;或,对神经网络的卷积层和Scale层进行合并预处理,得到第一目标层;或,对神经网络的卷积层、BN层和Scale层进行合并预处理,得到第一目标层。
图3A、图3B和图3C是本申请实施例的合并预处理的几种情况的示意图。图3D是最简单的卷积层之后是BN层的一种层连接方式。
如图3A所示,未进行合并预处理之前,卷积层后是BN层,再之后是激活层,将卷积层和BN层合并为第一目标层,其后为激活层,得到类似于图3D的两层结构。
应理解,某些IP核支持Scale层的处理,那么合并预处理中卷积层与BN层的合并,可以替换为卷积层与Scale层的合并。如图3B所示,未进行合并预处理之前,卷积层后是Scale层,再之后是激活层,将卷积层和Scale层合并为第一目标层,其后为激活层,得到类似于图3D的两层结构。
如图3C所示,未进行合并预处理之前,卷积层后是BN层,继而为Scale层,再之后是激活层,将卷积层、BN层和Scale层合并为第一目标层,其后为激活层,得到类似于图3D的两层结构。
应理解,合并预处理后,S110中的最大输出值为多个输入样本中每个输入样本在合并后形成的第一目标层的最大输出值。
通过数据定点化方法100的步骤S110至S140,可以确定第一目标层的输出值的定点化位置。
S110,计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值。具体地,多个输入样本构成输入数据集。对输入数据集的多个,例如M个样本进行前向传播计算,对待定点化的第一目标层记录对每个样本的最大输出值,得到M个最大值。其中,M为大于或等于2的正整数。需要注意的是,前向传播计算时为保证计算精度,权重系数仍然可以使用浮点数。
S120,从多个最大输出值中选取至少两个最大输出值作为定点参考值,可以包括:对多个最大输出值进行排序,按照预设的选取参数从多个最大输出值中选取至少两个最大输出值作为定点参考值。应理解,选取参数可以在预设范围内。
具体而言,对多个最大输出值(例如,M个最大输出值)进行排序,例如升序排列或者降序排列,或者依照某预设规则排序。排好序后,按照预设的选取参数(例如选取参数为选取排序后特定位置的值)从M个最大输出值中选取出N个最大输出值。其中,N为小于或等于M的正整数。
图4是本申请一个实施例的选取定点参考值的示意图。在该具体的例子 中,将M个最大输出值按从小到大的顺序排列,选取参数为a(j),选取第a(j)×M个最大输出值作为定点参考值,其中,j的取值为1,…,N,a(j)大于或等于0且小于或等于1。例如,N可以等于10,a(1),…,a(10)分别为0.5,0.6,0.7,0.8,0.9,0.92,0.94,0.96,0.98,1。
在一些实施例中,选取参数a(j)可以为选取最大值和次大值。在又一些实施例中,选取参数a(j)的值可以为均匀的取值,例如,为0.1,0.2,0.3,…,1等,这里对选取定点参考值的方法不做限定。
S130,根据每个定点参考值确定参考整数部分位宽,可以包括:根据定点参考值的大小确定参考整数部分位宽。在一些实施例中,方法100还可以包括:确定预设的第一符号位宽和输出值总位宽;根据第一符号位宽、输出值总位宽和参考整数部分位宽,确定参考小数部分位宽。在本申请实施例中,第一符号位和参考整数部分可以认为是参考非小数部分。换而言之,参考非小数部分位宽包括第一符号位宽(通常而言第一符号位宽为1)和参考整数部分位宽。具体而言,例如N个定点参考值中的第j个定点参考值为Oj。bwo为对输出值预设的输出值总位宽。根据定点参考值Oj的大小确定参考非小数部分位宽,例如参考非小数部分位宽iwoj=ceil(log2(Oj)+1),则定点参考值Oj对应的参考小数部分位宽fwoj=bwo-iwoj,其中,j的取值为1,…,N,ceil()表示向上取整。应理解,参考非小数部分位宽中包括第一符号位宽(第一符号位宽为1)和参考整数部分位宽iwoj-1。
在另一些实施例中,数据定点化后不存在符号位。S130,根据每个定点参考值确定参考整数部分位宽,可以包括:根据定点参考值的大小确定参考整数部分位宽。具体而言,在本申请实施例中,例如N个定点参考值中的第j个定点参考值为Oj。bwo为对输出值预设的输出值总位宽。根据定点参考值Oj的大小确定参考整数部分位宽,例如参考整数部分位宽iwoj=ceil(log2(Oj)),则定点参考值Oj对应的参考小数部分位宽fwoj=bwo-iwoj,其中,j的取值为1,…,N,ceil()表示向上取整。
S140,基于预设的输出值总位宽和每个参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为第一目标层在输出值定点化时使用的整数部分位宽。
具体而言,第一目标层有N个可能定点化方案,预测准确率损失最少的一个定点化方案。在图4的例子中,在a(j)等于0.98时,即定点参考值为127 时,预测准确率损失最少。以存在符号位的情况为例,则该第一目标层的非小数部分位宽iwoj等于8(1位符号位,7位整数位)。如果输出值总位宽为16位,则小数部分位宽等于16-8=8。
以上说明了确定输出值定点化方案的过程,数据定点化方法还可以包括确定权重系数定点化方案的过程,步骤包括:确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;根据第一目标层中最大权重系数的大小确定权重整数部分位宽;根据权重定点总位宽、第二符号位宽和权重整数部分位宽,确定权重小数部分位宽,其中,将第二符号位宽、权重整数部分位宽和权重小数部分位宽确定为第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
确定权重系数定点化方案的过程与确定输出值定点化方案的过程有类似之处。区别在于,直接从第一目标层找到最大权重系数,根据最大权重系数的大小确定权重非小数部分位宽即可。在一个具体的例子中,为权重系数预设的权重定点总位宽可以为bww。计算第一目标层中最大权重系数w对应的权重非小数部分位宽iww=ceil(log2(w)+1),其中包括第二符号位宽和权重整数部分位宽。从而,最大权重系数w对应的重小数部分位宽fww=bww-iww。将第二符号位宽(通常为1位)、权重整数部分位宽iww-1和权重小数部分位宽fww确定为第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
应理解,如果存在合并预处理,最大权重系数为对神经网络的至少两层进行合并预处理后形成的第一目标层的权重系数的最大值。
可选地,本申请实施例可以包括后处理,以解决一些层有输入数据小数点对齐需求的问题。因此,需要其上的至少两层(例如,包括第一目标层和第二目标层)的输出值小数点对齐,数据定点化方法100还可以包括:确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使第二目标层在输出值定点化时使用的整数部分位宽和第一目标层在输出值定点化时使用的整数部分位宽相等。
在系统预设的输出值总位宽一定的情况下,由于第二目标层在输出值定点化时使用的整数部分位宽和第一目标层在输出值定点化时使用的整数部分位宽相等。应理解,第二目标层在输出值定点化时使用的小数部分位宽和第一目标层在输出值定点化时使用的小数部分位宽也相等。
在第一目标层和第二目标层按照各自的输出值定点化方案确定出的定点化位置不同,即整数部分位宽不同时,确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,包括:将第一目标层和第二目标层输出值定点化应使用的整数部分位宽中的最大值,确定为第一目标层和第二目标层输出值定点化最终使用的整数部分位宽。例如,按照各自的输出值定点化方案,第一目标层的非小数部分位宽为7(第一符号位宽为1,整数部分位宽为6),第二目标层的非小数部分位宽为5(第一符号位宽为1,整数部分位宽为4)。为了保证整数部分不被截断,第一目标层和第二目标层输出值定点化最终使用的非小数部分位宽可以为7。非小数部分位宽7中,可以包括1位符号位6为整数位,如果预设的输出值总位宽为16,则小数部分位宽为9。
可选地,第一目标层的输出值与第二目标层的输出值在拼接Concatenation层和/或element-wise addition层进行后续处理。当然根据IP核支持的层种类不同,小数点对齐后的输出值也可以在其他层进行后续处理,本申请实施例对此不作限定。
具体而言,后处理主要是针对Concatenation层和element-wise addition层,使这两层的输入值(即输入特征图)的小数点位置是对齐的。Concatenation层实现的功能是把两组输入特征图合并到一起,达到融合特征的效果,在计算机里可以理解为两块离散的内存块拼接成连续的内存块。图5示出了Concatenation层的工作原理的示意图。element-wise addition层实现的功能是对两组输入特征图进行点加运算,计算残差特征图。由于这两层输入的两组特征图定点化后的小数点位置有可能是不一致的,因此,这两层需要对两组输入特征图的数值进行小数点对齐处理。虽然输入特征图的数值的小数点对齐可以由硬件通过移位实现,但这样做会浪费一定的硬件资源。Concatenation层或element-wise addition层输入的两组特征图是某两层(例如,包括第一目标层和第二目标层)输出的特征图,在该两层输出的时候会做一次定点化处理,因此只需该两层的输出值保持小数点对齐即可。本申请实施例的后处理可以减少硬件资源的使用,提高系统效率。
图6是本申请一个实施例的后处理的示意图。现有的处理方案中,数据格式为Q5.10的特征图经卷积运算后,得到数据格式为Q4.11的特征图;数据格式为Q4.11的特征图经卷积运算后,得到数据格式为Q6.9的特征图;得到的数据格式为Q4.11的特征图经移位后将数据格式转换为数据格式 Q6.9,与得到的数据格式为Q6.9的特征图作为Concatenation层的输入,经Concatenation层运算后得到数据格式为Q6.9的特征图(Concatenation层的输出)。如图6所示,本申请一个实施例的方案则为数据格式为Q5.10的特征图经卷积运算以及结合后处理(确定数据格式应为Q6.9)后,得到数据格式为Q6.9的特征图;数据格式为Q4.11的特征图经卷积运算以及结合后处理后,得到数据格式为Q6.9的特征图;得到的两个数据格式为Q6.9的特征图作为Concatenation层的输入,经Concatenation层运算后得到数据格式为Q6.9的特征图(Concatenation层的输出)。
应理解,图6的方案仅是本申请的一个具体的实施例。在其他实施例中仍以上述例子为例,后处理可以选取以数据格式Q4.11进行对齐,即以保证小数位位宽最大为标准对齐;或者其他实施例还可以以其他标准选取对齐的位宽,本申请实施例对此不作限定。
图7是本申请一个实施例的数据定点化方法的示意性流程图。如图7所示,确定数据定点化方案需要获得神经网络的结构,各层的权重系数以及用于确定定点化方案的输入数据集。神经网络的结构是指神经网络所包括的层的类型。根据神经网络的结构,执行S210的合并预处理。之后可以执行S220,确定各层的权重系数的定点化方案。根据输入数据集得到在各层的输出值,执行S230各层输出值的定点化,结合S240准确率测试的结果,确定各层的权重系数的定点化方案。最后,可以执行S250后处理。根据S210至S250的结果,输出各层权重系数和输出值的定点化参数,例如,非小数部分位宽,或者非小数部分位宽和小数部分位宽,或者整数部分位宽和小数部分位宽,或者符号位宽、整数部分位宽和小数部分位宽等等。
本申请实施例还提供了一种数据定点化方法,图8是本申请一个实施例的数据定点化方法300的示意性流程图。数据定点化方法300可以包括:
S310,计算输入样本在神经网络的第一目标层的参考输出值。
S320,确定为输出值预设的输出值总位宽和预设的第一符号位宽。
S330,根据参考输出值的大小确定输出值整数部分位宽。
S340,根据输出值总位宽、第一符号位宽和输出值整数部分位宽,确定输出值小数部分位宽,其中,第一符号位宽、输出值整数部分位宽和输出值小数部分位宽作为第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
本申请实施例的数据定点化方法在输出值定点化时考虑符号位,这样使得确定的定点化方案更优,提高增加网络准确率的可能性。
应理解,本申请实施例的参考输出值可以为一个值,也可以为多个输入样本产生的多个参考输出值。参考输出值可以为输入样本在第一目标层的最大输出值,也可以是次大输出值或者除最大输出值以外的其他值。根据准确率测试,从多个参考输出值(例如多个最大输出值)对应的定点化方案中确定出最优的定点化方案。具体过程已在前文的实施例中进行了描述,此处不再赘述。
可选地,以参考输出值为最大输出值为例,可以根据最大输出值O的大小确定非小数部分位宽,例如非小数部分位宽iwo=ceil(log2(O)+1),则小数部分位宽fwo=bwo-iwo,ceil()表示向上取整。应理解,参考非小数部分位宽中可以包括第一符号位宽(通常而言第一符号位宽为1)和整数部分位宽iwo-1;参考非小数部分位宽也可以没有符号位,仅包括整数部分位宽iwo。
可选地,作为一个实施例,数据定点化方法300还可以包括:确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;根据第一目标层中最大权重系数的大小确定权重整数部分位宽;根据权重定点总位宽、第二符号位宽和权重整数部分位宽,确定权重小数部分位宽,其中,将第二符号位宽、权重整数部分位宽和权重小数部分位宽确定为第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
可选地,作为一个实施例,数据定点化方法300还可以包括:对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层。
可选地,作为一个实施例,参考输出值为多个输入样本中每个输入样本在合并后形成的第一目标层的参考输出值。
可选地,作为一个实施例,最大权重系数为对神经网络的至少两层进行合并预处理后形成的第一目标层的权重系数的最大值。
可选地,作为一个实施例,对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层,可以包括:对神经网络的卷积层和归一化层进行合并预处理,得到第一目标层;或,对神经网络的卷积层和缩放层进行合并预处理,得到第一目标层;或,对神经网络的卷积层、归一化层和缩放层进行合并预处理,得到第一目标层。
可选地,作为一个实施例,第一目标层可以包括卷积层、转置卷积层、 归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
可选地,作为一个实施例,数据定点化方法300还可以包括:确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使第二目标层在输出值定点化时使用的整数部分位宽和第一目标层在输出值定点化时使用的整数部分位宽相等。
可选地,作为一个实施例,第二目标层在输出值定点化时使用的小数部分位宽和第一目标层在输出值定点化时使用的小数部分位宽相等。
可选地,作为一个实施例,第一目标层的输出值与第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
上述可选的各实施例的具体流程可以参考前文的说明,此处不再赘述。
本申请实施例还提供了一种数据处理方法。图9是本申请实施例的数据处理方法400的示意性流程图。数据处理方法400可以包括:
S410,对神经网络的至少两层进行合并预处理。
S420,基于合并预处理后的神经网络进行神经网络运算。
本申请实施例的数据处理方法,对神经网络的至少两层进行合并预处理,基于合并预处理后的神经网络进行运算,可以节省计算资源,提高系统效率。
可选地,作为一个实施例,S410对神经网络的至少两层进行合并预处理,可以包括:对神经网络的卷积层和归一化层进行合并预处理;或,对神经网络的卷积层和缩放层进行合并预处理;或,对神经网络的卷积层、归一化层和缩放层进行合并预处理。
可选地,作为一个实施例,数据处理方法400还可以包括:确定至少两层进行合并预处理后形成的第一目标层的权重系数。
可选地,作为一个实施例,S420基于合并预处理后的神经网络进行神经网络运算,包括:对至少两层进行合并预处理后形成的第一目标层进行定点化计算。
可选地,作为一个实施例,对至少两层进行合并预处理后形成的第一目标层进行定点化计算,可以包括:根据前文描述的数据定点化方法100或200确定第一目标层定点化使用的整数部分位宽。
上述可选的各实施例的具体流程可以参考前文的说明,此处不再赘述。
本申请实施例还提供了一种数据对齐方法。图10是本申请实施例的数据对齐方法500的示意性流程图。数据对齐方法500可以包括:
S510,从神经网络中确定需数据对齐的多个层。
S520,根据多个层中每层输出值定点化应使用的整数部分位宽,确定多个层输出值定点化最终使用的整数部分位宽,其中,多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
本申请实施例的数据对齐方法可以在确定定点化方案时解决一些层有输入数据小数点对齐需求的问题,可以减少硬件资源的使用,提高系统效率。
可选地,作为一个实施例,数据对齐方法500还可以包括:根据前文描述的数据定点化方法100或200确定多个层中每层输出值定点化应使用的整数部分位宽。
可选地,作为一个实施例,多个层中任意两层输出值定点化最终使用的小数部分位宽相等。
可选地,作为一个实施例,S520确定多个层输出值定点化最终使用的整数部分位宽,可以包括:将多个层中定点化应使用的所有整数部分位宽中的最大值,确定为多个层输出值定点化最终使用的整数部分位宽。
应理解,S520确定多个层输出值定点化最终使用的整数部分位宽,也可以包括:将多个层中定点化应使用的所有整数部分位宽中的最小值,确定为多个层输出值定点化最终使用的整数部分位宽;或者按照其他标准或预设规则确定最终使用的整数部分位宽,本申请实施例对此不作限定。
本申请实施例还提供了一种数据定点化方法。该数据定点化方法包括计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值。从多个最大输出值中选取一个最大输出值作为定点参考值。根据定点参考值确定参考整数部分位宽,作为第一目标层在输出值定点化时使用的整数部分位宽。
应理解,从多个最大输出值中选取一个最大输出值作为定点参考值可以按照预设规则选取。例如,从多个最大输出值中选取出数值最大的一个最大输出值作为定点参考值;或者从多个最大输出值中选取出数值次大的一个最大输出值作为定点参考值;或者从多个最大输出值中选取出数值处于中间某位置的一个最大输出值作为定点参考值;或者对多个最大输出值进行排序,按照预设的选取参数从多个最大输出值中选取一个最大输出值作为定点参 考值,等等,本申请实施例对具体的选取方法不作限定。
可选地,作为一个实施例,根据定点参考值确定参考整数部分位宽,作为第一目标层在输出值定点化时使用的整数部分位宽,包括:根据定点参考值确定参考整数部分位宽;基于预设的输出值总位宽和参考整数部分位宽进行准确率测试,在准确率不小于预设阈值时,将参考整数部分位宽作为第一目标层在输出值定点化时使用的整数部分位宽。
在一个具体的例子中,例如预设阈值为85%,当从多个最大输出值中选取出数值次大的最大输出值作为定点参考值对应的参考整数部分位宽使得准确率不小于85%时,则将该参考整数部分位宽作为第一目标层在输出值定点化时使用的整数部分位宽;当从多个最大输出值中选取出数值次大的最大输出值作为定点参考值对应的参考整数部分位宽使得准确率小于85%时,则将数值最大的最大输出值作为定点参考值重新计算参考整数部分位宽,当该参考整数部分位宽使得准确率不小于85%时,将该参考整数部分位宽作为第一目标层在输出值定点化时使用的整数部分位宽。应理解,这仅是确定第一目标层在输出值定点化时使用的整数部分位宽的一个具体的例子,而非对本申请实施例的限定。
以上详细说明了本申请实施例的方法,下面详细说明了本申请实施例的装置。
图11是本申请一个实施例的数据定点化装置600的示意性框图。数据定点化装置600包括:
前向传播计算模块610,用于计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值。
定点参考选取模块620,用于从前向传播计算模块610得到的多个最大输出值中选取至少两个最大输出值作为定点参考值。
参考位宽确定模块630,用于根据定点参考选取模块620选取的每个定点参考值确定参考整数部分位宽。
准确率测试模块640,用于基于预设的输出值总位宽和参考位宽确定模块630确定的每个参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为第一目标层在输出值定点化时使用的整数部分位宽。
本申请实施例的数据定点化装置600通过从第一目标层的多个最大输出值中选取多个值作为定点参考值,确定每个定点参考值对应的参考整数部分 位宽,并基于准确率测试确定最优的整数部分位宽,根据最优的整数部分位宽使得定点化后网络可以在传递更多的有用信息同时保持较高的精度,提高网络的表达能力和准确率。
可选地,作为一个实施例,定点参考选取模块620从多个最大输出值中选取至少两个最大输出值作为定点参考值,可以包括:定点参考选取模块620对多个最大输出值进行排序,按照预设的选取参数从多个最大输出值中选取至少两个最大输出值作为定点参考值。
可选地,作为一个实施例,参考位宽确定模块630根据每个定点参考值确定参考整数部分位宽,包括:参考位宽确定模块630根据定点参考值的大小确定参考整数部分位宽;参考位宽确定模块630还用于:确定预设的第一符号位宽和输出值总位宽;根据第一符号位宽、输出值总位宽和参考整数部分位宽,确定参考小数部分位宽。
可选地,作为一个实施例,数据定点化装置600还可以包括权重位宽确定模块,用于:确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;根据第一目标层中最大权重系数的大小确定权重整数部分位宽;根据权重定点总位宽、第二符号位宽和权重整数部分位宽,确定权重小数部分位宽,其中,将第二符号位宽、权重整数部分位宽和权重小数部分位宽确定为第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
可选地,作为一个实施例,数据定点化装置600还可以包括预处理模块,用于:对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层。
可选地,作为一个实施例,最大输出值为多个输入样本中每个输入样本在合并后形成的第一目标层的最大输出值。
可选地,作为一个实施例,最大权重系数为对神经网络的至少两层进行合并预处理后形成的第一目标层的权重系数的最大值。
可选地,作为一个实施例,预处理模块对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层,包括:预处理模块对神经网络的卷积层和归一化层进行合并预处理,得到第一目标层;或,预处理模块对神经网络的卷积层和缩放层进行合并预处理,得到第一目标层;或,预处理模块对神经网络的卷积层、归一化层和缩放层进行合并预处理,得到第一目标层。
可选地,作为一个实施例,第一目标层为卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
可选地,作为一个实施例,数据定点化装置600还包括对齐模块,用于:确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使第二目标层在输出值定点化时使用的整数部分位宽和第一目标层在输出值定点化时使用的整数部分位宽相等。
可选地,作为一个实施例,第二目标层在输出值定点化时使用的小数部分位宽和第一目标层在输出值定点化时使用的小数部分位宽相等。
可选地,作为一个实施例,对齐模块确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,包括:对齐模块将第一目标层和第二目标层输出值定点化应使用的整数部分位宽中的最大值,确定为第一目标层和第二目标层输出值定点化最终使用的整数部分位宽。
可选地,作为一个实施例,第一目标层的输出值与第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
图12是本申请一个实施例的数据定点化装置700的示意性框图。数据定点化装置700包括:
前向传播计算模块710,用于计算输入样本在神经网络的第一目标层的参考输出值。
确定模块720,用于确定为输出值预设的输出值总位宽和预设的第一符号位宽。
输出值位宽确定模块730,用于根据前向传播计算模块710得到的参考输出值的大小确定输出值整数部分位宽;根据确定模块720确定的输出值总位宽、第一符号位宽和输出值整数部分位宽,确定输出值小数部分位宽,其中,第一符号位宽、输出值整数部分位宽和输出值小数部分位宽作为第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
本申请实施例的数据定点化装置在输出值定点化时考虑符号位,这样使得确定的定点化方案更优,提高增加网络准确率的可能性。
可选地,作为一个实施例,参考输出值可以为输入样本在第一目标层的最大输出值。
可选地,作为一个实施例,数据定点化装置700还可以包括权重位宽确 定模块,用于:确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;根据第一目标层中最大权重系数的大小确定权重整数部分位宽;根据权重定点总位宽、第二符号位宽和权重整数部分位宽,确定权重小数部分位宽,其中,将第二符号位宽、权重整数部分位宽和权重小数部分位宽确定为第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
可选地,作为一个实施例,数据定点化装置700还可以包括预处理模块,用于:对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层。
可选地,作为一个实施例,参考输出值为多个输入样本中每个输入样本在合并后形成的第一目标层的参考输出值。
可选地,作为一个实施例,最大权重系数为对神经网络的至少两层进行合并预处理后形成的第一目标层的权重系数的最大值。
可选地,作为一个实施例,预处理模块对对神经网络的至少两层进行合并预处理,得到合并后形成的第一目标层,包括:预处理模块对对神经网络的卷积层和归一化层进行合并预处理,得到第一目标层;或,预处理模块对对神经网络的卷积层和缩放层进行合并预处理,得到第一目标层;或,预处理模块对对神经网络的卷积层、归一化层和缩放层进行合并预处理,得到第一目标层。
可选地,作为一个实施例,第一目标层为卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
可选地,作为一个实施例,数据定点化装置700还可以包括对齐模块,用于:对齐模块确定神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使第二目标层在输出值定点化时使用的整数部分位宽和第一目标层在输出值定点化时使用的整数部分位宽相等。
可选地,作为一个实施例,第二目标层在输出值定点化时使用的小数部分位宽和第一目标层在输出值定点化时使用的小数部分位宽相等。
可选地,作为一个实施例,第一目标层的输出值与第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
图13是本申请一个实施例的数据处理装置800的示意性框图。该数据 处理装置800包括:
预处理模块810,用于对神经网络的至少两层进行合并预处理;
运算模块820,用于基于预处理模块810合并预处理后的神经网络进行神经网络运算。
本申请实施例的数据处理装置,对神经网络的至少两层进行合并预处理,基于合并预处理后的神经网络进行运算,可以节省计算资源,提高系统效率。
可选地,作为一个实施例,预处理模块810对神经网络的至少两层进行合并预处理,可以包括:预处理模块对神经网络的卷积层和归一化层进行合并预处理;或,预处理模块对神经网络的卷积层和缩放层进行合并预处理;或,预处理模块对神经网络的卷积层、归一化层和缩放层进行合并预处理。
可选地,作为一个实施例,数据处理装置800还可以包括确定模块,用于:确定至少两层进行合并预处理后形成的第一目标层的权重系数。
可选地,作为一个实施例,运算模块820基于合并预处理后的神经网络进行神经网络运算,可以包括:运算模块820对至少两层进行合并预处理后形成的第一目标层进行定点化计算。
可选地,作为一个实施例,运算模块820对至少两层进行合并预处理后形成的第一目标层进行定点化计算,可以包括:运算模块820根据前文描述的数据定点化方法100或200确定第一目标层定点化使用的整数部分位宽。
图14是本申请一个实施例的数据对齐装置900的示意性框图。数据对齐装置900包括:
第一确定模块910,用于从神经网络中确定需数据对齐的多个层。
第二确定模块920,用于根据多个层中每层输出值定点化应使用的整数部分位宽,确定多个层输出值定点化最终使用的整数部分位宽,其中,多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
本申请实施例的数据对齐装置可以在确定定点化方案时解决一些层有输入数据对齐需求的问题,可以减少硬件资源的使用,提高系统效率。
可选地,作为一个实施例,数据对齐装置900还可以包括第三确定模块,用于:根据前文描述的数据定点化方法100或200确定多个层中每层输出值定点化应使用的整数部分位宽。
可选地,作为一个实施例,多个层中任意两层输出值定点化最终使用的 小数部分位宽相等。
可选地,作为一个实施例,第二确定模块920确定多个层输出值定点化最终使用的整数部分位宽,包括:第二确定模块将多个层中定点化应使用的所有整数部分位宽中的最大值,确定为多个层输出值定点化最终使用的整数部分位宽。
本申请实施例还提供了一种数据定点化装置。该数据定点化装置包括:前向传播计算模块,用于计算多个输入样本中每个输入样本在神经网络的第一目标层的最大输出值;定点参考选取模块,用于从前向传播计算模块得到的多个最大输出值中选取一个最大输出值作为定点参考值;和位宽确定模块,用于根据定点参考选取模块选取的定点参考值确定参考整数部分位宽,作为第一目标层在输出值定点化时使用的整数部分位宽。
可选地,作为一个实施例,位宽确定模块根据定点参考值确定参考整数部分位宽,作为第一目标层在输出值定点化时使用的整数部分位宽,可以包括:位宽确定模块根据定点参考值确定参考整数部分位宽;位宽确定模块基于预设的输出值总位宽和参考整数部分位宽进行准确率测试,在准确率不小于预设阈值时,将参考整数部分位宽作为第一目标层在输出值定点化时使用的整数部分位宽。
应理解,本申请各实施例的装置可以基于存储器和处理器实现,各存储器用于存储用于执行本申请个实施例的方法的指令,处理器执行上述指令,使得装置执行本申请各实施例的方法。
应理解,本申请实施例中提及的处理器可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
还应理解,本申请实施例中提及的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM) 或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DR RAM)。
需要说明的是,当处理器为通用处理器、DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件时,存储器(存储模块)集成在处理器中。
应注意,本文描述的存储器旨在包括但不限于这些和任意其它适合类型的存储器。
本申请实施例还提供一种计算机可读存储介质,其上存储有指令,当指令在计算机上运行时,使得计算机执行上述各方法实施例的方法。
本申请实施例还提供一种计算设备,该计算设备包括上述计算机可读存储介质。
本申请实施例可以应用在飞行器,尤其是无人机领域。
应理解,本申请各实施例的电路、子电路、子单元的划分只是示意性的。本领域普通技术人员可以意识到,本文中所公开的实施例描述的各示例的电路、子电路和子单元,能够再行拆分或组合。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无 线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,高密度数字视频光盘(Digital Video Disc,DVD))、或者半导体介质(例如,固态硬盘(Solid State Disk,SSD))等。
应理解,本申请各实施例均是以总位宽为16位(bit)为例进行说明的,本申请各实施例可以适用于其他的位宽。
应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
应理解,在本申请实施例中,“与A相应的B”表示B与A相关联,根据A可以确定B。但还应理解,根据A确定B并不意味着仅仅根据A确定B,还可以根据A和/或其它信息确定B。
应理解,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的 对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (64)

  1. 一种数据定点化方法,其特征在于,包括:
    计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;
    从多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值;
    根据每个所述定点参考值确定参考整数部分位宽;
    基于预设的输出值总位宽和每个所述参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为所述第一目标层在输出值定点化时使用的整数部分位宽。
  2. 根据权利要求1所述的数据定点化方法,其特征在于,所述从多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值,包括:
    对多个所述最大输出值进行排序,按照预设的选取参数从所述多个最大输出值中选取至少两个所述最大输出值作为所述定点参考值。
  3. 根据权利要求1或2所述的数据定点化方法,其特征在于,所述根据每个所述定点参考值确定参考整数部分位宽,包括:
    根据所述定点参考值的大小确定所述参考整数部分位宽;
    所述方法还包括:
    确定预设的第一符号位宽和所述输出值总位宽;
    根据所述第一符号位宽、所述输出值总位宽和所述参考整数部分位宽,确定参考小数部分位宽。
  4. 根据权利要求1或2所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;
    根据所述第一目标层中最大权重系数的大小确定权重整数部分位宽;
    根据所述权重定点总位宽、所述第二符号位宽和所述权重整数部分位宽,确定权重小数部分位宽,
    其中,将所述第二符号位宽、所述权重整数部分位宽和所述权重小数部分位宽确定为所述第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  5. 根据权利要求4所述的数据定点化方法,其特征在于,所述最大权重系数为对所述神经网络的至少两层进行合并预处理后形成的所述第一目标层的权重系数的最大值。
  6. 根据权利要求1所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层。
  7. 根据权利要求6所述的数据定点化方法,其特征在于,所述最大输出值为所述多个输入样本中每个所述输入样本在合并后形成的所述第一目标层的所述最大输出值。
  8. 根据权利要求6所述的数据定点化方法,其特征在于,所述对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层,包括:
    对所述神经网络的卷积层和归一化层进行合并预处理,得到所述第一目标层;或,
    对所述神经网络的卷积层和缩放层进行合并预处理,得到所述第一目标层;或,
    对所述神经网络的卷积层、归一化层和缩放层进行合并预处理,得到所述第一目标层。
  9. 根据权利要求1所述的数据定点化方法,其特征在于,所述第一目标层包括卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
  10. 根据权利要求1所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使所述第二目标层在输出值定点化时使用的整数部分位宽和所述第一目标层在输出值定点化时使用的整数部分位宽相等。
  11. 根据权利要求10所述的数据定点化方法,其特征在于,所述确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,包括:
    将所述第一目标层和所述第二目标层输出值定点化应使用的整数部分位宽中的最大值,确定为所述第一目标层和所述第二目标层输出值定点化最 终使用的整数部分位宽。
  12. 根据权利要求10或11所述的数据定点化方法,其特征在于,所述第一目标层的输出值与所述第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
  13. 一种数据定点化方法,其特征在于,包括:
    计算输入样本在神经网络的第一目标层的参考输出值;
    确定为输出值预设的输出值总位宽和预设的第一符号位宽;
    根据所述参考输出值的大小确定输出值整数部分位宽;
    根据所述输出值总位宽、所述第一符号位宽和所述输出值整数部分位宽,确定输出值小数部分位宽,其中,所述第一符号位宽、所述输出值整数部分位宽和所述输出值小数部分位宽作为所述第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  14. 根据权利要求13所述的数据定点化方法,其特征在于,所述参考输出值为所述输入样本在所述第一目标层的最大输出值。
  15. 根据权利要求13或14所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;
    根据所述第一目标层中最大权重系数的大小确定权重整数部分位宽;
    根据所述权重定点总位宽、所述第二符号位宽和所述权重整数部分位宽,确定权重小数部分位宽,
    其中,将所述第二符号位宽、所述权重整数部分位宽和所述权重小数部分位宽确定为所述第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  16. 根据权利要求15所述的数据定点化方法,其特征在于,所述最大权重系数为对所述神经网络的至少两层进行合并预处理后形成的所述第一目标层的权重系数的最大值。
  17. 根据权利要求13所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层。
  18. 根据权利要求17所述的数据定点化方法,其特征在于,所述参考 输出值为所述多个输入样本中每个所述输入样本在合并后形成的所述第一目标层的所述参考输出值。
  19. 根据权利要求17所述的数据定点化方法,其特征在于,所述对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层,包括:
    对所述神经网络的卷积层和归一化层进行合并预处理,得到所述第一目标层;或,
    对所述神经网络的卷积层和缩放层进行合并预处理,得到所述第一目标层;或,
    对所述神经网络的卷积层、归一化层和缩放层进行合并预处理,得到所述第一目标层。
  20. 根据权利要求13所述的数据定点化方法,其特征在于,所述第一目标层包括卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
  21. 根据权利要求13所述的数据定点化方法,其特征在于,所述数据定点化方法还包括:
    确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使所述第二目标层在输出值定点化时使用的整数部分位宽和所述第一目标层在输出值定点化时使用的整数部分位宽相等。
  22. 根据权利要求21所述的数据定点化方法,其特征在于,所述第一目标层的输出值与所述第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
  23. 一种数据处理方法,其特征在于,包括:
    对神经网络的至少两层进行合并预处理;
    基于合并预处理后的神经网络进行神经网络运算。
  24. 根据权利要求23所述的数据处理方法,其特征在于,所述对神经网络的至少两层进行合并预处理,包括:
    对所述神经网络的卷积层和归一化层进行合并预处理;或,
    对所述神经网络的卷积层和缩放层进行合并预处理;或,
    对所述神经网络的卷积层、归一化层和缩放层进行合并预处理。
  25. 根据权利要求23或24所述的数据处理方法,其特征在于,所述数 据处理方法还包括:
    确定所述至少两层进行合并预处理后形成的第一目标层的权重系数。
  26. 根据权利要求23或24所述的数据处理方法,其特征在于,所述基于合并预处理后的神经网络进行神经网络运算,包括:
    对所述至少两层进行合并预处理后形成的第一目标层进行定点化计算。
  27. 根据权利要求26所述的数据处理方法,其特征在于,所述对所述至少两层进行合并预处理后形成的第一目标层进行定点化计算,包括:
    根据权利要求1至12中任一项所述的数据定点化方法确定所述第一目标层定点化使用的整数部分位宽。
  28. 一种数据对齐方法,其特征在于,包括:
    从神经网络中确定需数据对齐的多个层;
    根据所述多个层中每层输出值定点化应使用的整数部分位宽,确定所述多个层输出值定点化最终使用的整数部分位宽,其中,所述多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
  29. 根据权利要求28所述的数据对齐方法,其特征在于,所述数据对齐方法还包括:
    根据权利要求1至12中任一项所述的数据定点化方法确定所述多个层中每层输出值定点化应使用的整数部分位宽。
  30. 根据权利要求28或29所述的数据对齐方法,其特征在于,所述确定所述多个层输出值定点化最终使用的整数部分位宽,包括:
    将所述多个层中定点化应使用的所有整数部分位宽中的最大值,确定为所述多个层输出值定点化最终使用的整数部分位宽。
  31. 一种数据定点化方法,其特征在于,包括:
    计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;
    从多个所述最大输出值中选取一个所述最大输出值作为定点参考值;
    根据所述定点参考值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽。
  32. 根据权利要求31所述的数据定点化方法,其特征在于,所述根据所述定点参考值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽,包括:
    根据所述定点参考值确定所述参考整数部分位宽;
    基于预设的输出值总位宽和所述参考整数部分位宽进行准确率测试,在准确率不小于预设阈值时,将所述参考整数部分位宽作为所述第一目标层在输出值定点化时使用的整数部分位宽。
  33. 一种数据定点化装置,其特征在于,包括:
    前向传播计算模块,用于计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;
    定点参考选取模块,用于从所述前向传播计算模块得到的多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值;
    参考位宽确定模块,用于根据所述定点参考选取模块选取的每个所述定点参考值确定参考整数部分位宽;
    准确率测试模块,用于基于预设的输出值总位宽和所述参考位宽确定模块确定的每个所述参考整数部分位宽进行准确率测试,将使得准确率最高的参考整数部分确定为所述第一目标层在输出值定点化时使用的整数部分位宽。
  34. 根据权利要求33所述的数据定点化装置,其特征在于,所述定点参考选取模块从多个所述最大输出值中选取至少两个所述最大输出值作为定点参考值,包括:
    所述定点参考选取模块对多个所述最大输出值进行排序,按照预设的选取参数从所述多个最大输出值中选取至少两个所述最大输出值作为所述定点参考值。
  35. 根据权利要求33或34所述的数据定点化装置,其特征在于,所述参考位宽确定模块根据每个所述定点参考值确定参考整数部分位宽,包括:
    所述参考位宽确定模块根据所述定点参考值的大小确定所述参考整数部分位宽;
    所述参考位宽确定模块还用于:
    确定预设的第一符号位宽和所述输出值总位宽;
    根据所述第一符号位宽、所述输出值总位宽和所述参考整数部分位宽,确定参考小数部分位宽。
  36. 根据权利要求33或34所述的数据定点化装置,其特征在于,所述数据定点化装置还包括权重位宽确定模块,用于:
    确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;
    根据所述第一目标层中最大权重系数的大小确定权重整数部分位宽;
    根据所述权重定点总位宽、所述第二符号位宽和所述权重整数部分位宽,确定权重小数部分位宽,
    其中,将所述第二符号位宽、所述权重整数部分位宽和所述权重小数部分位宽确定为所述第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  37. 根据权利要求36所述的数据定点化装置,其特征在于,所述最大权重系数为对所述神经网络的至少两层进行合并预处理后形成的所述第一目标层的权重系数的最大值。
  38. 根据权利要求33所述的数据定点化装置,其特征在于,所述数据定点化装置还包括预处理模块,用于:
    对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层。
  39. 根据权利要求38所述的数据定点化装置,其特征在于,所述最大输出值为所述多个输入样本中每个所述输入样本在合并后形成的所述第一目标层的所述最大输出值。
  40. 根据权利要求38所述的数据定点化装置,其特征在于,所述预处理模块对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层,包括:
    所述预处理模块对所述神经网络的卷积层和归一化层进行合并预处理,得到所述第一目标层;或,
    所述预处理模块对所述神经网络的卷积层和缩放层进行合并预处理,得到所述第一目标层;或,
    所述预处理模块对所述神经网络的卷积层、归一化层和缩放层进行合并预处理,得到所述第一目标层。
  41. 根据权利要求33所述的数据定点化装置,其特征在于,所述第一目标层包括卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
  42. 根据权利要求33所述的数据定点化装置,其特征在于,所述数据定点化装置还包括对齐模块,用于:
    确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使所述第二目标层在输出值定点化时使用的整数部分位宽和所述第一目标层在输出值定点化时使用的整数部分位宽相等。
  43. 根据权利要求42所述的数据定点化装置,其特征在于,所述对齐模块确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,包括:
    所述对齐模块将所述第一目标层和所述第二目标层输出值定点化应使用的整数部分位宽中的最大值,确定为所述第一目标层和所述第二目标层输出值定点化最终使用的整数部分位宽。
  44. 根据权利要求42或43所述的数据定点化装置,其特征在于,所述第一目标层的输出值与所述第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
  45. 一种数据定点化装置,其特征在于,包括:
    前向传播计算模块,用于计算输入样本在神经网络的第一目标层的参考输出值;
    确定模块,用于确定为输出值预设的输出值总位宽和预设的第一符号位宽;
    输出值位宽确定模块,用于根据所述前向传播计算模块得到的所述参考输出值的大小确定输出值整数部分位宽;根据所述确定模块确定的所述输出值总位宽、所述第一符号位宽和所述输出值整数部分位宽,确定输出值小数部分位宽,其中,所述第一符号位宽、所述输出值整数部分位宽和所述输出值小数部分位宽作为所述第一目标层在输出值定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  46. 根据权利要求45所述的数据定点化装置,其特征在于,所述参考输出值为所述输入样本在所述第一目标层的最大输出值。
  47. 根据权利要求45或46所述的数据定点化装置,其特征在于,所述数据定点化装置还包括权重位宽确定模块,用于:
    确定为权重系数预设的权重定点总位宽和预设的第二符号位宽;
    根据所述第一目标层中最大权重系数的大小确定权重整数部分位宽;
    根据所述权重定点总位宽、所述第二符号位宽和所述权重整数部分位宽,确定权重小数部分位宽,
    其中,将所述第二符号位宽、所述权重整数部分位宽和所述权重小数部分位宽确定为所述第一目标层在权重系数定点化时使用的符号位宽、整数部分位宽和小数部分位宽。
  48. 根据权利要求47所述的数据定点化装置,其特征在于,所述最大权重系数为对所述神经网络的至少两层进行合并预处理后形成的所述第一目标层的权重系数的最大值。
  49. 根据权利要求45所述的数据定点化装置,其特征在于,所述数据定点化装置还包括预处理模块,用于:
    对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层。
  50. 根据权利要求49所述的数据定点化装置,其特征在于,所述参考输出值为所述多个输入样本中每个所述输入样本在合并后形成的所述第一目标层的所述参考输出值。
  51. 根据权利要求49所述的数据定点化装置,其特征在于,所述预处理模块对对所述神经网络的至少两层进行合并预处理,得到合并后形成的所述第一目标层,包括:
    所述预处理模块对对所述神经网络的卷积层和归一化层进行合并预处理,得到所述第一目标层;或,
    所述预处理模块对对所述神经网络的卷积层和缩放层进行合并预处理,得到所述第一目标层;或,
    所述预处理模块对对所述神经网络的卷积层、归一化层和缩放层进行合并预处理,得到所述第一目标层。
  52. 根据权利要求45所述的数据定点化装置,其特征在于,所述第一目标层包括卷积层、转置卷积层、归一化层、缩放层、池化层、全连接层、拼接层、元素智能加法层和激活层中的一层或至少两层合并后的层。
  53. 根据权利要求45所述的数据定点化装置,其特征在于,所述数据定点化装置还包括对齐模块,用于:
    确定所述神经网络的第二目标层在输出值定点化时使用的整数部分位宽,使所述第二目标层在输出值定点化时使用的整数部分位宽和所述第一目标层在输出值定点化时使用的整数部分位宽相等。
  54. 根据权利要求53所述的数据定点化装置,其特征在于,所述第一目 标层的输出值与所述第二目标层的输出值在拼接层和/或元素智能加法层进行后续处理。
  55. 一种数据处理装置,其特征在于,包括:
    预处理模块,用于对神经网络的至少两层进行合并预处理;
    运算模块,用于基于所述预处理模块合并预处理后的神经网络进行神经网络运算。
  56. 根据权利要求55所述的数据处理装置,其特征在于,所述预处理模块对神经网络的至少两层进行合并预处理,包括:
    所述预处理模块对所述神经网络的卷积层和归一化层进行合并预处理;或,
    所述预处理模块对所述神经网络的卷积层和缩放层进行合并预处理;或,
    所述预处理模块对所述神经网络的卷积层、归一化层和缩放层进行合并预处理。
  57. 根据权利要求55或56所述的数据处理装置,其特征在于,所述数据处理装置还包括确定模块,用于:
    确定所述至少两层进行合并预处理后形成的第一目标层的权重系数。
  58. 根据权利要求55或56所述的数据处理装置,其特征在于,所述运算模块基于合并预处理后的神经网络进行神经网络运算,包括:
    所述运算模块对所述至少两层进行合并预处理后形成的第一目标层进行定点化计算。
  59. 根据权利要求58所述的数据处理装置,其特征在于,所述运算模块对所述至少两层进行合并预处理后形成的第一目标层进行定点化计算,包括:
    所述运算模块根据权利要求1至12中任一项所述的数据定点化方法确定所述第一目标层定点化使用的整数部分位宽。
  60. 一种数据对齐装置,其特征在于,包括:
    第一确定模块,用于从神经网络中确定需数据对齐的多个层;
    第二确定模块,用于根据所述多个层中每层输出值定点化应使用的整数部分位宽,确定所述多个层输出值定点化最终使用的整数部分位宽,其中,所述多个层中任意两层输出值定点化最终使用的整数部分位宽相等。
  61. 根据权利要求60所述的数据对齐装置,其特征在于,所述数据对齐装置还包括第三确定模块,用于:
    根据权利要求1至12中任一项所述的数据定点化方法确定所述多个层中每层输出值定点化应使用的整数部分位宽。
  62. 根据权利要求60或61所述的数据对齐装置,其特征在于,所述第二确定模块确定所述多个层输出值定点化最终使用的整数部分位宽,包括:
    所述第二确定模块将所述多个层中定点化应使用的所有整数部分位宽中的最大值,确定为所述多个层输出值定点化最终使用的整数部分位宽。
  63. 一种数据定点化装置,其特征在于,包括:
    前向传播计算模块,用于计算多个输入样本中每个所述输入样本在神经网络的第一目标层的最大输出值;
    定点参考选取模块,用于从所述前向传播计算模块得到的多个所述最大输出值中选取一个所述最大输出值作为定点参考值;
    位宽确定模块,用于根据所述定点参考选取模块选取的所述定点参考值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽。
  64. 根据权利要求63所述的数据定点化装置,其特征在于,所述位宽确定模块根据所述定点参考值确定参考整数部分位宽,作为所述第一目标层在输出值定点化时使用的整数部分位宽,包括:
    所述位宽确定模块根据所述定点参考值确定所述参考整数部分位宽;
    所述位宽确定模块基于预设的输出值总位宽和所述参考整数部分位宽进行准确率测试,在准确率不小于预设阈值时,将所述参考整数部分位宽作为所述第一目标层在输出值定点化时使用的整数部分位宽。
PCT/CN2017/106333 2017-10-16 2017-10-16 数据定点化方法和装置 WO2019075604A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
PCT/CN2017/106333 WO2019075604A1 (zh) 2017-10-16 2017-10-16 数据定点化方法和装置
CN201780008940.7A CN108701250B (zh) 2017-10-16 2017-10-16 数据定点化方法和装置
US16/842,145 US20200234133A1 (en) 2017-10-16 2020-04-07 Data fixed-point method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/106333 WO2019075604A1 (zh) 2017-10-16 2017-10-16 数据定点化方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/842,145 Continuation US20200234133A1 (en) 2017-10-16 2020-04-07 Data fixed-point method and device

Publications (1)

Publication Number Publication Date
WO2019075604A1 true WO2019075604A1 (zh) 2019-04-25

Family

ID=63844110

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/106333 WO2019075604A1 (zh) 2017-10-16 2017-10-16 数据定点化方法和装置

Country Status (3)

Country Link
US (1) US20200234133A1 (zh)
CN (1) CN108701250B (zh)
WO (1) WO2019075604A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116108473A (zh) * 2023-04-10 2023-05-12 极术(杭州)科技有限公司 多方安全计算中的数据处理方法及装置

Families Citing this family (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108596328B (zh) * 2018-04-26 2021-02-02 北京市商汤科技开发有限公司 一种定点化方法及装置、计算机设备
WO2020107265A1 (zh) * 2018-11-28 2020-06-04 深圳市大疆创新科技有限公司 神经网络处理装置、控制方法以及计算系统
CN111382831B (zh) * 2018-12-28 2024-04-16 Tcl科技集团股份有限公司 加速卷积神经网络模型前向推理的方法及装置
CN109754084B (zh) 2018-12-29 2020-06-12 中科寒武纪科技股份有限公司 网络结构的处理方法、装置及相关产品
CN109726801A (zh) * 2018-12-29 2019-05-07 北京中科寒武纪科技有限公司 卷积神经网络的优化方法、装置、存储介质和系统
CN110889497B (zh) * 2018-12-29 2021-04-23 中科寒武纪科技股份有限公司 一种人工智能处理器的学习任务编译方法及相关产品
US10592799B1 (en) * 2019-01-23 2020-03-17 StradVision, Inc. Determining FL value by using weighted quantization loss values to thereby quantize CNN parameters and feature values to be used for optimizing hardware applicable to mobile devices or compact networks with high precision
CN109800865B (zh) * 2019-01-24 2021-03-23 北京市商汤科技开发有限公司 神经网络生成及图像处理方法和装置、平台、电子设备
CN111488963B (zh) * 2019-01-28 2023-11-24 中科寒武纪科技股份有限公司 神经网络计算装置和方法
CN110070867B (zh) * 2019-04-26 2022-03-11 珠海普林芯驰科技有限公司 语音指令识别方法、计算机装置及计算机可读存储介质
WO2020223856A1 (zh) * 2019-05-05 2020-11-12 深圳市大疆创新科技有限公司 一种基于卷积神经网络架构的数据处理方法及装置
CN110298438B (zh) * 2019-07-05 2024-04-26 北京中星微电子有限公司 神经网络模型的调整方法和调整装置
CN112308199B (zh) * 2019-07-26 2024-05-10 杭州海康威视数字技术股份有限公司 数据块的处理方法、装置及存储介质
CN112308216B (zh) * 2019-07-26 2024-06-18 杭州海康威视数字技术股份有限公司 数据块的处理方法、装置及存储介质
CN112446460A (zh) * 2019-08-28 2021-03-05 上海寒武纪信息科技有限公司 用于处理数据的方法、装置以及相关产品
CN110512281B (zh) * 2019-09-26 2020-09-25 衡水学院 快速制备碳化硅的方法
CN113112008B (zh) * 2020-01-13 2024-05-10 中科寒武纪科技股份有限公司 用于神经网络数据量化的方法、装置和计算机可读存储介质
CN111581590B (zh) * 2020-05-07 2023-08-29 中车株洲电力机车研究所有限公司 一种基于定点数变量的积分计算方法及装置
CN111831359B (zh) * 2020-07-10 2023-06-23 北京灵汐科技有限公司 权重精度配置方法、装置、设备及存储介质
CN114692842A (zh) * 2020-12-25 2022-07-01 京东方科技集团股份有限公司 图像处理单元、图像处理方法及存储介质
CN113159177B (zh) * 2021-04-22 2022-11-25 中国科学院自动化研究所 基于批归一化参数定点化的目标检测方法、系统、设备
CN113593538B (zh) * 2021-09-02 2024-05-03 北京声智科技有限公司 语音特征的分类方法、相关设备及可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622207A (zh) * 2011-01-30 2012-08-01 中兴通讯股份有限公司 定点化处理方法及装置
CN104915654A (zh) * 2015-06-11 2015-09-16 浙江工业大学 一种基于受限玻尔兹曼机的路径点数据行为识别方法
US20160328646A1 (en) * 2015-05-08 2016-11-10 Qualcomm Incorporated Fixed point neural network based on floating point neural network quantization
US20160328647A1 (en) * 2015-05-08 2016-11-10 Qualcomm Incorporated Bit width selection for fixed point neural networks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622207A (zh) * 2011-01-30 2012-08-01 中兴通讯股份有限公司 定点化处理方法及装置
US20160328646A1 (en) * 2015-05-08 2016-11-10 Qualcomm Incorporated Fixed point neural network based on floating point neural network quantization
US20160328647A1 (en) * 2015-05-08 2016-11-10 Qualcomm Incorporated Bit width selection for fixed point neural networks
CN104915654A (zh) * 2015-06-11 2015-09-16 浙江工业大学 一种基于受限玻尔兹曼机的路径点数据行为识别方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116108473A (zh) * 2023-04-10 2023-05-12 极术(杭州)科技有限公司 多方安全计算中的数据处理方法及装置
CN116108473B (zh) * 2023-04-10 2023-06-27 极术(杭州)科技有限公司 多方安全计算中的数据处理方法及装置

Also Published As

Publication number Publication date
CN108701250B (zh) 2022-03-04
CN108701250A (zh) 2018-10-23
US20200234133A1 (en) 2020-07-23

Similar Documents

Publication Publication Date Title
WO2019075604A1 (zh) 数据定点化方法和装置
US11868426B2 (en) Hardware implementation of convolutional layer of deep neural network
US11734553B2 (en) Error allocation format selection for hardware implementation of deep neural network
US12020145B2 (en) End-to-end data format selection for hardware implementation of deep neural networks
EP3480689B1 (en) Hierarchical mantissa bit length selection for hardware implementation of deep neural network
WO2019165602A1 (zh) 数据转换方法和装置
WO2021143207A1 (zh) 图像处理方法、装置、计算处理设备及介质
EP4071650A2 (en) Graph alignment techniques for dimensioning drawings automatically
CN113421267B (zh) 一种基于改进PointConv的点云语义与实例联合分割方法及系统
EP4293576A1 (en) Hardware implementation of an attention-based neural network
CN113110843A (zh) 合约生成模型训练方法、合约生成方法及电子设备
CN115544257B (zh) 网盘文档快速分类方法、装置、网盘及存储介质
TW202333041A (zh) 執行浮點運算的系統及方法
CN115640517A (zh) 多方协同模型训练方法、装置、设备和介质
CN114491699A (zh) 基于拓展区间数的三维cad软件易用性量化方法及装置
TW202018716A (zh) 用於記憶體操作的電路和方法
CN112527858B (zh) 基于社交内容的营销账号识别方法、装置、介质和设备
CN111767706B (zh) 文本相似度的计算方法、装置、电子设备及介质
US20230040673A1 (en) Optimised machine learning processing
CN117271621A (zh) 向量模糊检索方法及npu
Niu et al. Segmentation of Lung Lesions through Bilateral Learning Branches to Aggregating Contextual and Local Characteristics
CN117950637A (zh) 对象序列化的方法、装置、电子设备及存储介质
CN115909327A (zh) 基于多尺度特征融合的有丝分裂细胞检测方法和系统
GB2603582A (en) End-to-end data format selection for hardware implementation of deep neural network
GB2603647A (en) End-to-end data format selection for hardware implementation of deep neural network

Legal Events

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

Ref document number: 17928874

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17928874

Country of ref document: EP

Kind code of ref document: A1