[go: up one dir, main page]

TWI786430B - Device and method for optimizing model conversion of deep learning model, and storage medium - Google Patents

Device and method for optimizing model conversion of deep learning model, and storage medium Download PDF

Info

Publication number
TWI786430B
TWI786430B TW109128492A TW109128492A TWI786430B TW I786430 B TWI786430 B TW I786430B TW 109128492 A TW109128492 A TW 109128492A TW 109128492 A TW109128492 A TW 109128492A TW I786430 B TWI786430 B TW I786430B
Authority
TW
Taiwan
Prior art keywords
deep learning
learning model
model
weight
distribution information
Prior art date
Application number
TW109128492A
Other languages
Chinese (zh)
Other versions
TW202209147A (en
Inventor
林子甄
孫國欽
盧志德
蔡東佐
楊榮浩
吳宗祐
李宛真
Original Assignee
鴻海精密工業股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 鴻海精密工業股份有限公司 filed Critical 鴻海精密工業股份有限公司
Priority to TW109128492A priority Critical patent/TWI786430B/en
Publication of TW202209147A publication Critical patent/TW202209147A/en
Application granted granted Critical
Publication of TWI786430B publication Critical patent/TWI786430B/en

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Electrically Operated Instructional Devices (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A method for optimizing model conversion of deep learning model includes: performing a model conversion on a first deep learning model to obtain a second deep learning model; obtaining weight arrangements of the first deep learning model and the second deep learning model according to deep learning frameworks of the first deep learning model and the second deep learning model; performing model quantifications on the first deep learning model and the second deep learning model; analyzing a weight similarity between the first deep learning model and the second deep learning model based on the weight arrangements and the model quantifications of the first deep learning model and the second deep learning model, and establishing a weight analysis report based on analyzed results of the weight similarity; testing the first learning model and the second deep learning model according to a preset test set to establish a model performance estimation report; obtaining one or more optimization suggestions for the second deep learning model based on the weight analysis report and the model performance estimation report; and using an optimized second deep learning model to process objective data.

Description

深度學習模型的模型轉換優化裝置、方法及存儲介質 Model conversion optimization device, method and storage medium for deep learning model

本發明涉及模型轉換優化技術領域,尤其涉及一種深度學習模型的模型轉換優化裝置、方法及電腦可讀取存儲介質。 The present invention relates to the technical field of model conversion optimization, in particular to a model conversion optimization device and method for a deep learning model, and a computer-readable storage medium.

現有的深度學習框架包括TensorFlow、Caffe、NCNN、Pytorch等框架。在進行演算法開發到演算法部署的過程中,往往都會用到不同的深度學習框架。例如,使用Tensorflow框架進行演算法開發和調試,而到了終端部署階段,可能會使用NCNN框架,這就存在模型轉換的問題。為了確保模型轉換後仍然可以保持有較好的預測準確性,需要對模型轉換之前和之後進行分析,而現有的模型分析一般是由具有豐富深度學習知識的人員來進行,過度依賴分析人員的專業性,且存在耗時高、效率低下的問題,導致最終部署在終端的模型存在性能不佳的情形。 Existing deep learning frameworks include TensorFlow, Caffe, NCNN, Pytorch and other frameworks. In the process from algorithm development to algorithm deployment, different deep learning frameworks are often used. For example, the Tensorflow framework is used for algorithm development and debugging, but in the terminal deployment stage, the NCNN framework may be used, which poses the problem of model conversion. In order to ensure that the model can still maintain good prediction accuracy after the conversion, it is necessary to analyze the model before and after the conversion, and the existing model analysis is generally carried out by personnel with rich deep learning knowledge, relying too much on the professionalism of analysts In addition, there are problems of high time consumption and low efficiency, which lead to poor performance of the model finally deployed on the terminal.

有鑑於此,有必要提供一種深度學習模型的模型轉換優化裝置、方法及電腦可讀取存儲介質,可實現自動對模型轉換之前和之後進行深入分析,最大程度避免出現轉換後的模型性能不佳的情形。 In view of this, it is necessary to provide a model conversion optimization device, method, and computer-readable storage medium for a deep learning model, which can automatically perform in-depth analysis before and after model conversion, and avoid poor performance of the converted model to the greatest extent. situation.

本發明一實施方式提供一種深度學習模型的模型轉換優化方法, 所述方法包括:對第一深度學習模型進行模型轉換,得到第二深度學習模型,其中所述第一深度學習模型與所述第二深度學習模型具有不同的深度學習框架;根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式;對所述第一深度學習模型及所述第二深度學習模型進行模型量化;基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告;根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告;根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化;及利用優化後的第二深度學習模型對待處理資料進行處理。 An embodiment of the present invention provides a model conversion optimization method for a deep learning model, The method includes: performing model conversion on the first deep learning model to obtain a second deep learning model, wherein the first deep learning model and the second deep learning model have different deep learning frameworks; according to the first The deep learning framework of the deep learning model obtains the weight arrangement of the first deep learning model and obtains the weight arrangement of the second deep learning model according to the deep learning framework of the second deep learning model; The deep learning model and the second deep learning model carry out model quantification; based on the weight arrangement and model quantification results of the first deep learning model, and the weight arrangement and model quantification results of the second deep learning model, it is obtained The weight similarity between the first deep learning model and the second deep learning model is used to construct a weight analysis report; the first deep learning model and the second deep learning model are respectively analyzed according to a preset test set Performing a test to construct a model performance estimation report; obtaining an optimization suggestion for the second deep learning model according to the weight analysis report and the model performance estimation report, so as to perform model optimization on the second deep learning model; And using the optimized second deep learning model to process the data to be processed.

本發明一實施方式提供一種深度學習模型的模型轉換優化裝置,所述裝置包括處理器及記憶體,所述記憶體上存儲有若干電腦程式,所述處理器用於執行記憶體中存儲的電腦程式時實現如下步驟:對第一深度學習模型進行模型轉換,得到第二深度學習模型,其中所述第一深度學習模型與所述第二深度學習模型具有不同的深度學習框架;根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式;對所述第一深度學習模型及所述第二深度學習模型進行模型量化;基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告;根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告;根據所 述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化;及利用優化後的第二深度學習模型對待處理資料進行處理。 One embodiment of the present invention provides a model conversion optimization device for a deep learning model, the device includes a processor and a memory, the memory stores a number of computer programs, and the processor is used to execute the computer programs stored in the memory When implementing the following steps: carry out model conversion to the first deep learning model to obtain a second deep learning model, wherein the first deep learning model and the second deep learning model have different deep learning frameworks; according to the first The deep learning framework of the deep learning model obtains the weight arrangement of the first deep learning model and obtains the weight arrangement of the second deep learning model according to the deep learning framework of the second deep learning model; The deep learning model and the second deep learning model carry out model quantification; based on the weight arrangement and model quantification results of the first deep learning model, and the weight arrangement and model quantification results of the second deep learning model, it is obtained The weight similarity between the first deep learning model and the second deep learning model is used to construct a weight analysis report; the first deep learning model and the second deep learning model are respectively analyzed according to a preset test set Tests are performed to build a model performance estimation report; based on the The weight analysis report and the model performance estimation report obtain optimization suggestions for the second deep learning model, so as to optimize the second deep learning model; and use the optimized second deep learning model to process data to process.

本發明一實施方式提供一種電腦可讀取存儲介質,所述電腦可讀取存儲介質存儲有多條指令,多條所述指令可被一個或者多個處理器執行,以實現如下步驟:對第一深度學習模型進行模型轉換,得到第二深度學習模型,其中所述第一深度學習模型與所述第二深度學習模型具有不同的深度學習框架;根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式;對所述第一深度學習模型及所述第二深度學習模型進行模型量化;基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告;根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告;根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化;及利用優化後的第二深度學習模型對待處理資料進行處理。 An embodiment of the present invention provides a computer-readable storage medium, the computer-readable storage medium stores a plurality of instructions, and the plurality of instructions can be executed by one or more processors to implement the following steps: A deep learning model performs model conversion to obtain a second deep learning model, wherein the first deep learning model and the second deep learning model have different deep learning frameworks; according to the deep learning framework of the first deep learning model Obtain the weight arrangement of the first deep learning model and obtain the weight arrangement of the second deep learning model according to the deep learning framework of the second deep learning model; for the first deep learning model and the second deep learning model Two deep learning models perform model quantification; based on the weight arrangement and model quantification results of the first deep learning model, and the weight arrangement and model quantification results of the second deep learning model, the first deep learning model is obtained Weight similarity with the second deep learning model to construct a weight analysis report; respectively test the first deep learning model and the second deep learning model according to a preset test set to construct model performance an estimation report; obtain an optimization suggestion for the second deep learning model according to the weight analysis report and the model performance estimation report, so as to perform model optimization on the second deep learning model; and use the optimized second The deep learning model processes the data to be processed.

與習知技術相比,上述深度學習模型的模型轉換優化裝置、方法及電腦可讀取存儲介質,可實現自動對深度學習模型轉換之前和之後進行深入分析,分析效率高,並可基於分析結果給出模型優化建議,實現最大程度避免出現轉換後的模型性能不佳的情形。 Compared with the conventional technology, the above-mentioned deep learning model conversion optimization device, method and computer-readable storage medium can realize automatic in-depth analysis before and after the conversion of the deep learning model, and the analysis efficiency is high, and can be based on the analysis results Provide model optimization suggestions to avoid poor performance of the converted model to the greatest extent.

10:記憶體 10: Memory

20:處理器 20: Processor

30:模型轉換優化程式 30:Model conversion optimization program

101:轉換模組 101: Conversion Module

102:確定模組 102: Determine the module

103:量化模組 103: Quantization module

104:第一構建模組 104:First Building Mod

105:第二構建模組 105:Second Building Module

106:優化模組 106: Optimize the module

107:處理模組 107: Processing module

100:模型轉換優化裝置 100:Model conversion optimization device

S300、S302、S304、S306、S308、S310、S312:步驟 S300, S302, S304, S306, S308, S310, S312: steps

圖1是本發明一實施方式的模型轉換優化裝置的功能模組圖。 FIG. 1 is a functional module diagram of a model conversion optimization device according to an embodiment of the present invention.

圖2是本發明一實施方式的模型轉換優化程式的功能模組圖。 FIG. 2 is a functional module diagram of a model conversion optimization program according to an embodiment of the present invention.

圖3是本發明一實施方式的模型轉換優化方法的流程圖。 Fig. 3 is a flow chart of a model conversion optimization method according to an embodiment of the present invention.

請參閱圖1,為本發明模型轉換優化裝置較佳實施例的示意圖。 Please refer to FIG. 1 , which is a schematic diagram of a preferred embodiment of the model conversion optimization device of the present invention.

模型轉換優化裝置100可以對不同框架之間的深度學習模型的模型轉換給出模型優化建議,並可對轉換前與轉換後的模型的預測效果進行驗證。模型轉換優化裝置100可以包括記憶體10、處理器20以及存儲在記憶體10中並可在處理器20上運行的模型轉換優化程式30。處理器20執行模型轉換優化程式30時實現模型轉換優化方法實施例中的步驟,例如圖3所示的步驟S300~S312。或者,所述處理器20執行模型轉換優化程式30時實現圖2中各模組的功能,例如模組101~107。 The model conversion optimization device 100 can provide model optimization suggestions for the model conversion of deep learning models between different frameworks, and can verify the prediction effect of the models before conversion and after conversion. The model conversion optimization apparatus 100 may include a memory 10 , a processor 20 and a model conversion optimization program 30 stored in the memory 10 and operable on the processor 20 . When the processor 20 executes the model conversion optimization program 30, the steps in the embodiment of the model conversion optimization method are implemented, such as steps S300-S312 shown in FIG. 3 . Alternatively, when the processor 20 executes the model conversion optimization program 30, the functions of the modules in FIG. 2 are implemented, such as the modules 101-107.

模型轉換優化程式30可以被分割成一個或多個模組,所述一個或者多個模組被存儲在記憶體10中,並由處理器20執行,以完成本發明。所述一個或多個模組可以是能夠完成特定功能的一系列電腦程式指令段,所述指令段用於描述模型轉換優化程式30在模型轉換優化裝置100中的執行過程。例如,模型轉換優化程式30可以被分割成圖2中的轉換模組101、確定模組102、量化模組103、第一構建模組104、第二構建模組105、優化模組106及處理模組107。各模組具體功能參見下圖2中各模組的功能。 The model conversion optimization program 30 can be divided into one or more modules, and the one or more modules are stored in the memory 10 and executed by the processor 20 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of accomplishing specific functions, and the instruction segments are used to describe the execution process of the model conversion optimization program 30 in the model conversion optimization device 100 . For example, the model conversion optimization program 30 can be divided into conversion module 101, determination module 102, quantization module 103, first construction module 104, second construction module 105, optimization module 106 and processing Module 107. For the specific functions of each module, see the functions of each module in Figure 2 below.

本領域技術人員可以理解,所述示意圖僅是模型轉換優化裝置100的示例,並不構成對模型轉換優化裝置100的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如模型轉換優化裝置100還可以包括輸入輸出設備、通信模組、匯流排等。 Those skilled in the art can understand that the schematic diagram is only an example of the model conversion optimization device 100, and does not constitute a limitation to the model conversion optimization device 100, and may include more or less components than those shown in the illustration, or combine certain components , or different components, for example, the model conversion optimization apparatus 100 may also include input and output devices, communication modules, bus bars, and the like.

處理器20可以是中央處理單元(Central Processing Unit,CPU),還 可以是其他通用處理器、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現成可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者處理器20也可以是任何常規的處理器等,處理器20可以利用各種介面和匯流排連接模型轉換優化裝置100的各個部分。 The processor 20 can be a central processing unit (Central Processing Unit, CPU), also It can be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other possible Program logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor 20 can also be any conventional processor, etc. The processor 20 can use various interfaces and buses to connect various parts of the model conversion optimization device 100 .

記憶體10可用於存儲模型轉換優化程式30和/或模組,處理器20通過運行或執行存儲在記憶體10內的電腦程式和/或模組,以及調用存儲在記憶體10內的資料,實現模型轉換優化裝置100的各種功能。記憶體10可以包括高速隨機存取記憶體,還可以包括非易失性記憶體,例如硬碟、記憶體、插接式硬碟,智慧存儲卡(Smart Media Card,SMC),安全數位(Secure Digital,SD)卡,快閃記憶體卡(Flash Card)、至少一個磁碟記憶體件、快閃記憶體器件、或其他易失性固態記憶體件。 The memory 10 can be used to store the model conversion optimization program 30 and/or modules, and the processor 20 runs or executes the computer programs and/or modules stored in the memory 10, and calls the data stored in the memory 10, Various functions of the model conversion optimization device 100 are realized. Memory 10 can include high-speed random access memory, and can also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart memory card (Smart Media Card, SMC), secure digital (Secure Digital (SD) card, flash memory card (Flash Card), at least one disk memory device, flash memory device, or other volatile solid state memory device.

圖2為本發明模型轉換優化程式較佳實施例的功能模組圖。 FIG. 2 is a functional module diagram of a preferred embodiment of the model conversion optimization program of the present invention.

參閱圖2所示,模型轉換優化程式30可以包括轉換模組101、確定模組102、量化模組103、第一構建模組104、第二構建模組105、優化模組106及處理模組107。在一實施方式中,上述模組可以為存儲於記憶體10中且可被處理器20調用執行的可程式化軟體指令。可以理解的是,在其他實施方式中,上述模組也可為固化於處理器20中的程式指令或固件(firmware)。 Referring to Fig. 2, the model conversion optimization program 30 may include a conversion module 101, a determination module 102, a quantization module 103, a first construction module 104, a second construction module 105, an optimization module 106 and a processing module 107. In one embodiment, the above-mentioned modules may be programmable software instructions stored in the memory 10 and called and executed by the processor 20 . It can be understood that, in other embodiments, the above-mentioned modules can also be program instructions or firmware solidified in the processor 20 .

轉換模組101用於對第一深度學習模型進行模型轉換,得到第二深度學習模型。 The conversion module 101 is used to perform model conversion on the first deep learning model to obtain a second deep learning model.

在一實施方式中,所述第一深度學習模型與所述第二深度學習模型優選具有不同的深度學習框架。比如,在模型開發階段,使用Tensorflow框架進行開發與測試得到所述第一深度學習模型,而到了終端部署階段,需使用 NCNN框架的模型來部署到終端,因而需要將具有Tensorflow框架的第一深度學習模型轉換為具有NCNN框架的第二深度學習模型,進而實現將所述第二深度學習模型部署到終端。所述終端可以是手機、平板電腦等電子設備。轉換模組101可以基於預設深度學習模型轉換工具對所述第一深度學習模型進行模型轉換,得到第二深度學習模型。所述預設深度學習模型轉換工具可以是現有的模型轉換器,在此不作限定。 In one embodiment, the first deep learning model and the second deep learning model preferably have different deep learning frameworks. For example, in the model development stage, use the Tensorflow framework for development and testing to obtain the first deep learning model, and in the terminal deployment stage, you need to use The model of the NCNN framework is deployed to the terminal, so the first deep learning model with the Tensorflow framework needs to be converted into a second deep learning model with the NCNN framework, and then the second deep learning model is deployed to the terminal. The terminal may be an electronic device such as a mobile phone or a tablet computer. The conversion module 101 can perform model conversion on the first deep learning model based on a preset deep learning model conversion tool to obtain a second deep learning model. The preset deep learning model conversion tool may be an existing model converter, which is not limited here.

可以理解,所述第一深度學習模型與所述第二深度學習模型的模型功能相同,所述第一深度學習模型與所述第二深度學習模型具有的模型功能可以根據實際開發需求確定。比如,所述第一深度學習模型與所述第二深度學習模型可用於進行圖像識別、語音辨識、影像處理、資料採擷、或自然語言處理等。 It can be understood that the model functions of the first deep learning model and the second deep learning model are the same, and the model functions of the first deep learning model and the second deep learning model can be determined according to actual development requirements. For example, the first deep learning model and the second deep learning model can be used for image recognition, voice recognition, image processing, data collection, or natural language processing.

可以理解,所述第一深度學習模型與所述第二深度學習模型均可以使用訓練樣本庫中的樣本進行模型訓練,該訓練樣本庫中的樣本被劃分為訓練集及驗證集。所述訓練集用於進行模型訓練,所述驗證集用於檢驗模型的性能。 It can be understood that both the first deep learning model and the second deep learning model can use samples in a training sample library for model training, and the samples in the training sample library are divided into a training set and a verification set. The training set is used for model training, and the verification set is used to test the performance of the model.

確定模組102用於根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式。 The determination module 102 is used to obtain the weight arrangement of the first deep learning model according to the deep learning framework of the first deep learning model and obtain the second deep learning model according to the deep learning framework of the second deep learning model. How the weights of the model are arranged.

在一實施方式中,當完成對所述第一深度學習模型進行模型轉換得到所述第二深度學習模型時,確定模組102可以根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式。確定模組102還可以根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式。所述第一深度學習模型的權重排列方式可以表徵所述第一深度學習模型中的權重參數的排列方式,所述第二深度學習模型的權重排列方式可 以表徵所述第二深度學習模型中的權重參數的排列方式。 In an embodiment, when the model transformation of the first deep learning model is completed to obtain the second deep learning model, the determining module 102 can obtain the second deep learning model according to the deep learning framework of the second deep learning model. 2. The weight arrangement of the deep learning model. The determination module 102 can also obtain the weight arrangement of the first deep learning model according to the deep learning framework of the first deep learning model. The weight arrangement of the first deep learning model may represent the arrangement of weight parameters in the first deep learning model, and the weight arrangement of the second deep learning model may be To characterize the arrangement of weight parameters in the second deep learning model.

量化模組103用於對所述第一深度學習模型及所述第二深度學習模型進行模型量化。 The quantization module 103 is used for performing model quantization on the first deep learning model and the second deep learning model.

在一實施方式中,量化模組103可以對所述第一深度學習模型及所述第二深度學習模型執行指定的量化類型的量化操作。比如,所述量化類型可以是只對模型權重進行量化,或對模型權重和模型啟動輸出都進行量化。 In one embodiment, the quantization module 103 may perform a quantization operation of a specified quantization type on the first deep learning model and the second deep learning model. For example, the quantization type may be to quantize only the model weight, or to quantize both the model weight and the model startup output.

在一實施方式中,量化模組103可以基於所述第一深度學習模型的權重排列方式統計得到所述第一深度學習模型的權重分佈資訊,進而根據所述第一深度學習模型的權重分佈資訊對所述第一深度學習模型進行模型量化。所述第一深度學習模型的權重分佈資訊可以表徵所述第一深度學習模型中的權重參數的分佈情況。量化模組103還可以基於所述第二深度學習模型的權重排列方式統計得到所述第二深度學習模型的權重分佈資訊,進而根據所述第二深度學習模型的權重分佈資訊對所述第二深度學習模型進行模型量化。所述第二深度學習模型的權重分佈資訊可以表徵所述第二深度學習模型中的權重參數的分佈情況。 In one embodiment, the quantization module 103 can obtain the weight distribution information of the first deep learning model based on statistics of the weight arrangement of the first deep learning model, and then according to the weight distribution information of the first deep learning model Model quantization is performed on the first deep learning model. The weight distribution information of the first deep learning model may represent the distribution of weight parameters in the first deep learning model. The quantization module 103 can also obtain the weight distribution information of the second deep learning model based on statistics of the weight arrangement of the second deep learning model, and then calculate the weight distribution information of the second deep learning model according to the weight distribution information of the second deep learning model. Model quantization for deep learning models. The weight distribution information of the second deep learning model may represent the distribution of weight parameters in the second deep learning model.

在一實施方式中,量化模組103根據所述第一深度學習模型的權重分佈資訊對所述第一深度學習模型進行模型量化的具體實現方式可以是:量化模組103可以根據所述第一深度學習模型的權重分佈資訊確定對所述第一深度學習模型進行模型量化的位元數(bits)與精度(比如int或float),再基於所確定的位元數與精度對所述第一深度學習模型進行模型量化。量化模組103根據所述第二深度學習模型的權重分佈資訊對所述第二深度學習模型進行模型量化的具體實現方式可以是:量化模組103根據所述第二深度學習模型的權重分佈資訊確定對所述第二深度學習模型進行模型量化的位元數與精度,再基於所確定的位元數與精度對所述第二深度學習模型進行模型量化。 In one embodiment, the quantization module 103 can perform model quantization on the first deep learning model according to the weight distribution information of the first deep learning model. The weight distribution information of the deep learning model determines the number of bits (bits) and precision (such as int or float) for model quantization of the first deep learning model, and then quantifies the first deep learning model based on the determined number of bits and precision. Model quantization for deep learning models. The quantization module 103 can perform model quantization on the second deep learning model according to the weight distribution information of the second deep learning model. Determine the number of bits and precision for model quantization of the second deep learning model, and then perform model quantization on the second deep learning model based on the determined number of bits and precision.

第一構建模組104用於基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告。 The first construction module 104 is configured to obtain the first deep learning model based on the weight arrangement and model quantization results of the first deep learning model, and the weight arrangement and model quantization results of the second deep learning model. and the weight similarity between the second deep learning model to construct a weight analysis report.

在一實施方式中,當量化模組103完成對所述第一深度學習模型及所述第二深度學習模型的模型量化時,第一構建模組104可以基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,進而可以基於分析得到的權重相似度來構建所述權重分析報告。 In one embodiment, when the quantization module 103 completes the model quantization of the first deep learning model and the second deep learning model, the first construction module 104 may base on the weight of the first deep learning model Arrangement and model quantification results, and the weight arrangement and model quantification results of the second deep learning model are analyzed to obtain the weight similarity between the first deep learning model and the second deep learning model, which can then be based on The obtained weight similarity is analyzed to construct the weight analysis report.

在一實施方式中,所述權重分析報告還可以包括所述第一深度學習模型的權重分佈資訊及所述第二深度學習模型的權重分佈資訊。 In an embodiment, the weight analysis report may further include weight distribution information of the first deep learning model and weight distribution information of the second deep learning model.

第二構建模組105根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告。 The second construction module 105 respectively tests the first deep learning model and the second deep learning model according to a preset test set to build a model performance estimation report.

在一實施方式中,所述模型性能估測報告包括所述第一深度學習模型的模型預測性能的測試結果及所述第二深度學習模型的模型預測性能的測試結果。所述預設測試集的資料可以包括用於對所述第一深度學習模型及所述第二深度學習模型進行模型訓練的訓練樣本庫,所述訓練樣本庫的樣本被劃分為訓練集與驗證集。 In one embodiment, the model performance estimation report includes the test results of the model prediction performance of the first deep learning model and the test results of the model prediction performance of the second deep learning model. The data of the preset test set may include a training sample library for model training of the first deep learning model and the second deep learning model, and the samples of the training sample library are divided into a training set and a verification set. set.

舉例而言,所述第一深度學習模型與所述第二深度學習模型的功能為圖像識別,訓練樣本庫包括1000張圖像樣本,其中訓練集包括800張圖像樣本,驗證集包括200張圖像樣本。在所述第一深度學習模型的模型訓練過程中,利用訓練集的圖像樣本對所述第一深度學習模型進行訓練,利用驗證集的圖像樣本校驗訓練後的第一深度學習模型的預測效果。在所述第二深度學習模 型的模型訓練過程中,同樣利用訓練集的圖像樣本對所述第二深度學習模型進行訓練,利用驗證集的圖像樣本校驗訓練後的第二深度學習模型的預測效果。所述預設測試集包括訓練樣本庫的所有圖像樣本,即第二構建模組105利用1000張圖像樣本對所述第一深度學習模型進行測試及利用1000張圖像樣本對所述第二深度學習模型進行測試,以根據測試結果來構建所述模型性能估測報告。 For example, the function of the first deep learning model and the second deep learning model is image recognition, and the training sample library includes 1000 image samples, wherein the training set includes 800 image samples, and the verification set includes 200 sample image. In the model training process of the first deep learning model, the image samples of the training set are used to train the first deep learning model, and the image samples of the verification set are used to verify the trained first deep learning model. predictive effect. In the second deep learning model During the training process of the type model, the image samples of the training set are also used to train the second deep learning model, and the image samples of the verification set are used to verify the prediction effect of the trained second deep learning model. The preset test set includes all image samples in the training sample library, that is, the second construction module 105 uses 1000 image samples to test the first deep learning model and uses 1000 image samples to test the first deep learning model. Two deep learning models are tested, so as to build the model performance estimation report according to the test results.

在一實施方式中,所述預設測試集的資料還可以包括未包含在所述訓練樣本庫中的現場樣本集,即模型在訓練過程中未接觸過的樣本資料。當所述第二深度學習模型部署在所述終端時,所述現場樣本集可以是指終端在實際測試使用場景中獲取的樣本資料。比如,所述第二深度學習模型是用來進行人臉識別的人臉識別模型,所述現場樣本集可以是終端在被使用過程中採集到的人臉圖像。 In one embodiment, the data of the preset test set may also include live sample sets not included in the training sample library, that is, sample data that the model has not been exposed to during the training process. When the second deep learning model is deployed on the terminal, the on-site sample set may refer to sample data acquired by the terminal in an actual test usage scenario. For example, the second deep learning model is a face recognition model used for face recognition, and the on-site sample set may be face images collected by the terminal during use.

在一實施方式中,所述預設測試集的資料還可以包括對所述驗證集進行擴增而生成的擴增樣本集。比如,可以對所述驗證集中的樣本進行翻轉、鏡像等操作,進而得到所述擴增樣本集。 In one embodiment, the data of the preset test set may also include an augmented sample set generated by augmenting the verification set. For example, operations such as flipping and mirroring may be performed on the samples in the verification set to obtain the augmented sample set.

舉例而言,所述驗證集可以200張圖像樣本,通過對驗證集中的多張圖像樣本進行平移、翻轉、旋轉、調整對比度、高斯雜訊、顏色變換等操作得到2000張圖像樣本,該2000張圖像樣本即構成所述擴增樣本集。 For example, the verification set can be 200 image samples, and 2000 image samples are obtained by performing operations such as translation, flipping, rotation, contrast adjustment, Gaussian noise, and color transformation on multiple image samples in the verification set. The 2000 image samples constitute the augmented sample set.

在一實施方式中,第二構建模組105根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告的具體方式可以包括:第二構建模組105利用所述訓練樣本庫、所述現場樣本集及所述擴增樣本集對所述第一深度學習模型與所述第二深度學習模型進行測試,再根據所述訓練樣本庫得到的第一測試結果、所述現場樣本集得到的第二測試結果及所述擴增樣本集得到的第三測試結果構建所述模型性能估測報告。 In one embodiment, the second construction module 105 respectively tests the first deep learning model and the second deep learning model according to a preset test set, so as to construct a model performance estimation report. Specific ways may include: The second construction module 105 uses the training sample library, the on-site sample set and the expanded sample set to test the first deep learning model and the second deep learning model, and then according to the training samples The first test result obtained from the library, the second test result obtained from the on-site sample set, and the third test result obtained from the expanded sample set construct the model performance estimation report.

優化模組106用於根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化。 The optimization module 106 is used to obtain optimization suggestions for the second deep learning model according to the weight analysis report and the model performance estimation report, so as to optimize the second deep learning model.

在一實施方式中,當得到所述權重分析報告及所述模型性能估測報告時,優化模組106可以根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化,進而可以提高部署在所述終端的第二深度學習模型的模型預測準確性,節省模型所佔用的運算資源。 In one embodiment, when the weight analysis report and the model performance estimation report are obtained, the optimization module 106 can obtain the second deep learning model according to the weight analysis report and the model performance estimation report The optimization suggestion is used to perform model optimization on the second deep learning model, thereby improving the model prediction accuracy of the second deep learning model deployed on the terminal, and saving computing resources occupied by the model.

在一實施方式中,當優化模組106根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議時,模型開發人員或者終端使用者可以控制所述第二深度學習模型執行所述優化建議。 In one embodiment, when the optimization module 106 obtains an optimization suggestion for the second deep learning model according to the weight analysis report and the model performance estimation report, the model developer or end user can control the second deep learning model. Two deep learning models execute the optimization suggestion.

處理模組107用於利用優化後的第二深度學習模型對待處理資料進行處理。 The processing module 107 is used to use the optimized second deep learning model to process the data to be processed.

在一實施方式中,所述待處理資料可以是指部署有所述第二深度學習模型的終端在實際使用場景中獲取並輸入至所述第二深度學習模型的輸入資料。當所述第二深度學習模型執行所述優化建議後,處理模組107可以利用優化後的第二深度學習模型對所述待處理資料進行處理,以得到所述待處理資料對應的處理結果。 In an implementation manner, the data to be processed may refer to input data obtained by a terminal deployed with the second deep learning model in an actual usage scenario and input to the second deep learning model. After the second deep learning model executes the optimization suggestion, the processing module 107 can use the optimized second deep learning model to process the data to be processed to obtain a processing result corresponding to the data to be processed.

圖3為本發明一實施方式中深度學習模型的模型轉換優化方法的流程圖。根據不同的需求,所述流程圖中步驟的順序可以改變,某些步驟可以省略。 Fig. 3 is a flowchart of a model conversion optimization method for a deep learning model in an embodiment of the present invention. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

步驟S300,對第一深度學習模型進行模型轉換,得到第二深度學習模型。 Step S300, performing model conversion on the first deep learning model to obtain a second deep learning model.

在一實施方式中,所述第一深度學習模型與所述第二深度學習模 型優選具有不同的深度學習框架。比如,在模型開發階段,使用Tensorflow框架進行開發與測試得到所述第一深度學習模型,而到了終端部署階段,需使用NCNN框架的模型來部署到終端,因而需要將具有Tensorflow框架的第一深度學習模型轉換為具有NCNN框架的第二深度學習模型,進而實現將所述第二深度學習模型部署到終端。所述終端可以是手機、平板電腦等電子設備。可以基於預設深度學習模型轉換工具對所述第一深度學習模型進行模型轉換,得到第二深度學習模型。所述預設深度學習模型轉換工具可以是現有的模型轉換器,在此不作限定。 In one embodiment, the first deep learning model and the second deep learning model Model optimization has different deep learning frameworks. For example, in the model development stage, the Tensorflow framework is used for development and testing to obtain the first deep learning model, and in the terminal deployment stage, the model of the NCNN framework needs to be deployed to the terminal, so the first deep learning model with the Tensorflow framework needs to be The learning model is converted into a second deep learning model with an NCNN framework, and then the second deep learning model is deployed to the terminal. The terminal may be an electronic device such as a mobile phone or a tablet computer. The first deep learning model may be converted based on a preset deep learning model conversion tool to obtain a second deep learning model. The preset deep learning model conversion tool may be an existing model converter, which is not limited here.

可以理解,所述第一深度學習模型與所述第二深度學習模型的模型功能相同,所述第一深度學習模型與所述第二深度學習模型具有的模型功能可以根據實際開發需求確定。比如,所述第一深度學習模型與所述第二深度學習模型可用於進行圖像識別、語音辨識、影像處理、資料採擷、或自然語言處理等。 It can be understood that the model functions of the first deep learning model and the second deep learning model are the same, and the model functions of the first deep learning model and the second deep learning model can be determined according to actual development requirements. For example, the first deep learning model and the second deep learning model can be used for image recognition, voice recognition, image processing, data collection, or natural language processing.

步驟S302,根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式。 Step S302, obtaining the weight arrangement of the first deep learning model according to the deep learning framework of the first deep learning model and obtaining the weights of the second deep learning model according to the deep learning framework of the second deep learning model Arrangement.

在一實施方式中,當完成對所述第一深度學習模型進行模型轉換得到所述第二深度學習模型時,可以根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式。還可以根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式。所述第一深度學習模型的權重排列方式可以表徵所述第一深度學習模型中的權重參數的排列方式,所述第二深度學習模型的權重排列方式可以表徵所述第二深度學習模型中的權重參數的排列方式。 In one embodiment, when the model conversion of the first deep learning model is completed to obtain the second deep learning model, the second deep learning model can be obtained according to the deep learning framework of the second deep learning model weighted arrangement. The weight arrangement manner of the first deep learning model may also be obtained according to the deep learning framework of the first deep learning model. The weight arrangement of the first deep learning model can represent the arrangement of weight parameters in the first deep learning model, and the weight arrangement of the second deep learning model can represent the arrangement of weight parameters in the second deep learning model. The arrangement of weight parameters.

步驟S304,對所述第一深度學習模型及所述第二深度學習模型進 行模型量化。 Step S304, performing an operation on the first deep learning model and the second deep learning model Row model quantization.

在一實施方式中,可以對所述第一深度學習模型及所述第二深度學習模型執行指定的量化類型的量化操作。比如,所述量化類型可以是只對模型權重進行量化,或對模型權重和模型啟動輸出都進行量化。 In an embodiment, a quantization operation of a specified quantization type may be performed on the first deep learning model and the second deep learning model. For example, the quantization type may be to quantize only the model weight, or to quantize both the model weight and the model startup output.

在一實施方式中,可以基於所述第一深度學習模型的權重排列方式統計得到所述第一深度學習模型的權重分佈資訊,進而根據所述第一深度學習模型的權重分佈資訊對所述第一深度學習模型進行模型量化。所述第一深度學習模型的權重分佈資訊可以表徵所述第一深度學習模型中的權重參數的分佈情況。還可以基於所述第二深度學習模型的權重排列方式統計得到所述第二深度學習模型的權重分佈資訊,進而根據所述第二深度學習模型的權重分佈資訊對所述第二深度學習模型進行模型量化。所述第二深度學習模型的權重分佈資訊可以表徵所述第二深度學習模型中的權重參數的分佈情況。 In one embodiment, the weight distribution information of the first deep learning model can be statistically obtained based on the weight arrangement of the first deep learning model, and then the first deep learning model can be calculated according to the weight distribution information of the first deep learning model. A deep learning model for model quantization. The weight distribution information of the first deep learning model may represent the distribution of weight parameters in the first deep learning model. The weight distribution information of the second deep learning model can also be obtained statistically based on the weight arrangement of the second deep learning model, and then the second deep learning model can be calculated according to the weight distribution information of the second deep learning model. Model quantization. The weight distribution information of the second deep learning model may represent the distribution of weight parameters in the second deep learning model.

在一實施方式中,根據所述第一深度學習模型的權重分佈資訊對所述第一深度學習模型進行模型量化的步驟可以包括:根據所述第一深度學習模型的權重分佈資訊確定對所述第一深度學習模型進行模型量化的位元數(bits)與精度(比如int或float),再基於所確定的位元數與精度對所述第一深度學習模型進行模型量化。根據所述第二深度學習模型的權重分佈資訊對所述第二深度學習模型進行模型量化的步驟可以包括:根據所述第二深度學習模型的權重分佈資訊確定對所述第二深度學習模型進行模型量化的位元數與精度,再基於所確定的位元數與精度對所述第二深度學習模型進行模型量化。 In an embodiment, the step of performing model quantization on the first deep learning model according to the weight distribution information of the first deep learning model may include: determining the weight distribution information of the first deep learning model to the The number of bits (bits) and precision (such as int or float) for model quantization of the first deep learning model, and then model quantization of the first deep learning model based on the determined number of bits and precision. The step of performing model quantification on the second deep learning model according to the weight distribution information of the second deep learning model may include: determining to quantify the second deep learning model according to the weight distribution information of the second deep learning model The number of bits and precision of model quantization, and then perform model quantization on the second deep learning model based on the determined number of bits and precision.

步驟S306,基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告。 Step S306, based on the weight arrangement and model quantization results of the first deep learning model, and the weight arrangement and model quantification results of the second deep learning model, the first deep learning model and the second deep learning model are obtained. Weight similarity between deep learning models to build weight analysis reports.

在一實施方式中,當完成對所述第一深度學習模型及所述第二深度學習模型的模型量化時,可以基於所述第一深度學習模型的權重排列方式與模型量化結果,及所述第二深度學習模型的權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,進而可以基於分析得到的權重相似度來構建所述權重分析報告。 In one embodiment, when the model quantization of the first deep learning model and the second deep learning model is completed, it may be based on the weight arrangement and model quantization results of the first deep learning model, and the The weight arrangement mode of the second deep learning model and the model quantification result are analyzed to obtain the weight similarity between the first deep learning model and the second deep learning model, and then the weight similarity obtained based on the analysis can be used to construct the Weight analysis report.

在一實施方式中,所述權重分析報告還可以包括所述第一深度學習模型的權重分佈資訊及所述第二深度學習模型的權重分佈資訊。 In an embodiment, the weight analysis report may further include weight distribution information of the first deep learning model and weight distribution information of the second deep learning model.

步驟S308,根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告。 Step S308, respectively test the first deep learning model and the second deep learning model according to a preset test set, so as to build a model performance estimation report.

在一實施方式中,所述模型性能估測報告包括所述第一深度學習模型的模型預測性能的測試結果及所述第二深度學習模型的模型預測性能的測試結果。所述預設測試集的資料可以包括用於對所述第一深度學習模型及所述第二深度學習模型進行模型訓練的訓練樣本庫,所述訓練樣本庫的樣本被劃分為訓練集與驗證集。 In one embodiment, the model performance estimation report includes the test results of the model prediction performance of the first deep learning model and the test results of the model prediction performance of the second deep learning model. The data of the preset test set may include a training sample library for model training of the first deep learning model and the second deep learning model, and the samples of the training sample library are divided into a training set and a verification set. set.

舉例而言,所述第一深度學習模型與所述第二深度學習模型的功能為圖像識別,訓練樣本庫包括1000張圖像樣本,其中訓練集包括800張圖像樣本,驗證集包括200張圖像樣本。在所述第一深度學習模型的模型訓練過程中,利用訓練集的圖像樣本對所述第一深度學習模型進行訓練,利用驗證集的圖像樣本校驗訓練後的第一深度學習模型的預測效果。在所述第二深度學習模型的模型訓練過程中,同樣利用訓練集的圖像樣本對所述第二深度學習模型進行訓練,利用驗證集的圖像樣本校驗訓練後的第二深度學習模型的預測效果。所述預設測試集包括訓練樣本庫的所有圖像樣本,即利用1000張圖像樣本對所述第一深度學習模型進行測試及利用1000張圖像樣本對所述第二深度學習模型進行測試,以根據測試結果來構建所述模型性能估測報告。 For example, the function of the first deep learning model and the second deep learning model is image recognition, and the training sample library includes 1000 image samples, wherein the training set includes 800 image samples, and the verification set includes 200 sample image. In the model training process of the first deep learning model, the image samples of the training set are used to train the first deep learning model, and the image samples of the verification set are used to verify the trained first deep learning model. predictive effect. In the model training process of the second deep learning model, the image samples of the training set are also used to train the second deep learning model, and the image samples of the verification set are used to verify the trained second deep learning model prediction effect. The preset test set includes all image samples in the training sample library, that is, using 1000 image samples to test the first deep learning model and using 1000 image samples to test the second deep learning model , so as to construct the model performance estimation report according to the test results.

在一實施方式中,所述預設測試集的資料還可以包括未包含在所述訓練樣本庫中的現場樣本集,即模型在訓練過程中未接觸過的樣本資料。當所述第二深度學習模型部署在所述終端時,所述現場樣本集可以是指終端在實際測試使用場景中獲取的樣本資料。比如,所述第二深度學習模型是用來進行人臉識別的人臉識別模型,所述現場樣本集可以是終端在被使用過程中採集到的人臉圖像。 In one embodiment, the data of the preset test set may also include live sample sets not included in the training sample library, that is, sample data that the model has not been exposed to during the training process. When the second deep learning model is deployed on the terminal, the on-site sample set may refer to sample data acquired by the terminal in an actual test usage scenario. For example, the second deep learning model is a face recognition model used for face recognition, and the on-site sample set may be face images collected by the terminal during use.

在一實施方式中,所述預設測試集的資料還可以包括對所述驗證集進行擴增而生成的擴增樣本集。比如,可以對所述驗證集中的樣本進行翻轉、鏡像等操作,進而得到所述擴增樣本集。 In one embodiment, the data of the preset test set may also include an augmented sample set generated by augmenting the verification set. For example, operations such as flipping and mirroring may be performed on the samples in the verification set to obtain the augmented sample set.

舉例而言,所述驗證集可以200張圖像樣本,通過對驗證集中的多張圖像樣本進行平移、翻轉、旋轉、調整對比度、高斯雜訊、顏色變換等操作得到2000張圖像樣本,該2000張圖像樣本即構成所述擴增樣本集。 For example, the verification set can be 200 image samples, and 2000 image samples are obtained by performing operations such as translation, flipping, rotation, contrast adjustment, Gaussian noise, and color transformation on multiple image samples in the verification set. The 2000 image samples constitute the augmented sample set.

在一實施方式中,根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告的步驟可以包括:利用所述訓練樣本庫、所述現場樣本集及所述擴增樣本集對所述第一深度學習模型與所述第二深度學習模型進行測試,再根據所述訓練樣本庫得到的第一測試結果、所述現場樣本集得到的第二測試結果及所述擴增樣本集得到的第三測試結果構建所述模型性能估測報告。 In one embodiment, the step of testing the first deep learning model and the second deep learning model according to a preset test set to construct a model performance estimation report may include: using the training sample library, The on-site sample set and the expanded sample set test the first deep learning model and the second deep learning model, and then according to the first test result obtained from the training sample library, the on-site sample set The second test result obtained and the third test result obtained from the amplified sample set construct the model performance estimation report.

步驟S310,根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化。 Step S310, obtaining an optimization suggestion for the second deep learning model according to the weight analysis report and the model performance estimation report, so as to optimize the second deep learning model.

在一實施方式中,當得到所述權重分析報告及所述模型性能估測報告時,可以根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化,進而可以 提高部署在所述終端的第二深度學習模型的模型預測準確性,節省模型所佔用的運算資源。 In one embodiment, when the weight analysis report and the model performance estimation report are obtained, an optimization suggestion for the second deep learning model can be obtained according to the weight analysis report and the model performance estimation report, To perform model optimization on the second deep learning model, and then can The model prediction accuracy of the second deep learning model deployed on the terminal is improved, and computing resources occupied by the model are saved.

在一實施方式中,當根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議時,模型開發人員或者終端使用者可以控制所述第二深度學習模型執行所述優化建議。 In one embodiment, when the optimization suggestion of the second deep learning model is obtained according to the weight analysis report and the model performance estimation report, the model developer or end user can control the second deep learning model Execute the optimization suggestion.

步驟S312,利用優化後的第二深度學習模型對待處理資料進行處理。 Step S312, using the optimized second deep learning model to process the data to be processed.

在一實施方式中,所述待處理資料可以是指部署有所述第二深度學習模型的終端在實際使用場景中獲取並輸入至所述第二深度學習模型的輸入資料。當所述第二深度學習模型執行所述優化建議後,可以利用優化後的第二深度學習模型對所述待處理資料進行處理,以得到所述待處理資料對應的處理結果。 In an implementation manner, the data to be processed may refer to input data obtained by a terminal deployed with the second deep learning model in an actual usage scenario and input to the second deep learning model. After the second deep learning model executes the optimization suggestion, the optimized second deep learning model may be used to process the data to be processed, so as to obtain a processing result corresponding to the data to be processed.

上述深度學習模型的模型轉換優化裝置、方法及電腦可讀取存儲介質,可實現自動對深度學習模型轉換之前和之後進行深入分析,分析效率高,並可基於分析結果給出模型優化建議,實現最大程度避免出現轉換後的模型性能不佳的情形。 The model conversion optimization device, method and computer-readable storage medium for the above-mentioned deep learning model can realize automatic in-depth analysis before and after the conversion of the deep learning model, and the analysis efficiency is high, and model optimization suggestions can be given based on the analysis results to realize Minimize situations where the converted model performs poorly.

綜上所述,本發明符合發明專利要件,爰依法提出專利申請。惟,以上所述者僅為本發明之較佳實施方式,本發明之範圍並不以上述實施方式為限,舉凡熟悉本案技藝之人士爰依本發明之精神所作之等效修飾或變化,皆應涵蓋於以下申請專利範圍內。 In summary, the present invention meets the requirements of an invention patent, and a patent application is filed according to law. However, what is described above is only a preferred embodiment of the present invention, and the scope of the present invention is not limited to the above-mentioned embodiments. For example, all equivalent modifications or changes made by those who are familiar with the technology of this case according to the spirit of the present invention are acceptable. Should be covered in the scope of the following patent applications.

S300、S302、S304、S306、S308、S310、S312:步驟 S300, S302, S304, S306, S308, S310, S312: steps

Claims (10)

一種深度學習模型的模型轉換優化方法,所述方法包括:對第一深度學習模型進行模型轉換,得到第二深度學習模型,其中所述第一深度學習模型與所述第二深度學習模型具有不同的深度學習框架;根據所述第一深度學習模型的深度學習框架得到所述第一深度學習模型的權重排列方式及根據所述第二深度學習模型的深度學習框架得到所述第二深度學習模型的權重排列方式;對所述第一深度學習模型及所述第二深度學習模型進行模型量化;基於所述第一深度學習模型的所述權重排列方式與模型量化結果,及所述第二深度學習模型的所述權重排列方式與模型量化結果分析得到所述第一深度學習模型與所述第二深度學習模型之間的權重相似度,以構建權重分析報告;根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建模型性能估測報告;根據所述權重分析報告及所述模型性能估測報告得到所述第二深度學習模型的優化建議,以對所述第二深度學習模型進行模型優化;及利用優化後的第二深度學習模型對待處理資料進行處理。 A model conversion optimization method for a deep learning model, the method comprising: performing model conversion on a first deep learning model to obtain a second deep learning model, wherein the first deep learning model is different from the second deep learning model The deep learning framework of the first deep learning model; the weight arrangement of the first deep learning model is obtained according to the deep learning framework of the first deep learning model and the second deep learning model is obtained according to the deep learning framework of the second deep learning model The weight arrangement of the first deep learning model and the second deep learning model are quantified; based on the weight arrangement and model quantization results of the first deep learning model, and the second depth The weight arrangement of the learning model and the model quantification results are analyzed to obtain the weight similarity between the first deep learning model and the second deep learning model, so as to construct a weight analysis report; Test the first deep learning model and the second deep learning model to build a model performance estimation report; obtain optimization suggestions for the second deep learning model according to the weight analysis report and the model performance estimation report , to perform model optimization on the second deep learning model; and use the optimized second deep learning model to process the data to be processed. 如請求項1所述之深度學習模型的模型轉換優化方法,其中所述對所述第一深度學習模型及所述第二深度學習模型進行模型量化的步驟包括:基於所述第一深度學習模型的所述權重排列方式統計得到所述第一深度學習模型的權重分佈資訊,及根據所述第一深度學習模型的所述權重分佈資訊對所述第一深度學習模型進行模型量化;及基於所述第二深度學習模型的所述權重排列方式統計得到所述第二深度學習模型的權重分佈資訊,及根據所述第二深度學習模型的所述權重分佈資訊對 所述第二深度學習模型進行模型量化。 The model conversion optimization method for a deep learning model as described in Claim 1, wherein the step of quantifying the first deep learning model and the second deep learning model includes: based on the first deep learning model Obtain the weight distribution information of the first deep learning model according to the weight arrangement method, and perform model quantization on the first deep learning model according to the weight distribution information of the first deep learning model; and based on the weight distribution information of the first deep learning model; Obtaining the weight distribution information of the second deep learning model according to the weight arrangement method of the second deep learning model, and according to the weight distribution information of the second deep learning model The second deep learning model performs model quantization. 如請求項2所述之深度學習模型的模型轉換優化方法,其中所述權重分析報告還包括所述第一深度學習模型的所述權重分佈資訊及所述第二深度學習模型的所述權重分佈資訊。 The model conversion optimization method for a deep learning model as described in Claim 2, wherein the weight analysis report further includes the weight distribution information of the first deep learning model and the weight distribution of the second deep learning model Information. 如請求項2所述之深度學習模型的模型轉換優化方法,其中所述根據所述第一深度學習模型的所述權重分佈資訊對所述第一深度學習模型進行模型量化的步驟包括:根據所述第一深度學習模型的所述權重分佈資訊確定對所述第一深度學習模型進行模型量化的位元數與精度,以基於所確定的所述位元數與所述精度對所述第一深度學習模型進行模型量化。 The model conversion optimization method for a deep learning model as described in Claim 2, wherein the step of performing model quantization on the first deep learning model according to the weight distribution information of the first deep learning model includes: according to the weight distribution information of the first deep learning model The weight distribution information of the first deep learning model determines the number of bits and precision for model quantization of the first deep learning model, so as to quantify the first deep learning model based on the determined number of bits and the precision. Model quantization for deep learning models. 如請求項2所述之深度學習模型的模型轉換優化方法,其中所述根據所述第二深度學習模型的所述權重分佈資訊對所述第二深度學習模型進行模型量化的步驟包括:根據所述第二深度學習模型的所述權重分佈資訊確定對所述第二深度學習模型進行模型量化的位元數與精度,以基於所確定的所述位元數與所述精度對所述第二深度學習模型進行模型量化。 The model conversion optimization method for a deep learning model as described in Claim 2, wherein the step of performing model quantization on the second deep learning model according to the weight distribution information of the second deep learning model includes: according to the weight distribution information of the second deep learning model The weight distribution information of the second deep learning model determines the number of bits and precision for model quantization of the second deep learning model, so as to quantify the second deep learning model based on the determined number of bits and the precision. Model quantization for deep learning models. 如請求項1所述之深度學習模型的模型轉換優化方法,其中所述預設測試集的資料包括用於對所述第一深度學習模型及所述第二深度學習模型進行模型訓練的訓練樣本庫,所述訓練樣本庫的樣本被劃分為訓練集與驗證集。 The model conversion optimization method of the deep learning model as described in claim 1, wherein the data of the preset test set includes training samples for model training of the first deep learning model and the second deep learning model library, the samples of the training sample library are divided into training set and verification set. 如請求項6所述之深度學習模型的模型轉換優化方法,其中所述預設測試集的資料還包括未包含在所述訓練樣本庫中的現場樣本集和/或對所述驗證集進行擴增而生成的擴增樣本集。 The model conversion optimization method of the deep learning model as described in claim item 6, wherein the data of the preset test set also includes an on-site sample set not included in the training sample library and/or expanding the verification set The augmented sample set generated by the increase. 如請求項7所述之深度學習模型的模型轉換優化方法,其中所 述根據預設測試集分別對所述第一深度學習模型與所述第二深度學習模型進行測試,以構建所述模型性能估測報告的步驟包括:利用所述訓練樣本庫、所述現場樣本集及所述擴增樣本集對所述第一深度學習模型與所述第二深度學習模型進行測試;及根據所述訓練樣本庫得到的第一測試結果、所述現場樣本集得到的第二測試結果及所述擴增樣本集得到的第三測試結果構建所述模型性能估測報告。 The model conversion optimization method of the deep learning model as described in claim item 7, wherein the The step of respectively testing the first deep learning model and the second deep learning model according to the preset test set to construct the model performance estimation report includes: using the training sample library, the field sample set and the expanded sample set to test the first deep learning model and the second deep learning model; and the first test result obtained according to the training sample library and the second The test result and the third test result obtained from the amplified sample set construct the model performance estimation report. 一種深度學習模型的模型轉換優化裝置,所述裝置包括處理器及記憶體,所述記憶體上存儲有複數電腦程式,所述處理器用於執行記憶體中存儲之電腦程式時實現如請求項1至8中任一項所述之深度學習模型的模型轉換優化方法之步驟。 A model conversion and optimization device for a deep learning model, the device includes a processor and a memory, and a plurality of computer programs are stored in the memory, and the processor is used to execute the computer programs stored in the memory to achieve claim 1 The steps of the model conversion optimization method of the deep learning model described in any one of to 8. 一種電腦可讀取存儲介質,所述電腦可讀取存儲介質存儲有多條指令,多條所述指令可被一個或者多個處理器執行,以實現如請求項1至8中任一項所述之深度學習模型的模型轉換優化方法之步驟。 A computer-readable storage medium, the computer-readable storage medium stores a plurality of instructions, and the plurality of instructions can be executed by one or more processors, so as to implement any one of the requirements 1 to 8 The steps of the model conversion optimization method for the deep learning model described above.
TW109128492A 2020-08-20 2020-08-20 Device and method for optimizing model conversion of deep learning model, and storage medium TWI786430B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109128492A TWI786430B (en) 2020-08-20 2020-08-20 Device and method for optimizing model conversion of deep learning model, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109128492A TWI786430B (en) 2020-08-20 2020-08-20 Device and method for optimizing model conversion of deep learning model, and storage medium

Publications (2)

Publication Number Publication Date
TW202209147A TW202209147A (en) 2022-03-01
TWI786430B true TWI786430B (en) 2022-12-11

Family

ID=81747142

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109128492A TWI786430B (en) 2020-08-20 2020-08-20 Device and method for optimizing model conversion of deep learning model, and storage medium

Country Status (1)

Country Link
TW (1) TWI786430B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116415689A (en) * 2023-03-29 2023-07-11 北京沃东天骏信息技术有限公司 Model quantization method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110533162A (en) * 2019-07-25 2019-12-03 中国科学院计算技术研究所 It is a kind of to automatically generate the method and system that mapping is operated between deep learning frame
US20200151019A1 (en) * 2019-03-14 2020-05-14 Rednova Innovations,Inc. OPU-based CNN acceleration method and system
TW202029023A (en) * 2019-01-29 2020-08-01 鴻齡科技股份有限公司 Fire development situation trend method, device and computer storable medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW202029023A (en) * 2019-01-29 2020-08-01 鴻齡科技股份有限公司 Fire development situation trend method, device and computer storable medium
US20200151019A1 (en) * 2019-03-14 2020-05-14 Rednova Innovations,Inc. OPU-based CNN acceleration method and system
CN110533162A (en) * 2019-07-25 2019-12-03 中国科学院计算技术研究所 It is a kind of to automatically generate the method and system that mapping is operated between deep learning frame

Also Published As

Publication number Publication date
TW202209147A (en) 2022-03-01

Similar Documents

Publication Publication Date Title
CN116991711A (en) Test case generation method and device, terminal equipment and storage medium
US9857421B2 (en) Dynamic design partitioning for diagnosis
CN105701008A (en) Integrated automated test case generation for safety-critical software
CN112597718B (en) Verification method, verification device and storage medium for integrated circuit design
WO2022027913A1 (en) Target detection model generating method and apparatus, device and storage medium
CN113627107B (en) Method, device, electronic device and medium for determining power supply voltage data
CN111639470A (en) Simulation test method and system for processor cooperative chip and related components
CN110969600A (en) A product defect detection method, device, electronic device and storage medium
CN111309596B (en) Database testing method, device, terminal equipment and storage medium
CN113887722A (en) Neural network testing method and device, computer equipment and storage medium
CN112527676A (en) Model automation test method, device and storage medium
CN109840212A (en) Function test method, device, equipment and the readable storage medium storing program for executing of application program
CN114077884B (en) Model conversion optimization device, method and readable storage medium for deep learning model
CN109858548B (en) Method and device for judging abnormal power consumption, storage medium and communication terminal
TWI786430B (en) Device and method for optimizing model conversion of deep learning model, and storage medium
CN113377593A (en) CPU failure position positioning analysis method and related product
CN115511262A (en) Transformer quality detection method and device
WO2021134810A1 (en) Support-point parallel enumeration load-balancing method, apparatus, device, and medium
CN118626399A (en) Operator precision verification method, system, electronic device and storage medium
CN119476150A (en) Method, device, equipment and medium for verifying chip functional coverage
CN112712181A (en) Model construction optimization method, device, equipment and readable storage medium
EP4645095A1 (en) Program memory overflow early warning method and system, electronic device, and computer storage medium
CN115437958A (en) Automatic tuning method, device, equipment and storage medium for software testing environment
CN115033434A (en) Kernel performance theoretical value calculation method and device and storage medium
CN115510782A (en) Method for locating verification error, electronic device and storage medium