CN111539460A - Image classification method and device, electronic equipment and storage medium - Google Patents

Image classification method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111539460A
CN111539460A CN202010275340.0A CN202010275340A CN111539460A CN 111539460 A CN111539460 A CN 111539460A CN 202010275340 A CN202010275340 A CN 202010275340A CN 111539460 A CN111539460 A CN 111539460A
Authority
CN
China
Prior art keywords
image classification
layer
gradient
neural network
convolutional neural
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010275340.0A
Other languages
Chinese (zh)
Inventor
徐健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
MIGU Culture Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, MIGU Culture Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202010275340.0A priority Critical patent/CN111539460A/en
Publication of CN111539460A publication Critical patent/CN111539460A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Landscapes

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

Abstract

The embodiment of the invention provides an image classification method and device, electronic equipment and a storage medium. The method comprises the following steps: determining an image to be classified; inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels; the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model. The image classification method, the image classification device, the electronic equipment and the storage medium provided by the embodiment of the invention are used for thinning the gradient involved in the back propagation process of the convolutional neural network, so that the calculated amount is effectively reduced, and the training efficiency of the image classification model is effectively improved because the sparse process does not involve sequencing, the complexity is very low, and the occupation of resources can be almost ignored.

Description

Image classification method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to an image classification method and device, electronic equipment and a storage medium.
Background
Image classification is to label an image with a class. Image classification is one of the core problems in the field of computer vision. Currently, image classification methods are generally classified into 5 types: KNN (K-Nearest Neighbor, K Nearest Neighbor), SVM (Support Vector Machine), BP neural network, CNN (Convolutional neural network), and migratory learning.
Because the structure of the convolutional neural network is more complex than that of the traditional neural network, the problem of large resource consumption is faced when the convolutional neural network is adopted for image classification, particularly at the stage of training an image classification model by using the convolutional neural network.
In the prior art, there is a corresponding optimization method for the process of training an image classification model by using a convolutional neural network, which mainly includes the following two types:
(1) pruning: namely, parameters which do not have practical influence on the training result are deleted during training, and the scale of the parameters is compressed to reduce the calculation amount. According to different adjusted parameter objects, pruning compression on the convolutional neural network can be further subdivided into: unstructured pruning, structured pruning, gradient pruning, and the like.
(2) And (3) quantification: in general, parameters of the convolutional neural network are represented by floating point type numbers with a length of 32 bits, so that the precision is not required to be kept as high as practical, and the space required by each weight can be reduced by quantizing, for example, representing the precision represented by the original 32 bits by 0-255, and sacrificing the precision.
The gradient pruning method generally requires first performing a sorting operation on the gradient parameters, and then discarding a part of the gradient parameters from the sorting result. On one hand, the size of the gradient parameter is changed, and on the other hand, the sorting operation in the gradient pruning implementation process still causes great consumption on hardware resources and time resources.
Disclosure of Invention
The embodiment of the invention provides an image classification method, an image classification device, electronic equipment and a storage medium, which are used for solving the defect that hardware resources and time resources are greatly consumed by the method in the prior art.
An embodiment of a first aspect of the present invention provides an image classification method, including:
determining an image to be classified;
inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; wherein the content of the first and second substances,
the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels;
the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
In the above technical solution, the sparse processing of the gradient set output by the preset layer in the convolutional neural network model by the preset back propagation method includes:
and when the convolutional neural network model is a convolutional neural network model comprising a batch normalization layer, performing sparse processing on a gradient set output by the batch normalization layer in the convolutional neural network model.
In the above technical solution, the sparse processing of the gradient set output by the preset layer in the convolutional neural network model by the preset back propagation method includes:
and when the convolutional neural network model is a convolutional neural network model which does not contain a batch normalization layer, performing sparse processing on a gradient set output by a previous adjacent layer of a ReLU activation layer in the convolutional neural network model in the back propagation direction.
In the above technical solution, the sparse processing includes:
setting a first gradient value of which the absolute value is smaller than a preset sparseness processing threshold value in the gradient set to be 0, or setting the first gradient value to be a first preset value or setting the first gradient value to be a second preset value; wherein the content of the first and second substances,
the absolute value of the first preset value is the same as that of the second preset value, the first preset value is positive, and the second preset value is negative.
In the foregoing technical solution, the setting the first gradient value, of which the absolute value is smaller than the preset sparsity processing threshold, in the gradient set to 0, or to the first preset value, or to the second preset value further includes:
comparing the absolute value of the first gradient value with a first threshold, if the absolute value of the first gradient value is smaller than or equal to the first threshold, setting the first gradient value to be 0, if the absolute value of the first gradient value is larger than the first threshold, determining whether the first gradient value is larger than 0, if the first gradient value is larger than 0, setting the first gradient value to be a first preset value, and if the first gradient value is smaller than or equal to 0, setting the first gradient value to be a second preset value; wherein the content of the first and second substances,
the first threshold is a product of the sparse processing threshold and a first random number, and the first random number is a number with a value range within a [0,1] interval.
In the above technical solution, the convolutional neural network model sequentially includes, in the back propagation direction:
a ReLU activation layer, a batch normalization layer, a sparse processing layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is used for performing sparse processing on the first gradient set output by the batch of normalization layers in the back propagation to obtain a second gradient set, and the second gradient set is input to the convolution layer.
In the above technical solution, the convolutional neural network model sequentially includes, in the back propagation direction: a sparse processing layer, a ReLU activation layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is configured to perform sparse processing on a third gradient set to be input to the ReLU activation layer in reverse propagation to obtain a fourth gradient set, and input the fourth gradient set to the ReLU activation layer.
An embodiment of a second aspect of the present invention provides an image classification apparatus, including:
a determining module for determining an image to be classified;
the classification module is used for inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; wherein the content of the first and second substances,
the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels;
the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
In a third embodiment of the present invention, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps of the image classification method according to the first embodiment of the present invention.
A fourth aspect of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the image classification method according to the first aspect of the present invention.
The image classification method, the image classification device, the electronic equipment and the storage medium provided by the embodiment of the invention are used for thinning the gradient involved in the back propagation process of the convolutional neural network, so that the calculated amount is effectively reduced, and the training efficiency of the image classification model is effectively improved because the sparse process does not involve sequencing, the complexity is very low, and the occupation of resources can be almost ignored.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a flowchart of an image classification method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a partial structure of a convolutional neural network model that does not contain a batch normalization layer;
FIG. 3 is a schematic diagram of a partial structure of a convolutional neural network including a batch normalization layer;
FIG. 4 is a diagram illustrating a complete training process for a convolutional neural network in one embodiment;
FIG. 5 is a schematic diagram of an image classification apparatus according to another embodiment of the present invention;
fig. 6 illustrates a physical structure diagram of an electronic device.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before describing the image classification method provided by the embodiment of the present invention in detail, first, the contents related to the convolutional neural network model training will be described.
The training of the convolutional neural network model includes a forward propagation phase and a backward propagation phase.
The algorithm adopted in the back propagation stage is called a back propagation method, the back propagation method uses the mean square error (loss value) of the output error to feed back to each layer of neural network layer by layer, and the weight parameter of each layer of network is adjusted by a gradient descent method. The basic principle of the gradient descent method is to reduce the output error to a minimum value by calculating the derivative of the loss value (J) of the output error with respect to the parameter and adjusting the parameter in the opposite direction of the derivative, i.e. the gradient.
It can be seen that the gradient values play a very important role in the gradient descent method. In the back propagation calculation process of the convolutional neural network, if the gradient value can be optimized, the calculation amount of the back propagation process can be reduced.
Fig. 1 is a flowchart of an image classification method according to an embodiment of the present invention, and as shown in fig. 1, the image classification method according to the embodiment of the present invention includes:
step 101, determining an image to be classified.
The image to be classified is an image whose category is to be distinguished. For example, the images are classified according to whether or not the images contain peony flowers; as another example, the images are classified according to whether the running motion is included in the images.
In the embodiment of the present invention, the image to be classified may be an image in various formats known in the art, such as a GIF format, a JPEG format, a BMP format, a TIFF format, a RAW format, a PCX format, a TGA format, an EXIF format, a PNG format, a FPX format, an SVG format, a PSD format, a CDR format, a PCD format, a DXF format, a UFO format, an EPS format, and the like.
And 102, inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model.
In the embodiment of the invention, the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels.
The sample image data is image data used to train an image classification model. The sample image data may be an image in various formats known in the art, such as GIF format, JPEG format, BMP format, TIFF format, RAW format, PCX format, TGA format, EXIF format, PNG format, FPX format, SVG format, PSD format, CDR format, PCD format, DXF format, UFO format, EPS format, and the like.
The sample class label is used for identifying the class of the sample image data, and the sample class label can be labeled in a manual mode or obtained by adopting other image classification methods in the prior art.
In the embodiment of the invention, the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on the gradient set output by a preset layer in the convolutional neural network model.
Those skilled in the art will appreciate that the convolutional neural network model has a variety of structures, including, in addition to the convolutional layers that are commonly used, a ReLU activation layer, a pooling layer, a full link layer, a Batch Normalization (BN), and the like. The gradient sets output by different layers in the convolutional neural network model have respective characteristics. The purpose of reducing the calculation amount can be achieved only by thinning the gradient set output by the proper layer, otherwise, the calculation load of the convolutional neural network model is possibly increased, and the final accuracy of the convolutional neural network model is influenced. Therefore, an appropriate layer needs to be selected from the convolutional neural network model as a preset layer.
In the embodiment of the invention, which layer in the convolutional neural network model is selected as the preset layer is related to the type of the convolutional neural network model.
The types of the convolutional neural network models are classified into two types according to whether the convolutional neural network models contain batch normalization layers, one type is the convolutional neural network model containing the batch normalization layers, and the other type is the convolutional neural network model not containing the batch normalization layers.
In the embodiment of the invention, when the convolutional neural network model is a convolutional neural network model which does not contain a batch normalization layer, the previous adjacent layer of the ReLU activation layer in the convolutional neural network model in the back propagation direction is determined as the preset layer in the convolutional neural network model.
Fig. 2 is a schematic diagram of a partial structure of a convolutional neural network model without a batch normalization layer, and as shown in fig. 2, the convolutional neural network model uses a convolutional layer-ReLU active layer as a basic unit of the convolutional neural network model, that is, the convolutional layer and the ReLU active layer are sequentially connected in the forward propagation direction to form a basic unit.
In the process of back propagation, the gradient transmitted to the ReLU active layer is almost a non-0 value, and the precondition of sparse processing is provided; the distribution of the gradient values transmitted to the ReLU activation layer is symmetrical according to a 0 axis (similar to a positive distribution curve), and is concentrated in a small area, namely most of the gradient values are close to 0, so that the calculation amount is small when sparse processing is carried out; the ReLU activation layer will not convert the 0 value into non-0 value during the back propagation process, i.e. the next layer will preserve the sparsity of the gradient sequence. Therefore, the gradient value to be transmitted to the ReLU active layer is thinned, the calculation performance is improved, and the training effect is not influenced. Based on the above consideration, the previous adjacent layer of the ReLU activation layer in the backward propagation direction in the convolutional neural network is determined as the preset layer in the convolutional neural network model.
In the embodiment of the invention, when the convolutional neural network model is a convolutional neural network model comprising a batch normalization layer, the batch normalization layer is determined as a preset layer in the convolutional neural network model.
Fig. 3 is a schematic diagram of a partial structure of a convolutional neural network including a batch normalization layer, and as shown in fig. 3, the convolutional neural network model uses a convolutional layer-batch normalization layer-ReLU active layer as a basic unit of the convolutional neural network model, that is, according to a forward propagation direction, the convolutional layer, the batch normalization layer and the ReLU active layer are sequentially connected in sequence to form a basic unit. Due to the existence of the batch normalization layer, the gradient distribution characteristics of the batch normalization layer before and after the batch normalization layer in the back propagation process are kept consistent, and therefore the batch normalization layer is determined as a preset layer in the convolutional neural network model.
After a preset layer in the convolutional neural network model is determined, sparse processing is carried out on a gradient set output by the preset layer.
In the embodiment of the invention, the sparse processing is to directly reset the smaller value close to 0 (the smaller value has almost no influence on the updating of the network parameters) in the gradient set to be processed to 0 or a fixed value so as to reduce the data scale, thereby reducing the calculation overhead in the back propagation and gradient descent and improving the training performance.
Specifically, assume that a one-dimensional column vector g is a gradient column to be processed, the length of the one-dimensional column vector g is n, a thinning threshold is τ, and a gradient vector after thinning is
Figure BDA0002444564870000071
The specific flow of the sparse processing is as follows:
step (1), assuming that the cyclic scalar i is 1, for each gradient in g, gi,i∈[1,n]If | giIf the | is smaller than the sparse processing threshold tau, skipping to the step (2); otherwise, jumping to the step (4);
randomly generating a number in a [0,1] interval: r ═ random (0, 1);
step (3), if | giIf | is less than or equal to τ r, let
Figure BDA0002444564870000072
If | giIf | > tau r, then judge giPositive and negative values of (c): if g isiIf greater than 0, then order
Figure BDA0002444564870000081
Otherwise
Figure BDA0002444564870000082
Step (4), i is i +1, repeating the step (1) to the step (3), and traversing the vector g;
step (5), outputting
Figure BDA0002444564870000083
The sparse processing threshold τ is a preset scalar, and the value of the sparse processing threshold τ is determined by percentile (g, p) of gradient distribution. Only the conditions need to be met: the p value is obtained when the pencentile (g, p) is larger than (2 p-100)% of the gradient value. The resulting P value can divide the gradient values into two parts: one part represents more values close to 0, and the other part represents the others. At this time, the order:
Figure BDA0002444564870000084
and obtaining the specific value of the sparse processing threshold tau.
For example, p is 85 and τ is 0.7.
In the foregoing example, the absolute value of the preset value reset when the gradient values in the gradient set are sparsely processed is the same as the sparsely processed threshold, the positive and negative of the preset value depend on whether the first gradient value in the gradient set is greater than 0, if the first gradient value is greater than 0, the reset preset value is positive, and if the first gradient value is less than or equal to 0, the reset preset value is negative. The first gradient value refers to a gradient value of which the absolute value in the gradient set is smaller than a preset sparse processing threshold value.
After the gradient set is subjected to sparse processing, a new gradient set is obtained. The new set of gradients will be transmitted to the next layer of the convolutional neural network model in the backward propagation direction.
Specifically, when the convolutional neural network model is a convolutional neural network model including a batch normalization layer, the first gradient set is subjected to sparse processing to obtain a second gradient set, and the second gradient set is input to the convolutional layer.
And when the convolutional neural network model is a convolutional neural network which does not comprise a batch normalization layer, performing sparse processing on a third gradient set to be input to the ReLU activation layer to obtain a fourth gradient set, and inputting the fourth gradient set to the ReLU activation layer.
The above is a description of the basic implementation steps of the image classification method provided by the embodiment of the present invention. With the continuous expansion of the scale of the convolutional neural network model, the structure becomes increasingly complex, and more than one basic unit such as a convolutional layer-ReLU active layer or a convolutional layer-batch normalization layer-ReLU active layer may exist in the convolutional neural network, so that in one back propagation process of the convolutional neural network model, the operation of performing sparseness processing on the gradient set output by the preset layer may be performed more than once.
The image classification method provided by the embodiment of the invention performs sparsification on the gradient involved in the back propagation process of the convolutional neural network model, so that the calculated amount is effectively reduced, and the training efficiency of the image classification model is effectively improved because the sparse process does not involve sequencing, the complexity is very low, and the occupation of resources can be almost ignored.
In order to better understand the image classification method provided by the embodiment of the present invention, in the following embodiment, a process related to training a convolutional neural network model in the image classification method will be described with reference to the accompanying drawings.
FIG. 4 is a diagram illustrating a complete training process for a convolutional neural network, in one embodiment. In the embodiment shown in fig. 4, the weights of the layers (including the hidden layer and the output layer) of the convolutional neural network model are defined as W, and the offset is b; the gradient iteration step length is alpha, the maximum iteration time is M, and the iteration stop threshold is omega. The detailed steps of the training process are as follows:
s1, weighting parameters W and offset b of each layer of the initial convolutional neural network model;
s2, performing input forward propagation according to the characteristics of each layer of the convolutional neural network model, and obtaining final output at an output layer;
step S3, calculating the gradient g of the output layer through a loss function;
step S4, reversely propagating layer by layer to calculate the gradient of each layer; performing gradient sparsification on the gradient value obtained by calculation of the preset layer, and inputting the sparse gradient to the next layer;
step S5, combining the iteration step alpha and the gradient of the current layer, calculating and updating the layer weight and the offset;
step S6, judging whether the updated weight change and offset change are all smaller than an iteration stop threshold, and for each parameter, if delta W is less than omega and delta b is less than omega, or the maximum iteration number M is reached, turning to step S7; otherwise, jumping to the step S2, and restarting iteration;
and step S7, meeting the output condition, namely finding the network parameter which enables the loss function to take the minimum value at the moment, and outputting the convolutional neural network model.
As can be known from the complete description of the training process of the convolutional neural network model, compared with the prior art, the image classification method provided by the embodiment of the invention mainly optimizes the gradient set output by the preset layer in the convolutional neural network model in the direction propagation stage.
Based on any one of the above embodiments, in an embodiment of the present invention, the convolutional neural network model sequentially includes, in a back propagation direction:
a ReLU activation layer, a batch normalization layer, a sparse processing layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is used for performing sparse processing on the first gradient set output by the batch of normalization layers in the back propagation to obtain a second gradient set, and the second gradient set is input to the convolution layer.
The image classification method provided by the embodiment of the invention aims at the convolutional neural network model comprising the batch normalization layer, and the sparse processing layer is added between the batch normalization layer and the convolutional layer, so that the method is beneficial to reducing the calculation quantity related to the gradient.
Based on any one of the above embodiments, in an embodiment of the present invention, the convolutional neural network model sequentially includes, in a back propagation direction:
a sparse processing layer, a ReLU activation layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is configured to perform sparse processing on a third gradient set to be input to the ReLU activation layer in reverse propagation to obtain a fourth gradient set, and input the fourth gradient set to the ReLU activation layer.
The image classification method provided by the embodiment of the invention aims at the convolutional neural network model which does not contain a batch normalization layer, and adds a sparse processing layer before the back propagation direction of the ReLU activation layer, thereby being beneficial to reducing the calculation quantity related to the gradient.
Based on any of the above embodiments, fig. 5 is a schematic diagram of an image classification apparatus according to another embodiment of the present invention, and as shown in fig. 5, the image classification apparatus according to another embodiment of the present invention includes:
a determining module 501, configured to determine an image to be classified;
a classification module 502, configured to input the image to be classified into an image classification model, so as to obtain an image classification result output by the image classification model; wherein the content of the first and second substances,
the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels;
the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
The image classification device provided by the embodiment of the invention performs sparsification on the gradient involved in the reverse propagation process of the convolutional neural network, so that the calculated amount is effectively reduced, and the training efficiency of the image classification model is effectively improved because the sparse process does not involve sequencing, the complexity is very low, and the occupation of resources can be almost ignored.
Fig. 6 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 6: a processor (processor)610, a communication Interface (Communications Interface)620, a memory (memory)630 and a communication bus 640, wherein the processor 610, the communication Interface 620 and the memory 630 communicate with each other via the communication bus 640. The processor 610 may call logic instructions in the memory 630 to perform the following method: determining an image to be classified; inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels; the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
It should be noted that, when being implemented specifically, the electronic device in this embodiment may be a server, a PC, or other devices, as long as the structure includes the processor 610, the communication interface 620, the memory 630, and the communication bus 640 shown in fig. 6, where the processor 610, the communication interface 620, and the memory 630 complete mutual communication through the communication bus 640, and the processor 610 may call the logic instruction in the memory 630 to execute the above method. The embodiment does not limit the specific implementation form of the electronic device.
In addition, the logic instructions in the memory 630 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Further, embodiments of the present invention disclose a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which when executed by a computer, the computer is capable of performing the methods provided by the above-mentioned method embodiments, for example, comprising: determining an image to be classified; inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels; the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
In another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented by a processor to perform the method provided by the foregoing embodiments, for example, including: determining an image to be classified; inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels; the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An image classification method, comprising:
determining an image to be classified;
inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; wherein the content of the first and second substances,
the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels;
the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
2. The image classification method according to claim 1, wherein the preset back propagation method for sparsifying the gradient set output by the preset layer in the convolutional neural network model includes:
and when the convolutional neural network model is a convolutional neural network model comprising a batch normalization layer, performing sparse processing on a gradient set output by the batch normalization layer in the convolutional neural network model.
3. The image classification method according to claim 1, wherein the preset back propagation method for sparsifying the gradient set output by the preset layer in the convolutional neural network model includes:
and when the convolutional neural network model is a convolutional neural network model which does not contain a batch normalization layer, performing sparse processing on a gradient set output by a previous adjacent layer of a ReLU activation layer in the convolutional neural network model in the back propagation direction.
4. The image classification method according to claim 1, characterized in that the sparseness processing includes:
setting a first gradient value of which the absolute value is smaller than a preset sparseness processing threshold value in the gradient set to be 0, or setting the first gradient value to be a first preset value or setting the first gradient value to be a second preset value; wherein the content of the first and second substances,
the absolute value of the first preset value is the same as that of the second preset value, the first preset value is positive, and the second preset value is negative.
5. The image classification method according to claim 4, wherein the setting of the first gradient value, whose absolute value is smaller than a preset sparseness threshold, in the gradient set to 0 or to a first preset value or to a second preset value further comprises:
comparing the absolute value of the first gradient value with a first threshold, if the absolute value of the first gradient value is smaller than or equal to the first threshold, setting the first gradient value to be 0, if the absolute value of the first gradient value is larger than the first threshold, determining whether the first gradient value is larger than 0, if the first gradient value is larger than 0, setting the first gradient value to be a first preset value, and if the first gradient value is smaller than or equal to 0, setting the first gradient value to be a second preset value; wherein the content of the first and second substances,
the first threshold is a product of the sparse processing threshold and a first random number, and the first random number is a number with a value range within a [0,1] interval.
6. The image classification method according to claim 1, characterized in that the convolutional neural network model comprises, in order in the backward propagation direction:
a ReLU activation layer, a batch normalization layer, a sparse processing layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is used for performing sparse processing on the first gradient set output by the batch of normalization layers in the back propagation to obtain a second gradient set, and the second gradient set is input to the convolution layer.
7. The image classification method according to claim 1, characterized in that the convolutional neural network model comprises, in order in the backward propagation direction: a sparse processing layer, a ReLU activation layer and a convolution layer; wherein the content of the first and second substances,
the sparse processing layer is configured to perform sparse processing on a third gradient set to be input to the ReLU activation layer in reverse propagation to obtain a fourth gradient set, and input the fourth gradient set to the ReLU activation layer.
8. An image classification apparatus, comprising:
a determining module for determining an image to be classified;
the classification module is used for inputting the image to be classified into an image classification model to obtain an image classification result output by the image classification model; wherein the content of the first and second substances,
the image classification model is obtained by training a convolutional neural network model based on sample image data and sample class labels;
the image classification model adopts a preset back propagation method during training, and the preset back propagation method carries out sparse processing on a gradient set output by a preset layer in the convolutional neural network model.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the image classification method according to any of claims 1 to 7 are implemented when the processor executes the program.
10. A non-transitory computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the image classification method according to any one of claims 1 to 7.
CN202010275340.0A 2020-04-09 2020-04-09 Image classification method and device, electronic equipment and storage medium Pending CN111539460A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010275340.0A CN111539460A (en) 2020-04-09 2020-04-09 Image classification method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010275340.0A CN111539460A (en) 2020-04-09 2020-04-09 Image classification method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111539460A true CN111539460A (en) 2020-08-14

Family

ID=71978555

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010275340.0A Pending CN111539460A (en) 2020-04-09 2020-04-09 Image classification method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111539460A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117875397A (en) * 2024-03-11 2024-04-12 浪潮电子信息产业股份有限公司 Parameter selection method and device to be updated, computing equipment and storage medium
CN117875397B (en) * 2024-03-11 2024-06-04 浪潮电子信息产业股份有限公司 Parameter selection method and device to be updated, computing equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108898112A (en) * 2018-07-03 2018-11-27 东北大学 A kind of near-infrared human face in-vivo detection method and system
CN110147834A (en) * 2019-05-10 2019-08-20 上海理工大学 Fine granularity image classification method based on rarefaction bilinearity convolutional neural networks
CN110390394A (en) * 2019-07-19 2019-10-29 深圳市商汤科技有限公司 Criticize processing method and processing device, electronic equipment and the storage medium of normalization data
CN110610229A (en) * 2019-07-30 2019-12-24 北京航空航天大学 Dynamic sparsification method for convolutional neural network training process

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108898112A (en) * 2018-07-03 2018-11-27 东北大学 A kind of near-infrared human face in-vivo detection method and system
CN110147834A (en) * 2019-05-10 2019-08-20 上海理工大学 Fine granularity image classification method based on rarefaction bilinearity convolutional neural networks
CN110390394A (en) * 2019-07-19 2019-10-29 深圳市商汤科技有限公司 Criticize processing method and processing device, electronic equipment and the storage medium of normalization data
CN110610229A (en) * 2019-07-30 2019-12-24 北京航空航天大学 Dynamic sparsification method for convolutional neural network training process

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
HIDENORI IDE等: "Improvement of learning for CNN with ReLU activation by sparse regularization", 《RESEARCHGATE》 *
JUN CAI等: "Facial Expression Recognition Method Based on Sparse Bath Normalization CNN", 《PROCEEDINGS OF THE 37TH CHINESE CONTROL CONFERENCE》 *
叶会娟等: "基于稀疏卷积核的卷积神经网络研究及其应用", 《信息技术》 *
周安众等: "一种卷积神经网络的稀疏性Dropout正则化方法", 《小型微型计算机系统》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117875397A (en) * 2024-03-11 2024-04-12 浪潮电子信息产业股份有限公司 Parameter selection method and device to be updated, computing equipment and storage medium
CN117875397B (en) * 2024-03-11 2024-06-04 浪潮电子信息产业股份有限公司 Parameter selection method and device to be updated, computing equipment and storage medium

Similar Documents

Publication Publication Date Title
US20180260711A1 (en) Calculating device and method for a sparsely connected artificial neural network
US10902318B2 (en) Methods and systems for improved transforms in convolutional neural networks
EP3979143A1 (en) Method of performing splitting in neural network model by means of multi-core processor, and related product
CN111507521A (en) Method and device for predicting power load of transformer area
CN110781686B (en) Statement similarity calculation method and device and computer equipment
US20190311266A1 (en) Device and method for artificial neural network operation
CN110909874A (en) Convolution operation optimization method and device of neural network model
CN115860100A (en) Neural network model training method and device and computing equipment
CN116385773A (en) Small target detection method, storage medium and electronic equipment
CN114511042A (en) Model training method and device, storage medium and electronic device
CN112132255A (en) Batch normalization layer fusion and quantification method for model inference in artificial intelligence neural network engine
JP6895415B2 (en) Arithmetic logic unit, calculation program, recording medium and calculation method
CN112528650B (en) Bert model pre-training method, system and computer equipment
Qi et al. Learning low resource consumption cnn through pruning and quantization
WO2020195940A1 (en) Model reduction device of neural network
US11481604B2 (en) Apparatus and method for neural network processing
CN111539460A (en) Image classification method and device, electronic equipment and storage medium
EP4227850A1 (en) Program, learning method, and information processing apparatus
Zhan et al. Field programmable gate array‐based all‐layer accelerator with quantization neural networks for sustainable cyber‐physical systems
CN117035045A (en) Model parameter updating method, device, equipment, storage medium and program product
CN112966723B (en) Video data augmentation method, video data augmentation device, electronic device and readable storage medium
US20220391761A1 (en) Machine learning device, information processing method, and recording medium
CN110610227B (en) Artificial neural network adjusting method and neural network computing platform
CN110852112A (en) Word vector embedding method and device
CN111899161A (en) Super-resolution reconstruction method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200814

RJ01 Rejection of invention patent application after publication