WO2019120114A1 - Data fixed point processing method, device, electronic apparatus and computer storage medium - Google Patents

Data fixed point processing method, device, electronic apparatus and computer storage medium Download PDF

Info

Publication number
WO2019120114A1
WO2019120114A1 PCT/CN2018/120512 CN2018120512W WO2019120114A1 WO 2019120114 A1 WO2019120114 A1 WO 2019120114A1 CN 2018120512 W CN2018120512 W CN 2018120512W WO 2019120114 A1 WO2019120114 A1 WO 2019120114A1
Authority
WO
WIPO (PCT)
Prior art keywords
feature map
weight parameter
original
convolutional neural
neural network
Prior art date
Application number
PCT/CN2018/120512
Other languages
French (fr)
Chinese (zh)
Inventor
牟永强
韦国恒
严蕤
田第鸿
Original Assignee
深圳励飞科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳励飞科技有限公司 filed Critical 深圳励飞科技有限公司
Publication of WO2019120114A1 publication Critical patent/WO2019120114A1/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/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 invention relates to the field of computer technologies, and in particular, to a data fixed point processing method and apparatus, an electronic device, and a computer storage medium.
  • Convolutional neural networks are an important algorithm in machine learning algorithms. With the continuous research of people, the recognition accuracy of convolutional neural networks continues to increase, and the computational and storage complexity of their algorithms also increases.
  • GPU Graphic Processing Unit
  • DSP Digital Signal Processing
  • ARM Advanced RISC Machines
  • an algorithm running on an embedded platform requires a fixed-point process. This process will result in different degrees of precision loss with different quantization bit widths. High quantization bit width will result in less precision loss and slower operation efficiency. Low quantization bit width will result in higher precision loss. At the same time, the operation efficiency will be faster, and it is generally necessary to strike a balance between the two.
  • the deep learning algorithm is generally high in complexity, and usually only uses a relatively low quantization bit width to ensure the operating efficiency on the terminal device, which causes a relatively large loss of precision. It can be seen that how to use a lower quantization bit width while ensuring a small loss of precision is a technical problem to be solved.
  • a data fixed-point processing method comprising:
  • the original weight parameter is replaced with the second weight parameter
  • the original feature map is replaced with the second feature map
  • the performing the point processing on the original weight parameter and the original feature map separately, and obtaining the first weight parameter and the first feature map includes:
  • the rounding off the weight parameter after the rounding is performed, and obtaining the first weight parameter includes:
  • weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
  • Performing truncation on the rounded feature map to obtain the first feature map includes:
  • the parameter quantization bit width is 8 bits
  • the feature quantization bit width is 8 bits
  • the method further includes:
  • the method further includes:
  • a second convolutional neural network model is generated.
  • the first convolutional neural network model is a floating point model
  • the second convolutional neural network model is a fixed point model
  • a data fixed point processing device comprising:
  • An extracting unit configured to extract, from the first convolutional neural network model that is completed by the training, an original weight parameter and an original feature map of the i-th data layer of the first convolutional neural network model, where the i is an initialized network layer Number, the i is a positive integer;
  • a processing unit configured to perform a fixed-point processing on the original weight parameter and the original feature map, respectively, to obtain a first weight parameter and a first feature map
  • a converting unit configured to convert the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map
  • a replacement unit configured to replace the original weight parameter with the second weight parameter, and replace the original feature map with the second feature map.
  • An electronic device comprising a processor and a memory for executing a computer program stored in a memory to implement the data fixed point processing method.
  • a computer readable storage medium storing at least one instruction that, when executed by a processor, implements the data fixed point processing method.
  • the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, where The i is an initialized network layer, the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further, the electronic The device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may replace the original weight parameter with The second weight parameter, and replacing the original feature map with the second feature map.
  • the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure.
  • the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame.
  • the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
  • FIG. 1 is a flow chart of a preferred embodiment of a data fixed point processing method disclosed by the present invention.
  • FIG. 2 is a flow chart of another preferred embodiment of a data fixed-point processing method disclosed by the present invention.
  • FIG. 3 is a functional block diagram of a preferred embodiment of a data fixed point processing apparatus disclosed by the present invention.
  • FIG. 4 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention for implementing a data point processing method.
  • the electronic device is a device capable of automatically performing numerical calculation and/or information processing according to an instruction set or stored in advance
  • the hardware includes but is not limited to a microprocessor and an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA), Digital Signal Processor (DSP), embedded devices, etc.
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Signal Processor
  • the electronic device includes, but is not limited to, any electronic product that can interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, such as a personal computer, a tablet computer, a smart phone, and a personal digital device.
  • PDA Personal Digital Assistant
  • IPTV Internet Protocol Television
  • FIG. 1 is a flowchart of a preferred embodiment of a data fixed-point processing method according to the present disclosure. The order of the steps in the flowchart may be changed according to different requirements, and some steps may be omitted.
  • the electronic device extracts the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model.
  • the original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
  • the deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like.
  • the first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
  • the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data.
  • the feature map of the layer is generated.
  • the electronic device performs a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map.
  • the present invention in order to operate on an embedded platform, a fixed-point process is required.
  • the present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
  • the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
  • the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width
  • the original feature map is fixed-pointed by using the 8-bit feature quantization bit width
  • the data structure of the first weight parameter after the fixed-point processing is determined
  • the number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
  • the electronic device separately performs a fixed-point processing on the original weight parameter and the original feature map, and obtaining the first weight parameter and the first feature map includes:
  • the truncating the weight parameter after rounding is performed, and obtaining the first weight parameter includes:
  • weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
  • Performing truncation on the rounded feature map to obtain the first feature map includes:
  • the preset parameter quantization bit width and the preset feature quantization bit width refer to a lower quantization bit width, and according to a plurality of experiments, the lower quantization bit width applicable to the present invention may be (6). 12) bit, for example, the parameter quantization bit width may be 8 bits, and the feature quantization bit width may be 8 bits. It should be noted that, due to the different structures of different convolutional neural networks, the range of lower quantization bit widths will be different, and the precision loss caused by different quantization bit widths will be different, and a comparison provided by the present invention is provided.
  • the low quantization bit width is only a lower range obtained by experimental data and does not represent the range of lower quantization bit widths to which all convolutional neural networks or frame models are applicable.
  • each data layer has multiple weight parameters
  • the range of the 8bit energy representation is [-128,127], the scaling factor ⁇ should satisfy ⁇ p max ⁇ 127, and ⁇ p min >-128, usually the scaling factor ⁇ is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor ⁇ .
  • each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
  • the weighting parameter after rounding can be truncated to obtain the first weight parameter.
  • the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
  • each data layer has multiple feature maps
  • the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
  • the electronic device converts the first weight parameter and the first feature map into floating point numbers respectively, and obtains a second weight parameter and the second feature map.
  • the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
  • the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number.
  • the electronic device may divide the first feature map by a second.
  • the scaling factor is obtained to obtain a second feature map whose data structure is a floating point number.
  • the second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
  • the electronic device replaces the original weight parameter with the second weight parameter, and replaces the original feature map with the second feature map.
  • the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
  • the above replacement is the original weight parameter on the i-th data layer of the first convolutional neural network and the replacement of the original feature map, and so on, the electronic device can follow the above-mentioned original weight on the i-th data layer of the first convolutional neural network.
  • the parameters and the fixed-point processing of the original feature map are used to perform fixed-point processing on other data layers of the first convolutional neural network until the entire first convolutional neural network is completed.
  • the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, where And the i is a positive integer; the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further, The electronic device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may replace the original weight parameter For the second weight parameter, and replacing the original feature map with the second feature map.
  • the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure.
  • the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame.
  • the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
  • FIG. 2 is a flowchart of another preferred embodiment of a data fixed-point processing method according to the present disclosure.
  • the order of the steps in the flowchart may be changed according to different requirements, and some steps may be omitted.
  • the electronic device extracts the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model.
  • the original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
  • the deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like.
  • the first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
  • the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data.
  • the feature map of the layer is generated.
  • the electronic device performs fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map.
  • the present invention in order to operate on an embedded platform, a fixed-point process is required.
  • the present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
  • the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
  • the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width
  • the original feature map is fixed-pointed by using the 8-bit feature quantization bit width
  • the data structure of the first weight parameter after the fixed-point processing is determined
  • the number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
  • the electronic device separately performs a fixed-point processing on the original weight parameter and the original feature map, and obtaining the first weight parameter and the first feature map includes:
  • the parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
  • the truncating the weight parameter after rounding is performed, and obtaining the first weight parameter includes:
  • weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
  • Performing truncation on the rounded feature map to obtain the first feature map includes:
  • each data layer has multiple weight parameters
  • the range of the 8bit energy representation is [-128,127], the scaling factor ⁇ should satisfy ⁇ p max ⁇ 127, and ⁇ p min >-128, usually the scaling factor ⁇ is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor ⁇ .
  • each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
  • the weighting parameter after rounding can be truncated to obtain the first weight parameter.
  • the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
  • each data layer has multiple feature maps
  • the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
  • the electronic device converts the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map.
  • the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
  • the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number.
  • the electronic device may divide the first feature map by a second.
  • the scaling factor is obtained to obtain a second feature map whose data structure is a floating point number.
  • the second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
  • the electronic device replaces the original weight parameter with the second weight parameter, and replaces the original feature map with the second feature map.
  • the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
  • the electronic device determines whether the first convolutional neural network model completes the fixed point process. If not, steps S26 to S27 are performed, and if yes, step S27 is performed.
  • the fixed-point process of the network model is described by the network model.
  • the first convolutional neural network model is a floating point model
  • the second convolutional neural network model is a fixed point model
  • the electronic device needs to perform a fixed-point processing on the weight parameter and the feature map of each data layer of the first convolutional neural network, and all data in the first convolutional neural network model.
  • a second convolutional neural network model can be generated.
  • the second convolutional neural network model has compatibility and can be applied to existing traditional floating-point frames, and can be guaranteed to be achieved at a lower bit width. Smaller loss of precision.
  • FIG. 3 is a functional block diagram of a preferred embodiment of a data fixed point processing apparatus according to the present invention.
  • the data fixed-point processing device described in FIG. 3 is used to perform some or all of the steps in the data fixed-point processing method described in FIG. 1 or FIG.
  • a unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor and that are capable of performing a fixed function, which are stored in a memory. In the present embodiment, the functions of the respective units will be described in detail in the subsequent embodiments.
  • the data pointing processing device 11 depicted in FIG. 3 may include:
  • the extracting unit 101 is configured to extract, for the first convolutional neural network model that is completed by the training, an original weight parameter and an original feature map of the i-th data layer of the first convolutional neural network model, where the i is an initialized network The number of layers, the i is a positive integer;
  • the original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
  • the deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like.
  • the first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
  • the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data.
  • the feature map of the layer is generated.
  • the processing unit 102 is configured to perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map;
  • the present invention in order to operate on an embedded platform, a fixed-point process is required.
  • the present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
  • the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
  • the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width
  • the original feature map is fixed-pointed by using the 8-bit feature quantization bit width
  • the data structure of the first weight parameter after the fixed-point processing is determined
  • the number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
  • the converting unit 103 is configured to convert the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map;
  • the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
  • the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number.
  • the electronic device may divide the first feature map by a second.
  • the scaling factor is obtained to obtain a second feature map whose data structure is a floating point number.
  • the second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
  • the replacing unit 104 is configured to replace the original weight parameter with the second weight parameter, and replace the original feature map with the second feature map.
  • the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
  • the above replacement is the original weight parameter on the i-th data layer of the first convolutional neural network and the replacement of the original feature map, and so on, the electronic device can follow the above-mentioned original weight on the i-th data layer of the first convolutional neural network.
  • the parameters and the fixed-point processing of the original feature map are used to perform fixed-point processing on other data layers of the first convolutional neural network until the entire first convolutional neural network is completed.
  • the processing unit 102 performs a fixed-point processing on the original weight parameter and the original feature map respectively, and obtaining the first weight parameter and the first feature map includes:
  • the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes:
  • weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
  • Performing truncation on the rounded feature map to obtain the first feature map includes:
  • the parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
  • each data layer has multiple weight parameters
  • the range of the 8bit energy representation is [-128,127], the scaling factor ⁇ should satisfy ⁇ p max ⁇ 127, and ⁇ p min >-128, usually the scaling factor ⁇ is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor ⁇ .
  • each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
  • the weighting parameter after rounding can be truncated to obtain the first weight parameter.
  • the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
  • each data layer has multiple feature maps
  • the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
  • the data fixed point processing apparatus 11 described in FIG. 3 may further include:
  • a determining unit configured to determine whether the first convolutional neural network model completes a fixed point process
  • the data fixed point processing apparatus 11 described in FIG. 3 may further include:
  • a generating unit configured to generate a second convolutional neural network model after the end of the fixed-point process of all the data layers of the first convolutional neural network model.
  • the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model may be extracted first.
  • i is an initial number of network layers, and the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further And converting the first weight parameter and the first feature map into a floating point number, respectively obtaining a second weight parameter and the second feature map; and further, the original weight parameter may be replaced by the a second weight parameter, and replacing the original feature map with the second feature map.
  • the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure.
  • the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame.
  • the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
  • the above-described integrated unit implemented in the form of a software function module can be stored in a computer readable storage medium.
  • the computer readable storage medium can store a computer program, which when executed by the processor, can implement the steps of the various method embodiments described above.
  • the computer program comprises computer program code, which may be in the form of source code, object code form, executable file or some intermediate form.
  • the computer readable storage medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read only memory (ROM, Read-Only Memory). ), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media.
  • the content contained in the computer readable storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in a jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, computer readable The medium does not include electrical carrier signals and telecommunication signals.
  • FIG. 4 is a schematic structural diagram of an electronic device according to a preferred embodiment of the method for implementing data fixed point processing according to the present invention.
  • the electronic device 1 includes a memory 12 and a processor 13. It can be understood by those skilled in the art that the schematic diagram shown in FIG. 4 is only an example of the electronic device 1, does not constitute a limitation on the electronic device 1, may include more or less components than illustrated, or may combine some Components, or different components, such as the electronic device 1 may also include input and output devices, network access devices, buses, and the like.
  • the electronic device 1 further includes, but is not limited to, any electronic product that can interact with a user through a keyboard, a mouse, a remote controller, a touch panel, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, Personal Digital Assistant (PDA), game consoles, Internet Protocol Television (IPTV), smart wearable devices, etc.
  • the network in which the electronic device 1 is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), and the like.
  • VPN virtual private network
  • the memory 12 optionally includes one or more computer readable storage media for storing a program of the data fixed point processing method and various data, and implementing the program or data at a high speed and automatically during the running process. access.
  • the memory 12 optionally includes a high speed random access memory, and optionally also a non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid state memory devices.
  • the processor 13 is also referred to as a central processing unit (CPU). It is a very large-scale integrated circuit and is a computing core (Core) and a control unit of the electronic device 1.
  • the processor 13 can execute an operating system of the electronic device 1 and various installed application programs, program codes, and the like, such as the data fixed point processing device 11.
  • the memory 12 in the electronic device 1 stores a plurality of instructions to implement a data pointing processing method
  • the processor 13 may execute the plurality of instructions to implement:
  • the original weight parameter is replaced with the second weight parameter
  • the original feature map is replaced with the second feature map
  • the performing the point processing on the original weight parameter and the original feature map separately, and obtaining the first weight parameter and the first feature map includes:
  • the rounding off the weight parameter after the rounding is performed, and obtaining the first weight parameter includes:
  • weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
  • Performing truncation on the rounded feature map to obtain the first feature map includes:
  • the parameter quantization bit width is 8 bits
  • the feature quantization bit width is 8 bits
  • processor 13 may execute the multiple instructions to implement:
  • processor 13 may execute the multiple instructions to implement:
  • a second convolutional neural network model is generated.
  • the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model.
  • i is an initial number of network layers, and the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further The electronic device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may use the original weight parameter The second weight parameter is replaced with the original feature map and the original feature map is replaced with the second feature map.
  • the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure.
  • the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame.
  • the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
  • modules described as separate components may or may not be physically separated, and the components displayed as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional module in each embodiment of the present invention 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.
  • the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software function modules.

Landscapes

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

Abstract

Disclosed is a data fixed point processing method, the method comprising: extracting, with respect to a first convolutional neural network model which has completed training, a raw weighting parameter and a raw feature map of an i th data layer of the first convolutional neural network model, wherein i is a number of initialized network layers and is a positive integer; respectively performing fixed point processing on the raw weighting parameter and the raw feature map to obtain a first weighting parameter and a first feature map; respectively converting the first weighting parameter and the first feature map into floating point numbers to obtain a second weighting parameter and a second feature map; and replacing the raw weighting parameter with the second weighting parameter and the raw feature map with the second feature map. The present invention can be used to ensure that a smaller loss in precision is achieved under a lower quantization bit width.

Description

数据定点化处理方法、装置、电子设备及计算机存储介质Data fixed point processing method, device, electronic device and computer storage medium
本申请要求于2017年12月21日提交中国专利局,申请号为201711392617.2、发明名称为“数据定点化处理方法、装置、电子设备及计算机存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on December 21, 2017, the Chinese Patent Office, the application number is 201711392617.2, and the invention name is "data fixed-point processing method, device, electronic device and computer storage medium". This is incorporated herein by reference.
技术领域Technical field
本发明涉及计算机技术领域,尤其涉及一种数据定点化处理方法、装置、电子设备及计算机存储介质。The present invention relates to the field of computer technologies, and in particular, to a data fixed point processing method and apparatus, an electronic device, and a computer storage medium.
背景技术Background technique
卷积神经网络是机器学习算法中的一种重要算法。随着人们的不断研究,卷积神经网络的识别准确率不断提升,同时其算法的计算与存储复杂度也随之增长。Convolutional neural networks are an important algorithm in machine learning algorithms. With the continuous research of people, the recognition accuracy of convolutional neural networks continues to increase, and the computational and storage complexity of their algorithms also increases.
随着深度学习和图形处理器(Graphic Processing Unit,GPU)技术的大规模流行,诸如基于视频的目标检测、识别等任务逐渐涌现在人们的视野中而且时刻改变着我们的生活。GPU技术虽然有着强大的计算能力,但是在功耗和面积方面却非常高,这也限制了其在很多领域的应用,尤其是在终端产品上的扩展。数字信号处理(Digital Signal Process,DSP)和ARM(Advanced RISC Machines)处理器有着功耗和面积方面的巨大优势,在很多终端产品上有着非常广阔的应用前景,但是由于这些平台的计算资源有限,一般采用定点数作为基本的数据结构。With the deep popularity of deep learning and Graphic Processing Unit (GPU) technology, tasks such as video-based object detection and recognition are gradually emerging in people's field of vision and changing our lives. Although GPU technology has powerful computing power, it is very high in power consumption and area, which limits its application in many fields, especially in the terminal products. Digital Signal Processing (DSP) and ARM (Advanced RISC Machines) processors have great advantages in power consumption and area. They have very broad application prospects in many terminal products, but due to the limited computing resources of these platforms, Fixed-point numbers are generally used as the basic data structure.
通常来讲,某个算法在嵌入式平台上运行是需要有一个定点化的过程。这个过程会随着量化位宽的不同造成不同程度的精度损失,高的量化位宽会带来较小的精度损失同时运行效率会更慢,低的量化位宽会带来较高的精度损失同时运行效率会更快,一般需要在这两者之间做一个平衡。而深度学习算法由于其复杂度一般都较高,通常只能使用比较低的量化位宽来保证在终端设备上的 运行效率,这样会造成比较大的精度损失。可见,如何在使用较低的量化位宽的同时又能保证较小的精度损失是一个亟待解决的技术难题。In general, an algorithm running on an embedded platform requires a fixed-point process. This process will result in different degrees of precision loss with different quantization bit widths. High quantization bit width will result in less precision loss and slower operation efficiency. Low quantization bit width will result in higher precision loss. At the same time, the operation efficiency will be faster, and it is generally necessary to strike a balance between the two. The deep learning algorithm is generally high in complexity, and usually only uses a relatively low quantization bit width to ensure the operating efficiency on the terminal device, which causes a relatively large loss of precision. It can be seen that how to use a lower quantization bit width while ensuring a small loss of precision is a technical problem to be solved.
发明内容Summary of the invention
鉴于以上内容,有必要提供一种数据定点化处理方法、装置、电子设备及计算机存储介质,能够确保在较低量化位宽下能达到较小的精度损失。In view of the above, it is necessary to provide a data fixed-point processing method, apparatus, electronic device and computer storage medium, which can ensure a small precision loss at a lower quantization bit width.
一种数据定点化处理方法,所述方法包括:A data fixed-point processing method, the method comprising:
针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;Extracting, from the first convolutional neural network model of the training, the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, wherein the i is an initialized network layer number, the i Is a positive integer;
对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;Performing a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map;
将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;Converting the first weight parameter and the first feature map into a floating point number, respectively obtaining a second weight parameter and the second feature map;
将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。The original weight parameter is replaced with the second weight parameter, and the original feature map is replaced with the second feature map.
在一种可能的实现方式中,所述对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:In a possible implementation manner, the performing the point processing on the original weight parameter and the original feature map separately, and obtaining the first weight parameter and the first feature map includes:
从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
在一种可能的实现方式中,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:In a possible implementation manner, the rounding off the weight parameter after the rounding is performed, and obtaining the first weight parameter includes:
若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
在一种可能的实现方式中,所述参数量化位宽为8比特,所述特征量化位宽为8比特。In a possible implementation manner, the parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
在一种可能的实现方式中,所述方法还包括:In a possible implementation manner, the method further includes:
判断所述第一卷积神经网络模型是否完成定点化过程;Determining whether the first convolutional neural network model completes a fixed-point process;
若否,确定i=i+1,并执行所述第一卷积神经网络模型的定点化过程。If not, i=i+1 is determined and the fixed-point process of the first convolutional neural network model is performed.
在一种可能的实现方式中,所述方法还包括:In a possible implementation manner, the method further includes:
在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,生成第二卷积神经网络模型。After the end of the fixed-point process of all data layers of the first convolutional neural network model, a second convolutional neural network model is generated.
在一种可能的实现方式中,所述第一卷积神经网络模型为浮点模型,所述第二卷积神经网络模型为定点模型。In a possible implementation manner, the first convolutional neural network model is a floating point model, and the second convolutional neural network model is a fixed point model.
一种数据定点化处理装置,所述数据定点化处理装置包括:A data fixed point processing device, the data fixed point processing device comprising:
提取单元,用于针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;An extracting unit, configured to extract, from the first convolutional neural network model that is completed by the training, an original weight parameter and an original feature map of the i-th data layer of the first convolutional neural network model, where the i is an initialized network layer Number, the i is a positive integer;
处理单元,用于对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;a processing unit, configured to perform a fixed-point processing on the original weight parameter and the original feature map, respectively, to obtain a first weight parameter and a first feature map;
转换单元,用于将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;a converting unit, configured to convert the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map;
替换单元,用于将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。And a replacement unit, configured to replace the original weight parameter with the second weight parameter, and replace the original feature map with the second feature map.
一种电子设备,所述电子设备包括处理器和存储器,所述处理器用于执行 存储器中存储的计算机程序以实现所述的数据定点化处理方法。An electronic device comprising a processor and a memory for executing a computer program stored in a memory to implement the data fixed point processing method.
一种计算机可读存储介质,所述计算机可读存储介质存储有至少一个指令,所述至少一个指令被处理器执行时实现所述的数据定点化处理方法。A computer readable storage medium storing at least one instruction that, when executed by a processor, implements the data fixed point processing method.
由以上技术方案,本发明中,针对训练完成的第一卷积神经网络模型,电子设备可以先提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;进一步地,电子设备可以将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;更进一步地,电子设备可以将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。可见,通过本发明的实施例,针对训练完成的第一卷积神经网络模型,电子设备可以对该第一卷积神经网络模型的数据层的权重参数及特征图进行定点化处理,获得数据结构为定点数的权重参数和特征图,进一步再将定点数的权重参数和特征图分别转化为浮点数,用来替换原始的权重参数和特征图,从而能够在现有的浮点框架基础上,通过对原始的权重参数和特征图的定点化处理,使得处理后的权重参数和特征图能达到定点数的精度范围,并能够在浮点框架上兼容,进而能够确保在较低量化位宽下能达到较小的精度损失。According to the above technical solution, in the present invention, for the first convolutional neural network model that is completed by training, the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, where The i is an initialized network layer, the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further, the electronic The device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may replace the original weight parameter with The second weight parameter, and replacing the original feature map with the second feature map. It can be seen that, by using the first convolutional neural network model in which the training is completed, the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure. For the weight parameter and feature map of the fixed point number, the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame. Through the fixed-point processing of the original weight parameters and feature maps, the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is an embodiment of the present invention, and those skilled in the art can obtain other drawings according to the provided drawings without any creative work.
图1是本发明公开的一种数据定点化处理方法的较佳实施例的流程图。1 is a flow chart of a preferred embodiment of a data fixed point processing method disclosed by the present invention.
图2是本发明公开的另一种数据定点化处理方法的较佳实施例的流程图。2 is a flow chart of another preferred embodiment of a data fixed-point processing method disclosed by the present invention.
图3是本发明公开的一种数据定点化处理装置的较佳实施例的功能模块 图。3 is a functional block diagram of a preferred embodiment of a data fixed point processing apparatus disclosed by the present invention.
图4是本发明实现数据定点化处理方法的较佳实施例的电子设备的结构示意图。FIG. 4 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention for implementing a data point processing method.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明作进一步详细的说明。The present invention will be further described in detail with reference to the accompanying drawings and specific embodiments.
其中,所述电子设备是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。The electronic device is a device capable of automatically performing numerical calculation and/or information processing according to an instruction set or stored in advance, and the hardware includes but is not limited to a microprocessor and an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA), Digital Signal Processor (DSP), embedded devices, etc.
所述电子设备包括但不限于任何一种可与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互的电子产品,例如,个人计算机、平板电脑、智能手机、个人数字助理(Personal Digital Assistant,PDA)、交互式网络电视(Internet Protocol Television,IPTV)等。The electronic device includes, but is not limited to, any electronic product that can interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, such as a personal computer, a tablet computer, a smart phone, and a personal digital device. Personal Digital Assistant (PDA), Internet Protocol Television (IPTV), etc.
请参见图1,图1是本发明公开的一种数据定点化处理方法的较佳实施例的流程图。其中,根据不同的需求,该流程图中步骤的顺序可以改变,某些步骤可以省略。Referring to FIG. 1, FIG. 1 is a flowchart of a preferred embodiment of a data fixed-point processing method according to the present disclosure. The order of the steps in the flowchart may be changed according to different requirements, and some steps may be omitted.
S11、针对训练完成的第一卷积神经网络模型,电子设备提取所述第一 卷积神经网络模型第i数据层的原始权重参数和原始特征图。S11. For the first convolutional neural network model that is completed by the training, the electronic device extracts the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model.
其中,所述i为初始化的网络层数,所述i为正整数。原始权重参数为训练完成的第一卷积神经网络模型第i数据层的权重参数,原始特征图训练完成的第一卷积神经网络模型第i数据层的特征图,其中,每个数据层的权重参数可以有多个,每个数据层输出的特征图也可以有多个,具体数量取决于第一卷积神经网络模型的结构。Where i is the number of initialized network layers, and the i is a positive integer. The original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
本发明使用的深度学习框架均采用浮点作为其基本数据结构,该深度学习框架可以包括但不限于Caffe、MxNet、TensorFlow等。该训练完成的第一卷积神经网络模型为浮点模型,即该第一卷积神经网络模型的每个数据层的数据结构为浮点数。The deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like. The first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
其中,在第一卷积神经网络模型的训练过程中,通常是将第i数据层的特征图和第(i+1)数据层的权重参数进行卷积操作来确定第(i+1)数据层的特征图。以此类推,直至生成第一卷积神经网络模型。Wherein, in the training process of the first convolutional neural network model, the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data. The feature map of the layer. And so on, until the first convolutional neural network model is generated.
S12、电子设备对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图。S12. The electronic device performs a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map.
本发明中,为了在嵌入式平台上运行,需要有个定点化的过程。本发明可以使用任意的浮点框架对第一卷积神经网络模型进行训练,比如使用caffe作为基础训练框架,训练网络使用ResNet18,数据使用Minist。In the present invention, in order to operate on an embedded platform, a fixed-point process is required. The present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
电子设备在提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图之后,可以对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图。After extracting the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
其中,可以使用8bit的参数量化位宽对原始权重参数进行定点化处理,使用8bit的特征量化位宽对原始特征图进行定点化处理,该定点化处理后的第一权重参数的数据结构为定点数,该定点化处理后的第一特征图的数据结构为定点数。Wherein, the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width, and the original feature map is fixed-pointed by using the 8-bit feature quantization bit width, and the data structure of the first weight parameter after the fixed-point processing is determined The number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
具体的,所述电子设备对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:Specifically, the electronic device separately performs a fixed-point processing on the original weight parameter and the original feature map, and obtaining the first weight parameter and the first feature map includes:
从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
具体的,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:Specifically, the truncating the weight parameter after rounding is performed, and obtaining the first weight parameter includes:
若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
其中,预设的参数量化位宽以及预设的特征量化位宽均是指一个较低的量化位宽,根据多次试验,本发明适用的较低的量化位宽的范围可以为(6,12)bit,举例来说,所述参数量化位宽可以为8比特,所述特征量化位宽可以为8比特。需要说明的是,由于不同卷积神经网络的结构不同,使得较低的量化位宽的范围也会不同,不同的量化位宽所导致的精度损失也会不 一样,本发明所提供的一个较低的量化位宽仅仅是通过实验数据得到的一个较低的范围,并不代表所有的卷积神经网络或框架模型所适用的较低量化位宽的范围。Wherein, the preset parameter quantization bit width and the preset feature quantization bit width refer to a lower quantization bit width, and according to a plurality of experiments, the lower quantization bit width applicable to the present invention may be (6). 12) bit, for example, the parameter quantization bit width may be 8 bits, and the feature quantization bit width may be 8 bits. It should be noted that, due to the different structures of different convolutional neural networks, the range of lower quantization bit widths will be different, and the precision loss caused by different quantization bit widths will be different, and a comparison provided by the present invention is provided. The low quantization bit width is only a lower range obtained by experimental data and does not represent the range of lower quantization bit widths to which all convolutional neural networks or frame models are applicable.
在该实施方式中,每个数据层均有多个权重参数,电子设备可以从第i数据层提取的原始权重参数M中确定最大权重参数和最小权重参数,比如p max=max(M),p min=min(M)。进一步地,根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,找出一个合适的缩放因子α,确保原始权重参数M能使用预设的参数量化位宽(如8bit)来表达,具体方法如下: In this embodiment, each data layer has multiple weight parameters, and the electronic device may determine a maximum weight parameter and a minimum weight parameter from the original weight parameter M extracted from the ith data layer, such as p max =max(M), p min =min(M). Further, according to the maximum weight parameter, the minimum weight parameter, and the preset parameter quantization bit width, find a suitable scaling factor α, and ensure that the original weight parameter M can use the preset parameter quantization bit width (such as 8 bit). ) to express, the specific method is as follows:
8bit能表示的数的取值范围为[-128,127],缩放因子α应当满足αp max≤127,并且αp min>-128,通常缩放因子α为整数,根据上述的调节,可以唯一确定合适的缩放因子α。 The range of the 8bit energy representation is [-128,127], the scaling factor α should satisfy αp max ≤127, and αp min >-128, usually the scaling factor α is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor α.
进一步地,根据确定的缩放因子,可以依次对每个所述原始权重参数进行量化处理以及四舍五入处理。具体的,将每个所述原始权重参数与缩放因子进行相乘,并将相乘的结果进行四舍五入处理。Further, according to the determined scaling factor, each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
更进一步地,可以对四舍五入后的权重参数进行截断处理,获得第一权重参数。具体的,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数。即:当原始权重参数M中的某个参数大于p max时,将该某个参数重新赋值为p max,当原始权重参数M中的某个参数小于p min,将该某个参数重新赋值为p minFurther, the weighting parameter after rounding can be truncated to obtain the first weight parameter. Specifically, the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
类似的,每个数据层的输出均有多个特征图,电子设备可以参照对原始权重参数类似的定点化处理方式来对原始特征图进行定点化处理,获得第一特征图包括,在此不再赘述。Similarly, the output of each data layer has multiple feature maps, and the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
S13、电子设备将所述第一权重参数以及所述第一特征图分别转化为浮 点数,获得第二权重参数以及所述第二特征图。S13. The electronic device converts the first weight parameter and the first feature map into floating point numbers respectively, and obtains a second weight parameter and the second feature map.
本发明中,电子设备获得的所述第一权重参数的数据结构以及所述第一特征图的数据结构均是定点数,而定点数在现有的浮点框架上是无法运行的,需要转换数据结构。In the present invention, the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
具体的,电子设备可以将所述第一权重参数除以第一缩放因子,以获得数据结构为浮点数的第二权重参数,同理,电子设备可以将所述第一特征图除以第二缩放因子,以获得数据结构为浮点数的第二特征图。其中,该第二权重参数以及所述第二特征图虽然是浮点数据类型,但是该第二权重参数以及所述第二特征图均达到了定点数的精度范围,不仅能够适用于现有的浮点框架,还能够在较低位宽下达到较小的性能损失。Specifically, the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number. Similarly, the electronic device may divide the first feature map by a second. The scaling factor is obtained to obtain a second feature map whose data structure is a floating point number. The second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
S14、电子设备将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。S14. The electronic device replaces the original weight parameter with the second weight parameter, and replaces the original feature map with the second feature map.
本发明中,所述原始权重参数有多个,相应地,所述第二权重参数也有多个,同理,所述原始特征图有多个,相应地,所述第二特征图也有多个。针对每个所述原始权重参数,电子设备需要将所述原始权重参数替换为所述第二权重参数,针对每个所述第二特征图,电子设备需要将所述原始特征图替换为所述第二特征图。In the present invention, there are multiple original weight parameters, and correspondingly, there are multiple second weight parameters. Similarly, the original feature map has multiple, and correspondingly, the second feature map has multiple . For each of the original weight parameters, the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
上述替换是在第一卷积神经网络第i数据层上的原始权重参数以及原始特征图的替换,以此类推,电子设备可以按照上述对第一卷积神经网络第i数据层上的原始权重参数以及原始特征图的定点化处理方式来对第一卷积神经网络的其他数据层进行定点化处理,直至完成整个第一卷积神经网络的定点化过程。The above replacement is the original weight parameter on the i-th data layer of the first convolutional neural network and the replacement of the original feature map, and so on, the electronic device can follow the above-mentioned original weight on the i-th data layer of the first convolutional neural network. The parameters and the fixed-point processing of the original feature map are used to perform fixed-point processing on other data layers of the first convolutional neural network until the entire first convolutional neural network is completed.
在图1所描述的方法流程中,针对训练完成的第一卷积神经网络模型,电子设备可以先提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;对所 述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;进一步地,电子设备可以将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;更进一步地,电子设备可以将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。可见,通过本发明的实施例,针对训练完成的第一卷积神经网络模型,电子设备可以对该第一卷积神经网络模型的数据层的权重参数及特征图进行定点化处理,获得数据结构为定点数的权重参数和特征图,进一步再将定点数的权重参数和特征图分别转化为浮点数,用来替换原始的权重参数和特征图,从而能够在现有的浮点框架基础上,通过对原始的权重参数和特征图的定点化处理,使得处理后的权重参数和特征图能达到定点数的精度范围,并能够在浮点框架上兼容,进而能够确保在较低量化位宽下能达到较小的精度损失。In the method flow described in FIG. 1 , for the trained first convolutional neural network model, the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, where And the i is a positive integer; the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further, The electronic device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may replace the original weight parameter For the second weight parameter, and replacing the original feature map with the second feature map. It can be seen that, by using the first convolutional neural network model in which the training is completed, the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure. For the weight parameter and feature map of the fixed point number, the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame. Through the fixed-point processing of the original weight parameters and feature maps, the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
请参见图2,图2是本发明公开的另一种数据定点化处理方法的较佳实施例的流程图。其中,根据不同的需求,该流程图中步骤的顺序可以改变,某些步骤可以省略。Referring to FIG. 2, FIG. 2 is a flowchart of another preferred embodiment of a data fixed-point processing method according to the present disclosure. The order of the steps in the flowchart may be changed according to different requirements, and some steps may be omitted.
S21、针对训练完成的第一卷积神经网络模型,电子设备提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图。S21. For the first convolutional neural network model that is completed by the training, the electronic device extracts the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model.
其中,所述i为初始化的网络层数,所述i为正整数。原始权重参数为训练完成的第一卷积神经网络模型第i数据层的权重参数,原始特征图训练完成的第一卷积神经网络模型第i数据层的特征图,其中,每个数据层的权重参数可以有多个,每个数据层输出的特征图也可以有多个,具体数量取决于第一卷积神经网络模型的结构。Where i is the number of initialized network layers, and the i is a positive integer. The original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
本发明使用的深度学习框架均采用浮点作为其基本数据结构,该深度学习框架可以包括但不限于Caffe、MxNet、TensorFlow等。该训练完成的第一卷积神经网络模型为浮点模型,即该第一卷积神经网络模型的每个数据层的数据结构为浮点数。The deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like. The first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
其中,在第一卷积神经网络模型的训练过程中,通常是将第i数据层的特征图和第(i+1)数据层的权重参数进行卷积操作来确定第(i+1)数据层的特征图。以此类推,直至生成第一卷积神经网络模型。Wherein, in the training process of the first convolutional neural network model, the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data. The feature map of the layer. And so on, until the first convolutional neural network model is generated.
S22、电子设备对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图。S22. The electronic device performs fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map.
本发明中,为了在嵌入式平台上运行,需要有个定点化的过程。本发明可以使用任意的浮点框架对第一卷积神经网络模型进行训练,比如使用caffe作为基础训练框架,训练网络使用ResNet18,数据使用Minist。In the present invention, in order to operate on an embedded platform, a fixed-point process is required. The present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
电子设备在提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图之后,可以对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图。After extracting the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
其中,可以使用8bit的参数量化位宽对原始权重参数进行定点化处理,使用8bit的特征量化位宽对原始特征图进行定点化处理,该定点化处理后的第一权重参数的数据结构为定点数,该定点化处理后的第一特征图的数据结构为定点数。Wherein, the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width, and the original feature map is fixed-pointed by using the 8-bit feature quantization bit width, and the data structure of the first weight parameter after the fixed-point processing is determined The number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
具体的,所述电子设备对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:Specifically, the electronic device separately performs a fixed-point processing on the original weight parameter and the original feature map, and obtaining the first weight parameter and the first feature map includes:
从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处 理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
其中,所述参数量化位宽为8比特,所述特征量化位宽为8比特。The parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
具体的,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:Specifically, the truncating the weight parameter after rounding is performed, and obtaining the first weight parameter includes:
若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
在该实施方式中,每个数据层均有多个权重参数,电子设备可以从第i数据层提取的原始权重参数M中确定最大权重参数和最小权重参数,比如p max=max(M),p min=min(M)。进一步地,根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,找出一个合适的缩放因子α,确保原始权重参数M能使用预设的参数量化位宽(如8bit)来表达,具体方法如下: In this embodiment, each data layer has multiple weight parameters, and the electronic device may determine a maximum weight parameter and a minimum weight parameter from the original weight parameter M extracted from the ith data layer, such as p max =max(M), p min =min(M). Further, according to the maximum weight parameter, the minimum weight parameter, and the preset parameter quantization bit width, find a suitable scaling factor α, and ensure that the original weight parameter M can use the preset parameter quantization bit width (such as 8 bit). ) to express, the specific method is as follows:
8bit能表示的数的取值范围为[-128,127],缩放因子α应当满足αp max≤127,并且αp min>-128,通常缩放因子α为整数,根据上述的调节,可以唯一确定合适的缩放因子α。 The range of the 8bit energy representation is [-128,127], the scaling factor α should satisfy αp max ≤127, and αp min >-128, usually the scaling factor α is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor α.
进一步地,根据确定的缩放因子,可以依次对每个所述原始权重参数进行量化处理以及四舍五入处理。具体的,将每个所述原始权重参数与缩放因子进行相乘,并将相乘的结果进行四舍五入处理。Further, according to the determined scaling factor, each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
更进一步地,可以对四舍五入后的权重参数进行截断处理,获得第一权重参数。具体的,所述对四舍五入后的权重参数进行截断处理,获得第一权 重参数包括:若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数。即:当原始权重参数M中的某个参数大于p max时,将该某个参数重新赋值为p max,当原始权重参数M中的某个参数小于p min,将该某个参数重新赋值为p minFurther, the weighting parameter after rounding can be truncated to obtain the first weight parameter. Specifically, the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
类似的,每个数据层的输出均有多个特征图,电子设备可以参照对原始权重参数类似的定点化处理方式来对原始特征图进行定点化处理,获得第一特征图包括,在此不再赘述。Similarly, the output of each data layer has multiple feature maps, and the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
S23、电子设备将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图。S23. The electronic device converts the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map.
本发明中,电子设备获得的所述第一权重参数的数据结构以及所述第一特征图的数据结构均是定点数,而定点数在现有的浮点框架上是无法运行的,需要转换数据结构。In the present invention, the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
具体的,电子设备可以将所述第一权重参数除以第一缩放因子,以获得数据结构为浮点数的第二权重参数,同理,电子设备可以将所述第一特征图除以第二缩放因子,以获得数据结构为浮点数的第二特征图。其中,该第二权重参数以及所述第二特征图虽然是浮点数据类型,但是该第二权重参数以及所述第二特征图均达到了定点数的精度范围,不仅能够适用于现有的浮点框架,还能够在较低位宽下达到较小的性能损失。Specifically, the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number. Similarly, the electronic device may divide the first feature map by a second. The scaling factor is obtained to obtain a second feature map whose data structure is a floating point number. The second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
S24、电子设备将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。S24. The electronic device replaces the original weight parameter with the second weight parameter, and replaces the original feature map with the second feature map.
本发明中,所述原始权重参数有多个,相应地,所述第二权重参数也有多个,同理,所述原始特征图有多个,相应地,所述第二特征图也有多个。针对每个所述原始权重参数,电子设备需要将所述原始权重参数替换为所述第二权重参数,针对每个所述第二特征图,电子设备需要将所述原始特征图 替换为所述第二特征图。In the present invention, there are multiple original weight parameters, and correspondingly, there are multiple second weight parameters. Similarly, the original feature map has multiple, and correspondingly, the second feature map has multiple . For each of the original weight parameters, the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
S25、电子设备判断所述第一卷积神经网络模型是否完成定点化过程,若否,执行步骤S26至S27,若是,执行步骤S27。S25. The electronic device determines whether the first convolutional neural network model completes the fixed point process. If not, steps S26 to S27 are performed, and if yes, step S27 is performed.
本发明中,电子设备需要对所述第一卷积神经网络模型的每个数据层的数据进行定点化处理,故电子设备在对第i数据层完成定点化过程后,还需要进一步判断所述第一卷积神经网络模型是否完成定点化过程,若未完成,电子设备需要对下一个数据层的数据进行定点化处理,即令i=i+1进行迭代,直至完成所述第一卷积神经网络模型的定点化过程。In the present invention, the electronic device needs to perform fixed-point processing on the data of each data layer of the first convolutional neural network model, so after the electronic device completes the fixed-point process on the ith data layer, it is further required to determine the Whether the first convolutional neural network model completes the fixed-point process, if not completed, the electronic device needs to perform fixed-point processing on the data of the next data layer, that is, i=i+1 is iterated until the first convolutional nerve is completed. The fixed-point process of the network model.
S26、电子设备确定i=i+1,并执行所述第一卷积神经网络模型的定点化过程。S26. The electronic device determines i=i+1, and performs a fixed-point process of the first convolutional neural network model.
S27、在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,生成第二卷积神经网络模型。S27. After the fixed-point process of all data layers of the first convolutional neural network model ends, generate a second convolutional neural network model.
其中,所述第一卷积神经网络模型为浮点模型,所述第二卷积神经网络模型为定点模型。The first convolutional neural network model is a floating point model, and the second convolutional neural network model is a fixed point model.
在图2所描述的方法流程中,电子设备需要对第一卷积神经网络的每个数据层的权重参数和特征图都进行定点化处理,在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,可以生成第二卷积神经网络模型,第二卷积神经网络模型具备兼容性,可以适用于现有传统的浮点框架,同时能够保证在较低位宽下达到较小的精度损失。In the method flow described in FIG. 2, the electronic device needs to perform a fixed-point processing on the weight parameter and the feature map of each data layer of the first convolutional neural network, and all data in the first convolutional neural network model. After the fixed-point process of the layer is completed, a second convolutional neural network model can be generated. The second convolutional neural network model has compatibility and can be applied to existing traditional floating-point frames, and can be guaranteed to be achieved at a lower bit width. Smaller loss of precision.
请参见图3,图3是本发明公开的一种数据定点化处理装置的较佳实施例的功能模块图。其中,图3描述的数据定点化处理装置用于执行图1或图2所描述的数据定点化处理方法中的部分或全部步骤。本发明所称的单元是指一种能够被处理器所执行并且能够完成固定功能的一系列计算机程序段,其存储在存储器中。在本实施例中,关于各单元的功能将在后续的实施例中 详述。Please refer to FIG. 3. FIG. 3 is a functional block diagram of a preferred embodiment of a data fixed point processing apparatus according to the present invention. The data fixed-point processing device described in FIG. 3 is used to perform some or all of the steps in the data fixed-point processing method described in FIG. 1 or FIG. A unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor and that are capable of performing a fixed function, which are stored in a memory. In the present embodiment, the functions of the respective units will be described in detail in the subsequent embodiments.
图3所描述的数据定点化处理装置11可以包括:The data pointing processing device 11 depicted in FIG. 3 may include:
提取单元101,用于针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;The extracting unit 101 is configured to extract, for the first convolutional neural network model that is completed by the training, an original weight parameter and an original feature map of the i-th data layer of the first convolutional neural network model, where the i is an initialized network The number of layers, the i is a positive integer;
其中,所述i为初始化的网络层数,所述i为正整数。原始权重参数为训练完成的第一卷积神经网络模型第i数据层的权重参数,原始特征图训练完成的第一卷积神经网络模型第i数据层的特征图,其中,每个数据层的权重参数可以有多个,每个数据层输出的特征图也可以有多个,具体数量取决于第一卷积神经网络模型的结构。Where i is the number of initialized network layers, and the i is a positive integer. The original weight parameter is the weight parameter of the i-th data layer of the first convolutional neural network model trained, and the characteristic map of the i-th data layer of the first convolutional neural network model is completed by the original feature map training, wherein each data layer There may be multiple weight parameters, and there may be multiple feature maps output by each data layer, and the specific number depends on the structure of the first convolutional neural network model.
本发明使用的深度学习框架均采用浮点作为其基本数据结构,该深度学习框架可以包括但不限于Caffe、MxNet、TensorFlow等。该训练完成的第一卷积神经网络模型为浮点模型,即该第一卷积神经网络模型的每个数据层的数据结构为浮点数。The deep learning framework used in the present invention uses floating point as its basic data structure, which may include, but is not limited to, Caffe, MxNet, TensorFlow, and the like. The first convolutional neural network model completed by the training is a floating point model, that is, the data structure of each data layer of the first convolutional neural network model is a floating point number.
其中,在第一卷积神经网络模型的训练过程中,通常是将第i数据层的特征图和第(i+1)数据层的权重参数进行卷积操作来确定第(i+1)数据层的特征图。以此类推,直至生成第一卷积神经网络模型。Wherein, in the training process of the first convolutional neural network model, the feature map of the i-th data layer and the weight parameter of the (i+1)th data layer are generally convoluted to determine the (i+1)th data. The feature map of the layer. And so on, until the first convolutional neural network model is generated.
处理单元102,用于对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;The processing unit 102 is configured to perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map;
本发明中,为了在嵌入式平台上运行,需要有个定点化的过程。本发明可以使用任意的浮点框架对第一卷积神经网络模型进行训练,比如使用caffe作为基础训练框架,训练网络使用ResNet18,数据使用Minist。In the present invention, in order to operate on an embedded platform, a fixed-point process is required. The present invention can train the first convolutional neural network model using any floating point framework, such as using caffe as a basic training framework, training network using ResNet 18, and data using Minist.
电子设备在提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图之后,可以对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图。After extracting the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, the electronic device may perform a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight. Parameters and first feature map.
其中,可以使用8bit的参数量化位宽对原始权重参数进行定点化处理,使用8bit的特征量化位宽对原始特征图进行定点化处理,该定点化处理后的第一权重参数的数据结构为定点数,该定点化处理后的第一特征图的数据结构为定点数。Wherein, the original weight parameter can be fixed-pointed by using the 8-bit parameter quantization bit width, and the original feature map is fixed-pointed by using the 8-bit feature quantization bit width, and the data structure of the first weight parameter after the fixed-point processing is determined The number of points, the data structure of the first feature map after the fixed point processing is a fixed point number.
转换单元103,用于将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;The converting unit 103 is configured to convert the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map;
本发明中,电子设备获得的所述第一权重参数的数据结构以及所述第一特征图的数据结构均是定点数,而定点数在现有的浮点框架上是无法运行的,需要转换数据结构。In the present invention, the data structure of the first weight parameter obtained by the electronic device and the data structure of the first feature map are both fixed point numbers, and the fixed point number cannot be operated on the existing floating point frame, and needs to be converted. data structure.
具体的,电子设备可以将所述第一权重参数除以第一缩放因子,以获得数据结构为浮点数的第二权重参数,同理,电子设备可以将所述第一特征图除以第二缩放因子,以获得数据结构为浮点数的第二特征图。其中,该第二权重参数以及所述第二特征图虽然是浮点数据类型,但是该第二权重参数以及所述第二特征图均达到了定点数的精度范围,不仅能够适用于现有的浮点框架,还能够在较低位宽下达到较小的性能损失。Specifically, the electronic device may divide the first weight parameter by a first scaling factor to obtain a second weight parameter whose data structure is a floating point number. Similarly, the electronic device may divide the first feature map by a second. The scaling factor is obtained to obtain a second feature map whose data structure is a floating point number. The second weight parameter and the second feature map are floating point data types, but the second weight parameter and the second feature map both reach the precision range of the fixed point number, and can be applied not only to the existing The floating point frame also achieves a small performance penalty at lower bit widths.
替换单元104,用于将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。The replacing unit 104 is configured to replace the original weight parameter with the second weight parameter, and replace the original feature map with the second feature map.
本发明中,所述原始权重参数有多个,相应地,所述第二权重参数也有多个,同理,所述原始特征图有多个,相应地,所述第二特征图也有多个。针对每个所述原始权重参数,电子设备需要将所述原始权重参数替换为所述第二权重参数,针对每个所述第二特征图,电子设备需要将所述原始特征图替换为所述第二特征图。In the present invention, there are multiple original weight parameters, and correspondingly, there are multiple second weight parameters. Similarly, the original feature map has multiple, and correspondingly, the second feature map has multiple . For each of the original weight parameters, the electronic device needs to replace the original weight parameter with the second weight parameter, and for each of the second feature maps, the electronic device needs to replace the original feature map with the Second feature map.
上述替换是在第一卷积神经网络第i数据层上的原始权重参数以及原始特征图的替换,以此类推,电子设备可以按照上述对第一卷积神经网络第i数据层上的原始权重参数以及原始特征图的定点化处理方式来对第一卷积 神经网络的其他数据层进行定点化处理,直至完成整个第一卷积神经网络的定点化过程。The above replacement is the original weight parameter on the i-th data layer of the first convolutional neural network and the replacement of the original feature map, and so on, the electronic device can follow the above-mentioned original weight on the i-th data layer of the first convolutional neural network. The parameters and the fixed-point processing of the original feature map are used to perform fixed-point processing on other data layers of the first convolutional neural network until the entire first convolutional neural network is completed.
可选的,所述处理单元102对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:Optionally, the processing unit 102 performs a fixed-point processing on the original weight parameter and the original feature map respectively, and obtaining the first weight parameter and the first feature map includes:
从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
其中,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:The truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes:
若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
其中,所述参数量化位宽为8比特,所述特征量化位宽为8比特。The parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
在该实施方式中,每个数据层均有多个权重参数,电子设备可以从第i 数据层提取的原始权重参数M中确定最大权重参数和最小权重参数,比如p max=max(M),p min=min(M)。进一步地,根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,找出一个合适的缩放因子α,确保原始权重参数M能使用预设的参数量化位宽(如8bit)来表达,具体方法如下: In this embodiment, each data layer has multiple weight parameters, and the electronic device can determine the maximum weight parameter and the minimum weight parameter from the original weight parameter M extracted from the ith data layer, such as p max =max(M), p min =min(M). Further, according to the maximum weight parameter, the minimum weight parameter, and the preset parameter quantization bit width, find a suitable scaling factor α, and ensure that the original weight parameter M can use the preset parameter quantization bit width (such as 8 bit). ) to express, the specific method is as follows:
8bit能表示的数的取值范围为[-128,127],缩放因子α应当满足αp max≤127,并且αp min>-128,通常缩放因子α为整数,根据上述的调节,可以唯一确定合适的缩放因子α。 The range of the 8bit energy representation is [-128,127], the scaling factor α should satisfy αp max ≤127, and αp min >-128, usually the scaling factor α is an integer. According to the above adjustment, the appropriate scaling can be uniquely determined. Factor α.
进一步地,根据确定的缩放因子,可以依次对每个所述原始权重参数进行量化处理以及四舍五入处理。具体的,将每个所述原始权重参数与缩放因子进行相乘,并将相乘的结果进行四舍五入处理。Further, according to the determined scaling factor, each of the original weight parameters may be sequentially subjected to quantization processing and rounding processing. Specifically, each of the original weight parameters is multiplied by a scaling factor, and the multiplied result is rounded off.
更进一步地,可以对四舍五入后的权重参数进行截断处理,获得第一权重参数。具体的,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数。即:当原始权重参数M中的某个参数大于p max时,将该某个参数重新赋值为p max,当原始权重参数M中的某个参数小于p min,将该某个参数重新赋值为p minFurther, the weighting parameter after rounding can be truncated to obtain the first weight parameter. Specifically, the truncating process is performed on the weighting parameter after the rounding, and obtaining the first weight parameter includes: if the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; The subsequent weight parameter is smaller than the minimum weight parameter, and the minimum weight parameter is determined as the first weight parameter. That is, when a parameter in the original weight parameter M is greater than p max , the certain parameter is re-assigned to p max , and when a parameter in the original weight parameter M is less than p min , the certain parameter is re-assigned. p min .
类似的,每个数据层的输出均有多个特征图,电子设备可以参照对原始权重参数类似的定点化处理方式来对原始特征图进行定点化处理,获得第一特征图包括,在此不再赘述。Similarly, the output of each data layer has multiple feature maps, and the electronic device can perform fixed-point processing on the original feature map by referring to a fixed-point processing method similar to the original weight parameter, and obtain the first feature map including, Let me repeat.
可选的,图3所描述的数据定点化处理装置11还可以包括:Optionally, the data fixed point processing apparatus 11 described in FIG. 3 may further include:
判断单元,用于判断所述第一卷积神经网络模型是否完成定点化过程;a determining unit, configured to determine whether the first convolutional neural network model completes a fixed point process;
确定执行单元,用于当所述判断单元判断所述第一卷积神经网络模型未完成定点化过程时,确定i=i+1,并执行所述第一卷积神经网络模型的定点化过程。Determining an execution unit, configured to determine i=i+1 when the determining unit determines that the first convolutional neural network model has not completed the fixed-point process, and perform a fixed-point process of the first convolutional neural network model .
可选的,图3所描述的数据定点化处理装置11还可以包括:Optionally, the data fixed point processing apparatus 11 described in FIG. 3 may further include:
生成单元,用于在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,生成第二卷积神经网络模型。And a generating unit, configured to generate a second convolutional neural network model after the end of the fixed-point process of all the data layers of the first convolutional neural network model.
在图3所描述的数据定点化处理装置中,针对训练完成的第一卷积神经网络模型,可以先提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;进一步地,可以将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;更进一步地,可以将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。可见,通过本发明的实施例,针对训练完成的第一卷积神经网络模型,电子设备可以对该第一卷积神经网络模型的数据层的权重参数及特征图进行定点化处理,获得数据结构为定点数的权重参数和特征图,进一步再将定点数的权重参数和特征图分别转化为浮点数,用来替换原始的权重参数和特征图,从而能够在现有的浮点框架基础上,通过对原始的权重参数和特征图的定点化处理,使得处理后的权重参数和特征图能达到定点数的精度范围,并能够在浮点框架上兼容,进而能够确保在较低量化位宽下能达到较小的精度损失。In the data de-pointing processing device described in FIG. 3, for the first convolutional neural network model that is completed by training, the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model may be extracted first. Wherein, i is an initial number of network layers, and the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further And converting the first weight parameter and the first feature map into a floating point number, respectively obtaining a second weight parameter and the second feature map; and further, the original weight parameter may be replaced by the a second weight parameter, and replacing the original feature map with the second feature map. It can be seen that, by using the first convolutional neural network model in which the training is completed, the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure. For the weight parameter and feature map of the fixed point number, the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame. Through the fixed-point processing of the original weight parameters and feature maps, the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
上述以软件功能模块的形式实现的集成的单元,可以存储在一个计算机可读存储介质中。其中,该计算机可读存储介质可以存储计算机程序,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读存储介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、 电信信号以及软件分发介质等。需要说明的是,所述计算机可读存储介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。The above-described integrated unit implemented in the form of a software function module can be stored in a computer readable storage medium. Wherein, the computer readable storage medium can store a computer program, which when executed by the processor, can implement the steps of the various method embodiments described above. Wherein, the computer program comprises computer program code, which may be in the form of source code, object code form, executable file or some intermediate form. The computer readable storage medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read only memory (ROM, Read-Only Memory). ), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media. It should be noted that the content contained in the computer readable storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in a jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, computer readable The medium does not include electrical carrier signals and telecommunication signals.
如图4所示,图4是本发明实现数据定点化处理方法的较佳实施例的电子设备的结构示意图。所述电子设备1包括存储器12及处理器13。本领域技术人员可以理解,所述图4所示的示意图仅仅是电子设备1的示例,并不构成对电子设备1的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述电子设备1还可以包括输入输出设备、网络接入设备、总线等。As shown in FIG. 4, FIG. 4 is a schematic structural diagram of an electronic device according to a preferred embodiment of the method for implementing data fixed point processing according to the present invention. The electronic device 1 includes a memory 12 and a processor 13. It can be understood by those skilled in the art that the schematic diagram shown in FIG. 4 is only an example of the electronic device 1, does not constitute a limitation on the electronic device 1, may include more or less components than illustrated, or may combine some Components, or different components, such as the electronic device 1 may also include input and output devices, network access devices, buses, and the like.
所述电子设备1还包括但不限于任何一种可与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互的电子产品,例如,个人计算机、平板电脑、智能手机、个人数字助理(Personal Digital Assistant,PDA)、游戏机、交互式网络电视(Internet Protocol Television,IPTV)、智能式穿戴式设备等。所述电子设备1所处的网络包括但不限于互联网、广域网、城域网、局域网、虚拟专用网络(Virtual Private Network,VPN)等。The electronic device 1 further includes, but is not limited to, any electronic product that can interact with a user through a keyboard, a mouse, a remote controller, a touch panel, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, Personal Digital Assistant (PDA), game consoles, Internet Protocol Television (IPTV), smart wearable devices, etc. The network in which the electronic device 1 is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), and the like.
所述存储器12可选地包括一个或多个计算机可读存储介质,用于存储一种数据定点化处理方法的程序和各种数据,并在运行过程中实现高速、自动地完成程序或数据的存取。所述存储器12可选地包括高速随机存取存储器,并且还可选地包括非易失性存储器,诸如一个或多个磁盘存储设备、闪存存储器设备、或其它非易失性固态存储器设备。The memory 12 optionally includes one or more computer readable storage media for storing a program of the data fixed point processing method and various data, and implementing the program or data at a high speed and automatically during the running process. access. The memory 12 optionally includes a high speed random access memory, and optionally also a non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid state memory devices.
所述处理器13又称中央处理器(CPU,Central Processing Unit),是一块超大规模的集成电路,是电子设备1的运算核心(Core)和控制核心(Control Unit)。所述处理器13可执行所述电子设备1的操作系统以及安装的各类应用程序、程序代码等,例如数据定点化处理装置11。The processor 13 is also referred to as a central processing unit (CPU). It is a very large-scale integrated circuit and is a computing core (Core) and a control unit of the electronic device 1. The processor 13 can execute an operating system of the electronic device 1 and various installed application programs, program codes, and the like, such as the data fixed point processing device 11.
结合图1或图2,所述电子设备1中的所述存储器12存储多个指令以实现一种数据定点化处理方法,所述处理器13可执行所述多个指令从而实现:1 or 2, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a data pointing processing method, and the processor 13 may execute the plurality of instructions to implement:
针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;Extracting, from the first convolutional neural network model of the training, the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, wherein the i is an initialized network layer number, the i Is a positive integer;
对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;Performing a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map;
将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;Converting the first weight parameter and the first feature map into a floating point number, respectively obtaining a second weight parameter and the second feature map;
将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。The original weight parameter is replaced with the second weight parameter, and the original feature map is replaced with the second feature map.
在一种可选的实施方式中,所述对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:In an optional implementation manner, the performing the point processing on the original weight parameter and the original feature map separately, and obtaining the first weight parameter and the first feature map includes:
从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
在一种可选的实施方式中,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:In an optional implementation manner, the rounding off the weight parameter after the rounding is performed, and obtaining the first weight parameter includes:
若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确 定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
在一种可选的实施方式中,所述参数量化位宽为8比特,所述特征量化位宽为8比特。In an optional implementation manner, the parameter quantization bit width is 8 bits, and the feature quantization bit width is 8 bits.
在一种可选的实施方式中,所述处理器13可执行所述多个指令从而实现:In an optional implementation manner, the processor 13 may execute the multiple instructions to implement:
判断所述第一卷积神经网络模型是否完成定点化过程;Determining whether the first convolutional neural network model completes a fixed-point process;
若否,确定i=i+1,并执行所述第一卷积神经网络模型的定点化过程。If not, i=i+1 is determined and the fixed-point process of the first convolutional neural network model is performed.
在一种可选的实施方式中,所述处理器13可执行所述多个指令从而实现:In an optional implementation manner, the processor 13 may execute the multiple instructions to implement:
在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,生成第二卷积神经网络模型。After the end of the fixed-point process of all data layers of the first convolutional neural network model, a second convolutional neural network model is generated.
具体地,所述处理器13对上述指令的具体实现方法可参考图1或图2对应实施例中相关步骤的描述,在此不赘述。For details, refer to the description of the related steps in the corresponding embodiment of FIG. 1 or FIG. 2, and the details are not described here.
在图4所描述的电子设备1中,针对训练完成的第一卷积神经网络模型,电子设备可以先提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;进一步地,电子设备可以将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;更进一步地,电子设备可以将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。可见,通过本发明的实施例,针对训练完成的第一卷 积神经网络模型,电子设备可以对该第一卷积神经网络模型的数据层的权重参数及特征图进行定点化处理,获得数据结构为定点数的权重参数和特征图,进一步再将定点数的权重参数和特征图分别转化为浮点数,用来替换原始的权重参数和特征图,从而能够在现有的浮点框架基础上,通过对原始的权重参数和特征图的定点化处理,使得处理后的权重参数和特征图能达到定点数的精度范围,并能够在浮点框架上兼容,进而能够确保在较低量化位宽下能达到较小的精度损失。In the electronic device 1 described in FIG. 4, for the trained first convolutional neural network model, the electronic device may first extract the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model. Wherein, i is an initial number of network layers, and the i is a positive integer; and the original weight parameter and the original feature map are respectively subjected to a fixed point processing to obtain a first weight parameter and a first feature map; further The electronic device may convert the first weight parameter and the first feature map into a floating point number, respectively obtain a second weight parameter and the second feature map; and further, the electronic device may use the original weight parameter The second weight parameter is replaced with the original feature map and the original feature map is replaced with the second feature map. It can be seen that, by using the first convolutional neural network model in which the training is completed, the electronic device can perform fixed-point processing on the weight parameter and the feature map of the data layer of the first convolutional neural network model to obtain a data structure. For the weight parameter and feature map of the fixed point number, the weight parameter and the feature map of the fixed point number are further converted into floating point numbers, which are used to replace the original weight parameter and the feature map, thereby being able to be based on the existing floating point frame. Through the fixed-point processing of the original weight parameters and feature maps, the processed weight parameters and feature maps can reach the precision range of fixed-point numbers and can be compatible on the floating-point framework, thereby ensuring the lower quantization bit width. Can achieve a small loss of precision.
在本发明所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and the actual implementation may have another division manner.
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and the components displayed as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention 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. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software function modules.
对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本发明内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利 要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。It is apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, and the present invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the invention is defined by the appended claims instead All changes in the meaning and scope of equivalent elements are included in the present invention. Any accompanying drawings in the claims should not be construed as limiting the claim. In addition, it is to be understood that the word "comprising" does not exclude other elements or steps. The plurality of units or devices recited in the system claims may also be implemented by a unit or device by software or hardware. The second word is used to denote the name and does not denote any particular order.
最后应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或等同替换,而不脱离本发明技术方案的精神和范围。It should be noted that the above embodiments are only for explaining the technical solutions of the present invention and are not intended to be limiting, and the present invention will be described in detail with reference to the preferred embodiments. Modifications or equivalents are made without departing from the spirit and scope of the invention.

Claims (10)

  1. 一种数据定点化处理方法,其特征在于,所述方法包括:A data fixed-point processing method, characterized in that the method comprises:
    针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;Extracting, from the first convolutional neural network model of the training, the original weight parameter and the original feature map of the i-th data layer of the first convolutional neural network model, wherein the i is an initialized network layer number, the i Is a positive integer;
    对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;Performing a fixed-point processing on the original weight parameter and the original feature map to obtain a first weight parameter and a first feature map;
    将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;Converting the first weight parameter and the first feature map into a floating point number, respectively obtaining a second weight parameter and the second feature map;
    将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。The original weight parameter is replaced with the second weight parameter, and the original feature map is replaced with the second feature map.
  2. 根据权利要求1所述的方法,其特征在于,所述对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图包括:The method according to claim 1, wherein the performing the fixed-point processing on the original weight parameter and the original feature map separately, obtaining the first weight parameter and the first feature map comprises:
    从所述原始权重参数中确定最大权重参数和最小权重参数;根据所述最大权重参数、所述最小权重参数以及预设的参数量化位宽,确定第一缩放因子;根据所述第一缩放因子,依次对每个所述原始权重参数进行量化处理以及四舍五入处理,并对四舍五入后的权重参数进行截断处理,获得第一权重参数;Determining a maximum weight parameter and a minimum weight parameter from the original weight parameter; determining a first scaling factor according to the maximum weight parameter, the minimum weight parameter, and a preset parameter quantization bit width; according to the first scaling factor And performing quantization processing and rounding processing on each of the original weight parameters in turn, and performing truncation processing on the rounded weight parameters to obtain the first weight parameter;
    从所述原始特征图中确定最大特征图和最小特征图;根据所述最大特征图、所述最小特征图以及预设的特征量化位宽,确定第二缩放因子;根据所述第二缩放因子,依次对每个所述原始特征图进行量化处理以及四舍五入处理,并对四舍五入后的特征图进行截断处理,获得第一特征图。Determining a maximum feature map and a minimum feature map from the original feature map; determining a second zoom factor according to the maximum feature map, the minimum feature map, and a preset feature quantization bit width; according to the second zoom factor And performing quantization processing and rounding processing on each of the original feature maps in turn, and performing truncation processing on the rounded feature maps to obtain a first feature map.
  3. 根据权利要求2所述的方法,其特征在于,所述对四舍五入后的权重参数进行截断处理,获得第一权重参数包括:The method according to claim 2, wherein the truncating the rounded weight parameter is performed, and obtaining the first weight parameter comprises:
    若四舍五入后的权重参数大于所述最大权重参数,将所述最大权重参数确定作为第一权重参数;若四舍五入后的权重参数小于所述最小权重参数,将所述最小权重参数确定作为第一权重参数;If the weight parameter after rounding is greater than the maximum weight parameter, determining the maximum weight parameter as the first weight parameter; if the weight parameter after rounding is smaller than the minimum weight parameter, determining the minimum weight parameter as the first weight parameter;
    所述对四舍五入后的特征图进行截断处理,获得第一特征图包括:Performing truncation on the rounded feature map to obtain the first feature map includes:
    若四舍五入后的特征图大于所述最大特征图,将所述最大特征图确定作为第一特征图;若四舍五入后的特征图小于所述最小特征图,将所述最小特征图确定作为第一特征图。If the feature map after rounding is greater than the maximum feature map, determining the maximum feature map as the first feature map; if the rounded feature map is smaller than the minimum feature map, determining the minimum feature map as the first feature Figure.
  4. 根据权利要求2所述的方法,其特征在于,所述参数量化位宽为8比特,所述特征量化位宽为8比特。The method of claim 2 wherein said parameter quantization bit width is 8 bits and said feature quantization bit width is 8 bits.
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, further comprising:
    判断所述第一卷积神经网络模型是否完成定点化过程;Determining whether the first convolutional neural network model completes a fixed-point process;
    若否,确定i=i+1,并执行所述第一卷积神经网络模型的定点化过程。If not, i=i+1 is determined and the fixed-point process of the first convolutional neural network model is performed.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method of claim 5, wherein the method further comprises:
    在所述第一卷积神经网络模型的所有数据层的定点化过程结束后,生成第二卷积神经网络模型。After the end of the fixed-point process of all data layers of the first convolutional neural network model, a second convolutional neural network model is generated.
  7. 根据权利要求6所述的方法,其特征在于,所述第一卷积神经网络模型为浮点模型,所述第二卷积神经网络模型为定点模型。The method according to claim 6, wherein the first convolutional neural network model is a floating point model and the second convolutional neural network model is a fixed point model.
  8. 一种数据定点化处理装置,其特征在于,所述数据定点化处理装置包括:A data fixed-point processing device, wherein the data fixed-point processing device comprises:
    提取单元,用于针对训练完成的第一卷积神经网络模型,提取所述第一卷积神经网络模型第i数据层的原始权重参数和原始特征图,其中,所述i为初始化的网络层数,所述i为正整数;An extracting unit, configured to extract, from the first convolutional neural network model that is completed by the training, an original weight parameter and an original feature map of the i-th data layer of the first convolutional neural network model, where the i is an initialized network layer Number, the i is a positive integer;
    处理单元,用于对所述原始权重参数和所述原始特征图分别进行定点化处理,获得第一权重参数和第一特征图;a processing unit, configured to perform a fixed-point processing on the original weight parameter and the original feature map, respectively, to obtain a first weight parameter and a first feature map;
    转换单元,用于将所述第一权重参数以及所述第一特征图分别转化为浮点数,获得第二权重参数以及所述第二特征图;a converting unit, configured to convert the first weight parameter and the first feature map into a floating point number, respectively, to obtain a second weight parameter and the second feature map;
    替换单元,用于将所述原始权重参数替换为所述第二权重参数,以及将所述原始特征图替换为所述第二特征图。And a replacement unit, configured to replace the original weight parameter with the second weight parameter, and replace the original feature map with the second feature map.
  9. 一种电子设备,其特征在于,所述电子设备包括处理器和存储器,所述处理器用于执行存储器中存储的计算机程序以实现如权利要求1至7中任意一项所述的数据定点化处理方法。An electronic device, comprising: a processor and a memory, the processor for executing a computer program stored in a memory to implement the data fixed-point processing according to any one of claims 1 to 7. method.
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有至少一个指令,所述至少一个指令被处理器执行时实现如权利要求1至7任意一项所述的数据定点化处理方法。A computer readable storage medium, wherein the computer readable storage medium stores at least one instruction, the at least one instruction being executed by a processor to implement the data fixed point according to any one of claims 1 to 7. Processing method.
PCT/CN2018/120512 2017-12-21 2018-12-12 Data fixed point processing method, device, electronic apparatus and computer storage medium WO2019120114A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711392617.2 2017-12-21
CN201711392617.2A CN108053028B (en) 2017-12-21 2017-12-21 Data fixed-point processing method and device, electronic equipment and computer storage medium

Publications (1)

Publication Number Publication Date
WO2019120114A1 true WO2019120114A1 (en) 2019-06-27

Family

ID=62131187

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/120512 WO2019120114A1 (en) 2017-12-21 2018-12-12 Data fixed point processing method, device, electronic apparatus and computer storage medium

Country Status (2)

Country Link
CN (1) CN108053028B (en)
WO (1) WO2019120114A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110363297A (en) * 2019-07-05 2019-10-22 上海商汤临港智能科技有限公司 Neural metwork training and image processing method, device, equipment and medium
CN111310890A (en) * 2020-01-19 2020-06-19 深圳云天励飞技术有限公司 Deep learning model optimization method and device and terminal equipment
CN111368978A (en) * 2020-03-02 2020-07-03 开放智能机器(上海)有限公司 Precision improving method for offline quantization tool
CN111783957A (en) * 2020-07-02 2020-10-16 厦门美图之家科技有限公司 Model quantitative training method and device, machine-readable storage medium and electronic equipment
CN112308105A (en) * 2019-08-02 2021-02-02 北京图森智途科技有限公司 Target detection method, target detector and related equipment
CN112561779A (en) * 2019-09-26 2021-03-26 北京字节跳动网络技术有限公司 Image stylization processing method, device, equipment and storage medium
CN113177471A (en) * 2021-04-28 2021-07-27 Oppo广东移动通信有限公司 Motion detection method, motion detection device, electronic device, and storage medium

Families Citing this family (33)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11437032B2 (en) 2017-09-29 2022-09-06 Shanghai Cambricon Information Technology Co., Ltd Image processing apparatus and method
CN108053028B (en) * 2017-12-21 2021-09-14 深圳励飞科技有限公司 Data fixed-point processing method and device, electronic equipment and computer storage medium
US11709672B2 (en) 2018-02-13 2023-07-25 Shanghai Cambricon Information Technology Co., Ltd Computing device and method
US11630666B2 (en) 2018-02-13 2023-04-18 Shanghai Cambricon Information Technology Co., Ltd Computing device and method
EP3617959B1 (en) 2018-02-13 2021-08-04 Shanghai Cambricon Information Technology Co., Ltd Computing device and method
CN116991225A (en) 2018-02-14 2023-11-03 上海寒武纪信息科技有限公司 Control device, method and equipment of processor
WO2019218896A1 (en) 2018-05-18 2019-11-21 上海寒武纪信息科技有限公司 Computing method and related product
US20210350210A1 (en) * 2018-07-30 2021-11-11 Intel Corporation Method and apparatus for keeping statistical inference accuracy with 8-bit winograd convolution
CN109344840B (en) * 2018-08-07 2022-04-01 深圳市商汤科技有限公司 Image processing method and apparatus, electronic device, storage medium, and program product
KR102519467B1 (en) 2018-08-28 2023-04-06 캠브리콘 테크놀로지스 코퍼레이션 리미티드 Data pre-processing method, device, computer equipment and storage medium
CN110929837B (en) * 2018-09-19 2024-05-10 北京搜狗科技发展有限公司 Associated word prediction method and device
US11703939B2 (en) 2018-09-28 2023-07-18 Shanghai Cambricon Information Technology Co., Ltd Signal processing device and related products
CN111126558B (en) * 2018-10-31 2024-04-02 嘉楠明芯(北京)科技有限公司 Convolutional neural network calculation acceleration method and device, equipment and medium
CN111191783B (en) * 2018-11-15 2024-04-05 嘉楠明芯(北京)科技有限公司 Self-adaptive quantization method and device, equipment and medium
CN111353517B (en) * 2018-12-24 2023-09-26 杭州海康威视数字技术股份有限公司 License plate recognition method and device and electronic equipment
CN109697083B (en) * 2018-12-27 2021-07-06 深圳云天励飞技术有限公司 Fixed-point acceleration method and device for data, electronic equipment and storage medium
CN111385462A (en) 2018-12-28 2020-07-07 上海寒武纪信息科技有限公司 Signal processing device, signal processing method and related product
CN111383157B (en) * 2018-12-29 2023-04-14 北京市商汤科技开发有限公司 Image processing method and device, vehicle-mounted operation platform, electronic equipment and system
CN111695671B (en) * 2019-03-12 2023-08-08 北京地平线机器人技术研发有限公司 Method and device for training neural network and electronic equipment
CN111832739B (en) 2019-04-18 2024-01-09 中科寒武纪科技股份有限公司 Data processing method and related product
US11934940B2 (en) 2019-04-18 2024-03-19 Cambricon Technologies Corporation Limited AI processor simulation
CN110135568B (en) * 2019-05-28 2022-03-04 赵恒锐 Full-integer neural network method applying bounded linear rectification unit
US11675676B2 (en) 2019-06-12 2023-06-13 Shanghai Cambricon Information Technology Co., Ltd Neural network quantization parameter determination method and related products
US11676028B2 (en) 2019-06-12 2023-06-13 Shanghai Cambricon Information Technology Co., Ltd Neural network quantization parameter determination method and related products
CN110309877B (en) * 2019-06-28 2021-12-07 北京百度网讯科技有限公司 Feature map data quantization method and device, electronic equipment and storage medium
CN110298438B (en) * 2019-07-05 2024-04-26 北京中星微电子有限公司 Neural network model adjusting method and device
WO2021036904A1 (en) 2019-08-23 2021-03-04 安徽寒武纪信息科技有限公司 Data processing method, apparatus, computer device, and storage medium
US20210064985A1 (en) * 2019-09-03 2021-03-04 International Business Machines Corporation Machine learning hardware having reduced precision parameter components for efficient parameter update
CN111461302B (en) * 2020-03-30 2024-04-19 嘉楠明芯(北京)科技有限公司 Data processing method, device and storage medium based on convolutional neural network
CN111985495B (en) * 2020-07-09 2024-02-02 珠海亿智电子科技有限公司 Model deployment method, device, system and storage medium
CN113255901B (en) * 2021-07-06 2021-10-08 上海齐感电子信息科技有限公司 Real-time quantization method and real-time quantization system
CN113593538B (en) * 2021-09-02 2024-05-03 北京声智科技有限公司 Voice characteristic classification method, related equipment and readable storage medium
CN114065913A (en) * 2021-10-28 2022-02-18 深圳云天励飞技术股份有限公司 Model quantization method and device and terminal equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105760933A (en) * 2016-02-18 2016-07-13 清华大学 Method and apparatus for fixed-pointing layer-wise variable precision in convolutional neural network
CN107292334A (en) * 2017-06-08 2017-10-24 北京深瞐科技有限公司 Image-recognizing method and device
CN107330515A (en) * 2016-04-29 2017-11-07 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing artificial neural network forward operation
CN108053028A (en) * 2017-12-21 2018-05-18 深圳云天励飞技术有限公司 Data fixed point processing method, device, electronic equipment and computer storage media

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981854A (en) * 2012-11-16 2013-03-20 天津市天祥世联网络科技有限公司 Neural network optimization method based on floating number operation inline function library
WO2016039651A1 (en) * 2014-09-09 2016-03-17 Intel Corporation Improved fixed point integer implementations for neural networks
US9563825B2 (en) * 2014-11-20 2017-02-07 Adobe Systems Incorporated Convolutional neural network using a binarized convolution layer
CN106570559A (en) * 2015-10-09 2017-04-19 阿里巴巴集团控股有限公司 Data processing method and device based on neural network
US10831444B2 (en) * 2016-04-04 2020-11-10 Technion Research & Development Foundation Limited Quantized neural network training and inference
US10621486B2 (en) * 2016-08-12 2020-04-14 Beijing Deephi Intelligent Technology Co., Ltd. Method for optimizing an artificial neural network (ANN)
CN106326939A (en) * 2016-08-31 2017-01-11 深圳市诺比邻科技有限公司 Parameter optimization method and system of convolutional neural network
CN106502626A (en) * 2016-11-03 2017-03-15 北京百度网讯科技有限公司 Data processing method and device
CN106855952B (en) * 2016-12-29 2020-08-18 北京旷视科技有限公司 Neural network-based computing method and device
CN107451658B (en) * 2017-07-24 2020-12-15 杭州菲数科技有限公司 Fixed-point method and system for floating-point operation
CN107480770B (en) * 2017-07-27 2020-07-28 中国科学院自动化研究所 Neural network quantization and compression method and device capable of adjusting quantization bit width

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105760933A (en) * 2016-02-18 2016-07-13 清华大学 Method and apparatus for fixed-pointing layer-wise variable precision in convolutional neural network
CN107330515A (en) * 2016-04-29 2017-11-07 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing artificial neural network forward operation
CN107292334A (en) * 2017-06-08 2017-10-24 北京深瞐科技有限公司 Image-recognizing method and device
CN108053028A (en) * 2017-12-21 2018-05-18 深圳云天励飞技术有限公司 Data fixed point processing method, device, electronic equipment and computer storage media

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110363297A (en) * 2019-07-05 2019-10-22 上海商汤临港智能科技有限公司 Neural metwork training and image processing method, device, equipment and medium
CN112308105A (en) * 2019-08-02 2021-02-02 北京图森智途科技有限公司 Target detection method, target detector and related equipment
CN112308105B (en) * 2019-08-02 2024-04-12 北京图森智途科技有限公司 Target detection method, target detector and related equipment
CN112561779A (en) * 2019-09-26 2021-03-26 北京字节跳动网络技术有限公司 Image stylization processing method, device, equipment and storage medium
CN112561779B (en) * 2019-09-26 2023-09-29 北京字节跳动网络技术有限公司 Image stylization processing method, device, equipment and storage medium
CN111310890A (en) * 2020-01-19 2020-06-19 深圳云天励飞技术有限公司 Deep learning model optimization method and device and terminal equipment
CN111310890B (en) * 2020-01-19 2023-10-17 深圳云天励飞技术有限公司 Optimization method and device of deep learning model and terminal equipment
CN111368978A (en) * 2020-03-02 2020-07-03 开放智能机器(上海)有限公司 Precision improving method for offline quantization tool
CN111368978B (en) * 2020-03-02 2023-03-24 开放智能机器(上海)有限公司 Precision improving method for offline quantization tool
CN111783957A (en) * 2020-07-02 2020-10-16 厦门美图之家科技有限公司 Model quantitative training method and device, machine-readable storage medium and electronic equipment
CN111783957B (en) * 2020-07-02 2024-05-03 厦门美图之家科技有限公司 Model quantization training method and device, machine-readable storage medium and electronic equipment
CN113177471A (en) * 2021-04-28 2021-07-27 Oppo广东移动通信有限公司 Motion detection method, motion detection device, electronic device, and storage medium

Also Published As

Publication number Publication date
CN108053028B (en) 2021-09-14
CN108053028A (en) 2018-05-18

Similar Documents

Publication Publication Date Title
WO2019120114A1 (en) Data fixed point processing method, device, electronic apparatus and computer storage medium
WO2020233130A1 (en) Deep neural network compression method and related device
CN107239826A (en) Computational methods and device in convolutional neural networks
WO2019007406A1 (en) Data processing apparatus and method
CN114022882B (en) Text recognition model training method, text recognition device, text recognition equipment and medium
CN113657399A (en) Training method of character recognition model, character recognition method and device
WO2021053381A1 (en) Compression and acceleration method for neural network model, and data processing method and apparatus
US20220148239A1 (en) Model training method and apparatus, font library establishment method and apparatus, device and storage medium
CN113392962A (en) Method, device and circuit for decoding weights of neural network
CN111341299B (en) Voice processing method and device
EP3425630A1 (en) Electronic device-awakening method and apparatus, device and computer-readable storage medium
CN112989935A (en) Video generation method, device, equipment and storage medium
CN110942763A (en) Voice recognition method and device
US11568254B2 (en) Electronic apparatus and control method thereof
EP4390725A1 (en) Video retrieval method and apparatus, device, and storage medium
JP7408723B2 (en) Neural network processing unit, neural network processing method and device
CN112002311A (en) Text error correction method and device, computer readable storage medium and terminal equipment
KR20210129605A (en) Text key information extracting method, apparatus, electronic device and storage medium
KR20150105847A (en) Method and Apparatus for detecting speech segment
CN116543076A (en) Image processing method, device, electronic equipment and storage medium
JP2019525233A (en) Speech recognition method and apparatus
CN113360683A (en) Method for training cross-modal retrieval model and cross-modal retrieval method and device
CN117151178A (en) FPGA-oriented CNN customized network quantification acceleration method
US20220113943A1 (en) Method for multiply-add operations for neural network
CN115588227A (en) Emotion recognition method and device, electronic equipment and storage medium

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 23.10.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18890109

Country of ref document: EP

Kind code of ref document: A1