WO2020082595A1 - Image classification method, terminal device and non-volatile computer readable storage medium - Google Patents

Image classification method, terminal device and non-volatile computer readable storage medium Download PDF

Info

Publication number
WO2020082595A1
WO2020082595A1 PCT/CN2018/124630 CN2018124630W WO2020082595A1 WO 2020082595 A1 WO2020082595 A1 WO 2020082595A1 CN 2018124630 W CN2018124630 W CN 2018124630W WO 2020082595 A1 WO2020082595 A1 WO 2020082595A1
Authority
WO
WIPO (PCT)
Prior art keywords
image classification
preset
classification model
trained
value
Prior art date
Application number
PCT/CN2018/124630
Other languages
French (fr)
Chinese (zh)
Inventor
金戈
徐亮
肖京
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020082595A1 publication Critical patent/WO2020082595A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Definitions

  • the present application belongs to the field of computer technology, and particularly relates to an image classification method, a terminal device, and a computer non-volatile readable storage medium.
  • Image classification models based on deep learning or partial machine learning require training before they can be used to perform specific image classification functions, such as ethnic classification functions.
  • the process of training the image classification model is actually the process of optimizing the parameters in the image classification model, that is, to find the optimal parameters of the image classification model.
  • the image classification model can be used To perform the corresponding image classification function.
  • common momentum optimization algorithms such as stochastic gradient descent algorithm can generally be used to update the parameters in the image classification model to find the optimal parameters.
  • the stochastic gradient descent algorithm specifically needs to determine whether the model finds the optimal parameter by whether the loss function in the image classification model reaches the global minimum.
  • the loss function may be caused by the saddle point in the loss function It will not be able to converge to the global extremum point, and the optimal parameters of the image classification model cannot be determined.
  • the image classification model needs to analyze the image characteristics of the input image based on the optimal parameters in the model. For the image classification model that cannot determine the optimal parameters, the classification accuracy of the corresponding image classification model decreases.
  • An embodiment of the present application provides an image classification method, terminal device, and computer non-volatile readable storage medium to solve the problem of low classification accuracy of the image classification model in the prior art.
  • a first aspect of the embodiments of the present application provides that the first aspect provides an image classification method, including:
  • the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model
  • the optimal parameters are in the image classification model
  • the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
  • the image classification result is output.
  • a second aspect of the embodiments of the present application provides a terminal device.
  • the terminal device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor.
  • the processor The following steps are realized when the computer-readable instructions are executed:
  • the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the
  • the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
  • the image classification result is output.
  • a third aspect of the embodiments of the present application provides a terminal device, including:
  • An obtaining unit used to obtain the target image to be classified
  • the execution unit is configured to perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain image classification results, where the optimal parameters are in all
  • the second norm of the loss function of the image classification model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to make iterative optimization of the model parameters determined by the trained image classification model Avoid the saddle point
  • the output unit is used to output the image classification result.
  • a fourth aspect of the embodiments of the present application provides a computer nonvolatile readable storage medium, the computer nonvolatile readable storage medium stores computer readable instructions, and the computer readable instructions are executed by a processor The following steps are implemented:
  • the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model
  • the optimal parameters are in the image classification model
  • the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
  • the image classification result is output.
  • the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results,
  • the optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image
  • the model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and can more accurately extract the image feature corresponding to the target image ;
  • the predicted image classification result will also be more accurate.
  • FIG. 3 is a schematic diagram of a terminal device according to a third embodiment of the present application.
  • FIG. 4 is a schematic diagram of a terminal device according to a fourth embodiment of the present application.
  • FIG. 1 is a flowchart of an image classification method in the first embodiment of the present application.
  • the execution subject of the image classification method in this embodiment is a terminal device.
  • the image classification method as shown in the figure may include the following steps:
  • the user when a user needs to perform classification processing on a target image to be classified through the terminal device, the user may input the target image to be classified into the terminal device, and the terminal device acquires the target image to be classified. Among them, the terminal device classifies the target image based on the pre-stored image classification model pre-stored in the terminal device.
  • the image classification model may specifically be a classification model that implements a race classification function. All classification results that the image classification model can predict include at least two Of course, it is not limited to this.
  • S102 Perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain image classification results, where the optimal parameters are classified in the image
  • the second norm of the loss function of the model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to avoid the model parameters determined by the trained image classification model during the iterative optimization. Saddle point.
  • the terminal device performs feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and performs classification prediction processing on the image features to obtain image classification results.
  • Image classification The classification of model prediction is generally only one.
  • the preset noise value is used to classify the trained image
  • the model parameters determined by the model avoid the saddle point during iterative optimization, so that the optimal parameters are those determined when the image classification model converges to the global extremum during training, and the terminal device is based on the optimal parameters in the image classification model
  • the terminal device performs classification prediction processing on the image features based on the optimal parameters in the image classification model to obtain the image classification result.
  • the predicted image classification results will also be more accurate.
  • the image classification model may include a convolutional layer and a fully connected layer.
  • the model parameters may specifically be parameters in the convolutional layer and the fully connected layer.
  • the terminal device performs based on the parameter target image corresponding to the convolutional layer in the image classification model. Convolution calculation to extract the image features corresponding to the target image; the terminal device calculates based on the parametric image features corresponding to the fully connected layer in the image classification model, and predicts the image classification results corresponding to the image features.
  • the terminal device outputs the image classification result predicted by the image classification model, so that the user can obtain the corresponding image classification result.
  • the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results,
  • the optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image
  • the model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and more accurately extract the image feature corresponding to the target image ;
  • the predicted image classification result will also be more accurate.
  • FIG. 2 is an implementation flowchart of the image classification method provided by the second embodiment of the present application.
  • S2011-S2014 are further included.
  • S201-S204 are the same as S101-S104 in the first embodiment.
  • S2011 ⁇ S2014 are as follows:
  • S2011 Determine the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the two corresponding to the first gradient according to the first gradient. Norm.
  • the image classification model needs to be trained to perform the image classification function, and the process of training the image classification model is the process of iterative optimization of the model parameters of the image classification model, so that the model parameters of the image classification model can be optimized .
  • the terminal device determines the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model under the current iteration optimization times of the image classification model, and The second norm corresponding to the first gradient is determined according to the first gradient.
  • the first loss function value is the loss function value calculated by the loss function in the current iteration optimization times, and the gradient is used to represent the parameter vector corresponding to the loss function that changes the fastest and has the largest change rate during the current iteration optimization, the first gradient
  • the terminal device will also determine and obtain the second norm corresponding to the first gradient according to the first gradient.
  • S2012 Determine whether the second norm is less than the first preset value.
  • the terminal device Since the loss function has a saddle point, and the saddle point is the local minimum value of the loss function, in the prior art, the terminal device cannot distinguish whether the loss function is a local minimum value or a global minimum value, resulting in the image classification model unable to converge to The situation of the global extreme point.
  • the terminal device determines whether the second norm corresponding to the first gradient is less than the first A preset value to determine whether the loss function reaches the saddle point, where the first preset value is a preset value.
  • the second norm corresponding to the first gradient When the second norm corresponding to the first gradient is less than the first preset value, it means that the loss function reaches the saddle point; when the second norm corresponding to the first gradient is greater than or the first preset value, it means that the loss function has not reached the saddle point Office.
  • the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration.
  • the preset noise value is used to make the The model parameters determined by the trained image classification model bring disturbance effects when iterative optimization is performed, so that the model parameters determined by the trained image classification model can avoid the saddle point during iterative optimization, and the preset noise value is for the image
  • the model parameters in the classification model are iteratively optimized, they are obtained by random sampling in the sample library of model parameters. Adding noise values to the model parameters determined by the image classification model can avoid stopping at the saddle point when iteratively optimizing the image classification model, so as to avoid that the terminal device will directly use the corresponding model parameters when converging to the local minimum as image classification The optimal parameters of the model.
  • the terminal device determines whether the difference between the value of the second loss function corresponding to the image classification model trained and the value of the first loss function corresponding to the image classification model trained in the current iteration Less than the second preset value, if the difference between the second loss function value corresponding to the trained image classification model and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset value
  • the terminal device determines that the image classification model has converged to the global extremum point during training, and outputs the second model parameter determined in the target iteration as the optimal parameter of the trained image classification model.
  • the terminal device takes the corresponding model parameter when the image classification model converges to the global minimum as the optimal parameter, so that the terminal device can extract the feature of the target image based on the optimal parameter in the image classification model to obtain the image feature more accurately To the image feature corresponding to the target image; when the terminal device classifies and predicts the image feature based on the optimal parameters in the image classification model to obtain the image classification result, the predicted image classification result will be more accurate.
  • the calculation method of the first preset value is specifically: Terminal equipment according to preset calculation formula as well as The first preset value is calculated.
  • g is a preset first preset value
  • d is the number of corresponding model parameters in the trained image classification model
  • c, ⁇ , and ⁇ are preset constants
  • l is a Lipschitz continuous constant
  • ⁇ f is the gradient function corresponding to the loss function of the trained image classification model.
  • the second norm is less than the first preset value, including:
  • adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration includes:
  • the terminal device When the second norm corresponding to the first gradient is less than the first preset value, before adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration, the terminal device also determines Before the current iteration, whether the number of iterations without the preset noise value added to the model parameters determined by the trained image classification model reaches the third preset value, where the third preset value is a positive integer, if the During the iterative optimization process with three preset values, and the corresponding second norm is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, so that The terminal equipment can accurately determine whether the loss function reaches the saddle point.
  • the method for calculating the third preset value includes:
  • the third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ⁇ , ⁇ , and ⁇ are preset constants, and l is the profit Pushitz continuous constant, ⁇ f is the gradient function corresponding to the loss function of the trained image classification model.
  • the third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ⁇ , ⁇ , and ⁇ are preset constants, and l is Lipschitz continuous constant, ⁇ f is the gradient function corresponding to the loss function of the trained image classification model. It should be noted that, when the third preset value k is not a positive integer, the terminal device will select a positive integer with the smallest difference from the third preset value k to round the third preset value k.
  • FIG. 3 is a schematic diagram of a terminal device according to a third embodiment of the present application.
  • Each unit included in the terminal device is used to execute each step in the embodiment corresponding to FIG. 1 or FIG. 2.
  • the terminal equipment includes:
  • the obtaining unit 101 is used to obtain a target image to be classified.
  • the execution unit 102 is configured to perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain an image classification result, where the optimal parameters are When the second norm of the loss function of the image classification model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to iterate the model parameters determined by the trained image classification model Avoid the saddle point when optimizing.
  • the output unit 103 is configured to output the image classification result.
  • the terminal device further includes:
  • a determining unit configured to determine a first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the first gradient according to the first gradient Corresponding second norm.
  • the judging unit is used to judge whether the second norm is less than the first preset value.
  • An adding unit configured to add a preset noise value to the first model parameter determined by the image classification model trained in the current iteration if the second norm is less than the first preset value, the preset noise value Used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization.
  • the determining unit is used if the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the first Two preset values, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameters determined in the target iteration are output as the optimal parameters of the trained image classification model.
  • the determining unit is also used to:
  • the first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, ⁇ , and ⁇ are preset constants, and l is Lipsch Tz continuous constant, ⁇ f is the gradient function corresponding to the loss function of the trained image classification model.
  • the terminal device further includes:
  • the judging unit is further configured to judge whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value;
  • the adding unit is specifically configured to: if the model parameter determined by the image classification model trained before the current iteration does not add a preset noise value, the number of iterations reaches a third preset value, and the second norm is less than the first preset Value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration.
  • the determining unit is also used to:
  • the third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ⁇ , ⁇ , and ⁇ are preset constants, and l is the profit Pushitz continuous constant, ⁇ f is the gradient function corresponding to the loss function of the trained image classification model.
  • the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results,
  • the optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image
  • the model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and can more accurately extract the image feature corresponding to the target image ;
  • the predicted image classification result will also be more accurate.
  • FIG. 4 is a schematic diagram of a terminal device according to a fourth embodiment of the present application.
  • the terminal device 4 of this embodiment includes: a processor 40, a memory 41, and computer-readable instructions 42 stored in the memory 41 and executable on the processor 40, such as the terminal device ’s control program.
  • the processor 40 executes the computer-readable instruction 42
  • the steps in the above embodiments of the image classification method of each terminal device 4 are implemented, for example, S101 to S103 shown in FIG. 1.
  • the processor 40 executes the computer-readable instructions 42
  • the functions of the units in the foregoing device embodiments are realized, for example, the functions of the units 101 to 103 shown in FIG. 3.
  • the computer-readable instructions 42 may be divided into one or more units, and the one or more units are stored in the memory 41 and executed by the processor 40 to complete the application .
  • the one or more units may be an instruction segment of a series of computer-readable instructions capable of performing a specific function.
  • the instruction segment is used to describe the execution process of the computer-readable instruction 42 in the terminal device 4.
  • the computer-readable instructions 42 may be divided into an acquisition unit, an execution unit, and an output unit, and the specific functions of each unit are as described above.
  • the terminal device may include, but is not limited to, the processor 40 and the memory 41.
  • FIG. 4 is only an example of the terminal device 4 and does not constitute a limitation on the terminal device 4, and may include more or fewer components than the illustration, or a combination of certain components, or different components.
  • the terminal device may further include an input and output device, a network access device, a bus, and the like.
  • the so-called processor 40 may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the memory 41 may be an internal storage unit of the terminal device 4, such as a hard disk or a memory of the terminal device 4.
  • the memory 41 may also be an external storage terminal device of the terminal device 4, such as a plug-in hard disk equipped on the terminal device 4, a smart memory card (Smart, Media, Card, SMC), and secure digital (SD) ) Card, flash card (Flash Card), etc.
  • the memory 41 may include both an internal storage unit of the terminal device 4 and an external storage terminal device.
  • the memory 41 is used to store the computer-readable instructions and other programs and data required by the terminal device.
  • the memory 41 can also be used to temporarily store data that has been or will be output.

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Image Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Disclosed are an image classification method, a terminal device, and a non-volatile computer readable storage medium, applicable to the technical field of computers. The method comprises: obtaining a target image to be classified (S101); on the basis of optimal parameters in an image classification model, performing feature extraction on the target image to obtain image features, and performing classification prediction process on the image features to obtain an image classification result (S102); the optimal parameters are obtained on the basis of a preset noise value when the 2-norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to enable model parameters determined by the trained image classification model to avoid saddle points during iterative optimization; and outputting the image classification result (S103). The described image classification method can analyze the image features of an input image on the basis of the optimal parameters in the model, thereby improving the classification accuracy of the image classification model.

Description

图像分类方法、终端设备及计算机非易失性可读存储介质Image classification method, terminal device and computer non-volatile readable storage medium
本申请要求于2018年10月26日提交中国专利局、申请号为201811255779.6、发明名称为“图像分类方法、终端设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application filed on October 26, 2018 in the China Patent Office, with the application number 201811255779.6 and the invention titled "Image Classification Method, Terminal Equipment, and Computer-readable Storage Media" Incorporated in this application.
技术领域Technical field
本申请属于计算机技术领域,尤其涉及一种图像分类方法、终端设备及计算机非易失性可读存储介质。The present application belongs to the field of computer technology, and particularly relates to an image classification method, a terminal device, and a computer non-volatile readable storage medium.
背景技术Background technique
基于深度学习或部分机器学习的图像分类模型,需要经过训练才能用于执行特定的图像分类功能,例如种族分类功能。对图像分类模型进行训练的过程,实际上是对图像分类模型中的参数进行优化的过程,即找到该图像分类模型的最优参数,在图像分类模型训练完成后,该图像分类模型就可以用于执行对应的图像分类功能。Image classification models based on deep learning or partial machine learning require training before they can be used to perform specific image classification functions, such as ethnic classification functions. The process of training the image classification model is actually the process of optimizing the parameters in the image classification model, that is, to find the optimal parameters of the image classification model. After the image classification model training is completed, the image classification model can be used To perform the corresponding image classification function.
在对模型中的参数进行优化时,一般可采用随机梯度下降算法等常见的动量优化算法来实现对图像分类模型中的参数进行更新以找到最优的参数。随机梯度下降算法具体需要通过图像分类模型中的损失函数是否达到全局极小值来确定模型是否找到最优参数,然而在使用随机梯度下降算法时,由于损失函数中存在着鞍点,导致损失函数可能会无法收敛至全局极值点,从而无法确定得到图像分类模型的最优参数。而图像分类模型需要基于模型中的最优参数去对输入图像的图像特征进行分析,对于无法确定最优参数的图像分类模型,其对应的图像分类模型的分类准确性降低。When optimizing the parameters in the model, common momentum optimization algorithms such as stochastic gradient descent algorithm can generally be used to update the parameters in the image classification model to find the optimal parameters. The stochastic gradient descent algorithm specifically needs to determine whether the model finds the optimal parameter by whether the loss function in the image classification model reaches the global minimum. However, when using the stochastic gradient descent algorithm, the loss function may be caused by the saddle point in the loss function It will not be able to converge to the global extremum point, and the optimal parameters of the image classification model cannot be determined. The image classification model needs to analyze the image characteristics of the input image based on the optimal parameters in the model. For the image classification model that cannot determine the optimal parameters, the classification accuracy of the corresponding image classification model decreases.
技术问题technical problem
本申请实施例一种图像分类方法、终端设备及计算机非易失性可读存储介质,以解决现有技术中,现有技术中图像分类模型的分类准确性低的问题。An embodiment of the present application provides an image classification method, terminal device, and computer non-volatile readable storage medium to solve the problem of low classification accuracy of the image classification model in the prior art.
技术解决方案Technical solution
本申请实施例的第一方面提供了第一方面提供了一种图像分类方法,包括:A first aspect of the embodiments of the present application provides that the first aspect provides an image classification method, including:
获取待分类的目标图像;Obtain the target image to be classified;
基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
输出所述图像分类结果。The image classification result is output.
本申请实施例的第二方面提供了一种终端设备,所述终端设备包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A second aspect of the embodiments of the present application provides a terminal device. The terminal device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. The processor The following steps are realized when the computer-readable instructions are executed:
获取待分类的目标图像;Obtain the target image to be classified;
基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
输出所述图像分类结果。The image classification result is output.
本申请实施例的第三方面提供了一种终端设备,包括:A third aspect of the embodiments of the present application provides a terminal device, including:
获取单元,用于获取待分类的目标图像;An obtaining unit, used to obtain the target image to be classified;
执行单元,用于基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;The execution unit is configured to perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain image classification results, where the optimal parameters are in all When the second norm of the loss function of the image classification model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to make iterative optimization of the model parameters determined by the trained image classification model Avoid the saddle point
输出单元,用于输出所述图像分类结果。The output unit is used to output the image classification result.
本申请实施例的第四方面提供了一种计算机非易失性可读存储介质,所述 计算机非易失性可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现以下步骤:A fourth aspect of the embodiments of the present application provides a computer nonvolatile readable storage medium, the computer nonvolatile readable storage medium stores computer readable instructions, and the computer readable instructions are executed by a processor The following steps are implemented:
获取待分类的目标图像;Obtain the target image to be classified;
基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
输出所述图像分类结果。The image classification result is output.
有益效果Beneficial effect
本申请实施例,终端设备获取待分类的目标图像;基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点,使得终端设备基于图像分类模型中的最优参数对目标图像进行特征提取得到图像特征时,能更准确的提取到目标图像所对应的图像特征;终端设备基于图像分类模型中的最优参数对图像特征进行分类预测处理得到图像分类结果时,进行预测的图像分类结果也会更加准确。In the embodiment of the present application, the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, The optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image The model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and can more accurately extract the image feature corresponding to the target image ; When the terminal device classifies and predicts the image features based on the optimal parameters in the image classification model to obtain the image classification result, the predicted image classification result will also be more accurate.
附图说明BRIEF DESCRIPTION
图1是本申请第一实施例提供的一种图像分类方法的实现流程图;1 is a flowchart of an image classification method provided by the first embodiment of the present application;
图2是本申请第二实施例提供的一种图像分类方法的实现流程图;2 is a flowchart of an image classification method provided by the second embodiment of the present application;
图3是本申请第三实施例提供的一种终端设备的示意图;3 is a schematic diagram of a terminal device according to a third embodiment of the present application;
图4是本申请第四实施例提供的一种终端设备的示意图。4 is a schematic diagram of a terminal device according to a fourth embodiment of the present application.
本发明的实施方式Embodiments of the invention
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术 之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structure and technology are proposed to thoroughly understand the embodiments of the present application. However, those skilled in the art should understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary details.
参阅图1,图1为本申请第一实施例中的图像分类方法的实现流程图。本实施例中的图像分类方法的执行主体为终端设备。如图所述的图像分类方法可以包括如下步骤:Referring to FIG. 1, FIG. 1 is a flowchart of an image classification method in the first embodiment of the present application. The execution subject of the image classification method in this embodiment is a terminal device. The image classification method as shown in the figure may include the following steps:
S101,获取待分类的目标图像。S101. Acquire a target image to be classified.
在S101中,当用户需要通过终端设备对待分类的某个目标图像进行分类处理时,可以将待分类的目标图像输入至终端设备中,终端设备获取待分类的目标图像。其中,终端设备基于终端设备中预存的已经训练完成的图像分类模型对目标图像进行分类处理,图像分类模型具体可以为实现种族分类功能的分类模型,图像分类模型能预测的所有分类结果至少包括两种以上,当然并不限于此。In S101, when a user needs to perform classification processing on a target image to be classified through the terminal device, the user may input the target image to be classified into the terminal device, and the terminal device acquires the target image to be classified. Among them, the terminal device classifies the target image based on the pre-stored image classification model pre-stored in the terminal device. The image classification model may specifically be a classification model that implements a race classification function. All classification results that the image classification model can predict include at least two Of course, it is not limited to this.
S102,基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点。S102: Perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain image classification results, where the optimal parameters are classified in the image When the second norm of the loss function of the model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to avoid the model parameters determined by the trained image classification model during the iterative optimization. Saddle point.
在S102中,当图像分类模型已经训练好了之后,终端设备基于图像分类模型中的最优参数对目标图像进行特征提取得到图像特征,并对图像特征进行分类预测处理得到图像分类结果,图像分类模型预测的分类一般仅为一种。其中,由于图像分类模型中的最优参数在图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点,以使得最优参数为图像分类模型在训练时收敛至全局极值点时所确定的模型参数,终端设备基于图像分类模 型中的最优参数对目标图像进行特征提取得到图像特征时,能更准确的提取到目标图像所对应的图像特征;终端设备基于图像分类模型中的最优参数对图像特征进行分类预测处理得到图像分类结果时,进行预测的图像分类结果也会更加准确。具体的,图像分类模型可以包括卷积层和全连接层,模型参数具体可以为卷积层以及全连接层中的参数,终端设备基于图像分类模型中的卷积层所对应的参数目标图像进行卷积计算,提取得到目标图像所对应的图像特征;终端设备基于图像分类模型中的全连接层所对应的参数图像特征进行计算,预测得到图像特征所对应的图像分类结果。In S102, after the image classification model has been trained, the terminal device performs feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and performs classification prediction processing on the image features to obtain image classification results. Image classification The classification of model prediction is generally only one. Among them, since the optimal parameters in the image classification model are obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than the first preset value, the preset noise value is used to classify the trained image The model parameters determined by the model avoid the saddle point during iterative optimization, so that the optimal parameters are those determined when the image classification model converges to the global extremum during training, and the terminal device is based on the optimal parameters in the image classification model When feature extraction is performed on the target image to obtain image features, the image features corresponding to the target image can be more accurately extracted; the terminal device performs classification prediction processing on the image features based on the optimal parameters in the image classification model to obtain the image classification result. The predicted image classification results will also be more accurate. Specifically, the image classification model may include a convolutional layer and a fully connected layer. The model parameters may specifically be parameters in the convolutional layer and the fully connected layer. The terminal device performs based on the parameter target image corresponding to the convolutional layer in the image classification model. Convolution calculation to extract the image features corresponding to the target image; the terminal device calculates based on the parametric image features corresponding to the fully connected layer in the image classification model, and predicts the image classification results corresponding to the image features.
S103中,输出所述图像分类结果。In S103, the image classification result is output.
在S103中,终端设备输出图像分类模型预测得到的图像分类结果,便于用户获取对应的图像分类结果。In S103, the terminal device outputs the image classification result predicted by the image classification model, so that the user can obtain the corresponding image classification result.
以上可以看出,终端设备获取待分类的目标图像;基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点,使得终端设备基于图像分类模型中的最优参数对目标图像进行特征提取得到图像特征时,能更准确的提取到目标图像所对应的图像特征;终端设备基于图像分类模型中的最优参数对图像特征进行分类预测处理得到图像分类结果时,进行预测的图像分类结果也会更加准确。It can be seen from the above that the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, The optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image The model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and more accurately extract the image feature corresponding to the target image ; When the terminal device classifies and predicts the image features based on the optimal parameters in the image classification model to obtain the image classification result, the predicted image classification result will also be more accurate.
参阅图2,图2是本申请第二实施例提供的图像分类方法的实现流程图。本实施例与第一实施例的区别在于,本实施例中在S201之后,S202之前还包括S2011~S2014。其中S201~S204与第一实施例中的S101~S104相同,具体请参阅第一实施例中S101~S104的相关描述,此处不赘述。S2011~S2014具体如下:Referring to FIG. 2, FIG. 2 is an implementation flowchart of the image classification method provided by the second embodiment of the present application. The difference between this embodiment and the first embodiment is that in this embodiment, after S201 and before S202, S2011-S2014 are further included. S201-S204 are the same as S101-S104 in the first embodiment. For details, please refer to the relevant descriptions of S101-S104 in the first embodiment, which will not be repeated here. S2011 ~ S2014 are as follows:
S2011,根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定 所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数。S2011. Determine the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the two corresponding to the first gradient according to the first gradient. Norm.
对于图像分类模型需要进行训练才能用于执行图像分类功能,而对图像分类模型进行训练的过程即是对图像分类模型的模型参数进行迭代优化的过程,以使得图像分类模型的模型参数能进行优化。终端设备在对图像分类模型中的模型参数进行迭代优化时,根据图像分类模型在当前迭代优化次数下,图像分类模型对应的第一损失函数值确定第一损失函数值对应的第一梯度,并根据第一梯度确定得到第一梯度对应的二范数。其中,第一损失函数值为损失函数在当前迭代优化次数下计算得到的损失函数值,梯度用以表示损失函数在当前迭代优化时变化最快、变化率最大所对应的参数向量,第一梯度为根据第一损失函数值对应的梯度值,终端设备还将根据第一梯度确定得到第一梯度对应的二范数。The image classification model needs to be trained to perform the image classification function, and the process of training the image classification model is the process of iterative optimization of the model parameters of the image classification model, so that the model parameters of the image classification model can be optimized . When iteratively optimizing the model parameters in the image classification model, the terminal device determines the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model under the current iteration optimization times of the image classification model, and The second norm corresponding to the first gradient is determined according to the first gradient. Among them, the first loss function value is the loss function value calculated by the loss function in the current iteration optimization times, and the gradient is used to represent the parameter vector corresponding to the loss function that changes the fastest and has the largest change rate during the current iteration optimization, the first gradient In order to obtain the gradient value corresponding to the first loss function value, the terminal device will also determine and obtain the second norm corresponding to the first gradient according to the first gradient.
S2012,判断所述二范数是否小于第一预设值。S2012: Determine whether the second norm is less than the first preset value.
由于损失函数存在有鞍点,而鞍点为损失函数的局部极小值,现有技术中,终端设备无法区分损失函数是否为局部极小值或全局极小值,从而导致图像分类模型存在无法收敛至全局极值点的情况。在本实施例中,当处于鞍点时对应的损失函数对应的梯度向量为零,对应的梯度向量的二范数也为零,因此终端设备通过判断第一梯度对应的二范数是否小于第一预设值,来确定损失函数是否到达鞍点处,其中,第一预设值为预设的某个数值。Since the loss function has a saddle point, and the saddle point is the local minimum value of the loss function, in the prior art, the terminal device cannot distinguish whether the loss function is a local minimum value or a global minimum value, resulting in the image classification model unable to converge to The situation of the global extreme point. In this embodiment, when at the saddle point, the gradient vector corresponding to the corresponding loss function is zero, and the second norm of the corresponding gradient vector is also zero. Therefore, the terminal device determines whether the second norm corresponding to the first gradient is less than the first A preset value to determine whether the loss function reaches the saddle point, where the first preset value is a preset value.
S2013,若所述二范数小于第一预设值,则添加所述预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开对应的鞍点。S2013, if the second norm is less than the first preset value, add the preset noise value to the first model parameter determined by the image classification model trained in the current iteration, the preset noise value is used Therefore, the model parameters determined by the trained image classification model avoid corresponding saddle points when iterative optimization is performed.
当第一梯度对应的二范数小于第一预设值时,则说明损失函数到达鞍点处;当第一梯度对应的二范数大于或者第一预设值时,则说明损失函数没有到达鞍点处。当第一梯度对应的二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,预设的噪声值用于使得 所训练的图像分类模型确定的模型参数在进行迭代优化时带来扰动的效果,以使得所训练的图像分类模型确定的模型参数在进行迭代优化时能避开鞍点,预设的噪声值为对图像分类模型中的模型参数进行迭代优化时,在模型参数的样本库中进行随机采样所获到。添加噪声值至图像分类模型确定的模型参数中,可以使得在对图像分类模型进行迭代优化时避免停留至鞍点,从而避免使得终端设备将收敛至局部极小值时对应的模型参数直接作为图像分类模型的最优参数。When the second norm corresponding to the first gradient is less than the first preset value, it means that the loss function reaches the saddle point; when the second norm corresponding to the first gradient is greater than or the first preset value, it means that the loss function has not reached the saddle point Office. When the second norm corresponding to the first gradient is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration. The preset noise value is used to make the The model parameters determined by the trained image classification model bring disturbance effects when iterative optimization is performed, so that the model parameters determined by the trained image classification model can avoid the saddle point during iterative optimization, and the preset noise value is for the image When the model parameters in the classification model are iteratively optimized, they are obtained by random sampling in the sample library of model parameters. Adding noise values to the model parameters determined by the image classification model can avoid stopping at the saddle point when iteratively optimizing the image classification model, so as to avoid that the terminal device will directly use the corresponding model parameters when converging to the local minimum as image classification The optimal parameters of the model.
S2014,若当前迭代后的目标迭代中所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,其中第二预设值一般为接近零的某个常数,则判定图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中所确定的第二模型参数作为所训练的图像分类模型的最优参数,此时也将完成对图像分类模型的训练,对应的图像分类模型即可用于执行相应对应的图像分类功能。S2014, if the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset Value, where the second preset value is generally a constant close to zero, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameter determined in the target iteration is output as the trained image The optimal parameters of the classification model will also complete the training of the image classification model, and the corresponding image classification model can be used to perform the corresponding image classification function.
若当前迭代后的某次目标迭代中,终端设备判断所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值是否小于第二预设值,若当所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值则终端设备,则终端设备判定图像分类模型在训练时已收敛至全局极值点,并输出该目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。终端设备将图像分类模型收敛至全局极小值时对应的模型参数作为最优参数,使得终端设备基于图像分类模型中的最优参数对目标图像进行特征提取得到图像特征时,能更准确的提取到目标图像所对应的图像特征;终端设备基于图像分类模型中的最优参数对图像特征进行分类预测处理得到图像分类结果时,进行预测的图像分类结果也会更加准确。If in a target iteration after the current iteration, the terminal device determines whether the difference between the value of the second loss function corresponding to the image classification model trained and the value of the first loss function corresponding to the image classification model trained in the current iteration Less than the second preset value, if the difference between the second loss function value corresponding to the trained image classification model and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset value For the terminal device, the terminal device determines that the image classification model has converged to the global extremum point during training, and outputs the second model parameter determined in the target iteration as the optimal parameter of the trained image classification model. The terminal device takes the corresponding model parameter when the image classification model converges to the global minimum as the optimal parameter, so that the terminal device can extract the feature of the target image based on the optimal parameter in the image classification model to obtain the image feature more accurately To the image feature corresponding to the target image; when the terminal device classifies and predicts the image feature based on the optimal parameters in the image classification model to obtain the image classification result, the predicted image classification result will be more accurate.
可选地,在本实施例中,为了更加准确地确定得到第一预设值,以使得终端设备能准确地确定损失函数是否到达鞍点处,所述第一预设值的计算方法具 体为,终端设备根据预设的计算公式
Figure PCTCN2018124630-appb-000001
以及
Figure PCTCN2018124630-appb-000002
计算得到第一预设值。其中,g为预设的第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
Optionally, in this embodiment, in order to determine the first preset value more accurately, so that the terminal device can accurately determine whether the loss function reaches the saddle point, the calculation method of the first preset value is specifically: Terminal equipment according to preset calculation formula
Figure PCTCN2018124630-appb-000001
as well as
Figure PCTCN2018124630-appb-000002
The first preset value is calculated. Where g is a preset first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is a Lipschitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
可选地,所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中之前,包括:Optionally, before adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration, if the second norm is less than the first preset value, including:
判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值。It is determined whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value.
所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,包括:If the second norm is less than the first preset value, adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration includes:
若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。If the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value, and the second norm is less than the first preset value, add the preset noise Value into the first model parameter determined by the image classification model trained in the current iteration.
当在第一梯度对应的二范数小于第一预设值时,终端设备在添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数之前,终端设备还判断在当前迭代之前,所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值,其中该第三预设值为正整数,若在当前迭代之前的第三预设值次数的迭代优化过程中,且对应的二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,使得终端设备能准确地确定损失函数是否到达鞍点。When the second norm corresponding to the first gradient is less than the first preset value, before adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration, the terminal device also determines Before the current iteration, whether the number of iterations without the preset noise value added to the model parameters determined by the trained image classification model reaches the third preset value, where the third preset value is a positive integer, if the During the iterative optimization process with three preset values, and the corresponding second norm is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, so that The terminal equipment can accurately determine whether the loss function reaches the saddle point.
优选地,所述第三预设值的计算方法,包括:Preferably, the method for calculating the third preset value includes:
根据预设的计算公式
Figure PCTCN2018124630-appb-000003
以及
Figure PCTCN2018124630-appb-000004
计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
According to the preset calculation formula
Figure PCTCN2018124630-appb-000003
as well as
Figure PCTCN2018124630-appb-000004
The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ε are preset constants, and l is the profit Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
终端设备具体根据预设的计算公式
Figure PCTCN2018124630-appb-000005
以及
Figure PCTCN2018124630-appb-000006
计算得到第三预设值,其中,k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。需要说明的是,当计算得到第三预设值k不是正整数时,终端设备将选取与该第三预设值k差值最小的正整数对第三预设值k进行取整处理。
Terminal equipment according to preset calculation formula
Figure PCTCN2018124630-appb-000005
as well as
Figure PCTCN2018124630-appb-000006
The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ∈ are preset constants, and l is Lipschitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model. It should be noted that, when the third preset value k is not a positive integer, the terminal device will select a positive integer with the smallest difference from the third preset value k to round the third preset value k.
参阅图3,图3是本申请第三实施例提供的一种终端设备的示意图。终端设备包括的各单元用于执行图1或图2对应的实施例中的各步骤。具体请参阅图1或图2各自对应的实施例中的相关描述。为了便于说明,仅示出了与本实施例相关的部分。参见图3,终端设备包括:Refer to FIG. 3, which is a schematic diagram of a terminal device according to a third embodiment of the present application. Each unit included in the terminal device is used to execute each step in the embodiment corresponding to FIG. 1 or FIG. 2. For details, please refer to the related descriptions in the embodiments corresponding to FIG. 1 or FIG. 2. For ease of explanation, only parts related to this embodiment are shown. Referring to FIG. 3, the terminal equipment includes:
获取单元101,用于获取待分类的目标图像。The obtaining unit 101 is used to obtain a target image to be classified.
执行单元102,用于基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点。The execution unit 102 is configured to perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain an image classification result, where the optimal parameters are When the second norm of the loss function of the image classification model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to iterate the model parameters determined by the trained image classification model Avoid the saddle point when optimizing.
输出单元103,用于输出所述图像分类结果。The output unit 103 is configured to output the image classification result.
可选地,所述终端设备还包括:Optionally, the terminal device further includes:
确定单元,用于根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数。A determining unit, configured to determine a first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the first gradient according to the first gradient Corresponding second norm.
判断单元,用于判断所述二范数是否小于第一预设值。The judging unit is used to judge whether the second norm is less than the first preset value.
添加单元,用于若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点。An adding unit, configured to add a preset noise value to the first model parameter determined by the image classification model trained in the current iteration if the second norm is less than the first preset value, the preset noise value Used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization.
判定单元,用于若当前迭代后的目标迭代中所训练的图像分类模型对应的 第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,则判定所述图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。The determining unit is used if the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the first Two preset values, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameters determined in the target iteration are output as the optimal parameters of the trained image classification model.
可选地,所述确定单元还用于:Optionally, the determining unit is also used to:
根据预设的计算公式
Figure PCTCN2018124630-appb-000007
以及
Figure PCTCN2018124630-appb-000008
计算得到第一预设值,其中g为第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
According to the preset calculation formula
Figure PCTCN2018124630-appb-000007
as well as
Figure PCTCN2018124630-appb-000008
The first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is Lipsch Tz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
可选地,所述终端设备,还包括:Optionally, the terminal device further includes:
所述判断单元还用于:判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值;The judging unit is further configured to judge whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value;
所述添加单元具体用于:若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。The adding unit is specifically configured to: if the model parameter determined by the image classification model trained before the current iteration does not add a preset noise value, the number of iterations reaches a third preset value, and the second norm is less than the first preset Value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration.
可选地,所述确定单元还用于:Optionally, the determining unit is also used to:
根据预设的计算公式
Figure PCTCN2018124630-appb-000009
以及
Figure PCTCN2018124630-appb-000010
计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
According to the preset calculation formula
Figure PCTCN2018124630-appb-000009
as well as
Figure PCTCN2018124630-appb-000010
The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ε are preset constants, and l is the profit Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
以上可以看出,终端设备获取待分类的目标图像;基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声 值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点,使得终端设备基于图像分类模型中的最优参数对目标图像进行特征提取得到图像特征时,能更准确的提取到目标图像所对应的图像特征;终端设备基于图像分类模型中的最优参数对图像特征进行分类预测处理得到图像分类结果时,进行预测的图像分类结果也会更加准确。It can be seen from the above that the terminal device acquires the target image to be classified; based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, The optimal parameter is obtained based on a preset noise value when the second norm of the loss function of the image classification model is less than a first preset value, and the preset noise value is used to classify the trained image The model parameters determined by the model avoid the saddle point during iterative optimization, so that the terminal device can extract the feature of the target image based on the optimal parameters in the image classification model to obtain the image feature, and can more accurately extract the image feature corresponding to the target image ; When the terminal device classifies and predicts the image features based on the optimal parameters in the image classification model to obtain the image classification result, the predicted image classification result will also be more accurate.
参阅图4,图4是本申请第四实施例提供的一种终端设备的示意图。如图4所示,该实施例的终端设备4包括:处理器40、存储器41以及存储在所述存储器41中并可在所述处理器40上运行的计算机可读指令42,例如终端设备的控制程序。所述处理器40执行所述计算机可读指令42时实现上述各个终端设备4的图像分类方法实施例中的步骤,例如图1所示的S101至S103。或者,所述处理器40执行所述计算机可读指令42时实现上述各装置实施例中各单元的功能,例如图3所示单元101至103功能。Refer to FIG. 4, which is a schematic diagram of a terminal device according to a fourth embodiment of the present application. As shown in FIG. 4, the terminal device 4 of this embodiment includes: a processor 40, a memory 41, and computer-readable instructions 42 stored in the memory 41 and executable on the processor 40, such as the terminal device ’s control program. When the processor 40 executes the computer-readable instruction 42, the steps in the above embodiments of the image classification method of each terminal device 4 are implemented, for example, S101 to S103 shown in FIG. 1. Alternatively, when the processor 40 executes the computer-readable instructions 42, the functions of the units in the foregoing device embodiments are realized, for example, the functions of the units 101 to 103 shown in FIG. 3.
示例性的,所述计算机可读指令42可以被分割成一个或多个单元,所述一个或者多个单元被存储在所述存储器41中,并由所述处理器40执行,以完成本申请。所述一个或多个单元可以是能够完成特定功能的一系列计算机可读指令的指令段,该指令段用于描述所述计算机可读指令42在所述终端设备4中的执行过程。例如,所述计算机可读指令42可以被分割成获取单元、执行单元以及输出单元,各单元具体功能如上所述。Exemplarily, the computer-readable instructions 42 may be divided into one or more units, and the one or more units are stored in the memory 41 and executed by the processor 40 to complete the application . The one or more units may be an instruction segment of a series of computer-readable instructions capable of performing a specific function. The instruction segment is used to describe the execution process of the computer-readable instruction 42 in the terminal device 4. For example, the computer-readable instructions 42 may be divided into an acquisition unit, an execution unit, and an output unit, and the specific functions of each unit are as described above.
所述终端设备可包括,但不仅限于,处理器40、存储器41。本领域技术人员可以理解,图4仅仅是终端设备4的示例,并不构成对终端设备4的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入输出设备、网络接入设备、总线等。The terminal device may include, but is not limited to, the processor 40 and the memory 41. Those skilled in the art may understand that FIG. 4 is only an example of the terminal device 4 and does not constitute a limitation on the terminal device 4, and may include more or fewer components than the illustration, or a combination of certain components, or different components. For example, the terminal device may further include an input and output device, a network access device, a bus, and the like.
所称处理器40可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或 者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 40 may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
所述存储器41可以是所述终端设备4的内部存储单元,例如终端设备4的硬盘或内存。所述存储器41也可以是所述终端设备4的外部存储终端设备,例如所述终端设备4上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器41还可以既包括所述终端设备4的内部存储单元也包括外部存储终端设备。所述存储器41用于存储所述计算机可读指令以及所述终端设备所需的其他程序和数据。所述存储器41还可以用于暂时地存储已经输出或者将要输出的数据。The memory 41 may be an internal storage unit of the terminal device 4, such as a hard disk or a memory of the terminal device 4. The memory 41 may also be an external storage terminal device of the terminal device 4, such as a plug-in hard disk equipped on the terminal device 4, a smart memory card (Smart, Media, Card, SMC), and secure digital (SD) ) Card, flash card (Flash Card), etc. Further, the memory 41 may include both an internal storage unit of the terminal device 4 and an external storage terminal device. The memory 41 is used to store the computer-readable instructions and other programs and data required by the terminal device. The memory 41 can also be used to temporarily store data that has been or will be output.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still implement the foregoing The technical solutions described in the examples are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application. Within the scope of protection of this application.

Claims (20)

  1. 一种图像分类方法,其特征在于,包括:An image classification method, characterized in that it includes:
    获取待分类的目标图像;Obtain the target image to be classified;
    基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    输出所述图像分类结果。The image classification result is output.
  2. 根据权利要求1所述的图像分类方法,其特征在于,所述在获取待分类的目标图像之后,所述基于所述图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征之前,所述图像分类方法还包括:The image classification method according to claim 1, wherein after acquiring the target image to be classified, the target image is subjected to feature extraction based on optimal parameters in the image classification model to obtain image features Previously, the image classification method also included:
    根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数;Determine the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the second norm corresponding to the first gradient according to the first gradient ;
    判断所述二范数是否小于第一预设值;Determine whether the second norm is less than the first preset value;
    若所述二范数小于第一预设值,则添加所述预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;If the second norm is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, and the preset noise value is used to make The model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    若当前迭代后的目标迭代中所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,则判定所述图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。If the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset value, Then, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameter determined in the target iteration is output as the optimal parameter of the trained image classification model.
  3. 根据权利要求2所述的图像分类方法,其特征在于,所述第一预设值的计算方法,包括:The image classification method according to claim 2, wherein the method for calculating the first preset value includes:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100001
    以及
    Figure PCTCN2018124630-appb-100002
    计算得到第一预设值,其中g为第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100001
    as well as
    Figure PCTCN2018124630-appb-100002
    The first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is Lipsch Tz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  4. 根据权利要求2所述的图像分类方法,其特征在于,所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中之前,包括:The image classification method according to claim 2, wherein if the second norm is less than the first preset value, the preset noise value is added to the first determination determined by the image classification model trained in the current iteration Before the model parameters, including:
    判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值;Determine whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches the third preset value;
    所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,包括:If the second norm is less than the first preset value, adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration includes:
    若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。If the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value, and the second norm is less than the first preset value, add the preset noise Value into the first model parameter determined by the image classification model trained in the current iteration.
  5. 根据权利要求4所述的图像分类方法,其特征在于,所述第三预设值的计算方法,包括:The image classification method according to claim 4, wherein the method for calculating the third preset value includes:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100003
    以及
    Figure PCTCN2018124630-appb-100004
    计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100003
    as well as
    Figure PCTCN2018124630-appb-100004
    The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ε are preset constants, and l is the profit Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  6. 一种终端设备,其特征在于,包括:A terminal device is characterized by comprising:
    获取单元,用于获取待分类的目标图像;An obtaining unit, used to obtain the target image to be classified;
    执行单元,用于基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值 时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;The execution unit is configured to perform feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features, and perform classification prediction processing on the image features to obtain image classification results, where the optimal parameters are in all When the second norm of the loss function of the image classification model is less than the first preset value, it is obtained based on a preset noise value, and the preset noise value is used to make iterative optimization of the model parameters determined by the trained image classification model Avoid the saddle point
    输出单元,用于输出所述图像分类结果。The output unit is used to output the image classification result.
  7. 如权利要求6所述的终端设备,其特征在于,还包括:The terminal device according to claim 6, further comprising:
    确定单元,用于根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数;A determining unit, configured to determine a first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the first gradient according to the first gradient Corresponding second norm;
    判断单元,用于判断所述二范数是否小于第一预设值;The judging unit is used to judge whether the second norm is less than the first preset value;
    添加单元,用于若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;An adding unit, configured to add a preset noise value to the first model parameter determined by the image classification model trained in the current iteration if the second norm is less than the first preset value, the preset noise value Used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    判定单元,用于若当前迭代后的目标迭代中所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,则判定所述图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。The determining unit is used if the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the first Two preset values, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameters determined in the target iteration are output as the optimal parameters of the trained image classification model.
  8. 如权利要求7所述的终端设备,其特征在于,所述确定单元还用于:根据预设的计算公式
    Figure PCTCN2018124630-appb-100005
    以及
    Figure PCTCN2018124630-appb-100006
    计算得到第一预设值,其中g为第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    The terminal device according to claim 7, wherein the determination unit is further configured to: according to a preset calculation formula
    Figure PCTCN2018124630-appb-100005
    as well as
    Figure PCTCN2018124630-appb-100006
    The first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is Lipsch Tz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  9. 如权利要求7所述的终端设备,其特征在于,The terminal device according to claim 7, wherein:
    所述判断单元,还用于判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值;The judging unit is also used to judge whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value;
    所述添加单元具体用于:若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第 一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。The adding unit is specifically configured to: if the model parameter determined by the image classification model trained before the current iteration does not add a preset noise value, the number of iterations reaches a third preset value, and the second norm is less than the first preset Value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration.
  10. 如权利要求9所述的终端设备,其特征在于,所述确定单元还用于:The terminal device according to claim 9, wherein the determining unit is further configured to:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100007
    以及
    Figure PCTCN2018124630-appb-100008
    计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100007
    as well as
    Figure PCTCN2018124630-appb-100008
    The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ∈ are preset constants, and l is Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  11. 一种终端设备,其特征在于,所述终端设备包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal device, characterized in that the terminal device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the computer-readable instructions The following steps are implemented when instructing:
    获取待分类的目标图像;Obtain the target image to be classified;
    基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    输出所述图像分类结果。The image classification result is output.
  12. 根据权利要求11所述的终端设备,其特征在于,所述在获取待分类的目标图像之后,所述基于所述图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征之前,所述处理器执行所述计算机可读指令时还实现如下步骤:The terminal device according to claim 11, wherein after acquiring the target image to be classified, before performing feature extraction on the target image based on the optimal parameters in the image classification model to obtain image features , The processor also implements the following steps when executing the computer-readable instructions:
    根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数;Determine the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the second norm corresponding to the first gradient according to the first gradient ;
    判断所述二范数是否小于第一预设值;Determine whether the second norm is less than the first preset value;
    若所述二范数小于第一预设值,则添加所述预设的噪声值至当前迭代中所 训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;If the second norm is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, and the preset noise value is used to make The model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    若当前迭代后的目标迭代中所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,则判定所述图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。If the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset value, Then, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameter determined in the target iteration is output as the optimal parameter of the trained image classification model.
  13. 根据权利要求11所述的终端设备,其特征在于,所述判断所述二范数是否小于第一预设值之前,所述处理器执行所述计算机可读指令时还实现如下步骤:The terminal device according to claim 11, wherein before determining whether the second norm is less than a first preset value, the processor further implements the following steps when executing the computer-readable instruction:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100009
    以及
    Figure PCTCN2018124630-appb-100010
    计算得到第一预设值,其中g为第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100009
    as well as
    Figure PCTCN2018124630-appb-100010
    The first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is Lipsch Tz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  14. 根据权利要求12所述的终端设备,其特征在于,所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中之前,所述处理器执行所述计算机可读指令时还实现如下步骤:The terminal device according to claim 12, wherein if the second norm is less than a first preset value, a preset noise value is added to the first determined by the image classification model trained in the current iteration Before the model parameters, the processor also implements the following steps when executing the computer-readable instructions:
    判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值;Determine whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches the third preset value;
    所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,包括:If the second norm is less than the first preset value, adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration includes:
    若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。If the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value, and the second norm is less than the first preset value, add the preset noise Value into the first model parameter determined by the image classification model trained in the current iteration.
  15. 根据权利要求14所述的终端设备,其特征在于,所述若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第 三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中之前,所述处理器执行所述计算机可读指令时还实现如下步骤:The terminal device according to claim 14, wherein if the model parameters determined by the image classification model trained before the current iteration do not add a preset noise value, the number of iterations reaches a third preset value, and the If the second norm is less than the first preset value, before the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, the processor also implements the computer-readable instruction The following steps:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100011
    以及
    Figure PCTCN2018124630-appb-100012
    计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100011
    as well as
    Figure PCTCN2018124630-appb-100012
    The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ∈ are preset constants, and l is Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  16. 一种计算机非易失性可读存储介质,所述计算机非易失性可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:A computer nonvolatile readable storage medium, the computer nonvolatile readable storage medium storing computer readable instructions, characterized in that, when the computer readable instructions are executed by at least one processor, the following steps are realized :
    获取待分类的目标图像;Obtain the target image to be classified;
    基于图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征,并对所述图像特征进行分类预测处理得到图像分类结果,其中,所述最优参数在所述图像分类模型的损失函数的二范数小于第一预设值时基于预设的噪声值得到,所述预设的噪声值用于使得所训练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;Based on the optimal parameters in the image classification model, the target image is subjected to feature extraction to obtain image features, and the image features are subjected to classification prediction processing to obtain image classification results, wherein the optimal parameters are in the image classification model When the second norm of the loss function is less than the first preset value, it is obtained based on a preset noise value, which is used to make the model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    输出所述图像分类结果。The image classification result is output.
  17. 根据权利要求15所述的计算机非易失性可读存储介质,其特征在于,所述在获取待分类的目标图像之后,所述基于所述图像分类模型中的最优参数对所述目标图像进行特征提取得到图像特征之前,所述图像分类方法还包括:The computer non-volatile storage medium according to claim 15, wherein after acquiring the target image to be classified, the target image is based on the optimal parameters in the image classification model Before performing feature extraction to obtain image features, the image classification method further includes:
    根据当前迭代中所训练的图像分类模型对应的第一损失函数值确定所述第一损失函数值对应的第一梯度,并根据所述第一梯度确定得到所述第一梯度对应的二范数;Determine the first gradient corresponding to the first loss function value according to the first loss function value corresponding to the image classification model trained in the current iteration, and determine the second norm corresponding to the first gradient according to the first gradient ;
    判断所述二范数是否小于第一预设值;Determine whether the second norm is less than the first preset value;
    若所述二范数小于第一预设值,则添加所述预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,所述预设的噪声值用于使得所训 练的图像分类模型确定的模型参数在进行迭代优化时避开鞍点;If the second norm is less than the first preset value, the preset noise value is added to the first model parameter determined by the image classification model trained in the current iteration, and the preset noise value is used to make The model parameters determined by the trained image classification model avoid the saddle point during iterative optimization;
    若当前迭代后的目标迭代中所训练的图像分类模型对应的第二损失函数值与当前迭代中所训练的图像分类模型对应的第一损失函数值之间的差值小于第二预设值,则判定所述图像分类模型在训练时已收敛至全局极值点,并输出目标迭代中确定的第二模型参数作为所训练的图像分类模型的最优参数。If the difference between the second loss function value corresponding to the image classification model trained in the target iteration after the current iteration and the first loss function value corresponding to the image classification model trained in the current iteration is less than the second preset value, Then, it is determined that the image classification model has converged to the global extremum point during training, and the second model parameter determined in the target iteration is output as the optimal parameter of the trained image classification model.
  18. 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述第一预设值的计算方法,包括:The computer non-volatile storage medium according to claim 17, wherein the calculation method of the first preset value includes:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100013
    以及
    Figure PCTCN2018124630-appb-100014
    计算得到第一预设值,其中g为第一预设值,d为所训练的图像分类模型中对应的模型参数的个数,c、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100013
    as well as
    Figure PCTCN2018124630-appb-100014
    The first preset value is calculated, where g is the first preset value, d is the number of corresponding model parameters in the trained image classification model, c, δ, and ∈ are preset constants, and l is Lipsch Tz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
  19. 根据权利要求17所述的计算机非易失性可读存储介质,其特征在于,所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中之前,包括:The computer non-volatile readable storage medium according to claim 17, wherein, if the second norm is less than the first preset value, a preset noise value is added to the trained in the current iteration Before the first model parameter determined by the image classification model, it includes:
    判断当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数是否达到第三预设值;Determine whether the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches the third preset value;
    所述若所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中,包括:If the second norm is less than the first preset value, adding the preset noise value to the first model parameter determined by the image classification model trained in the current iteration includes:
    若当前迭代之前所训练的图像分类模型确定的模型参数未添加预设的噪声值的迭代次数达到第三预设值,且所述二范数小于第一预设值,则添加预设的噪声值至当前迭代中所训练的图像分类模型确定的第一模型参数中。If the number of iterations without adding a preset noise value to the model parameters determined by the image classification model trained before the current iteration reaches a third preset value, and the second norm is less than the first preset value, add the preset noise Value into the first model parameter determined by the image classification model trained in the current iteration.
  20. 根据权利要求19所述的计算机非易失性可读存储介质,其特征在于,所述第三预设值的计算方法,包括:The computer non-volatile readable storage medium according to claim 19, wherein the method for calculating the third preset value includes:
    根据预设的计算公式
    Figure PCTCN2018124630-appb-100015
    以及
    Figure PCTCN2018124630-appb-100016
    计算得到第三预设值,其中k为第三预设值,d为所训练的图像分类模型中对应的模型参数的 个数,c、ρ、δ以及∈为预设的常数,l为利普希茨连续常数,Δf为所训练的图像分类模型的损失函数对应的梯度函数。
    According to the preset calculation formula
    Figure PCTCN2018124630-appb-100015
    as well as
    Figure PCTCN2018124630-appb-100016
    The third preset value is calculated, where k is the third preset value, d is the number of corresponding model parameters in the trained image classification model, c, ρ, δ, and ε are preset constants, and l is the profit Pushitz continuous constant, Δf is the gradient function corresponding to the loss function of the trained image classification model.
PCT/CN2018/124630 2018-10-26 2018-12-28 Image classification method, terminal device and non-volatile computer readable storage medium WO2020082595A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811255779.6A CN109522939B (en) 2018-10-26 2018-10-26 Image classification method, terminal device and computer readable storage medium
CN201811255779.6 2018-10-26

Publications (1)

Publication Number Publication Date
WO2020082595A1 true WO2020082595A1 (en) 2020-04-30

Family

ID=65773935

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/124630 WO2020082595A1 (en) 2018-10-26 2018-12-28 Image classification method, terminal device and non-volatile computer readable storage medium

Country Status (2)

Country Link
CN (1) CN109522939B (en)
WO (1) WO2020082595A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111368792B (en) * 2020-03-18 2024-05-14 北京奇艺世纪科技有限公司 Feature point labeling model training method and device, electronic equipment and storage medium
CN113628759A (en) * 2021-07-22 2021-11-09 中国科学院重庆绿色智能技术研究院 Infectious disease epidemic situation safety region prediction method based on big data
CN115035353B (en) * 2022-08-11 2022-12-23 粤港澳大湾区数字经济研究院(福田) Image classification method, image classification model, intelligent terminal and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106779073A (en) * 2016-12-27 2017-05-31 西安石油大学 Media information sorting technique and device based on deep neural network
US20180068463A1 (en) * 2016-09-02 2018-03-08 Artomatix Ltd. Systems and Methods for Providing Convolutional Neural Network Based Image Synthesis Using Stable and Controllable Parametric Models, a Multiscale Synthesis Framework and Novel Network Architectures
CN108229543A (en) * 2017-12-22 2018-06-29 中国科学院深圳先进技术研究院 Image classification design methods and device
CN108229298A (en) * 2017-09-30 2018-06-29 北京市商汤科技开发有限公司 The training of neural network and face identification method and device, equipment, storage medium
CN108268855A (en) * 2018-02-05 2018-07-10 北京信息科技大学 A kind of optimization method and device of the function model identified again towards pedestrian

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105160444B (en) * 2015-10-22 2017-02-15 广东电网有限责任公司电力调度控制中心 Electrical equipment failure rate determining method and system
CN107133626B (en) * 2017-05-10 2020-03-17 安徽大学 Medical image classification method based on partial average stochastic optimization model
CN107688823B (en) * 2017-07-20 2018-12-04 北京三快在线科技有限公司 A kind of characteristics of image acquisition methods and device, electronic equipment
CN108229379A (en) * 2017-12-29 2018-06-29 广东欧珀移动通信有限公司 Image-recognizing method, device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180068463A1 (en) * 2016-09-02 2018-03-08 Artomatix Ltd. Systems and Methods for Providing Convolutional Neural Network Based Image Synthesis Using Stable and Controllable Parametric Models, a Multiscale Synthesis Framework and Novel Network Architectures
CN106779073A (en) * 2016-12-27 2017-05-31 西安石油大学 Media information sorting technique and device based on deep neural network
CN108229298A (en) * 2017-09-30 2018-06-29 北京市商汤科技开发有限公司 The training of neural network and face identification method and device, equipment, storage medium
CN108229543A (en) * 2017-12-22 2018-06-29 中国科学院深圳先进技术研究院 Image classification design methods and device
CN108268855A (en) * 2018-02-05 2018-07-10 北京信息科技大学 A kind of optimization method and device of the function model identified again towards pedestrian

Also Published As

Publication number Publication date
CN109522939A (en) 2019-03-26
CN109522939B (en) 2024-05-07

Similar Documents

Publication Publication Date Title
Jin et al. Provably efficient reinforcement learning with linear function approximation
WO2020082595A1 (en) Image classification method, terminal device and non-volatile computer readable storage medium
WO2021089013A1 (en) Spatial graph convolutional network training method, electronic device and storage medium
WO2021208079A1 (en) Method and apparatus for obtaining power battery life data, computer device, and medium
WO2016151618A1 (en) Predictive model updating system, predictive model updating method, and predictive model updating program
KR101828215B1 (en) A method and apparatus for learning cyclic state transition model on long short term memory network
Yuan et al. Design and performance analysis of deterministic learning of sampled-data nonlinear systems
CN110458875B (en) Abnormal point pair detection method, image splicing method, corresponding device and equipment
WO2021051556A1 (en) Deep learning weight updating method and system, and computer device and storage medium
CN110969100B (en) Human body key point identification method and device and electronic equipment
US10635078B2 (en) Simulation system, simulation method, and simulation program
US8589852B1 (en) Statistical corner extraction using worst-case distance
CN111652371A (en) Offline reinforcement learning network training method, device, system and storage medium
JP2013097467A (en) Image processor and method for controlling the same
WO2022143224A1 (en) Amplitude estimation method and device for quantum circuit, storage medium, and electronic device
Lesser et al. Approximate safety verification and control of partially observable stochastic hybrid systems
WO2020107264A1 (en) Neural network architecture search method and apparatus
He et al. Transfer learning in high‐dimensional semiparametric graphical models with application to brain connectivity analysis
CN116756536B (en) Data identification method, model training method, device, equipment and storage medium
WO2020230043A1 (en) Feature vector feasibilty estimation
CN108921207B (en) Hyper-parameter determination method, device and equipment
KR102430989B1 (en) Method, device and system for predicting content category based on artificial intelligence
CN111026879B (en) Multi-dimensional value-oriented intent-oriented object-oriented numerical calculation method
CN111582456B (en) Method, apparatus, device and medium for generating network model information
WO2021146977A1 (en) Neural architecture search method and apparatus

Legal Events

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

Ref document number: 18937780

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18937780

Country of ref document: EP

Kind code of ref document: A1