[go: up one dir, main page]

CN114462582A - Data processing method, device and equipment based on convolutional neural network model - Google Patents

Data processing method, device and equipment based on convolutional neural network model Download PDF

Info

Publication number
CN114462582A
CN114462582A CN202210183475.3A CN202210183475A CN114462582A CN 114462582 A CN114462582 A CN 114462582A CN 202210183475 A CN202210183475 A CN 202210183475A CN 114462582 A CN114462582 A CN 114462582A
Authority
CN
China
Prior art keywords
pruning
convolutional neural
target
neural network
algorithm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210183475.3A
Other languages
Chinese (zh)
Inventor
刘瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210183475.3A priority Critical patent/CN114462582A/en
Publication of CN114462582A publication Critical patent/CN114462582A/en
Pending legal-status Critical Current

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
    • G06N3/082Learning methods modifying the architecture, e.g. adding, deleting or silencing nodes or connections

Landscapes

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

Abstract

The embodiment of the application can be applied to various scenes such as cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and the like, and particularly discloses a data processing method, device and equipment based on a convolutional neural network model. The method comprises the following steps: acquiring a convolutional neural network model to be processed and a pruning configuration file matched with the convolutional neural network model; identifying a network structure of the convolutional neural network model based on an identification algorithm to obtain a target network structure, and determining a target pruning algorithm based on a pruning configuration file, wherein the target pruning algorithm is independent of the identification algorithm; pruning the target network structure based on a target pruning algorithm to obtain a pruned convolutional neural network model; and processing the data to be processed based on the pruned convolutional neural network model to obtain a processing result. According to the technical scheme of the embodiment of the application, the data processing efficiency based on the convolutional neural network model is improved, and the data processing scheme based on the convolutional neural network model is greatly optimized.

Description

基于卷积神经网络模型的数据处理方法及装置、设备Data processing method, device and equipment based on convolutional neural network model

技术领域technical field

本申请涉及计算机技术领域,具体而言,涉及一种基于卷积神经网络模型的数据处理方法、基于卷积神经网络模型的数据处理装置、电子设备及计算机可读介质。The present application relates to the field of computer technology, and in particular, to a data processing method based on a convolutional neural network model, a data processing apparatus based on a convolutional neural network model, an electronic device, and a computer-readable medium.

背景技术Background technique

相关技术中基于卷积神经网络模型的数据处理方案通常是先对卷积神经网络模型进行训练,之后基于训练后的卷积神经网络模型进行剪枝优化,之后再基于剪枝优化后的卷积神经网络模型进行相应数据处理。其中,在剪枝优化的过程中,通常是由相关工作者手动选取合适的剪枝算法进行剪枝优化,但是这样的剪枝优化方式效率较低,从而使得基于剪枝优化后的卷积神经网络模型进行相应数据处理的效率也较低。The data processing scheme based on the convolutional neural network model in the related art usually firstly trains the convolutional neural network model, then performs pruning and optimization based on the trained convolutional neural network model, and then performs pruning and optimization based on the convolutional neural network model after the pruning optimization. The neural network model performs corresponding data processing. Among them, in the process of pruning optimization, relevant workers usually manually select a suitable pruning algorithm for pruning optimization, but such a pruning optimization method is inefficient, which makes the convolutional neural network based on pruning optimization. The network model is also less efficient for corresponding data processing.

可见,如何提升基于卷积神经网络模型的数据处理效率是亟待解决的问题。It can be seen that how to improve the data processing efficiency based on the convolutional neural network model is an urgent problem to be solved.

发明内容SUMMARY OF THE INVENTION

为解决上述技术问题,本申请的实施例提供了一种基于卷积神经网络模型的数据处理方法及装置、设备、介质,进而至少在一定程度上提升了基于卷积神经网络模型的数据处理效率。In order to solve the above technical problems, the embodiments of the present application provide a data processing method, device, equipment, and medium based on a convolutional neural network model, thereby improving the data processing efficiency based on the convolutional neural network model at least to a certain extent. .

根据本申请实施例的一个方面,本申请实施例提供了一种基于卷积神经网络模型的数据处理方法,所述方法包括:获取待处理的卷积神经网络模型以及与所述卷积神经网络模型匹配的剪枝配置文件;基于识别算法对所述卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于所述剪枝配置文件确定目标剪枝算法,其中,所述目标剪枝算法独立于所述识别算法;基于所述目标剪枝算法对所述目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型;基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。According to an aspect of the embodiments of the present application, the embodiments of the present application provide a data processing method based on a convolutional neural network model, the method comprising: acquiring a convolutional neural network model to be processed and combining with the convolutional neural network model A pruning configuration file for model matching; the network structure of the convolutional neural network model is identified based on an identification algorithm to obtain a target network structure, and a target pruning algorithm is determined based on the pruning configuration file, wherein the target pruning The pruning algorithm is independent of the identifying algorithm; the target network structure is pruned based on the target pruning algorithm to obtain a pruned convolutional neural network model; the data to be processed is based on the pruned convolutional neural network model Process and get the processing result.

根据本申请实施例的一个方面,本申请实施例提供了一种基于卷积神经网络模型的数据处理装置,所述装置包括:获取模块,配置为获取待处理的卷积神经网络模型以及与所述卷积神经网络模型匹配的剪枝配置文件;识别与确定模块,配置为基于识别算法对所述卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于所述剪枝配置文件确定目标剪枝算法,其中,所述目标剪枝算法独立于所述识别算法;剪枝模块,配置为基于所述目标剪枝算法对所述目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型;处理模块,配置为基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。According to an aspect of the embodiments of the present application, the embodiments of the present application provide a data processing apparatus based on a convolutional neural network model, the apparatus comprising: an acquisition module configured to acquire a convolutional neural network model to be processed and a The pruning configuration file matched with the convolutional neural network model; the identification and determination module is configured to identify the network structure of the convolutional neural network model based on the recognition algorithm, obtain the target network structure, and based on the pruning configuration file Determine a target pruning algorithm, wherein the target pruning algorithm is independent of the identification algorithm; a pruning module is configured to prune the target network structure based on the target pruning algorithm to obtain a pruned volume The convolutional neural network model; the processing module is configured to process the data to be processed based on the pruned convolutional neural network model to obtain the processing result.

在本申请的一个实施例中,基于前述方案,所述剪枝配置文件中包括第一裁剪率;所述剪枝模块,包括:第一读取单元,配置为读取所述剪枝配置文件中含有的所述第一裁剪率;第一确定单元,配置为基于所述第一裁剪率确定所述目标网络结构所包含的各网络层对应的第二裁剪率;第一剪枝单元,配置为根据所述各网络层对应的第二裁剪率,通过所述目标剪枝算法分别对所述各网络层进行剪枝,得到剪枝后的各网络层;生成单元,配置为基于剪枝后的各网络层生成剪枝后的卷积神经网络模型。In an embodiment of the present application, based on the foregoing solution, the pruning configuration file includes a first pruning rate; the pruning module includes: a first reading unit configured to read the pruning configuration file The first cropping rate contained in the target network structure; a first determining unit, configured to determine, based on the first cropping rate, a second cropping rate corresponding to each network layer included in the target network structure; a first pruning unit, configured In order to prune the network layers respectively through the target pruning algorithm according to the second clipping rate corresponding to the network layers, to obtain the network layers after the pruning; the generating unit is configured to be based on the pruning Each layer of the network generates a pruned convolutional neural network model.

在本申请的一个实施例中,基于前述方案,所述第一确定单元,具体配置为:若所述第一裁剪率表征全局裁剪率,则基于剪枝先验知识信息与所述第一裁剪率,确定所述目标网络结构所包含的各网络层对应的第二裁剪率;若所述第一裁剪率表征所述目标网络结构包含的指定网络层裁剪率,则基于所述第一裁剪率确定所述指定网络层对应的第二裁剪率,以及基于所述剪枝先验知识信息与所述第一裁剪率,确定所述目标网络结构包含的除所述指定网络层之外的其他网络层对应的第二裁剪率。In an embodiment of the present application, based on the foregoing solution, the first determining unit is specifically configured to: if the first cropping rate represents a global cropping rate, then based on the pruning prior knowledge information and the first cropping rate rate, and determine the second cropping rate corresponding to each network layer included in the target network structure; if the first cropping rate represents the cropping rate of the specified network layer contained in the target network structure, then based on the first cropping rate determining a second cropping rate corresponding to the specified network layer, and determining other networks other than the specified network layer included in the target network structure based on the pruning prior knowledge information and the first cropping rate The second cropping rate corresponding to the layer.

在本申请的一个实施例中,基于前述方案,所述第一剪枝单元,具体配置为:若所述目标剪枝算法为结构化的剪枝算法,则基于所述结构化的剪枝算法分别对所述各网络层对应的特征图进行删除处理,以对所述各网络层进行剪枝,得到结构化剪枝后的各网络层;若所述目标剪枝算法为非结构化的剪枝算法,则基于所述非结构化的剪枝算法分别对所述各网络层对应的特征图含有的特征值进行置零处理,以对所述各网络层进行剪枝,得到非结构化剪枝后的各网络层。In an embodiment of the present application, based on the foregoing solution, the first pruning unit is specifically configured to: if the target pruning algorithm is a structured pruning algorithm, then based on the structured pruning algorithm Delete the feature maps corresponding to the network layers respectively, so as to prune the network layers to obtain the network layers after structured pruning; if the target pruning algorithm is an unstructured pruning algorithm based on the unstructured pruning algorithm, the eigenvalues contained in the feature maps corresponding to the network layers are respectively zeroed, so as to prune the network layers to obtain an unstructured pruning algorithm. Each network layer after the branch.

在本申请的一个实施例中,基于前述方案,所述剪枝配置文件中包括跳跃结构的处理信息;所述剪枝模块,包括:第二读取单元,配置为读取所述剪枝配置文件中含有的跳跃结构的处理信息;第二剪枝单元,配置为若所述处理信息指示对跳跃结构进行处理,则对所述目标网络结构中包含的跳跃结构的所有网络层进行剪枝,得到剪枝后的卷积神经网络模型;第三剪枝单元,配置为若所述处理信息指示不对跳跃结构进行处理,则获取所述目标网络结构中包含的跳跃结构的可跳跃网络层,并对所述可跳跃网络层进行剪枝,得到剪枝后的卷积神经网络模型。In an embodiment of the present application, based on the foregoing solution, the pruning configuration file includes processing information of a hopping structure; the pruning module includes: a second reading unit configured to read the pruning configuration processing information of the skip structure contained in the file; the second pruning unit is configured to prune all network layers of the skip structure included in the target network structure if the processing information indicates to process the skip structure, obtaining the pruned convolutional neural network model; the third pruning unit is configured to obtain the skippable network layer of the skipping structure included in the target network structure if the processing information indicates that the skipping structure is not to be processed, and The skippable network layer is pruned to obtain a pruned convolutional neural network model.

在本申请的一个实施例中,基于前述方案,所述剪枝模块,包括:第二确定单元,配置为从所述目标网络结构中确定出用于表征输出的网络节点;第四剪枝单元,配置为基于所述目标剪枝算法对所述目标网络结构包含的除用于表征输出的网络节点之外的其他网络节点进行剪枝,得到剪枝后的卷积神经网络模型。In an embodiment of the present application, based on the foregoing solution, the pruning module includes: a second determining unit configured to determine a network node for characterizing the output from the target network structure; a fourth pruning unit is configured to prune other network nodes included in the target network structure except the network nodes used to characterize the output based on the target pruning algorithm, to obtain a pruned convolutional neural network model.

在本申请的一个实施例中,基于前述方案,所述剪枝配置文件中包括所述目标剪枝算法的标识信息;所述识别与确定模块,包括:第三读取单元,配置为读取所述剪枝配置文件中含有的目标剪枝算法的标识信息;第三确定单元,配置为根据所述标识信息从预置的至少两种剪枝算法中确定出与所述标识信息匹配的目标剪枝算法。In an embodiment of the present application, based on the foregoing solution, the pruning configuration file includes identification information of the target pruning algorithm; the identification and determination module includes: a third reading unit configured to read The identification information of the target pruning algorithm contained in the pruning configuration file; the third determining unit is configured to determine the target matching the identification information from at least two preset pruning algorithms according to the identification information Pruning algorithm.

在本申请的一个实施例中,基于前述方案,所述剪枝配置文件中包括所述目标剪枝算法的标识信息;所述识别与确定模块,包括:识别单元,配置为通过识别算法对所述卷积神经网络模型进行识别,得到所述卷积神经网络模型中含有的算子的依赖关系,并将所述算子的依赖关系映射为有向无环图;获得单元,配置为基于所述有向无环图得到所述目标网络结构。In an embodiment of the present application, based on the foregoing solution, the pruning configuration file includes identification information of the target pruning algorithm; the identification and determination module includes: an identification unit, configured to use the identification algorithm to The convolutional neural network model is identified, the dependencies of the operators contained in the convolutional neural network models are obtained, and the dependencies of the operators are mapped to a directed acyclic graph; the obtaining unit is configured to be based on the The directed acyclic graph is used to obtain the target network structure.

在本申请的一个实施例中,基于前述方案,所述待处理数据包括图像数据、语音数据以及文字数据中的至少一种;所述处理模块,包括:第一处理单元,配置为若所述待处理数据为图像数据,则基于剪枝后的卷积神经网络模型对图像数据进行处理,得到图像处理结果;第二处理单元,配置为若所述待处理数据为语音数据,则基于剪枝后的卷积神经网络模型对语音数据进行处理,得到语音处理结果;第三处理单元,配置为若所述待处理数据为文字数据,则基于剪枝后的卷积神经网络模型对文字数据进行处理,得到文字处理结果。In an embodiment of the present application, based on the foregoing solution, the data to be processed includes at least one of image data, voice data, and text data; the processing module includes: a first processing unit configured to: If the data to be processed is image data, then the image data is processed based on the pruned convolutional neural network model to obtain an image processing result; the second processing unit is configured to, if the data to be processed is speech data, process the image data based on the pruning The subsequent convolutional neural network model processes the voice data to obtain a voice processing result; the third processing unit is configured to, if the data to be processed is text data, perform processing on the text data based on the pruned convolutional neural network model. Process to get the word processing result.

在本申请的一个实施例中,基于前述方案,用于对所述卷积神经网络模型进行处理的剪枝框架包括用户层、中间层和剪枝层;用户层对应用户模块,所述用户层用于获取所述待处理的卷积神经网络模型,以及与所述卷积神经网络模型匹配的剪枝配置文件;中间层对应中间模块,所述中间层用于基于所述剪枝配置文件确定目标剪枝算法;剪枝层对应底层模块,所述剪枝层用于基于识别算法对所述卷积神经网络模型的网络结构进行识别,得到目标网络结构,以及基于所述目标剪枝算法对所述目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型。In an embodiment of the present application, based on the foregoing solution, the pruning framework for processing the convolutional neural network model includes a user layer, an intermediate layer and a pruning layer; the user layer corresponds to a user module, and the user layer for obtaining the convolutional neural network model to be processed and a pruning configuration file matching the convolutional neural network model; the middle layer corresponds to the middle module, and the middle layer is used to determine based on the pruning configuration file Target pruning algorithm; the pruning layer corresponds to the underlying module, and the pruning layer is used to identify the network structure of the convolutional neural network model based on the recognition algorithm to obtain the target network structure, and based on the target pruning algorithm The target network structure is pruned to obtain a pruned convolutional neural network model.

在本申请的一个实施例中,基于前述方案,所述装置还包括:获得模块,配置为获取用于对所述卷积神经网络模型的网络结构进行识别的识别算法,以及至少两种用于对所述目标网络结构进行剪枝的剪枝算法;构建与生成模块,配置为基于所述识别算法以及至少两种剪枝算法构建并生成所述剪枝框架。In an embodiment of the present application, based on the foregoing solution, the apparatus further includes: an obtaining module configured to obtain an identification algorithm for identifying the network structure of the convolutional neural network model, and at least two algorithms for identifying the network structure of the convolutional neural network model. A pruning algorithm for pruning the target network structure; a construction and generation module is configured to construct and generate the pruning framework based on the identification algorithm and at least two pruning algorithms.

在本申请的一个实施例中,基于前述方案,所述构建与生成模块,包括:构建单元,配置为构建用户层、中间层以及剪枝层;预置单元,配置为调用所述中间层的第一接口,将所述至少两种剪枝算法预置在所述中间层,以及调用所述剪枝层的第二接口,将所述识别算法预置在所述剪枝层;生成单元,配置为通过所述用户层、预置有剪枝算法的中间层以及预置有识别算法的剪枝层生成所述剪枝框架。In an embodiment of the present application, based on the foregoing solution, the construction and generation module includes: a construction unit, configured to construct a user layer, an intermediate layer and a pruning layer; a preset unit, configured to call the intermediate layer a first interface for presetting the at least two pruning algorithms in the middle layer, and calling a second interface of the pruning layer to preset the identification algorithm in the pruning layer; a generating unit, It is configured to generate the pruning framework through the user layer, the middle layer with preset pruning algorithms, and the pruning layer with preset recognition algorithms.

根据本申请实施例的一个方面,本申请实施例提供了一种电子设备,包括一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述电子设备实现如上所述的基于卷积神经网络模型的数据处理方法。According to an aspect of the embodiments of the present application, the embodiments of the present application provide an electronic device, including one or more processors; and a storage device for storing one or more programs, when the one or more programs are stored When executed by the one or more processors, the electronic device implements the data processing method based on the convolutional neural network model as described above.

根据本申请实施例的一个方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机程序,当所述计算机程序被处理器执行时,使计算机执行如上所述的基于卷积神经网络模型的数据处理方法。According to an aspect of the embodiments of the present application, the embodiments of the present application provide a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, causes the computer to perform the above-mentioned convolution-based Data processing methods for neural network models.

根据本申请实施例的一个方面,本申请实施例提供了一种计算机程序产品,包括计算机指令,该计算机指令被处理器执行时实现如上所述的基于卷积神经网络模型的数据处理方法。According to an aspect of the embodiments of the present application, the embodiments of the present application provide a computer program product, including computer instructions, which, when executed by a processor, implement the above-mentioned data processing method based on a convolutional neural network model.

在本申请的实施例提供的技术方案中:In the technical solutions provided by the embodiments of this application:

一方面,基于识别算法和目标剪枝算法实现了对待处理的卷积神经网络模型的自动化剪枝优化,从而无需相关工作者手动选取合适的剪枝算法进行剪枝优化,不仅提升了剪枝效率,还在一定程度上提升了剪枝准确率,并且在极大程度上减少了相关工作者的工作量,为相关工作者带来诸多便利;相应地,由于提升了对待处理的卷积神经网络模型的剪枝效率以及准确率,那么基于剪枝优化后的卷积神经模型对待处理数据的处理效率以及准确率也得以提升。On the one hand, based on the recognition algorithm and the target pruning algorithm, the automatic pruning optimization of the convolutional neural network model to be processed is realized, so that the relevant workers do not need to manually select the appropriate pruning algorithm for pruning optimization, which not only improves the pruning efficiency , it also improves the pruning accuracy to a certain extent, and greatly reduces the workload of the relevant workers, bringing a lot of convenience to the relevant workers; correspondingly, due to the improvement of the convolutional neural network to be processed The pruning efficiency and accuracy of the model, then the processing efficiency and accuracy of the data to be processed based on the pruned-optimized convolutional neural model can also be improved.

一方面,目标剪枝算法独立于识别算法,即目标剪枝算法与识别算法是相隔离的;因而与相关技术中目标剪枝算法包含识别算法而言,不用再当目标剪枝算法中包含的识别算法无法识别卷积神经网络模型时,每次都需要修改目标剪枝算法中包含的识别算法以支持其识别卷积神经网络模型,耦合性低,能够适用于更加广泛的基于卷积神经网络模型的数据处理应用场景中。On the one hand, the target pruning algorithm is independent of the recognition algorithm, that is, the target pruning algorithm and the recognition algorithm are isolated; therefore, in terms of the target pruning algorithm including the recognition algorithm in the related art, it is no longer necessary to be included in the target pruning algorithm. When the recognition algorithm cannot recognize the convolutional neural network model, the recognition algorithm included in the target pruning algorithm needs to be modified every time to support the recognition of the convolutional neural network model. The coupling is low and can be applied to a wider range of convolutional neural networks. In the data processing application scenario of the model.

应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not limiting of the present application.

附图说明Description of drawings

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术者来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative effort.

图1是可以应用本申请实施例的技术方案的示例性实施环境的示意图。FIG. 1 is a schematic diagram of an exemplary implementation environment to which the technical solutions of the embodiments of the present application can be applied.

图2是本申请的一示例性实施例示出的基于卷积神经网络模型的数据处理方法的流程图。FIG. 2 is a flowchart of a data processing method based on a convolutional neural network model according to an exemplary embodiment of the present application.

图3是图2所示实施例中的步骤S202在一示例性实施例中的流程图。FIG. 3 is a flowchart of step S202 in the embodiment shown in FIG. 2 in an exemplary embodiment.

图4是本申请的一示例性实施例示出的有向无环图的示意图。FIG. 4 is a schematic diagram of a directed acyclic graph according to an exemplary embodiment of the present application.

图5是图2所示实施例中的步骤S202在一示例性实施例中的流程图。FIG. 5 is a flowchart of step S202 in the embodiment shown in FIG. 2 in an exemplary embodiment.

图6是图2所示实施例中的步骤S203在一示例性实施例中的流程图。FIG. 6 is a flowchart of step S203 in the embodiment shown in FIG. 2 in an exemplary embodiment.

图7是图2所示实施例中的步骤S203在一示例性实施例中的流程图。FIG. 7 is a flowchart of step S203 in the embodiment shown in FIG. 2 in an exemplary embodiment.

图8是图2所示实施例中的步骤S203在一示例性实施例中的流程图。FIG. 8 is a flowchart of step S203 in the embodiment shown in FIG. 2 in an exemplary embodiment.

图9是本申请的一示例性实施例示出的剪枝框架的示意图。FIG. 9 is a schematic diagram of a pruning frame shown in an exemplary embodiment of the present application.

图10是本申请的一示例性实施例示出的卷积神经网络模型各节点之间相关依赖关系的示意图。FIG. 10 is a schematic diagram of correlation dependencies between nodes of a convolutional neural network model according to an exemplary embodiment of the present application.

图11是本申请的一示例性实施例示出的跳跃结构的示意图。FIG. 11 is a schematic diagram of a jump structure shown in an exemplary embodiment of the present application.

图12是本申请的一示例性实施例示出的基于卷积神经网络模型的数据处理装置的框图。FIG. 12 is a block diagram of a data processing apparatus based on a convolutional neural network model according to an exemplary embodiment of the present application.

图13是适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。FIG. 13 is a schematic structural diagram of a computer system suitable for implementing the electronic device of the embodiment of the present application.

具体实施方式Detailed ways

这里将详细地对示例性实施例执行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相相同的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相同的装置和方法的例子。The description will now be made in detail of exemplary embodiments, examples of which are illustrated in the accompanying drawings. Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples are not intended to represent all implementations identical to the present application. Rather, they are merely examples of apparatus and methods that have some of the same aspects of the present application as recited in the appended claims.

附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。The block diagrams shown in the figures are merely functional entities and do not necessarily necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices entity.

附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。The flowcharts shown in the figures are only exemplary illustrations and do not necessarily include all contents and operations/steps, nor do they have to be performed in the order described. For example, some operations/steps can be decomposed, and some operations/steps can be combined or partially combined, so the actual execution order may be changed according to the actual situation.

需要说明的是,在本申请中提及的“多个”是指两个或者两个以上。“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。It should be noted that the "plurality" mentioned in this application refers to two or more. "And/or" describes the association relationship between associated objects, indicating that there can be three kinds of relationships, for example, A and/or B can indicate that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship.

人工智能(Artificial Intelligence,简称AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个综合技术,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。人工智能也就是研究各种智能机器的设计原理与实现方法,使机器具有感知、推理与决策的功能。Artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.

人工智能技术是一门综合学科,涉及领域广泛,既有硬件层面的技术也有软件层面的技术。人工智能基础技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理技术、操作/交互系统、机电一体化等技术。人工智能软件技术主要包括计算机视觉技术、语音处理技术、自然语言处理技术以及机器学习/深度学习、自动驾驶、智慧交通等几大方向。Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, including both hardware-level technology and software-level technology. The basic technologies of artificial intelligence generally include technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation/interaction systems, and mechatronics. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning/deep learning, autonomous driving, and smart transportation.

人工智能技术中的机器学习(Machine Learning,简称ML)是一门多领域交叉学科,涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科。专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能。机器学习是人工智能的核心,是使计算机具有智能的根本途径,其应用遍及人工智能的各个领域。机器学习和深度学习通常包括神经网络、置信网络、强化学习、迁移学习、归纳学习、示教学习等技术。Machine Learning (ML) in artificial intelligence technology is a multi-domain interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in how computers simulate or realize human learning behaviors to acquire new knowledge or skills, and to reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications are in all fields of artificial intelligence. Machine learning and deep learning usually include neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, teaching learning and other techniques.

相关技术中基于卷积神经网络模型的数据处理方案通常是先对卷积神经网络模型进行训练,之后基于训练后的卷积神经网络模型进行剪枝优化,之后再基于剪枝优化后的卷积神经网络模型进行相应数据处理。其中,在剪枝优化的过程中,通常是由相关工作者手动选取合适的剪枝算法进行剪枝优化,但是这样的剪枝优化方式效率较低,从而使得基于剪枝优化后的卷积神经网络模型进行相应数据处理的效率也较低。The data processing scheme based on the convolutional neural network model in the related art usually firstly trains the convolutional neural network model, then performs pruning and optimization based on the trained convolutional neural network model, and then performs pruning and optimization based on the convolutional neural network model after the pruning optimization. The neural network model performs corresponding data processing. Among them, in the process of pruning optimization, relevant workers usually manually select a suitable pruning algorithm for pruning optimization, but such a pruning optimization method is inefficient, which makes the convolutional neural network based on pruning optimization. The network model is also less efficient for corresponding data processing.

因此,在基于卷积神经网络模型的数据处理场景中,本申请实施例提出了一种基于卷积神经网络模型的数据处理方案。请参阅图1,图1是本申请一种示例性实施环境的示意图。该实施环境中包括终端设备101和服务器102,终端设备101和服务器102之间通过有线或者无线网络进行通信。Therefore, in a data processing scenario based on a convolutional neural network model, an embodiment of the present application proposes a data processing solution based on a convolutional neural network model. Please refer to FIG. 1 , which is a schematic diagram of an exemplary implementation environment of the present application. The implementation environment includes a terminal device 101 and a server 102, and the terminal device 101 and the server 102 communicate through a wired or wireless network.

应该理解,图1中的终端设备101和服务器102的数目仅仅是示意性的。根据实际需要,可以具有任意数目的终端设备101和服务器102。It should be understood that the numbers of terminal devices 101 and servers 102 in FIG. 1 are only illustrative. According to actual needs, there may be any number of terminal devices 101 and servers 102 .

其中,终端设备101对应客户端,其可以是任意具有用户输入接口的电子设备,包括但不限于智能手机、平板、笔记本电脑、计算机、智能语音交互设备、智能家电、车载终端、飞行器等等,其中,用户输入接口包括但不限于触摸屏、键盘、物理按键、音频拾取装置等。Wherein, the terminal device 101 corresponds to a client, which can be any electronic device with a user input interface, including but not limited to smart phones, tablets, laptops, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc., The user input interface includes, but is not limited to, a touch screen, a keyboard, physical keys, an audio pickup device, and the like.

其中,服务器102对应服务端,其可以是提供各种服务的服务器,其可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content Delivery Network,内容分发网络)以及大数据和人工智能平台等基础云计算服务的云服务器,本处不对此进行限制。The server 102 corresponds to a server, which can be a server providing various services, an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud service, cloud Basic cloud computing services such as databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms Cloud server, which is not limited here.

在本申请的一些实施例中,基于卷积神经网络模型的数据处理方法可以由终端设备101执行,相应地,基于卷积神经网络模型的数据处理装置配置于终端设备101中。可选地,终端设备101可以获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件,之后基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中目标剪枝算法独立于识别算法,之后基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型,之后基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。In some embodiments of the present application, the data processing method based on the convolutional neural network model may be executed by the terminal device 101 , and accordingly, the data processing apparatus based on the convolutional neural network model is configured in the terminal device 101 . Optionally, the terminal device 101 can obtain the convolutional neural network model to be processed and the pruning configuration file matching the convolutional neural network model, and then identify the network structure of the convolutional neural network model based on the identification algorithm to obtain the target network. The target pruning algorithm is determined based on the pruning configuration file, in which the target pruning algorithm is independent of the recognition algorithm, and then the target network structure is pruned based on the target pruning algorithm to obtain the pruned convolutional neural network model. The data to be processed is processed based on the pruned convolutional neural network model, and the processing result is obtained.

在本申请的一些实施例中,基于卷积神经网络模型的数据处理方法可以由服务器102执行,相应地,基于卷积神经网络模型的数据处理装置配置于服务器102中。可选地,服务器102可以获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件,之后基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中目标剪枝算法独立于识别算法,之后基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型,之后基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。In some embodiments of the present application, the data processing method based on the convolutional neural network model may be executed by the server 102 , and accordingly, the data processing apparatus based on the convolutional neural network model is configured in the server 102 . Optionally, the server 102 can obtain the convolutional neural network model to be processed and the pruning configuration file matching the convolutional neural network model, and then identify the network structure of the convolutional neural network model based on the identification algorithm to obtain the target network structure. , and determine the target pruning algorithm based on the pruning configuration file, where the target pruning algorithm is independent of the recognition algorithm, and then prune the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network model. The pruned convolutional neural network model processes the data to be processed to obtain the processing result.

通过实施本申请实施例的技术方案,实现了对待处理的卷积神经网络模型的自动化剪枝优化,提升了对待处理的卷积神经网络模型的剪枝效率以及准确率,相应地,也提升了基于剪枝优化后的卷积神经模型对待处理数据的处理效率以及准确率;同时将目标剪枝算法与识别算法隔离开,耦合性低,能够在极大程度上减少修改量,从而减少相关工作者的工作量,为相关工作者带来诸多便利,能够适用于更加广泛的基于卷积神经网络模型的数据处理应用场景中。By implementing the technical solutions of the embodiments of the present application, automatic pruning and optimization of the convolutional neural network model to be processed is realized, the pruning efficiency and accuracy of the convolutional neural network model to be processed are improved, and correspondingly, the The processing efficiency and accuracy of the data to be processed based on the convolutional neural model optimized by pruning; at the same time, the target pruning algorithm and the recognition algorithm are isolated, and the coupling is low, which can greatly reduce the amount of modification, thereby reducing related work It brings a lot of convenience to related workers and can be applied to a wider range of data processing application scenarios based on the convolutional neural network model.

以下对本申请实施例的技术方案的各种实现细节进行详细阐述:Various implementation details of the technical solutions of the embodiments of the present application are described in detail below:

请参阅图2,图2是本申请的一个实施例示出的基于卷积神经网络模型的数据处理方法的流程图,该基于卷积神经网络模型的数据处理方法可以由图1中所示的终端设备101或服务器102来执行。如图2所示,基于卷积神经网络模型的数据处理方法至少包括步骤S201至步骤S204,详细介绍如下:Please refer to FIG. 2. FIG. 2 is a flowchart of a data processing method based on a convolutional neural network model shown in an embodiment of the present application. The data processing method based on a convolutional neural network model can be performed by the terminal shown in FIG. 1 device 101 or server 102 to execute. As shown in FIG. 2, the data processing method based on the convolutional neural network model includes at least steps S201 to S204, and the details are as follows:

步骤S201,获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件。Step S201, acquiring a convolutional neural network model to be processed and a pruning configuration file matching the convolutional neural network model.

本申请实施例中待处理的卷积神经网络模型指的是完成训练的卷积神经网络模型;其中完成训练可以指的是完成一轮或多轮(两轮及两轮以上)训练,可以理解的是,完成多轮训练通常是对卷积神经网络模型进行多轮训练直至其收敛从而得到训练好的卷积神经网络模型。The convolutional neural network model to be processed in the embodiment of the present application refers to the convolutional neural network model that has completed training; the completion of the training may refer to the completion of one or more rounds (two or more rounds) of training, which can be understood The point is, to complete multiple rounds of training is usually to perform multiple rounds of training on the convolutional neural network model until it converges to obtain a trained convolutional neural network model.

本申请实施例中卷积神经网络模型匹配的剪枝配置文件指的是由相关管理者/使用者/开发者需要对卷积神经网络模型进行剪枝优化,从而配置得到的剪枝配置文件。例如管理者1需要对卷积神经网络模型A进行剪枝优化,那么其可以配置得到剪枝配置文件1,其中剪枝配置文件1即称之为与卷积神经网络模型A所匹配的剪枝配置文件。The pruning configuration file matched by the convolutional neural network model in the embodiment of the present application refers to the pruning configuration file obtained by the relevant administrator/user/developer who needs to perform pruning and optimization on the convolutional neural network model, thereby configuring. For example, if manager 1 needs to prune and optimize the convolutional neural network model A, it can be configured to obtain a pruning configuration file 1. The pruning configuration file 1 is called the pruning that matches the convolutional neural network model A. configuration file.

步骤S202,基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中,目标剪枝算法独立于识别算法。Step S202, the network structure of the convolutional neural network model is identified based on the identification algorithm to obtain the target network structure, and the target pruning algorithm is determined based on the pruning configuration file, wherein the target pruning algorithm is independent of the identification algorithm.

本申请实施例中获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件,之后可以基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中目标剪枝算法独立于识别算法。In the embodiment of the present application, the convolutional neural network model to be processed and the pruning configuration file matching the convolutional neural network model are obtained, and then the network structure of the convolutional neural network model can be identified based on the identification algorithm to obtain the target network structure, And the target pruning algorithm is determined based on the pruning configuration file, wherein the target pruning algorithm is independent of the recognition algorithm.

可以理解的是,在对卷积神经网络模型进行剪枝优化时,是要基于卷积神经网络模型的网络结构;因而,本申请实施例中需要基于识别算法对卷积神经网络模型的网络结构进行识别,为了便于理解,本申请实施例中将识别到的卷积神经网络模型的网络结构称之为目标网络结构。需要说明的是,卷积神经网络模型的网络结构包括但不限于卷积神经网络模型对应哪些网络层,各个网络层之间是如何连接,以及卷积层中卷积核的数量等。It can be understood that when pruning and optimizing the convolutional neural network model, it is based on the network structure of the convolutional neural network model; therefore, in the embodiment of the present application, it is necessary to prune the network structure of the convolutional neural network model based on the recognition algorithm. For identification, in order to facilitate understanding, the identified network structure of the convolutional neural network model is referred to as the target network structure in the embodiments of the present application. It should be noted that the network structure of the convolutional neural network model includes, but is not limited to, which network layers the convolutional neural network model corresponds to, how each network layer is connected, and the number of convolution kernels in the convolutional layer.

在本申请的一个实施例中,请参阅图3,步骤S202中基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构的过程,可以包括以下步骤S301至步骤S302,详细介绍如下:In an embodiment of the present application, please refer to FIG. 3 , in step S202, the network structure of the convolutional neural network model is identified based on the identification algorithm, and the process of obtaining the target network structure may include the following steps S301 to S302. The detailed introduction as follows:

步骤S301,通过识别算法对卷积神经网络模型进行识别,得到卷积神经网络模型中含有的算子的依赖关系,并将算子的依赖关系映射为有向无环图;Step S301, identify the convolutional neural network model by an identification algorithm, obtain the dependencies of the operators contained in the convolutional neural network model, and map the dependencies of the operators into a directed acyclic graph;

步骤S302,基于有向无环图得到目标网络结构。In step S302, the target network structure is obtained based on the directed acyclic graph.

也即,可选实施例中可以通过识别算法对卷积神经网络模型进行识别,得到卷积神经网络模型中含有的算子的依赖关系,并将算子的依赖关系映射为有向无环图,之后基于有向无环图得到目标网络结构。That is, in an optional embodiment, the convolutional neural network model can be identified by an identification algorithm, the dependencies of the operators contained in the convolutional neural network model can be obtained, and the dependencies of the operators can be mapped to a directed acyclic graph. , and then the target network structure is obtained based on the directed acyclic graph.

其中,可以理解的是,通常卷积神经网络模型中包括大量的算子(也称之为网络节点),算子其实可以简单看作是卷积神经网络模型中的部分算法过程,算子可以把函数映射为函数,或者把函数映射为数,算子之间又具有相互的依赖关系,依赖关系可以简单理解为数据上的依赖。Among them, it is understandable that a large number of operators (also called network nodes) are usually included in the convolutional neural network model. In fact, the operator can be simply regarded as part of the algorithm process in the convolutional neural network model. When a function is mapped to a function, or a function is mapped to a number, the operators have mutual dependencies, and the dependencies can be simply understood as data dependencies.

举例说明,例如在卷积神经网络模型中有算子a、算子b、算子c、算子d、算子e、算子f、算子g以及算子h。其中,设卷积神经网络模型定义了算子d的输入数据为算子b的输出数据,而算子b的输入数据又是算子a的输出数据,算子a仅有数据输出;那么可以得知,算子d的运算是需要算子b的输出数据的,即算子d是依赖于算子b的,同理,算子b的运算是需要算子a的输出数据的,那么算子b是依赖于算子a的。同时,设卷积神经网络模型还定义了算子c的输出数据为算子f的输入数据,算子e的输入数据为算子a的输出数据,而算子f的输入数据除了来源于算子c外,还来源于算子b,算子g的输入数据来源于算子b、算子c以及算子e,算子h的输入数据来源于算子d和算子f;那么可以得知,算子f同时依赖于算子b以及算子c,算子e依赖于算子a,算子g同时依赖于算子b、算子c以及算子e,算子h同时依赖于算子d以及算子f。For example, in the convolutional neural network model, there are operator a, operator b, operator c, operator d, operator e, operator f, operator g and operator h. Among them, let the convolutional neural network model define that the input data of operator d is the output data of operator b, and the input data of operator b is the output data of operator a, and operator a has only data output; then it can be It is known that the operation of operator d requires the output data of operator b, that is, operator d depends on operator b. Similarly, the operation of operator b requires the output data of operator a, then calculate Sub b is dependent on operator a. At the same time, the convolutional neural network model also defines that the output data of operator c is the input data of operator f, the input data of operator e is the output data of operator a, and the input data of operator f is derived from the operator f. In addition to operator c, it also comes from operator b, the input data of operator g comes from operator b, operator c and operator e, and the input data of operator h comes from operator d and operator f; then we can get It is known that operator f depends on operator b and operator c at the same time, operator e depends on operator a, operator g depends on operator b, operator c and operator e at the same time, and operator h also depends on operator Sub d and operator f.

因而,可选实施例中可以通过识别算法对卷积神经网络模型进行识别,从而得到卷积神经网络模型中含有的算子的依赖关系。Therefore, in an optional embodiment, the convolutional neural network model may be identified by an identification algorithm, so as to obtain the dependencies of the operators contained in the convolutional neural network model.

其中,可以理解的是,有向无环图(Directed Acyclic Graph)指的是在图论中一个有向图无法从某个顶点出发经过若干条边再回到该顶点,其实质与数组、排列、区块链一样,也是一种数据结构。Among them, it can be understood that a directed acyclic graph (Directed Acyclic Graph) refers to a directed graph in graph theory that cannot start from a vertex and go back to the vertex through several edges. Like the blockchain, it is also a data structure.

举例说明,承接前述所示例的依赖关系可以得到如图4所示的有向无环图。有向无环图中有节点0、节点1、节点2、节点3、节点4、节点5、节点6以及节点7;其中,节点0表征算子a,节点1表征算子b,节点2表征算子c,节点3表征算子d,节点4表征算子e,节点5表征算子f,节点6表征算子g,节点7表征算子h。可以理解的是,箭头所指向的节点依赖于箭头的起始节点。By way of example, the directed acyclic graph shown in FIG. 4 can be obtained by following the dependency relationship shown in the foregoing example. There are node 0, node 1, node 2, node 3, node 4, node 5, node 6 and node 7 in the directed acyclic graph; where node 0 represents operator a, node 1 represents operator b, and node 2 represents operator b Operator c, node 3 represents operator d, node 4 represents operator e, node 5 represents operator f, node 6 represents operator g, and node 7 represents operator h. It is understood that the node to which the arrow points depends on the starting node of the arrow.

因而,可选实施例中可以基于得到的有向无环图得到目标网络结构。Therefore, in an optional embodiment, the target network structure may be obtained based on the obtained directed acyclic graph.

这样,通过实施可选实施例,可以快速简便地得到目标网络结构,从而提升基于目标网络结构得到剪枝后的卷积神经网络模型的效率,为基于剪枝后的卷积神经网络模型对待处理数据进行处理提供支持。In this way, by implementing the optional embodiment, the target network structure can be obtained quickly and easily, thereby improving the efficiency of obtaining the pruned convolutional neural network model based on the target network structure, and treating the pruned convolutional neural network model based on the Data processing provides support.

可以理解的是,在对卷积神经网络模型进行剪枝优化时,是要基于剪枝算法;因而,本申请实施例中需要基于剪枝配置文件确定目标剪枝算法,为了便于理解,本申请实施例中对卷积神经网络模型进行剪枝优化的剪枝算法称之为目标剪枝算法。It can be understood that when pruning and optimizing the convolutional neural network model, it is based on the pruning algorithm; therefore, in the embodiment of the present application, the target pruning algorithm needs to be determined based on the pruning configuration file. The pruning algorithm for pruning and optimizing the convolutional neural network model in the embodiment is called a target pruning algorithm.

在本申请的一个实施例中,剪枝配置文件中可以包括目标剪枝算法的标识信息;请参阅图5,步骤S202中基于剪枝配置文件确定目标剪枝算法的过程,可以包括以下步骤S501至步骤S502,详细介绍如下:In an embodiment of the present application, the identification information of the target pruning algorithm may be included in the pruning configuration file; please refer to FIG. 5 , the process of determining the target pruning algorithm based on the pruning configuration file in step S202 may include the following steps S501 To step S502, the details are as follows:

步骤S501,读取剪枝配置文件中含有的目标剪枝算法的标识信息;Step S501, read the identification information of the target pruning algorithm contained in the pruning configuration file;

步骤S502,根据标识信息从预置的至少两种剪枝算法中确定出与标识信息匹配的目标剪枝算法。Step S502: Determine a target pruning algorithm matching the identification information from at least two preset pruning algorithms according to the identification information.

也即,可选实施例中可以先剪枝配置文件中读取得到目标剪枝算法的标识信息,之后根据标识信息从预置的至少两种剪枝算法中确定出与标识信息匹配的目标剪枝算法。That is, in an optional embodiment, the identification information of the target pruning algorithm may be read from the pruning configuration file first, and then the target pruning algorithm that matches the identification information is determined from at least two preset pruning algorithms according to the identification information. branch algorithm.

其中,可选实施例中目标剪枝算法的标识信息用于唯一标识剪枝算法,其包括但不限于目标剪枝算法的名称、特定标识号等。Wherein, the identification information of the target pruning algorithm in the optional embodiment is used to uniquely identify the pruning algorithm, which includes but is not limited to the name of the target pruning algorithm, a specific identification number, and the like.

其中,可以理解的是,由于不同剪枝算法各有利弊;因而,可选实施例中相关管理者/使用者/开发者可以在剪枝配置文件中指定对卷积神经网络模型进行剪枝优化的剪枝算法(即目标剪枝算法),以实现自主选择。Among them, it can be understood that, because different pruning algorithms have their own advantages and disadvantages; therefore, in an optional embodiment, relevant managers/users/developers can specify in the pruning configuration file to perform pruning optimization on the convolutional neural network model pruning algorithm (namely target pruning algorithm) to achieve autonomous selection.

举例说明,设读取到的目标剪枝算法的标识信息为“XX”,同时设预置有10种剪枝算法0-9,那么根据标识信息“XX”从10种剪枝算法0-9中确定出与标识信息“XX”匹配的目标剪枝算法,设10种剪枝算法0-9中剪枝算法2与标识信息“XX”匹配,那么剪枝算法2即为目标剪枝算法。For example, suppose that the read identification information of the target pruning algorithm is "XX", and 10 kinds of pruning algorithms 0-9 are preset at the same time, then according to the identification information "XX", 10 kinds of pruning algorithms 0-9 are set. Determine the target pruning algorithm that matches the identification information "XX", and suppose that the pruning algorithm 2 of the 10 pruning algorithms 0-9 matches the identification information "XX", then the pruning algorithm 2 is the target pruning algorithm.

这样,通过实施可选实施例,可以快速简便地得到目标剪枝算法,从而提升基于目标剪枝算法得到剪枝后的卷积神经网络模型的效率,为基于剪枝后的卷积神经网络模型对待处理数据进行处理提供支持。In this way, by implementing the optional embodiment, a target pruning algorithm can be obtained quickly and easily, thereby improving the efficiency of obtaining a pruned convolutional neural network model based on the target pruning algorithm, which is a pruned-based convolutional neural network model. Provide support for processing data to be processed.

在本申请的一个实施例中,剪枝配置文件中还可以包括目标剪枝算法,即剪枝配置文件中包含的是目标剪枝算法本身,那么可以直接从剪枝配置文件中读取得到目标剪枝算法,之后基于目标剪枝算法对目标网络结构进行剪枝,从而得到剪枝后的卷积神经网络模型。In an embodiment of the present application, the pruning configuration file may also include a target pruning algorithm, that is, the pruning configuration file contains the target pruning algorithm itself, then the target pruning algorithm can be directly read from the pruning configuration file. The pruning algorithm is then used to prune the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network model.

需要说明的是,本申请实施例中目标剪枝算法独立于识别算法,即目标剪枝算法与识别算法是相隔离的。而相关技术中,识别算法是包含在剪枝算法中的,可以理解的是,由于不同卷积神经网络模型的网络结构不同,而只有与网络结构匹配的识别算法才能识别网络结构;所以实际情况是,如果剪枝算法中含有的识别算法不能识别卷积神经网络模型的网络结构,那么是需要对剪枝算法中含有的识别算法进行修改,而该修改在一定程度上也会影响到剪枝算法,因而该给相关管理者/使用者/开发者带来一定困扰,并且如果剪枝算法的数量越多,都要使其所含有的识别算法能够识别卷积神经网络模型的网络结构,那么修改量是非常之大的。所以,本申请实施例中考虑到该存在的诸多问题,将目标剪枝算法与识别算法相隔离开,那么在使用或修改时,会给相关管理者/使用者/开发者带来诸多便利,减少其工作量以及相应困扰,节约了时间成本,从而提升基于剪枝后的卷积神经网络模型的数据处理效率。It should be noted that the target pruning algorithm in the embodiment of the present application is independent of the identification algorithm, that is, the target pruning algorithm and the identification algorithm are isolated. In the related art, the recognition algorithm is included in the pruning algorithm. It can be understood that due to the different network structures of different convolutional neural network models, only the recognition algorithm that matches the network structure can recognize the network structure; so the actual situation Yes, if the recognition algorithm contained in the pruning algorithm cannot recognize the network structure of the convolutional neural network model, then the recognition algorithm contained in the pruning algorithm needs to be modified, and the modification will also affect the pruning to a certain extent. Therefore, it should bring some trouble to the relevant managers/users/developers, and if the number of pruning algorithms is larger, the identification algorithms contained in it must be able to identify the network structure of the convolutional neural network model, then The amount of modification is very large. Therefore, in the embodiment of the present application, considering the existing problems, the target pruning algorithm and the identification algorithm are isolated, so that when using or modifying, it will bring a lot of convenience to the relevant managers/users/developers, reducing the Its workload and corresponding troubles save time and cost, thereby improving the data processing efficiency based on the pruned convolutional neural network model.

步骤S203,基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型。Step S203 , prune the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model.

本申请实施例中获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件,之后可以基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中目标剪枝算法独立于识别算法。In the embodiment of the present application, the convolutional neural network model to be processed and the pruning configuration file matching the convolutional neural network model are obtained, and then the network structure of the convolutional neural network model can be identified based on the identification algorithm to obtain the target network structure, And the target pruning algorithm is determined based on the pruning configuration file, wherein the target pruning algorithm is independent of the recognition algorithm.

在本申请的一个实施例中,剪枝配置文件中包括第一裁剪率;请参阅图6,步骤S203中基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型的过程,可以包括以下步骤S601至步骤S604,详细介绍如下:In an embodiment of the present application, the pruning configuration file includes a first pruning rate; please refer to FIG. 6 , in step S203, the target network structure is pruned based on the target pruning algorithm to obtain a pruned convolutional neural network The model process may include the following steps S601 to S604, which are described in detail as follows:

步骤S601,读取剪枝配置文件中含有的第一裁剪率;Step S601, read the first trimming rate contained in the pruning configuration file;

步骤S602,基于第一裁剪率确定目标网络结构所包含的各网络层对应的第二裁剪率;Step S602, determining the second trimming rate corresponding to each network layer included in the target network structure based on the first trimming rate;

步骤S603,根据各网络层对应的第二裁剪率,通过目标剪枝算法分别对各网络层进行剪枝,得到剪枝后的各网络层;Step S603, according to the second pruning rate corresponding to each network layer, respectively prune each network layer through the target pruning algorithm to obtain each network layer after pruning;

步骤S604,基于剪枝后的各网络层生成剪枝后的卷积神经网络模型。Step S604, a pruned convolutional neural network model is generated based on the pruned network layers.

也即,可选实施例中可以先读取剪枝配置文件中含有的第一裁剪率,之后基于第一裁剪率确定目标网络结构所包含的各网络层对应的第二裁剪率,之后根据各网络层对应的第二裁剪率,通过目标剪枝算法分别对各网络层进行剪枝,得到剪枝后的各网络层,之后基于剪枝后的各网络层生成剪枝后的卷积神经网络模型。That is, in an optional embodiment, the first trimming rate contained in the pruning configuration file may be read first, and then the second trimming rate corresponding to each network layer included in the target network structure is determined based on the first trimming rate, and then the second trimming rate corresponding to each network layer included in the target network structure may be determined based on the first trimming rate. The second pruning rate corresponding to the network layer is to prune each network layer through the target pruning algorithm to obtain the pruned network layers, and then generate the pruned convolutional neural network based on the pruned network layers. Model.

其中,可选实施例中目标网络结构包含有多个(两个及两个以上)网络层,例如可以包括但不限于多种卷积层、批归一化层、全连接层以及拼接层等。Wherein, in an optional embodiment, the target network structure includes multiple (two or more) network layers, such as but not limited to multiple convolution layers, batch normalization layers, fully connected layers, and splicing layers, etc. .

其中,可选实施例中相关管理者/使用者/开发者可以在剪枝配置文件中指定对卷积神经网络模型进行剪枝优化的裁剪率(也称剪枝率或压缩率),为了便于理解,可选实施例中将剪枝配置文件中含有的裁剪率称之为第一裁剪率。其中,裁剪率指的是裁剪的比例,例如可以取值50%、30%等,以从剪枝配置文件中读取到的具体裁剪率(即第一裁剪率)为准。Wherein, in an optional embodiment, the relevant manager/user/developer may specify the pruning rate (also called pruning rate or compression rate) for pruning and optimizing the convolutional neural network model in the pruning configuration file. It is understood that, in an optional embodiment, the pruning rate contained in the pruning configuration file is referred to as the first pruning rate. The cropping rate refers to the cropping ratio, for example, it may take a value of 50%, 30%, etc., and the specific cropping rate (ie, the first cropping rate) read from the pruning configuration file shall prevail.

其中,可选实施例中目标网络结构所包含的各网络层都有对应的裁剪率,为了便于理解,可选实施例中将各网络层对应的裁剪率称之为第二裁剪率。Wherein, each network layer included in the target network structure in the optional embodiment has a corresponding cropping rate. For ease of understanding, the cropping rate corresponding to each network layer is referred to as the second cropping rate in the optional embodiment.

这样,通过实施可选实施例,可以快速简便地对各网络层进行剪枝,并基于剪枝后的各网络层生成剪枝后的卷积神经网络模型,为基于剪枝后的卷积神经网络模型对待处理数据进行处理提供支持。In this way, by implementing the optional embodiment, each network layer can be pruned quickly and easily, and a pruned convolutional neural network model can be generated based on each pruned network layer, which is based on the pruned convolutional neural network. The network model provides support for processing the data to be processed.

在本申请的一个实施例中,步骤S602中基于第一裁剪率确定目标网络结构所包含的各网络层对应的第二裁剪率的过程,可以包括以下两种情况:In an embodiment of the present application, the process of determining the second cropping rate corresponding to each network layer included in the target network structure based on the first cropping rate in step S602 may include the following two situations:

情况一,若第一裁剪率表征全局裁剪率,则基于剪枝先验知识信息与第一裁剪率,确定目标网络结构所包含的各网络层对应的第二裁剪率。In case 1, if the first cropping rate represents the global cropping rate, the second cropping rate corresponding to each network layer included in the target network structure is determined based on the pruning prior knowledge information and the first cropping rate.

也即,可选实施例中如果第一裁剪率表征的是全局裁剪率,那么可以基于剪枝先验知识信息与表征全局裁剪率的第一裁剪率,确定目标网络结构所包含的各网络层对应的第二裁剪率。That is, in an optional embodiment, if the first cropping rate represents the global cropping rate, then each network layer included in the target network structure may be determined based on the prior knowledge information of pruning and the first cropping rate representing the global cropping rate. The corresponding second cropping rate.

其中,可以理解的是,可选实施例中基于剪枝先验知识信息与表征全局裁剪率的第一裁剪率,确定的是目标网络结构所包含的所有网络层对应的第二裁剪率,此可以看作是全自动化剪枝。It can be understood that, in the optional embodiment, based on the prior knowledge information of pruning and the first trimming rate representing the global trimming rate, the second trimming rate corresponding to all network layers included in the target network structure is determined. It can be seen as fully automated pruning.

举例说明,例如设第一裁剪率为50%,同时设目标网络结构包含的各网络层分别为卷积层1、卷积层2、卷积层3、批归一化层、全连接层以及拼接层;那么可以基于剪枝先验知识信息与第一裁剪率50%,确定各网络层对应的第二裁剪率,例如设确定出卷积层1对应的第二裁剪率为55%,卷积层2对应的第二裁剪率为50%,卷积层3对应的第二裁剪率为45%,批归一化层对应的第二裁剪率为55%,全连接层对应的第二裁剪率为50%,拼接层对应的第二裁剪率为60%。For example, for example, the first cropping rate is set to 50%, and each network layer included in the target network structure is set to be convolutional layer 1, convolutional layer 2, convolutional layer 3, batch normalization layer, fully connected layer and splicing layer; then the second cropping rate corresponding to each network layer can be determined based on the pruning prior knowledge information and the first cropping rate of 50%. For example, the second cropping rate corresponding to convolutional layer 1 can be determined to be 55%, The second cropping rate corresponding to the accumulation layer 2 is 50%, the second cropping rate corresponding to the convolutional layer 3 is 45%, the second cropping rate corresponding to the batch normalization layer is 55%, and the second cropping rate corresponding to the fully connected layer The rate is 50%, and the second cropping rate corresponding to the stitching layer is 60%.

情况二,若第一裁剪率表征目标网络结构包含的指定网络层裁剪率,则基于第一裁剪率确定指定网络层对应的第二裁剪率,以及基于剪枝先验知识信息与第一裁剪率,确定目标网络结构包含的除指定网络层之外的其他网络层对应的第二裁剪率。In case 2, if the first cropping rate represents the cropping rate of the specified network layer included in the target network structure, the second cropping rate corresponding to the specified network layer is determined based on the first cropping rate, and the first cropping rate is determined based on the pruning prior knowledge information and the first cropping rate. , and determine the second cropping rate corresponding to other network layers except the specified network layer included in the target network structure.

也即,可选实施例中如果第一裁剪率表征的是目标网络结构包含的指定网络层的裁剪率,那么可以基于表征目标网络结构包含的指定网络层裁剪率的第一裁剪率确定指定网络层对应的第二裁剪率,以及基于剪枝先验知识信息与表征的是目标网络结构包含的指定网络层裁剪率的第一裁剪率,确定目标网络结构包含的除指定网络层之外的其他网络层对应的第二裁剪率。That is, in an optional embodiment, if the first cropping rate represents the cropping rate of the specified network layer included in the target network structure, then the specified network can be determined based on the first cropping rate representing the cropping rate of the specified network layer contained in the target network structure. The second cropping rate corresponding to the layer, and the first cropping rate based on the pruning prior knowledge information and characterizing the specified network layer cropping rate contained in the target network structure, determine other than the specified network layer contained in the target network structure. The second cropping rate corresponding to the network layer.

其中,可以理解的是,可选实施例中基于剪枝先验知识信息与表征目标网络结构包含的指定网络层裁剪率的第一裁剪率,确定的是目标网络结构所包含的部分网络层(即除指定网络层之外的其他网络层)对应的第二裁剪率,此可以看作是半自动化剪枝。It can be understood that, in the optional embodiment, based on the pruning prior knowledge information and the first clipping rate representing the designated network layer clipping rate included in the target network structure, what is determined is a part of the network layer ( That is, the second pruning rate corresponding to other network layers (other than the specified network layer), which can be regarded as semi-automatic pruning.

其中,可选实施例中第一裁剪率表征目标网络结构包含的指定网络层裁剪率,具体形式可以是“层标识-裁剪率”,层标识指的是用于具体唯一标识网络层,其包括但不限于网络层名称、层标识号等。Wherein, in an optional embodiment, the first cropping rate represents the cropping rate of a specified network layer included in the target network structure, and the specific form may be "layer identification-cropping rate", and the layer identification refers to the specific and unique identification of the network layer, which includes But not limited to the network layer name, layer identification number, etc.

举例说明,例如设第一裁剪率为卷积层2-50%,同时设目标网络结构包含的各网络层分别为卷积层1、卷积层2、卷积层3、批归一化层、全连接层以及拼接层;那么可以得知卷积层2即为指定卷积层,此时可以基于第一裁剪率卷积层2-50%确定卷积层2对应的第二裁剪率为50%。相应地,还需要基于剪枝先验知识信息与第一裁剪率卷积层2-50%,确定除卷积层2之外的各网络层对应的第二裁剪率,例如设确定出卷积层1对应的第二裁剪率为45%,卷积层3对应的第二裁剪率为45%,批归一化层对应的第二裁剪率为55%,全连接层对应的第二裁剪率为50%,拼接层对应的第二裁剪率为55%。For example, for example, the first cropping rate is set to 2-50% of the convolutional layer, and the network layers included in the target network structure are set to be convolutional layer 1, convolutional layer 2, convolutional layer 3, and batch normalization layer respectively. , the fully connected layer and the splicing layer; then it can be known that the convolution layer 2 is the designated convolution layer. At this time, the second cropping rate corresponding to the convolutional layer 2 can be determined based on the first cropping rate of the convolutional layer 2-50%. 50%. Correspondingly, it is also necessary to determine the second cropping rate corresponding to each network layer except the convolutional layer 2 based on the pruning prior knowledge information and the first cropping rate convolutional layer 2-50%. The second cropping rate corresponding to layer 1 is 45%, the second cropping rate corresponding to convolutional layer 3 is 45%, the second cropping rate corresponding to batch normalization layer is 55%, and the second cropping rate corresponding to fully connected layer. is 50%, and the second cropping rate corresponding to the stitching layer is 55%.

这样,通过实施可选实施例,可以快速简便地确定各网络层对应的第二剪枝率,实现全自动化或半自动化剪枝。In this way, by implementing the optional embodiment, the second pruning rate corresponding to each network layer can be quickly and easily determined, so as to realize fully automatic or semi-automatic pruning.

在本申请的一个实施例中,步骤S603中根据各网络层对应的第二裁剪率,通过目标剪枝算法分别对各网络层进行剪枝,得到剪枝后的各网络层的过程,可以包括以下两种情况:In an embodiment of the present application, in step S603, according to the second clipping rate corresponding to each network layer, the target pruning algorithm is used to prune each network layer respectively, and the process of obtaining the pruned network layers may include: The following two situations:

情况一,若目标剪枝算法为结构化的剪枝算法,则基于结构化的剪枝算法分别对各网络层对应的特征图进行删除处理,以对各网络层进行剪枝,得到结构化剪枝后的各网络层。In case 1, if the target pruning algorithm is a structured pruning algorithm, the feature maps corresponding to each network layer are deleted based on the structured pruning algorithm, so as to prune each network layer and obtain a structured pruning algorithm. Each network layer after the branch.

也即,可选实施例中如果目标剪枝算法为结构化的剪枝算法,则可以基于结构化的剪枝算法分别对各网络层对应的特征图进行删除处理,从而实现对各网络层的剪枝,以得到结构化剪枝后的各网络层。That is, in an optional embodiment, if the target pruning algorithm is a structured pruning algorithm, the feature maps corresponding to each network layer may be deleted based on the structured pruning algorithm, so as to realize the pruning of each network layer. Pruning to obtain each network layer after structured pruning.

其中,可以理解的是,可选实施例中结构化剪枝(structured pruning)简单来说就是去掉某个神经元;因而,可选实施例中如果是要进行结构化剪枝,那么是基于结构化的剪枝算法分别对各网络层对应的特征图(其与卷积核相对应)进行删除处理,即相当于是去掉了某个神经元。Among them, it can be understood that in the optional embodiment, structured pruning (structured pruning) simply means removing a certain neuron; therefore, if structured pruning is to be performed in the optional embodiment, it is based on the structure The optimized pruning algorithm deletes the feature maps (corresponding to the convolution kernels) corresponding to each network layer, which is equivalent to deleting a certain neuron.

其中,可选实施例中结构化剪枝算法包括但不限于L1范数剪枝算法、FPGM(FilterPruning via Geometric Median)剪枝算法以及网络瘦身剪枝算法等。Wherein, the structured pruning algorithm in the optional embodiment includes, but is not limited to, the L1 norm pruning algorithm, the FPGM (Filter Pruning via Geometric Median) pruning algorithm, the network slimming pruning algorithm, and the like.

情况二,若目标剪枝算法为非结构化的剪枝算法,则基于非结构化的剪枝算法分别对各网络层对应的特征图含有的特征值进行置零处理,以对各网络层进行剪枝,得到非结构化剪枝后的各网络层。In case 2, if the target pruning algorithm is an unstructured pruning algorithm, then based on the unstructured pruning algorithm, the eigenvalues contained in the feature maps corresponding to each network layer are set to zero respectively, so as to perform zero processing on each network layer. Pruning to get each network layer after unstructured pruning.

也即,可选实施例中如果目标剪枝算法为非结构化的剪枝算法,则可以基于非结构化的剪枝算法分别对各网络层对应的特征图含有的特征值进行置零处理,从而实现对各网络层的剪枝,以得到非结构化剪枝后的各网络层。That is, in an optional embodiment, if the target pruning algorithm is an unstructured pruning algorithm, the feature values contained in the feature maps corresponding to each network layer may be reset to zero based on the unstructured pruning algorithm, respectively. Thus, the pruning of each network layer is realized to obtain each network layer after unstructured pruning.

其中,可以理解的是,可选实施例中非结构化剪枝(unstructured pruning)简单来说就是去掉神经元之间的连线(即权重);因而,可选实施例中如果是要进行非结构化剪枝,那么是基于非结构化的剪枝算法分别对各网络层对应的特征图(其与卷积核相对应)含有的特征值进行置零处理,即相当于是去掉了神经元之间的连线。Among them, it can be understood that in the optional embodiment, unstructured pruning simply means removing the connections (ie weights) between neurons; therefore, in the optional embodiment, if the unstructured pruning is to be Structural pruning, then based on the unstructured pruning algorithm, the eigenvalues contained in the feature map corresponding to each network layer (which corresponds to the convolution kernel) are zeroed, which is equivalent to removing the neuron. connection between.

这样,通过实施可选实施例,可以灵活选择是对卷积神经网络模型进行结构化剪枝还是非结构化剪枝,灵活度更高。In this way, by implementing the optional embodiment, it is possible to flexibly choose whether to perform structured pruning or unstructured pruning on the convolutional neural network model, with higher flexibility.

在本申请的一个实施例中,剪枝配置文件中包括跳跃结构的处理信息;请参阅图7,步骤S203中基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型的过程,可以包括以下步骤S701至步骤S703,详细介绍如下:In an embodiment of the present application, the pruning configuration file includes the processing information of the skip structure; please refer to FIG. 7 , in step S203, the target network structure is pruned based on the target pruning algorithm, and the pruned convolutional neural network is obtained. The process of the network model may include the following steps S701 to S703, which are described in detail as follows:

步骤S701,读取剪枝配置文件中含有的跳跃结构的处理信息;Step S701, read the processing information of the jump structure contained in the pruning configuration file;

步骤S702,若处理信息指示对跳跃结构进行处理,则对目标网络结构中包含的跳跃结构的所有网络层进行剪枝,得到剪枝后的卷积神经网络模型;Step S702, if the processing information indicates to process the jump structure, then prune all network layers of the jump structure included in the target network structure to obtain a pruned convolutional neural network model;

步骤S703,若处理信息指示不对跳跃结构进行处理,则获取目标网络结构中包含的跳跃结构的可跳跃网络层,并对可跳跃网络层进行剪枝,得到剪枝后的卷积神经网络模型。Step S703, if the processing information indicates that the skipping structure is not to be processed, obtain the skippable network layer of the skipping structure included in the target network structure, and prune the skippable network layer to obtain a pruned convolutional neural network model.

也即,可选实施例中可以先读取剪枝配置文件中含有的跳跃结构的处理信息,之后根据处理信息所指示情况执行相应的剪枝,以得到剪枝后的卷积神经网络模型。That is, in an optional embodiment, the processing information of the skip structure contained in the pruning configuration file may be read first, and then corresponding pruning is performed according to the situation indicated by the processing information, so as to obtain a pruned convolutional neural network model.

其中,可选实施例中如果处理信息所指示情况是对跳跃结构进行处理,那么可以对目标网络结构中包含的跳跃结构的所有网络层进行剪枝,从而得到剪枝后的卷积神经网络模型。可以理解的是,如果对目标网络结构中包含的跳跃结构的所有网络层进行剪枝,相对仅对目标网络结构中包含的跳跃结构的可跳跃网络层进行剪枝而言,剪枝后的卷积神经网络模型的占用空间会更少,处理速度会更快。Among them, in an optional embodiment, if the situation indicated by the processing information is to process the skip structure, then all network layers of the skip structure included in the target network structure may be pruned, so as to obtain the pruned convolutional neural network model. . It can be understood that if all network layers of the skip structure included in the target network structure are pruned, compared to pruning only the skippable network layers of the skip structure included in the target network structure, the pruned volume The product neural network model will take up less space and the processing speed will be faster.

其中,可选实施例中如果处理信息所指示情况是不对跳跃结构进行处理,那么可以获取目标网络结构中包含的跳跃结构的可跳跃网络层,并对可跳跃网络层进行剪枝,从而得到剪枝后的卷积神经网络模型。可以理解的是,如果仅对目标网络结构中包含的跳跃结构的可跳跃网络层进行剪枝,相对对目标网络结构中包含的跳跃结构的所有网络层进行剪枝而言,剪枝后的卷积神经网络模型的精度会更高。Among them, in an optional embodiment, if the situation indicated by the processing information is that the skip structure is not processed, then the skippable network layer of the skip structure included in the target network structure can be obtained, and the skippable network layer can be pruned, so as to obtain the pruned network layer. A post-branch convolutional neural network model. It can be understood that if only the skippable network layers of the skip structure included in the target network structure are pruned, compared to pruning all the network layers of the skip structure included in the target network structure, the pruned volume The accuracy of the product neural network model will be higher.

这样,通过实施可选实施例,可以灵活选择对卷积神经网络模型中包含的跳跃结构进行处理还是不处理,灵活度更高。In this way, by implementing the optional embodiment, it is possible to flexibly choose to process or not to process the jumping structure included in the convolutional neural network model, and the degree of flexibility is higher.

在本申请的一个实施例中,剪枝配置文件中包括跳跃结构的处理信息;请参阅图8,步骤S203中基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型的过程,可以包括以下步骤S801至步骤S802,详细介绍如下:In an embodiment of the present application, the pruning configuration file includes the processing information of the jump structure; please refer to FIG. 8 , in step S203, the target network structure is pruned based on the target pruning algorithm, and the pruned convolutional neural network is obtained. The process of the network model may include the following steps S801 to S802, which are described in detail as follows:

步骤S801,从目标网络结构中确定出用于表征输出的网络节点;Step S801, determining the network node used to characterize the output from the target network structure;

步骤S802,基于目标剪枝算法对目标网络结构包含的除用于表征输出的网络节点之外的其他网络节点进行剪枝,得到剪枝后的卷积神经网络模型。Step S802 , prune other network nodes included in the target network structure except the network nodes used to characterize the output based on the target pruning algorithm, to obtain a pruned convolutional neural network model.

也即,可选实施例中可以先从目标网络结构中确定出用于表征输出的网络节点,之后基于目标剪枝算法对目标网络结构包含的除用于表征输出的网络节点之外的其他网络节点进行剪枝,得到剪枝后的卷积神经网络模型。That is, in an optional embodiment, the network nodes used to characterize the output may be determined from the target network structure first, and then other networks included in the target network structure except the network nodes used to characterize the output may be determined based on the target pruning algorithm. The nodes are pruned to obtain the pruned convolutional neural network model.

其中,可选实施例中从目标网络结构中确定出用于表征输出的网络节点,可以是通过前述所介绍的有向无环图中确定得到,在其他实施例中也可以采用其他任意方式。Wherein, in an optional embodiment, the network node used to characterize the output is determined from the target network structure, which may be determined through the directed acyclic graph described above, and other arbitrary methods may also be used in other embodiments.

其中,可选实施例中从目标网络结构中确定出用于表征输出的网络节点,可以同时对表征输出的网络节点进行标记,从而以将该表征输出的网络节点与其他网络节点相区分。Wherein, in an optional embodiment, the network node used for characterizing the output is determined from the target network structure, and the network node characterizing the output can be marked at the same time, so as to distinguish the network node characterizing the output from other network nodes.

举例说明,例如设从目标网络结构中包含的网络节点有50个,分别为0-49,以及设确定出用于表征输出的网络节点有5个,分别为网络节点10-15,那么其他网络节点为0-9、16-49,此时是基于目标剪枝算法对其他网络节点为0-9、16-49进行剪枝,从而得到剪枝后的卷积神经网络模型。For example, if there are 50 network nodes included in the target network structure, which are 0-49 respectively, and there are 5 network nodes determined to represent the output, which are network nodes 10-15, then other networks The nodes are 0-9 and 16-49. At this time, based on the target pruning algorithm, other network nodes are pruned from 0-9 and 16-49 to obtain the pruned convolutional neural network model.

这样,通过实施可选实施例,由于未对表征输出的网络节点进行剪枝,因而保证了剪枝后的卷积神经网络模型的输出正确以及完整,避免了对表征输出的网络节点进行剪枝后所造成的剪枝后的卷积神经网络模型无法输出或输出出错的现象,使得剪枝后的卷积神经网络模型的精度不受过大影响,平衡了剪枝后的卷积神经网络模型的占用空间、处理速度以及精度。In this way, by implementing the optional embodiment, since the network nodes representing the output are not pruned, the output of the pruned convolutional neural network model is guaranteed to be correct and complete, and the pruning of the network nodes representing the output is avoided. The phenomenon that the pruned convolutional neural network model cannot be output or the output is wrong, so that the accuracy of the pruned convolutional neural network model is not greatly affected, which balances the pruned convolutional neural network model. Footprint, processing speed, and precision.

步骤S204,基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。Step S204, processing the data to be processed based on the pruned convolutional neural network model to obtain a processing result.

本申请实施例中基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型,之后可以基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。In the embodiment of the present application, the target network structure is pruned based on the target pruning algorithm to obtain a pruned convolutional neural network model, and then the data to be processed can be processed based on the pruned convolutional neural network model to obtain a processing result .

本申请实施例中待处理数据包括但不限于图像数据、语音数据以及文字数据等;可选地,待处理数据可以包括图像数据、语音数据以及文字数据中的任意一种或多种。The data to be processed in this embodiment of the present application includes, but is not limited to, image data, voice data, and text data; optionally, the data to be processed may include any one or more of image data, voice data, and text data.

在本申请的一个实施例中,如果待处理数据为图像数据,则基于剪枝后的卷积神经网络模型对图像数据进行处理,从而得到图像处理结果。In an embodiment of the present application, if the data to be processed is image data, the image data is processed based on the pruned convolutional neural network model, thereby obtaining an image processing result.

在本申请的一个实施例中,如果待处理数据为语音数据,则基于剪枝后的卷积神经网络模型对语音数据进行处理,从而得到语音处理结果。In an embodiment of the present application, if the data to be processed is speech data, the speech data is processed based on the pruned convolutional neural network model, thereby obtaining a speech processing result.

在本申请的一个实施例中,如果待处理数据为文字数据,则基于剪枝后的卷积神经网络模型对文字数据进行处理,从而得到文字处理结果。In an embodiment of the present application, if the data to be processed is text data, the text data is processed based on the pruned convolutional neural network model, thereby obtaining a text processing result.

这样,通过实施可选实施例,可以基于剪枝后的卷积神经网络模型对多种待处理数据进行处理,适用于诸多应用场景,适用范围广。In this way, by implementing the optional embodiment, a variety of data to be processed can be processed based on the pruned convolutional neural network model, which is suitable for many application scenarios and has a wide range of applications.

本申请实施例中实现了对待处理的卷积神经网络模型的自动化剪枝优化,提升了对待处理的卷积神经网络模型的剪枝效率以及准确率,相应地,也提升了基于剪枝优化后的卷积神经模型对待处理数据的处理效率以及准确率;同时将目标剪枝算法与识别算法隔离开,耦合性低,能够在极大程度上减少修改量,从而减少相关工作者的工作量,为相关工作者带来诸多便利,能够适用于更加广泛的基于卷积神经网络模型的数据处理应用场景中。In the embodiment of the present application, automatic pruning and optimization of the convolutional neural network model to be processed is realized, the pruning efficiency and accuracy of the convolutional neural network model to be processed are improved, and correspondingly, the pruning-based optimization is also improved. The processing efficiency and accuracy of the data to be processed by the convolutional neural model; at the same time, the target pruning algorithm and the recognition algorithm are isolated, and the coupling is low, which can greatly reduce the amount of modification, thereby reducing the workload of related workers, It brings many conveniences to related workers and can be applied to a wider range of data processing application scenarios based on convolutional neural network models.

本申请实施例中提出一种用于对卷积神经网络模型进行处理的剪枝框架;请参阅图9,图9是本申请的一个实施例示出的剪枝框架的结构示意图。如图9所示,剪枝框架包括用户层901、中间层902和剪枝层903,其中:An embodiment of the present application proposes a pruning framework for processing a convolutional neural network model; please refer to FIG. 9 , which is a schematic structural diagram of a pruning framework according to an embodiment of the present application. As shown in Figure 9, the pruning framework includes a user layer 901, an intermediate layer 902 and a pruning layer 903, wherein:

用户层901,用于获取待处理的卷积神经网络模型,以及与卷积神经网络模型匹配的剪枝配置文件;User layer 901, used to obtain the convolutional neural network model to be processed, and the pruning configuration file matched with the convolutional neural network model;

中间层902,用于基于剪枝配置文件确定目标剪枝算法;The middle layer 902 is used to determine the target pruning algorithm based on the pruning configuration file;

剪枝层903,用于基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,以及基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型。The pruning layer 903 is used to identify the network structure of the convolutional neural network model based on the identification algorithm to obtain the target network structure, and to prune the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network Model.

在本申请的一个实施例中,基于卷积神经网络模型的数据处理方法还可以包括:获取用于对卷积神经网络模型的网络结构进行识别的识别算法,以及至少两种用于对目标网络结构进行剪枝的剪枝算法;基于识别算法以及至少两种剪枝算法构建并生成剪枝框架。In an embodiment of the present application, the data processing method based on the convolutional neural network model may further include: acquiring an identification algorithm for identifying the network structure of the convolutional neural network model, and at least two methods for identifying the target network A pruning algorithm for structure pruning; a pruning framework is constructed and generated based on the recognition algorithm and at least two pruning algorithms.

也即,可选实施例中识别算法是用于对卷积神经网络模型的网络结构进行识别,剪枝算法是用于对目标网络结构进行剪枝,即剪枝算法与识别算法相隔离开,分别获取识别算法和剪枝算法,并基于识别算法和剪枝算法构建并生成剪枝框架。That is, in the optional embodiment, the identification algorithm is used to identify the network structure of the convolutional neural network model, and the pruning algorithm is used to prune the target network structure, that is, the pruning algorithm and the identification algorithm are separated from each other, respectively. Obtain the recognition algorithm and pruning algorithm, and build and generate a pruning framework based on the recognition algorithm and pruning algorithm.

在本申请的一个实施例中,基于识别算法以及至少两种剪枝算法构建并生成剪枝框架,具体可以包括:构建用户层、中间层以及剪枝层;In an embodiment of the present application, a pruning framework is constructed and generated based on an identification algorithm and at least two pruning algorithms, which may specifically include: constructing a user layer, an intermediate layer, and a pruning layer;

调用中间层的第一接口,将至少两种剪枝算法预置在中间层,以及调用剪枝层的第二接口,将识别算法预置在剪枝层;通过用户层、预置有剪枝算法的中间层以及预置有识别算法的剪枝层生成剪枝框架。Call the first interface of the middle layer to preset at least two pruning algorithms in the middle layer, and call the second interface of the pruning layer to preset the recognition algorithm in the pruning layer; The middle layer of the algorithm and the pruning layer preset with the recognition algorithm generate the pruning framework.

也即,可选实施例中可以通过调用中间层设置有的第一接口,将至少两种剪枝算法预置在中间层,以及可以通过调用剪枝层的第二接口,将识别算法预置在剪枝层。That is, in an optional embodiment, at least two pruning algorithms can be preset in the middle layer by calling the first interface provided by the middle layer, and the recognition algorithm can be preset by calling the second interface of the pruning layer. in the pruning layer.

本申请实施例中剪枝框架在使用前,可以是先将剪枝框架打包为一个库,之后通过Python语言的PIP协议/工具安装并导入该剪枝框架。Before using the pruning framework in the embodiment of the present application, the pruning framework may be packaged as a library, and then the pruning framework is installed and imported through the PIP protocol/tool of the Python language.

针对剪枝框架中的各层,详细介绍如下:For each layer in the pruning framework, the details are as follows:

其中,可选实施例中用户层901指的是整个剪枝框架的输入部分,为使用剪枝框架,相关管理者/使用者/开发者需要提供已经训练好的卷积神经网络模型文件和剪枝配置文件。Among them, in the optional embodiment, the user layer 901 refers to the input part of the entire pruning framework. In order to use the pruning framework, the relevant manager/user/developer needs to provide the trained convolutional neural network model file and the pruning framework. stick configuration file.

可选地,剪枝配置文件可以共有三个配置项,分别为目标剪枝算法的标识信息、跳跃结构的处理信息以及第一裁剪率(可通过第一裁剪率的表征情况确定剪枝策略,或者剪枝配置文件中可以包含除前述三个配置项之外,还包含有剪枝策略);具体地:目标剪枝算法的标识信息为告知剪枝框架对卷积神经网络模型进行剪枝优化所应该使用的目标剪枝算法。跳跃结构的剪枝一定程度上会降低卷积神经网络模型的精度,因此,本申请实施例中的剪枝框架选择让相关管理者/使用者/开发者自行选择是否处理跳跃结构。剪枝策略分为全自动化剪枝策略与半自动化剪枝策略,全自动化策略是指第一裁剪率表征全局裁剪率,各网络层对应的第二裁剪率由剪枝框架自动来指定;半自动化剪枝策略则允许相关管理者/使用者/开发者使用如“层标识-裁剪率”这样的键值对来指定网络层的裁剪率,而未指定网络层对应的第二裁剪率仍旧由剪枝框架自动来指定。Optionally, the pruning configuration file may have a total of three configuration items, which are the identification information of the target pruning algorithm, the processing information of the jump structure, and the first trimming rate (the pruning strategy can be determined by the representation of the first trimming rate, Alternatively, the pruning configuration file may contain a pruning strategy in addition to the aforementioned three configuration items); specifically: the identification information of the target pruning algorithm is to inform the pruning framework to prune and optimize the convolutional neural network model. The target pruning algorithm that should be used. The pruning of the skip structure will reduce the accuracy of the convolutional neural network model to a certain extent. Therefore, the pruning framework selection in this embodiment of the present application allows the relevant managers/users/developers to choose whether to process the skip structure. The pruning strategy is divided into fully automatic pruning strategy and semi-automatic pruning strategy. The fully automatic strategy means that the first pruning rate represents the global pruning rate, and the second pruning rate corresponding to each network layer is automatically specified by the pruning framework; The pruning strategy allows the relevant managers/users/developers to specify the pruning rate of the network layer using key-value pairs such as "layer ID-pruning rate", while the second pruning rate corresponding to the unspecified network layer is still determined by the pruning rate. The branch frame is automatically specified.

其中,可选实施例中中间层902中设置有读取器、策略器以及剪枝算法库。Wherein, in an optional embodiment, the middle layer 902 is provided with a reader, a policyr, and a pruning algorithm library.

可选地,将模型文件和剪枝配置文件送入读取器后,读取器可以通过读取剪枝配置文件得到剪枝策略,如可以通过读取剪枝配置文件中含有的裁剪率的表征情况确定剪枝策略,或者通过读取剪枝配置文件中含有的剪枝策略得到。可以理解的是,读取器读取到的剪枝策略可以有全自动化剪枝策略或者半自动化剪枝策略。Optionally, after the model file and the pruning configuration file are sent to the reader, the reader can obtain the pruning strategy by reading the pruning configuration file, for example, by reading the pruning rate contained in the pruning configuration file. The pruning strategy is determined by characterizing the situation, or obtained by reading the pruning strategy contained in the pruning configuration file. It can be understood that the pruning strategy read by the reader may have a fully automatic pruning strategy or a semi-automatic pruning strategy.

可选地,策略器可以根据读取器中的内容确定当前的剪枝策略为全自动化剪枝策略还是半自动化剪枝策略。其中,如果是全自动化剪枝策略,则策略器通过分析卷积神经网络模型的网络结构(这里只是简单分析,确定卷积神经网络模型中具有哪些网络层),并结合以往的剪枝先验知识信息以及第一裁剪率,为各网络层设定第二裁剪率。其中,如果是半自动化剪枝策略,则策略器执行与全自动化剪枝策略基本相同的操作,区别在于,部分网络层(即指定网络层)的第二裁剪率是剪枝配置文件中所指定的。Optionally, the policer may determine whether the current pruning strategy is a fully automatic pruning strategy or a semi-automatic pruning strategy according to the content in the reader. Among them, if it is a fully automatic pruning strategy, the strategy device analyzes the network structure of the convolutional neural network model (here is just a simple analysis to determine which network layers are in the convolutional neural network model), and combines the previous pruning priors. The knowledge information and the first cropping rate are used to set the second cropping rate for each network layer. Among them, if it is a semi-automatic pruning strategy, the strategy device performs basically the same operation as the fully automatic pruning strategy, the difference is that the second pruning rate of some network layers (that is, the specified network layer) is specified in the pruning configuration file. of.

可选地,当确定好各网络层的第二裁剪率,之后可以在剪枝算法库中选择与剪枝配置文件中含有的目标剪枝算法的标识信息匹配的目标剪枝算法对卷积神经网络模型进行剪枝优化。其中,剪枝算法库中封装有L1范数剪枝算法,FPGM剪枝算法,网络瘦身剪枝算法等结构化剪枝算法,在其他实施例中,可以同时或者单独封装非结构化剪枝算法;可以理解的是,这些结构化剪枝算法的输入为指定网络层,输出为网络层中需要移除的算子索引。相应地,中间层得到需要移除的算子索引,之后可以将索引内容(即需要移除的算子索引)发送至剪枝层,进而剪枝层执行真正的剪枝操作。Optionally, when the second cropping rate of each network layer is determined, the target pruning algorithm that matches the identification information of the target pruning algorithm contained in the pruning configuration file can be selected from the pruning algorithm library to the convolutional neural network. The network model is pruned and optimized. Among them, structured pruning algorithms such as L1 norm pruning algorithm, FPGM pruning algorithm, and network slimming pruning algorithm are encapsulated in the pruning algorithm library. In other embodiments, unstructured pruning algorithms may be encapsulated simultaneously or separately ; It is understandable that the input of these structured pruning algorithms is the specified network layer, and the output is the operator index to be removed in the network layer. Correspondingly, the intermediate layer obtains the operator index to be removed, and then can send the index content (ie, the operator index to be removed) to the pruning layer, and then the pruning layer performs the real pruning operation.

可选地,剪枝算法库还预留有第一接口(即开发者接口),用于开发者为剪枝框架封装剪枝算法,包括但不限于增加剪枝算法、删除剪枝算法、修改剪枝算法以及查询剪枝算法等。Optionally, the pruning algorithm library also reserves a first interface (that is, a developer interface) for developers to encapsulate pruning algorithms for the pruning framework, including but not limited to adding pruning algorithms, deleting pruning algorithms, modifying Pruning algorithm and query pruning algorithm, etc.

其中,可选实施例中剪枝层903主要可以实现算子支持、计算图构建、跳跃结构识别以及剪枝保护四大功能。Among them, in an optional embodiment, the pruning layer 903 can mainly realize four functions of operator support, calculation graph construction, jump structure identification, and pruning protection.

可选地,算子支持是指对当前卷积神经网络模型的各网络层作剪枝操作的支持,包含多种卷积层、批归一化层,全连接层以及拼接等网络层。可以理解的是,为实现结构化剪枝,算子支持的实现方式具体可以为新建网络层并将原网络层中非冗余算子的参数复制至新建网络层。Optionally, operator support refers to support for pruning each network layer of the current convolutional neural network model, including multiple convolutional layers, batch normalization layers, fully connected layers, and splicing and other network layers. It can be understood that, in order to implement structured pruning, the implementation supported by the operator may specifically be to create a new network layer and copy the parameters of the non-redundant operators in the original network layer to the new network layer.

可选地,计算图(即有向无环图)构建可以利用卷积神经网络的链式法则这一识别算法,请参阅图10,卷积神经网络模型包括输入节点、隐藏节点以及输出节点,各节点之间存在着依赖关系,基于依赖关系可以构建得到计算图,之后基于计算图可以得到目标网络结构。可选地,剪枝层903还预留有第二接口(即开发者接口),用于开发者为剪枝框架封装识别算法。Optionally, the construction of the computational graph (ie, directed acyclic graph) can utilize the identification algorithm of the chain rule of the convolutional neural network. Please refer to Figure 10. The convolutional neural network model includes input nodes, hidden nodes, and output nodes. There is a dependency relationship between each node. Based on the dependency relationship, a computational graph can be constructed, and then the target network structure can be obtained based on the computational graph. Optionally, the pruning layer 903 further reserves a second interface (ie, a developer interface) for the developer to encapsulate the identification algorithm for the pruning framework.

可选地,跳跃结构识别,请参阅图11,为一种示例的跳跃结构,其中路径A与路径B在递归过程中相交于同一点,具体包括网络层1-3,网络层1可以跳跃到网络层3之后,那么网络层2即作为可跳跃网络层。如果剪枝配置文件中含有的跳跃结构的处理信息指示对跳跃结构进行处理,则是对网络层1-3进行剪枝,并保证剪枝后的网络层1-3仍可以执行相加操作;如果剪枝配置文件中含有的跳跃结构的处理信息指示不对跳跃结构进行处理,则是对网络层2进行剪枝,而对于网络层1、网络3则无需进行剪枝,同样地,保证剪枝后的网络层2与未剪枝的网络层1、网络3仍可以执行相加操作。这样,通过对跳跃结构的识别,可以灵活选择对卷积神经网络模型中包含的跳跃结构进行处理还是不处理,灵活度更高。Optionally, hopping structure identification, please refer to FIG. 11 , which is an exemplary hopping structure, in which path A and path B intersect at the same point in the recursive process, specifically including network layers 1-3, network layer 1 can jump to After the network layer 3, then the network layer 2 is the skippable network layer. If the processing information of the hopping structure contained in the pruning configuration file indicates that the hopping structure is to be processed, the network layers 1-3 are pruned, and it is ensured that the pruned network layers 1-3 can still perform the addition operation; If the processing information of the jump structure contained in the pruning configuration file indicates that the jump structure is not to be processed, the network layer 2 is pruned, but the network layer 1 and network 3 do not need to be pruned. Similarly, ensure that the pruning is performed. The added network layer 2 and the unpruned network layer 1 and network 3 can still perform the addition operation. In this way, by identifying the jumping structure, it is possible to flexibly choose to process or not to process the jumping structure included in the convolutional neural network model, and the flexibility is higher.

可选地,剪枝保护,可以通过从目标网络结构中确定出用于表征输出的网络节点,并对该表征输出的网络节点进行标记,相应地,进行标记过的网络节点无需进行剪枝,而仅对未标记过的网络节点进行剪枝。这样,可以得到正确的剪枝结果,保证了剪枝后的卷积神经网络模型的输出正确以及完整。Optionally, for pruning protection, the network node used to characterize the output can be determined from the target network structure, and the network node representing the output can be marked. Correspondingly, the marked network node does not need to be pruned, Instead, only unlabeled network nodes are pruned. In this way, the correct pruning result can be obtained, which ensures that the output of the pruned convolutional neural network model is correct and complete.

可选地,剪枝框架中各层的具体实施过程请参见前述实施例的技术方案,这里不再赘述。Optionally, for the specific implementation process of each layer in the pruning framework, please refer to the technical solutions in the foregoing embodiments, which will not be repeated here.

需要说明的是,本申请实施例中的剪枝框架不仅适用于简单的分类任务,还适用于复杂的目标检测任务以及语义分割等视觉任务,可以对视觉任务上提供较高的支持。其中,在分类任务中,本申请实施例中的剪枝框架支持ResNet(残差网络,Residual Network)以及MobileNet(可分离卷积)等网络;在目标检测任务中,本申请实施例中的剪枝框架支持YOLO(对象检测)全系列以及CenterNet等网络;在语义分割任务中,本申请实施例中的剪枝框架支持PSPNet(Pyramid Scene Parsing Network,语义分割)和U-Net(ConvolutionalNetworks for Biomedical Image Segmentation)等网络。请参阅表1,在PASCAL VOC2012+2017数据集中,本申请实施例中的剪枝框架可将YOLO-V5模型的参数量减少80.1%,mAP仅下降0.4%。It should be noted that the pruning framework in the embodiment of the present application is not only suitable for simple classification tasks, but also for complex target detection tasks and visual tasks such as semantic segmentation, and can provide high support for visual tasks. Among them, in the classification task, the pruning framework in the embodiment of the application supports ResNet (residual network, Residual Network) and MobileNet (separable convolution) and other networks; in the target detection task, the pruning in the embodiment of the application The pruning framework supports the whole series of YOLO (object detection) and CenterNet and other networks; in the semantic segmentation task, the pruning framework in the embodiment of this application supports PSPNet (Pyramid Scene Parsing Network, semantic segmentation) and U-Net (Convolutional Networks for Biomedical Image). Segmentation) and other networks. Please refer to Table 1. In the PASCAL VOC2012+2017 dataset, the pruning framework in this example can reduce the parameters of the YOLO-V5 model by 80.1%, and mAP by only 0.4%.

模型Model 参数量parameter quantity 精度(mAP@0.5)Accuracy (mAP@0.5) YOLO-V5模型YOLO-V5 model 2111441721114417 0.8240.824 剪枝后YOLO-V5模型YOLO-V5 model after pruning 42017684201768 0.8200.820

表1Table 1

本申请实施例中通过应用剪枝框架实现卷积神经网络模型的剪枝优化,不仅剪枝优化效率高,而且可以适用于诸多应用场景中,灵活性也更高。In the embodiment of the present application, the pruning optimization of the convolutional neural network model is realized by applying the pruning framework, which not only has high pruning and optimization efficiency, but also can be applied to many application scenarios and has higher flexibility.

图12是本申请的一个实施例示出的基于卷积神经网络模型的数据处理装置的框图。如图12所示,该基于卷积神经网络模型的数据处理装置包括:FIG. 12 is a block diagram of a data processing apparatus based on a convolutional neural network model according to an embodiment of the present application. As shown in Figure 12, the data processing device based on the convolutional neural network model includes:

获取模块1201,配置为获取待处理的卷积神经网络模型以及与卷积神经网络模型匹配的剪枝配置文件;Obtaining module 1201, configured to obtain a convolutional neural network model to be processed and a pruning configuration file matching the convolutional neural network model;

识别与确定模块1202,配置为基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,并基于剪枝配置文件确定目标剪枝算法,其中,目标剪枝算法独立于识别算法;The identification and determination module 1202 is configured to identify the network structure of the convolutional neural network model based on the identification algorithm, obtain the target network structure, and determine the target pruning algorithm based on the pruning configuration file, wherein the target pruning algorithm is independent of the identification algorithm ;

剪枝模块1203,配置为基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型;The pruning module 1203 is configured to prune the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network model;

处理模块1204,配置为基于剪枝后的卷积神经网络模型对待处理数据进行处理,得到处理结果。The processing module 1204 is configured to process the data to be processed based on the pruned convolutional neural network model to obtain a processing result.

在本申请的一个实施例中,剪枝配置文件中包括第一裁剪率;剪枝模块1203,包括:In an embodiment of the present application, the pruning configuration file includes a first pruning rate; the pruning module 1203 includes:

第一读取单元,配置为读取剪枝配置文件中含有的第一裁剪率;a first reading unit, configured to read the first pruning rate contained in the pruning configuration file;

第一确定单元,配置为基于第一裁剪率确定目标网络结构所包含的各网络层对应的第二裁剪率;a first determining unit, configured to determine a second trimming rate corresponding to each network layer included in the target network structure based on the first trimming rate;

第一剪枝单元,配置为根据各网络层对应的第二裁剪率,通过目标剪枝算法分别对各网络层进行剪枝,得到剪枝后的各网络层;The first pruning unit is configured to prune each network layer through the target pruning algorithm according to the second pruning rate corresponding to each network layer, and obtain each network layer after pruning;

生成单元,配置为基于剪枝后的各网络层生成剪枝后的卷积神经网络模型。The generating unit is configured to generate a pruned convolutional neural network model based on the pruned network layers.

在本申请的一个实施例中,第一确定单元,具体配置为:In an embodiment of the present application, the first determining unit is specifically configured as:

若第一裁剪率表征全局裁剪率,则基于剪枝先验知识信息与第一裁剪率,确定目标网络结构所包含的各网络层对应的第二裁剪率;If the first cropping rate represents the global cropping rate, then the second cropping rate corresponding to each network layer included in the target network structure is determined based on the pruning prior knowledge information and the first cropping rate;

若第一裁剪率表征目标网络结构包含的指定网络层裁剪率,则基于第一裁剪率确定指定网络层对应的第二裁剪率,以及基于剪枝先验知识信息与第一裁剪率,确定目标网络结构包含的除指定网络层之外的其他网络层对应的第二裁剪率。If the first cropping rate represents the cropping rate of the specified network layer included in the target network structure, the second cropping rate corresponding to the specified network layer is determined based on the first cropping rate, and the target is determined based on the pruning prior knowledge information and the first cropping rate The second cropping rate corresponding to other network layers except the specified network layer included in the network structure.

在本申请的一个实施例中,第一剪枝单元,具体配置为:In an embodiment of the present application, the first pruning unit is specifically configured as:

若目标剪枝算法为结构化的剪枝算法,则基于结构化的剪枝算法分别对各网络层对应的特征图进行删除处理,以对各网络层进行剪枝,得到结构化剪枝后的各网络层;If the target pruning algorithm is a structured pruning algorithm, the feature maps corresponding to each network layer are deleted based on the structured pruning algorithm, so as to prune each network layer, and the structured pruning algorithm is obtained. each network layer;

若目标剪枝算法为非结构化的剪枝算法,则基于非结构化的剪枝算法分别对各网络层对应的特征图含有的特征值进行置零处理,以对各网络层进行剪枝,得到非结构化剪枝后的各网络层。If the target pruning algorithm is an unstructured pruning algorithm, then based on the unstructured pruning algorithm, the eigenvalues contained in the feature maps corresponding to each network layer are set to zero, so as to prune each network layer. Get each network layer after unstructured pruning.

在本申请的一个实施例中,剪枝配置文件中包括跳跃结构的处理信息;剪枝模块1203,包括:In an embodiment of the present application, the pruning configuration file includes processing information of the skip structure; the pruning module 1203 includes:

第二读取单元,配置为读取剪枝配置文件中含有的跳跃结构的处理信息;The second reading unit is configured to read the processing information of the jump structure contained in the pruning configuration file;

第二剪枝单元,配置为若处理信息指示对跳跃结构进行处理,则对目标网络结构中包含的跳跃结构的所有网络层进行剪枝,得到剪枝后的卷积神经网络模型;The second pruning unit is configured to prune all network layers of the jump structure included in the target network structure if the processing information indicates that the skip structure is processed, to obtain a pruned convolutional neural network model;

第三剪枝单元,配置为若处理信息指示不对跳跃结构进行处理,则获取目标网络结构中包含的跳跃结构的可跳跃网络层,并对可跳跃网络层进行剪枝,得到剪枝后的卷积神经网络模型。The third pruning unit is configured to obtain the skippable network layer of the skip structure included in the target network structure if the processing information indicates that the skip structure is not to be processed, and prune the skippable network layer to obtain the pruned volume A neural network model.

在本申请的一个实施例中,剪枝模块1203,包括:In an embodiment of the present application, the pruning module 1203 includes:

第二确定单元,配置为从目标网络结构中确定出用于表征输出的网络节点;a second determining unit, configured to determine a network node for characterizing the output from the target network structure;

第四剪枝单元,配置为基于目标剪枝算法对目标网络结构包含的除用于表征输出的网络节点之外的其他网络节点进行剪枝,得到剪枝后的卷积神经网络模型。The fourth pruning unit is configured to prune other network nodes included in the target network structure except the network nodes used to characterize the output based on the target pruning algorithm, to obtain a pruned convolutional neural network model.

在本申请的一个实施例中,剪枝配置文件中包括目标剪枝算法的标识信息;识别与确定模块1202,包括:In an embodiment of the present application, the pruning configuration file includes identification information of the target pruning algorithm; the identification and determination module 1202 includes:

第三读取单元,配置为读取剪枝配置文件中含有的目标剪枝算法的标识信息;The third reading unit is configured to read the identification information of the target pruning algorithm contained in the pruning configuration file;

第三确定单元,配置为根据标识信息从预置的至少两种剪枝算法中确定出与标识信息匹配的目标剪枝算法。The third determining unit is configured to determine, according to the identification information, a target pruning algorithm matching the identification information from at least two preset pruning algorithms.

在本申请的一个实施例中,剪枝配置文件中包括目标剪枝算法的标识信息;识别与确定模块1202,包括:In an embodiment of the present application, the pruning configuration file includes identification information of the target pruning algorithm; the identification and determination module 1202 includes:

识别单元,配置为通过识别算法对卷积神经网络模型进行识别,得到卷积神经网络模型中含有的算子的依赖关系,并将算子的依赖关系映射为有向无环图;The identification unit is configured to identify the convolutional neural network model through the identification algorithm, obtain the dependencies of the operators contained in the convolutional neural network model, and map the dependencies of the operators into a directed acyclic graph;

获得单元,配置为基于有向无环图得到目标网络结构。The obtaining unit is configured to obtain the target network structure based on the directed acyclic graph.

在本申请的一个实施例中,待处理数据包括图像数据、语音数据以及文字数据中的至少一种;处理模块1204,包括:In an embodiment of the present application, the data to be processed includes at least one of image data, voice data, and text data; the processing module 1204 includes:

第一处理单元,配置为若待处理数据为图像数据,则基于剪枝后的卷积神经网络模型对图像数据进行处理,得到图像处理结果;The first processing unit is configured to, if the data to be processed is image data, process the image data based on the pruned convolutional neural network model to obtain an image processing result;

第二处理单元,配置为若待处理数据为语音数据,则基于剪枝后的卷积神经网络模型对语音数据进行处理,得到语音处理结果;The second processing unit is configured to, if the data to be processed is voice data, process the voice data based on the pruned convolutional neural network model to obtain a voice processing result;

第三处理单元,配置为若待处理数据为文字数据,则基于剪枝后的卷积神经网络模型对文字数据进行处理,得到文字处理结果。The third processing unit is configured to, if the data to be processed is text data, process the text data based on the pruned convolutional neural network model to obtain a text processing result.

在本申请的一个实施例中,用于对卷积神经网络模型进行处理的剪枝框架包括用户层、中间层和剪枝层;In an embodiment of the present application, the pruning framework for processing the convolutional neural network model includes a user layer, an intermediate layer and a pruning layer;

用户层对应用户模块,用户层用于获取待处理的卷积神经网络模型,以及与卷积神经网络模型匹配的剪枝配置文件;The user layer corresponds to the user module, and the user layer is used to obtain the convolutional neural network model to be processed and the pruning configuration file matching the convolutional neural network model;

中间层对应中间模块,中间层用于基于剪枝配置文件确定目标剪枝算法;The middle layer corresponds to the middle module, and the middle layer is used to determine the target pruning algorithm based on the pruning configuration file;

剪枝层对应底层模块,剪枝层用于基于识别算法对卷积神经网络模型的网络结构进行识别,得到目标网络结构,以及基于目标剪枝算法对目标网络结构进行剪枝,得到剪枝后的卷积神经网络模型。The pruning layer corresponds to the underlying module, and the pruning layer is used to identify the network structure of the convolutional neural network model based on the recognition algorithm to obtain the target network structure, and to prune the target network structure based on the target pruning algorithm to obtain the pruned The convolutional neural network model.

在本申请的一个实施例中,装置还包括:In an embodiment of the present application, the device further includes:

获得模块,配置为获取用于对卷积神经网络模型的网络结构进行识别的识别算法,以及至少两种用于对目标网络结构进行剪枝的剪枝算法;an obtaining module, configured to obtain an identification algorithm for identifying the network structure of the convolutional neural network model, and at least two pruning algorithms for pruning the target network structure;

构建与生成模块,配置为基于识别算法以及至少两种剪枝算法构建并生成剪枝框架。The construction and generation module is configured to construct and generate a pruning framework based on the recognition algorithm and at least two pruning algorithms.

在本申请的一个实施例中,构建与生成模块,包括:In an embodiment of the present application, the building and generating module includes:

构建单元,配置为构建用户层、中间层以及剪枝层;The building unit is configured to build the user layer, the middle layer and the pruning layer;

预置单元,配置为调用中间层的第一接口,将至少两种剪枝算法预置在中间层,以及调用剪枝层的第二接口,将识别算法预置在剪枝层;The preset unit is configured to call the first interface of the middle layer, preset at least two pruning algorithms in the middle layer, and call the second interface of the pruning layer, and preset the identification algorithm in the pruning layer;

生成单元,配置为通过用户层、预置有剪枝算法的中间层以及预置有识别算法的剪枝层生成剪枝框架。The generating unit is configured to generate a pruning framework through a user layer, an intermediate layer with a preset pruning algorithm, and a pruning layer with a preset identification algorithm.

需要说明的是,前述实施例所提供的装置与前述实施例所提供的方法属于同一构思,其中各个模块和单元执行操作的具体方式已经在方法实施例中进行了详细描述,这里不再赘述。It should be noted that the apparatuses provided in the foregoing embodiments belong to the same concept as the methods provided in the foregoing embodiments, and the specific manners in which each module and unit performs operations have been described in detail in the method embodiments, which will not be repeated here.

本申请的实施例还提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当一个或多个程序被一个或多个处理器执行时,使得电子设备实现如前的基于卷积神经网络模型的数据处理方法。Embodiments of the present application also provide an electronic device, including: one or more processors; and a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, The electronic device is made to realize the previous data processing method based on the convolutional neural network model.

图13是适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。FIG. 13 is a schematic structural diagram of a computer system suitable for implementing the electronic device of the embodiment of the present application.

需要说明的是,图13示出的电子设备的计算机系统1300仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。It should be noted that the computer system 1300 of the electronic device shown in FIG. 13 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present application.

如图13所示,计算机系统1300包括中央处理单元(Central Processing Unit,CPU)1301,其可以根据存储在只读存储器(Read-Only Memory,ROM)1302中的程序或者从存储部分1308加载到随机访问存储器(Random Access Memory,RAM)1303中的程序而执行各种适当的动作和处理,例如执行上述实施例中的方法。在RAM 1303中,还存储有系统操作所需的各种程序和数据。CPU 1301、ROM 1302以及RAM 1303通过总线1304彼此相连。输入/输出(Input/Output,I/O)接口1305也连接至总线1304。As shown in FIG. 13 , the computer system 1300 includes a central processing unit (Central Processing Unit, CPU) 1301, which can be loaded into a random device according to a program stored in a read-only memory (Read-Only Memory, ROM) 1302 or from a storage part 1308 Various appropriate actions and processes are performed by accessing a program in a memory (Random Access Memory, RAM) 1303, for example, performing the methods in the above-mentioned embodiments. In the RAM 1303, various programs and data necessary for system operation are also stored. The CPU 1301 , the ROM 1302 , and the RAM 1303 are connected to each other through a bus 1304 . An Input/Output (I/O) interface 1305 is also connected to the bus 1304 .

以下部件连接至I/O接口1305:包括键盘、鼠标等的输入部分1306;包括诸如阴极射线管(Cathode Ray Tube,CRT)、液晶显示器(Liquid Crystal Display,LCD)等以及扬声器等的输出部分1307;包括硬盘等的存储部分1308;以及包括诸如LAN(Local AreaNetwork,局域网)卡、调制解调器等的网络接口卡的通信部分1309。通信部分1309经由诸如因特网的网络执行通信处理。驱动器1310也根据需要连接至I/O接口1305。可拆卸介质1311,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1310上,以便于从其上读出的计算机程序根据需要被安装入存储部分1308。The following components are connected to the I/O interface 1305: an input section 1306 including a keyboard, a mouse, etc.; an output section 1307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc. ; a storage section 1308 including a hard disk and the like; and a communication section 1309 including a network interface card such as a LAN (Local Area Network) card, a modem, and the like. The communication section 1309 performs communication processing via a network such as the Internet. Drivers 1310 are also connected to I/O interface 1305 as needed. A removable medium 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 1310 as needed so that a computer program read therefrom is installed into the storage section 1308 as needed.

特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的计算机程序。在这样的实施例中,该计算机程序可以通过通信部分1309从网络上被下载和安装,和/或从可拆卸介质1311被安装。在该计算机程序被中央处理单元(CPU)1301执行时,执行本申请的系统中限定的各种功能。In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising a computer program for performing the method illustrated in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 1309, and/or installed from the removable medium 1311. When the computer program is executed by the central processing unit (CPU) 1301, various functions defined in the system of the present application are executed.

需要说明的是,本申请实施例所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、闪存、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的计算机程序。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的计算机程序可以用任何适当的介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples of computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Erasable Programmable Read Only Memory (EPROM), flash memory, optical fiber, portable Compact Disc Read-Only Memory (CD-ROM), optical storage device, magnetic storage device, or any suitable of the above The combination. In this application, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program therein. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device . A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.

附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。其中,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不相同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Wherein, each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the above-mentioned module, program segment, or part of code contains one or more executables for realizing the specified logical function instruction. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented in special purpose hardware-based systems that perform the specified functions or operations, or can be implemented using A combination of dedicated hardware and computer instructions is implemented.

描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现,所描述的单元也可以设置在处理器中。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定。The units involved in the embodiments of the present application may be implemented in software or hardware, and the described units may also be provided in a processor. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances.

本申请的另一方面还提供了一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如前的基于卷积神经网络模型的数据处理方法。该计算机可读存储介质可以是上述实施例中描述的电子设备中所包含的,也可以是单独存在,而未装配入该电子设备中。Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the aforementioned data processing method based on a convolutional neural network model. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist alone without being assembled into the electronic device.

本申请的另一方面还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述各个实施例中提供的基于卷积神经网络模型的数据处理方法。Another aspect of the present application also provides a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the data processing method based on the convolutional neural network model provided in each of the foregoing embodiments.

上述内容,仅为本申请的较佳示例性实施例,并非用于限制本申请的实施方案,本领域普通技术人员根据本申请的主要构思和精神,可以十分方便地进行相应的变通或修改,故本申请的保护范围应以权利要求书所要求的保护范围为准。The above contents are only preferred exemplary embodiments of the present application, and are not intended to limit the embodiments of the present application. Those of ordinary skill in the art can easily make corresponding changes or modifications according to the main concept and spirit of the present application, Therefore, the protection scope of the present application shall be subject to the protection scope required by the claims.

Claims (15)

1. A data processing method based on a convolutional neural network model is characterized by comprising the following steps:
acquiring a convolutional neural network model to be processed and a pruning configuration file matched with the convolutional neural network model;
identifying a network structure of the convolutional neural network model based on an identification algorithm to obtain a target network structure, and determining a target pruning algorithm based on the pruning configuration file, wherein the target pruning algorithm is independent of the identification algorithm;
pruning the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model;
and processing the data to be processed based on the pruned convolutional neural network model to obtain a processing result.
2. The method of claim 1, wherein the pruning profile includes a first pruning rate; the pruning of the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network model comprises the following steps:
reading the first cutting rate contained in the pruning configuration file;
determining a second clipping rate corresponding to each network layer contained in the target network structure based on the first clipping rate;
according to the second cutting rate corresponding to each network layer, the target pruning algorithm is used for pruning each network layer to obtain each network layer after pruning;
and generating a pruned convolutional neural network model based on each pruned network layer.
3. The method of claim 2, wherein the determining a second clipping rate for each network layer included in the target network structure based on the first clipping rate comprises:
if the first clipping rate represents the global clipping rate, determining a second clipping rate corresponding to each network layer included in the target network structure based on the prior clipping knowledge information and the first clipping rate;
if the first clipping rate represents a designated network layer clipping rate contained in the target network structure, determining a second clipping rate corresponding to the designated network layer based on the first clipping rate, and determining a second clipping rate corresponding to other network layers except the designated network layer contained in the target network structure based on the pruning priori knowledge information and the first clipping rate.
4. The method according to claim 2, wherein the pruning, according to the second pruning rate corresponding to each network layer, each network layer through the target pruning algorithm to obtain each pruned network layer comprises:
if the target pruning algorithm is a structured pruning algorithm, deleting the feature maps corresponding to the network layers based on the structured pruning algorithm to prune the network layers to obtain the network layers after structured pruning;
and if the target pruning algorithm is an unstructured pruning algorithm, respectively carrying out zero setting processing on characteristic values contained in the characteristic graphs corresponding to the network layers based on the unstructured pruning algorithm so as to prune the network layers to obtain the network layers subjected to unstructured pruning.
5. The method of claim 1, wherein the pruning profile includes processing information for a skip structure; the pruning of the target network structure based on the target pruning algorithm to obtain the pruned convolutional neural network model comprises the following steps:
reading processing information of a jump structure contained in the pruning configuration file;
if the processing information indicates that the jump structure is processed, pruning all network layers of the jump structure contained in the target network structure to obtain a pruned convolutional neural network model;
and if the processing information indicates that the hopping structure is not processed, acquiring a jumpable network layer of the hopping structure contained in the target network structure, and pruning the jumpable network layer to obtain a pruned convolutional neural network model.
6. The method of claim 1, wherein said pruning the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model comprises:
determining a network node for characterizing an output from the target network structure;
and pruning other network nodes except the network node used for representing the output in the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model.
7. The method of claim 1, wherein the pruning configuration file includes identification information for the target pruning algorithm; the determining a target pruning algorithm based on the pruning configuration file comprises:
reading the identification information of the target pruning algorithm contained in the pruning configuration file;
and determining a target pruning algorithm matched with the identification information from at least two preset pruning algorithms according to the identification information.
8. The method of claim 1, wherein the identifying the network structure of the convolutional neural network model based on an identification algorithm to obtain a target network structure comprises:
identifying the convolutional neural network model through an identification algorithm to obtain the dependency relationship of operators contained in the convolutional neural network model, and mapping the dependency relationship of the operators into a directed acyclic graph;
and obtaining the target network structure based on the directed acyclic graph.
9. The method of claim 1, wherein the data to be processed comprises at least one of image data, voice data, and text data; the method for processing the data to be processed based on the pruned convolutional neural network model to obtain a processing result comprises the following steps:
if the data to be processed is image data, processing the image data based on the pruned convolutional neural network model to obtain an image processing result;
if the data to be processed is voice data, processing the voice data based on the pruned convolutional neural network model to obtain a voice processing result;
and if the data to be processed is character data, processing the character data based on the pruned convolutional neural network model to obtain a character processing result.
10. The method of any one of claims 1 to 9, wherein a pruning framework for processing the convolutional neural network model comprises a user layer, an intermediate layer, and a pruning layer;
the user layer is used for acquiring the convolutional neural network model to be processed and a pruning configuration file matched with the convolutional neural network model;
the middle layer is used for determining a target pruning algorithm based on the pruning configuration file;
the pruning layer is used for identifying the network structure of the convolutional neural network model based on an identification algorithm to obtain a target network structure, and pruning the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model.
11. The method of claim 10, wherein the method further comprises:
acquiring an identification algorithm for identifying the network structure of the convolutional neural network model and at least two pruning algorithms for pruning the target network structure;
and constructing and generating the pruning frame based on the identification algorithm and at least two pruning algorithms.
12. The method of claim 11, wherein said constructing and generating the pruning frame based on the recognition algorithm and at least two pruning algorithms comprises:
constructing a user layer, a middle layer and a pruning layer;
calling a first interface of the middle layer, presetting the at least two pruning algorithms in the middle layer, calling a second interface of the pruning layer, and presetting the identification algorithm in the pruning layer;
and generating the pruning frame through the user layer, the middle layer preset with the pruning algorithm and the pruning layer preset with the identification algorithm.
13. A data processing device based on a convolution neural network model is characterized in that,
the system comprises an acquisition module, a processing module and a pruning module, wherein the acquisition module is configured to acquire a convolutional neural network model to be processed and a pruning configuration file matched with the convolutional neural network model;
the identification and determination module is configured to identify a network structure of the convolutional neural network model based on an identification algorithm to obtain a target network structure, and determine a target pruning algorithm based on the pruning configuration file, wherein the target pruning algorithm is independent of the identification algorithm;
the pruning module is configured to prune the target network structure based on the target pruning algorithm to obtain a pruned convolutional neural network model;
and the processing module is configured to process the data to be processed based on the pruned convolutional neural network model to obtain a processing result.
14. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs that, when executed by the electronic device, cause the electronic device to implement the convolutional neural network model-based data processing method of any one of claims 1 to 12.
15. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out a method of data processing based on a convolutional neural network model as claimed in any one of claims 1 to 12.
CN202210183475.3A 2022-02-25 2022-02-25 Data processing method, device and equipment based on convolutional neural network model Pending CN114462582A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210183475.3A CN114462582A (en) 2022-02-25 2022-02-25 Data processing method, device and equipment based on convolutional neural network model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210183475.3A CN114462582A (en) 2022-02-25 2022-02-25 Data processing method, device and equipment based on convolutional neural network model

Publications (1)

Publication Number Publication Date
CN114462582A true CN114462582A (en) 2022-05-10

Family

ID=81415163

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210183475.3A Pending CN114462582A (en) 2022-02-25 2022-02-25 Data processing method, device and equipment based on convolutional neural network model

Country Status (1)

Country Link
CN (1) CN114462582A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114881227A (en) * 2022-05-13 2022-08-09 北京百度网讯科技有限公司 Model compression method, image processing method, device and electronic equipment
CN116468100A (en) * 2023-03-06 2023-07-21 美的集团(上海)有限公司 Residual pruning method, residual pruning device, electronic equipment and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190080238A1 (en) * 2017-09-08 2019-03-14 Vivante Corporation Pruning And Retraining Method For A Convolution Neural Network
CN110020724A (en) * 2019-03-18 2019-07-16 浙江大学 A kind of neural network column Sparse methods based on weight conspicuousness
CN110197257A (en) * 2019-05-28 2019-09-03 浙江大学 A kind of neural network structure Sparse methods based on increment regularization
CN110598731A (en) * 2019-07-31 2019-12-20 浙江大学 Efficient image classification method based on structured pruning
CN110874634A (en) * 2018-08-31 2020-03-10 阿里巴巴集团控股有限公司 Neural network optimization method and device, equipment and storage medium
CN112949840A (en) * 2021-04-20 2021-06-11 中国人民解放军国防科技大学 Channel attention guided convolutional neural network dynamic channel pruning method and device
CN113255650A (en) * 2021-06-24 2021-08-13 北京市水利自动化研究所 Rapid and accurate water meter metering identification method based on slimSSD model

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190080238A1 (en) * 2017-09-08 2019-03-14 Vivante Corporation Pruning And Retraining Method For A Convolution Neural Network
CN110874634A (en) * 2018-08-31 2020-03-10 阿里巴巴集团控股有限公司 Neural network optimization method and device, equipment and storage medium
CN110020724A (en) * 2019-03-18 2019-07-16 浙江大学 A kind of neural network column Sparse methods based on weight conspicuousness
CN110197257A (en) * 2019-05-28 2019-09-03 浙江大学 A kind of neural network structure Sparse methods based on increment regularization
CN110598731A (en) * 2019-07-31 2019-12-20 浙江大学 Efficient image classification method based on structured pruning
US20210049423A1 (en) * 2019-07-31 2021-02-18 Zhejiang University Efficient image classification method based on structured pruning
CN112949840A (en) * 2021-04-20 2021-06-11 中国人民解放军国防科技大学 Channel attention guided convolutional neural network dynamic channel pruning method and device
CN113255650A (en) * 2021-06-24 2021-08-13 北京市水利自动化研究所 Rapid and accurate water meter metering identification method based on slimSSD model

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HUI GUAN等: "Wootz: A Compiler-Based Framework for Fast CNNPruning via Composability", 《2019 ASSOCIATION FOR COMPUTING MACHINERY》, 26 June 2019 (2019-06-26), pages 1 - 12 *
王宜全: "基于图像识别的植保喷雾关键技术研究", 《中国优秀硕士学位论文全文数据库农业科技辑》, no. 04, 15 April 2021 (2021-04-15), pages 044 - 25 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114881227A (en) * 2022-05-13 2022-08-09 北京百度网讯科技有限公司 Model compression method, image processing method, device and electronic equipment
CN116468100A (en) * 2023-03-06 2023-07-21 美的集团(上海)有限公司 Residual pruning method, residual pruning device, electronic equipment and readable storage medium
CN116468100B (en) * 2023-03-06 2024-05-10 美的集团(上海)有限公司 Residual pruning method, residual pruning device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN111523640B (en) Training method and device for neural network model
WO2018059016A1 (en) Feature processing method and feature processing system for machine learning
CN112199086A (en) Automatic programming control system, method, device, electronic device and storage medium
CN113159315A (en) Neural network training method, data processing method and related equipment
CN114579584B (en) Data table processing method and device, computer equipment and storage medium
CN114462582A (en) Data processing method, device and equipment based on convolutional neural network model
CN115510249A (en) Knowledge graph construction method and device, electronic equipment and storage medium
WO2021000411A1 (en) Neural network-based document classification method and apparatus, and device and storage medium
CN117390150A (en) Problem processing method and device and computing device cluster
HK40070011A (en) Method and apparatus for data processing based on convolutional neural network model, and device
US20210326514A1 (en) Method for generating interpretation text, electronic device and storage medium
CN115630196A (en) Data query method, data query device, computer equipment, storage medium and program product
US20230018525A1 (en) Artificial Intelligence (AI) Framework to Identify Object-Relational Mapping Issues in Real-Time
CN111324757B (en) Map data problem processing method and device
CN115168609A (en) Text matching method and device, computer equipment and storage medium
CN114676677A (en) Information processing method, information processing apparatus, server, and storage medium
CN114186684A (en) A multi-task model training method, system, medium and electronic terminal
CN113535125A (en) Method and device for generating financial demand items
CN115481312A (en) Application recommended method, apparatus, computer equipment and storage medium
CN112101390A (en) Attribute information determination method, attribute information determination device and electronic equipment
CN116755714B (en) Method, device, equipment and storage medium for operating deep neural network model
CN114064106B (en) Middleware cluster recommendation method, device, electronic device and storage medium
US20230169408A1 (en) Annotation of a Machine Learning Pipeline with Operational Semantics
CN115510077A (en) Method, device, equipment and medium for updating graph data based on message passing
CN118586457A (en) Object risk identification method, device and equipment based on graph neural network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40070011

Country of ref document: HK