WO2020006881A1 - Butterfly identification network construction method and apparatus, and computer device and storage medium - Google Patents

Butterfly identification network construction method and apparatus, and computer device and storage medium Download PDF

Info

Publication number
WO2020006881A1
WO2020006881A1 PCT/CN2018/106395 CN2018106395W WO2020006881A1 WO 2020006881 A1 WO2020006881 A1 WO 2020006881A1 CN 2018106395 W CN2018106395 W CN 2018106395W WO 2020006881 A1 WO2020006881 A1 WO 2020006881A1
Authority
WO
WIPO (PCT)
Prior art keywords
butterfly
network
capsule
loss function
image
Prior art date
Application number
PCT/CN2018/106395
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 WO2020006881A1 publication Critical patent/WO2020006881A1/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Definitions

  • the present application relates to the field of computer technology, and in particular, to a method, a device, a computer device, and a storage medium for constructing a butterfly recognition network.
  • CNN convolutional neural network
  • butterfly recognition can be used as a study of biological diversity and species analysis. Due to the limited number of butterfly images in the existing image databases, there are few butterfly species, and the size of butterfly images is too small, which is not conducive to traditional convolutional neural networks to identify butterflies. Because the traditional convolutional neural network requires a large number of training images, and lacks the observation position and perspective information, that is, it cannot handle the polysemous expression of the image well. Because the traditional convolutional neural network cannot distinguish the same butterfly species based on different perspectives of the same butterfly, the accuracy of butterfly recognition is low.
  • the embodiments of the present application provide a method, a device, a computer device, and a storage medium for constructing a butterfly recognition network, so as to solve the problem that the traditional butterfly convolutional neural network recognizes the same type of butterflies from different perspectives as different kinds of butterflies, resulting in the accuracy of butterfly recognition Low problem.
  • a method for constructing a butterfly recognition network includes:
  • the target butterfly image used for training in the butterfly species is input into a capsule network, and passes through a first convolution calculation of a convolution layer of the capsule network and the capsule network. Calculation of the second convolution of the capsule layer to obtain the output vector of the butterfly species;
  • each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and each type of the butterfly species is updated.
  • the target butterfly image used in training is re-input to the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function The value is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  • a butterfly recognition network construction device includes:
  • An acquisition module for acquiring an original butterfly image corresponding to each butterfly species from a preset butterfly database
  • a resampling module for resampling the original butterfly image to obtain a target butterfly image
  • a convolution module for each of the butterfly species, inputting the target butterfly image used for training in the butterfly species into a capsule network, and passing a first convolution calculation of a convolution layer of the capsule network And a second convolution calculation of a capsule layer of the capsule network to obtain an output vector of the butterfly species;
  • a loss calculation module configured to perform a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
  • a training module configured to use the capsule network as a training network for identifying a butterfly when the loss function value of each of the output vectors is less than or equal to a preset loss threshold;
  • An update module is configured to update each capsule neuron in the capsule network by back propagation when the loss function value is greater than the preset loss threshold, obtain the updated capsule network, and update each capsule network.
  • the target butterfly image used for training among the butterfly species is re-input into the updated capsule network, and performs the first convolution calculation, the second convolution calculation, and the loss function calculation, Until the value of the loss function is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  • a computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor implements the computer-readable instructions to implement the above-mentioned butterfly recognition network construction Method steps.
  • One or more non-volatile readable storage media storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to execute the butterfly recognition network described above Steps in building the method.
  • FIG. 1 is a schematic diagram of an application environment of a method for constructing a butterfly recognition network according to an embodiment of the present application
  • FIG. 2 is an implementation flowchart of a method for constructing a butterfly recognition network according to an embodiment of the present application
  • step S2 in a method for constructing a butterfly recognition network according to an embodiment of the present application
  • step S3 is an implementation diagram of step S3 in a method for constructing a butterfly recognition network according to an embodiment of the present application
  • FIG. 5 is an implementation diagram of a training network for testing and identifying butterflies in a method for constructing a butterfly recognition network according to an embodiment of the present application
  • FIG. 6 is a schematic diagram of an apparatus for constructing a butterfly recognition network according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a computer device in an embodiment of the present application.
  • the method for constructing a butterfly recognition network can be applied in the application environment shown in FIG. 1, in which a server and a client are connected through a network, and the server performs a first convolution of a target butterfly image in a capsule network
  • the training, the second convolution calculation, and the loss function calculation process are used to obtain the training network for identifying the butterfly.
  • the user modifies the training parameters of the capsule network through the client.
  • the client can specifically, but not limited to, various personal computers, laptops, smartphones, tablets
  • the server can be implemented by an independent server or a server cluster composed of multiple servers.
  • a method for constructing a butterfly recognition network is provided.
  • the method is applied to the server in FIG. 1 as an example, and includes the following steps:
  • the preset butterfly database stores all original butterfly images in the existing butterfly database.
  • the preset butterfly database includes, but is not limited to, the Leeds butterfly database, the Ecuador butterfly database, and Costarica (Costa Marie). Butterfly database.
  • the preset butterfly database can also use the Fine-Grained (fine-grained) butterfly database, of which the Leeds butterfly database includes 14,270 original butterfly images corresponding to 636 butterfly species, and the Ecuador butterfly database includes 10 Butterfly types: 832 original butterfly images corresponding to butterfly types, Costarica (Costa Rica) includes 2120 original butterfly images corresponding to 675 butterfly types, and Fine-Grained (fine-grained) butterfly database includes 3,224 original butterfly images corresponding to 331 butterfly types
  • the butterfly database is not limited here.
  • resampling is resampling a digital image composed of discrete data formed after sampling according to a preset pixel position or pixel interval to form a new image after geometric transformation.
  • one part of the target butterfly image is used as training sample data for training the capsule network, and the other part of the butterfly image is used for training to identify the butterfly Test sample data for the network.
  • a target butterfly image of the same size is obtained, and the target butterfly image carries the corresponding butterfly type mark, which is beneficial for subsequent training or testing the training network that recognizes the butterfly.
  • the output result and the original input are obtained.
  • the target butterfly image is compared with the corresponding butterfly species mark to determine whether the output result is correct.
  • the target butterfly image used for training in this butterfly type is input into the capsule network, and passes through the first convolution calculation of the convolution layer of the capsule network and the second volume of the capsule layer of the capsule network. Product calculation to get the output vector of this butterfly species.
  • the capsule network consists of a parse tree.
  • the neurons in each layer of the neuron layer in the capsule network will be divided into multiple neuron groups.
  • Each neuron group is called a capsule.
  • Each node in the parse tree will correspond to an activated capsule ( active capsule).
  • An activated capsule is composed of multiple activated capsule neurons.
  • Each capsule neuron contains a convolution kernel.
  • the convolution kernel is a type of (filter) matrix or feature detector.
  • the weight in the convolution kernel is the characteristic expression of the attribute, that is, the capsule neuron represents the attribute of a certain butterfly species, among which the attributes can be different perspectives corresponding to each butterfly species such as different angles, positions and directions.
  • the training network for butterfly recognition improves the accuracy of butterfly recognition by continuously modifying the weights in the convolution kernel in the capsule neurons and other training parameters, among which other training parameters include coupling coefficients.
  • a target butterfly image of the butterfly species used for training is input to a convolution layer in a capsule network to perform a first convolution calculation.
  • the first convolution calculation is to calculate the target butterfly image and the convolution kernel in the convolution layer.
  • the convolution kernel calculation refers to the element value at each position in the convolution kernel and the corresponding point on the target butterfly image.
  • a second convolution calculation is performed in the layer, where the second convolution calculation is a convolution calculation of the result obtained by the first convolution calculation with the activated capsule neuron to obtain an output vector of the butterfly species.
  • the vector length in the output vector indicates the probability that the target butterfly image is recognized as the corresponding butterfly type in the capsule network
  • the vector direction of the output vector indicates the attributes of the butterfly type, such as different perspectives of the butterfly.
  • the loss function describes the loss of the training model under different parameter values, and is used to estimate the degree of inconsistency between the predicted value and the true value of the training model.
  • the loss function calculation is performed on the output vector of each butterfly species, and the loss function value of the output vector is a non-negative function value.
  • adjusting the training parameters of the training network for identifying the butterfly can reduce the value of the loss function.
  • the training parameters include convolution. Weights in the kernel.
  • the loss function value of each output vector obtained in step S4 is less than or equal to a preset loss threshold, that is, the robustness of the training network for butterfly recognition at this time has reached the expected effect of butterfly recognition
  • the current capsule network is used as the training network for the final recognition of butterflies.
  • the preset loss threshold may be 0.3 or a decimal from 0 to 1.
  • each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and the butterfly image used as a training target in each butterfly species Re-enter the updated capsule network and perform the first convolution calculation, the second convolution calculation, and the loss function calculation until the loss function value is less than or equal to the preset loss threshold, where the capsule neuron represents the butterfly species. Attributes.
  • each capsule neuron in the capsule network is updated by back propagation, where the back propagation is to obtain the loss function for each neuron layer by layer.
  • the partial derivative of the weight value so as to obtain the ladder function of the loss function to the output vector.
  • the ladder function is used as a basis for modifying the weight value in each capsule neuron, so that the developer can adjust each capsule neuron in the capsule network according to the ladder
  • the capsule network is updated, and the target butterfly image used for training in each butterfly species is re-entered into the updated capsule network, and step S3 is continued until the loss function value is less than or equal to the loss threshold.
  • the attributes of capsule neurons representing butterfly species include different perspectives corresponding to each butterfly species.
  • the original butterfly image corresponding to each butterfly type is obtained from a preset butterfly database, and the original butterfly image is resampled to obtain a target butterfly image;
  • the target butterfly image used for training in this butterfly type is input Into the capsule network, and after the first convolution calculation of the convolution layer of the capsule network and the second convolution calculation of the capsule layer of the capsule network, the output vector of the butterfly species is calculated by the loss function to obtain the loss function value; when the loss When the function value is greater than a preset value, each capsule neuron in the capsule network is updated by back propagation, thereby obtaining an updated capsule network.
  • the target butterfly image used as training is input to the updated capsule network for the first time.
  • step S2 the original butterfly image is resampled to obtain the target butterfly image, which specifically includes the following steps:
  • S21 Determine the zoom ratio of the original butterfly image according to the preset target size.
  • the scaling ratio of the original butterfly image is determined according to a preset target size, so that the obtained target butterfly image has the same size, which is beneficial for the capsule network to identify butterfly species, and reduces interference factors caused by inconsistent size. Prevent overfitting.
  • all original butterfly images are resampled to obtain a size of 32 ⁇ 32 ⁇ 3, where 32 pixels are in the row direction, 32 pixels are in the column direction, and 3 refers to three channels of RGB.
  • 3 refers to three channels of RGB.
  • a channel is used to represent a certain composition of an image.
  • an image taken by a standard digital camera will have three channels-red, green, and blue. Think of them as a two-dimensional matrix stacked on top of each other.
  • Each channel represents a color, and the pixel value of each channel ranges from 0 to In the range of 255.
  • step S21 starting from the target image, the original pixel points of the original butterfly image are divided according to the zoom ratio 2 to obtain each target pixel point of the target butterfly image corresponding to the original butterfly image.
  • the RGB values of each original pixel point are accumulated and averaged to obtain an average RGB value, and according to the correspondence between the original pixel point and each pixel point of the target butterfly image , Taking the average RGB value as the RGB value of the target pixel corresponding to the set of original pixels, where the average RGB value is a positive integer. For example, referring to the example of step S22, if the RGB values of 4 pixels are ⁇ 215,0,64,0 ⁇ , the average RGB value is
  • the scaling ratio of the original butterfly image is determined according to a preset target size, a set of original pixels corresponding to each target pixel point of the target butterfly image in the original butterfly image is obtained, and the set of original pixels is calculated.
  • the average RGB value of each original pixel in the image, and use the average RGB value as the RGB value of the target pixel corresponding to the set of original pixels, to achieve the goal of scaling all original butterfly images of different sizes to a uniform standard size Butterfly images are beneficial to provide good training sample data for the capsule network in the future, and avoid overfitting problems caused by the different sizes of the original butterfly images.
  • step S3 for each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network and passes through the capsule.
  • the first convolution calculation of the convolution layer of the network and the second convolution calculation of the capsule layer of the capsule network to obtain the output vector of the butterfly species include the following steps:
  • S31 Perform the first convolution calculation on the convolution layer of the capsule network by using the target butterfly image input into the butterfly species for training to obtain a feature vector.
  • a target butterfly image used for training in a butterfly species is input to a convolution layer of a capsule network, and a first convolution calculation is performed on a convolution kernel of the target butterfly image and each capsule neuron in the convolution layer,
  • the first convolution calculation is to multiply the element value at each position in the convolution kernel with the element value of the corresponding point on the target butterfly image, and the resulting feature vector is called a Convolved Feature or a feature map ( Feature map).
  • the depth is 256 and the convolution window size is 9 * 9, that is, a convolution kernel of 256 9 * 9 matrices is constructed.
  • zero supplementation is used, which is also called zero-padding.
  • the modified linear activation function namely the ReLU (Rectified Linear Unit) activation function
  • the ReLU Rectified Linear Unit activation function
  • the neuron activation function is a neuron activation function and a piecewise linear function. It can set all the pixel values less than 0 in the feature map to zero. While leaving other pixels with positive values, this operation is called unilateral suppression, so that the relevant features can be better mined in the sparse capsule network to avoid overfitting.
  • the feature vector is substituted into the modified linear activation function, that is, the pixel gray value of the feature map is converted into the activation value of the local feature.
  • the capsule layer of the capsule network in this embodiment is a 32-channel capsule, and each capsule includes 8 capsule neurons, and each capsule neuron includes 9 ⁇ 9 Convolution kernel with stride of 2.
  • the second convolution calculation refers to the convolution calculation of each capsule neuron and all local feature vectors of the convolution layer, and by using an iterative routing process, it is finally output by 32 ⁇ 32 ⁇ n capsules, and each capsule is 8-dimensional output vector, that is, each capsule actually outputs a set of output vectors.
  • an iterative routing process can obtain an output vector through formulas (1) to (4).
  • the output vector represents the probability of each butterfly species from different perspectives, including:
  • b ij refers to the softmax activation function between the i-th capsule neuron and the j-th capsule neuron.
  • a softmax activation function is a method that maps each value of a multidimensional vector into (0, 1) The function of the interval is used for classification here, c ij is the coupling coefficient, Is the local feature vector, W ij is the weight matrix, and S j is all the local feature vectors Weighted sum, V j is the output vector of the j-th capsule neuron.
  • c ij is the coupling coefficient determined by the iterative routing process.
  • the sum of the coupling coefficient between Capsule and the capsules in the previous layer is 1. This coefficient, along with other weights, is determined during training and depends on the position and type of the two capsules.
  • each capsule neuron in the capsule layer has the same coupling coefficient to each capsule neuron in the convolution layer; each capsule neuron in the capsule layer is calculated for each possible parent node
  • the local feature vector is used as the input of the parent node. If the inner product of the local feature vector and the output vector of a parent node is large, the coupling coefficient of the parent node will be increased through a top-down feedback, and at the same time it will be reduced. The coupling coefficient of the other parent nodes is small, and the result of dynamic selection is achieved. In addition, the sum of all coupling coefficients of a capsule neuron is 1.
  • low-level capsule neurons tend to be aligned with high-level capsule neurons, that is, a high coupling coefficient indicates a large tendency to predict the local characteristics of the butterfly species, and a low coupling coefficient indicates a local tendency to predict the butterfly characteristics.
  • the coupling coefficient c ij of capsule neuron i to capsule neuron j is 1. Since all the coupling coefficients of capsule neuron i are 1, the coupling coefficient of capsule neuron i to other capsule neurons is zero. That is, all local feature vectors of the capsule neuron i are only passed to the capsule neuron j.
  • V j is a probability value
  • a non-linear "squeeze" function is used to ensure that the short output vector is “compressed” to a length close to 0, The long vector is "compressed” to a value close to one in length.
  • the target butterfly image inputted into the butterfly species is used for training.
  • the first convolution calculation is performed in the convolution layer of the capsule network, and the obtained feature vector is substituted into the modified linear activation function to obtain local features.
  • Vector by using an iterative routing process, a second convolution calculation is performed on the local feature vector with each capsule neuron in the capsule layer of the capsule network to obtain an output vector.
  • the prediction tendency is more obvious, and the generalization of the target butterfly image is achieved, for example, the generalization includes perspective information such as likelihood, direction, and size, thereby improving the discrimination ability of different butterfly perspectives of the same butterfly species.
  • a loss function calculation is performed on an output vector of each butterfly species, and a specific implementation process of obtaining a loss function value of the output vector is obtained. Details are as follows:
  • c is the butterfly type
  • L c is the loss function value
  • T c is the indicator function of the butterfly type
  • ) 2 is taken as 0 and m + -
  • -m -) 2 is set to 0 and
  • is the vector length of the output vector V c
  • is the preset parameter value
  • m - is the lower boundary of the preset vector length.
  • the indication function is also called a feature function.
  • the indication function is to customize each butterfly type into a set, and the set includes a subset of various attributes of the butterfly type.
  • the target butterfly corresponding to the butterfly type The images belong to a certain subset in the collection, and the subset can be a certain attribute of the butterfly species.
  • the instruction function judges that the output vector is the same as the actual target butterfly image, the output is 1, otherwise it is 0.
  • the total length of a column vector is used to identify the total number of butterfly species, and the element of the column vector is 1.
  • the position represents the classification result of the butterfly species corresponding to the position, and 0 in the column vector indicates that it is not the butterfly species.
  • the output vector belongs to a certain subset, and the subset belongs to a set of certain butterfly species, the number of column items corresponding to the species is 1, however, in actual classification, the value in the column vector is the corresponding butterfly species.
  • Probability For example, the length of the output vector
  • the loss function value is calculated by calculating the loss function layer of each output vector in the capsule network, and the prediction effect of the capsule network on the butterfly species is measured according to the size of the loss function value, which is beneficial to further adjustment. Parameters in the capsule network.
  • step S6 the method for constructing a butterfly recognition network further includes the following steps:
  • the target butterfly image used as a test is input into a training network for recognition of a butterfly, and the loss function value of the test output vector is obtained through the first convolution calculation, the second convolution calculation, and the loss function calculation.
  • the target butterfly image used as the test that is, the test sample data is input into the training network for identifying the butterfly obtained in steps S1 to S5, and according to step S3, the first convolution calculation, the second Convolution calculation and loss function calculation, output the loss function value of the test output vector.
  • a test output vector corresponding to a loss function value that is greater than or equal to a preset upper boundary of the vector length is obtained. For example, if a type c butterfly type exists and the preset vector length is 0.9, the type c butterfly type When an output vector with a vector length of at least 0.9 is output, it can be indicated that the target butterfly image corresponding to the output vector belongs to the type c butterfly category, where 0.9 represents the upper boundary of the vector length.
  • test output vector is reconstructed through a decoder network.
  • the decoder network is composed of three fully connected layers, and an output image is obtained through the decoder network reconstruction.
  • Reconstruction refers to reconstructing a test output vector into an actual image corresponding to the test output vector, thereby constructing a complete output image.
  • the reconstruction method all test output vectors are obtained through the decoder network to obtain the output image, and the image comparison method is used to filter out the same output image as the target butterfly image used for testing.
  • the image comparison method includes but is not limited to perception Hash algorithm, gray-scale histogram similarity comparison method, or PSNR (Peak Signal-to-Noise Ratio) method, and calculate the total number of output images that are the same as the target butterfly image used for testing and the total of the target butterfly image used for testing
  • the proportion of the amount is the accuracy rate of the training network for butterfly recognition. If the accuracy rate obtained is less than the preset accuracy rate, it indicates that the recognition effect of the training network for butterfly recognition is not good, and the recognition butterfly needs to be further improved. Otherwise, there is no need to adjust the training network for butterfly recognition.
  • the preset accuracy rate can be set to 95% or a percentage value greater than 95%.
  • a target butterfly image used as a test is input to a training network that recognizes butterflies, and a test output vector corresponding to a loss function value that is greater than or equal to the upper boundary of the vector length is obtained.
  • the test output vector is reconstructed to obtain the output image, and then the accuracy rate of the training network for butterfly recognition is obtained.
  • the accuracy rate can intuitively determine the recognition effect of the butterfly recognition training network on the butterfly species, and determine whether to recognize the butterfly based on the recognition effect. Training network to make further improvements.
  • a device for constructing a butterfly recognition network corresponds to the method for constructing a butterfly recognition network in the above-mentioned embodiment.
  • the apparatus for constructing a butterfly recognition network includes an acquisition module 61, a resampling module 62, a convolution module 63, a calculation module 64, a training module 65, and an update module 66.
  • the detailed description of each function module is as follows:
  • An obtaining module 61 configured to obtain an original butterfly image corresponding to each butterfly type from a preset butterfly database
  • a resampling module 62 configured to resample the original butterfly image to obtain a target butterfly image
  • a convolution module 63 for each butterfly species, inputs a butterfly image used for training in the butterfly species into a capsule network, and passes the first convolution calculation of the convolution layer of the capsule network and the capsules of the capsule network The second convolution calculation of the layer to obtain the output vector of the butterfly species;
  • a loss calculation module 64 is configured to perform a loss function calculation on an output vector of each butterfly species in a loss function layer in the capsule network to obtain a loss function value of each output vector;
  • a training module 65 configured to use the capsule network as a training network for identifying butterflies when the loss function value of each output vector is less than or equal to a preset loss threshold;
  • An update module 66 is configured to update each capsule neuron in the capsule network by back propagation when the loss function value is greater than a preset loss threshold, to obtain the updated capsule network, and use each butterfly species as training
  • the target butterfly image is re-input into the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function value is less than or equal to a preset loss threshold, where the capsule neuron Attributes representing butterfly species.
  • the resampling module 62 includes:
  • a scaling unit 621 configured to determine a scaling ratio of the original butterfly image according to a preset target size
  • An obtaining unit 622 is configured to obtain the original pixel points of the original butterfly image according to the scaling ratio, obtain a set of original pixel points corresponding to each target pixel point of the target butterfly image in the original butterfly image, and establish each original pixel point. A correspondence between a set of pixels and each pixel of the target butterfly image;
  • a calculation unit 623 is configured to calculate an average RGB value of each original pixel in the set of original pixels, and use the average RGB value as an RGB value of a target pixel corresponding to the set of original pixels according to a corresponding relationship.
  • the convolution module 63 includes:
  • a first convolution unit 631 configured to perform a first convolution calculation in a convolution layer of a capsule network on a target butterfly image input into a butterfly species for training, to obtain a feature vector;
  • An activation unit 632 configured to substitute the feature vector into a modified linear activation function to obtain a local feature vector
  • a second convolution unit 633 is configured to perform a second convolution calculation using a local feature vector with each capsule neuron in a capsule layer of the capsule network by using an iterative routing processing method to obtain an output vector of a butterfly type.
  • calculation loss module 64 includes:
  • a formula unit 641 is configured to calculate each loss vector of the output vector in a loss function layer in the capsule network according to formula (6):
  • c is the butterfly type
  • L c is the loss function value
  • T c is the indicator function of the butterfly type
  • ) 2 is taken as 0 and m + -
  • -m -) 2 is taken and
  • is the vector length of the output vector V c
  • is the preset parameter value
  • m - is the lower boundary of the preset vector length.
  • the apparatus for constructing a butterfly recognition network further includes:
  • a test calculation module 67 is configured to input a target butterfly image used as a test into a training network for recognition of a butterfly, and obtain a loss function value of a test output vector through a first convolution calculation, a second convolution calculation, and a loss function calculation. ;
  • a reconstruction module 68 is configured to take a test output vector corresponding to a loss function value that is greater than or equal to a preset upper boundary of the vector length, and reconstruct the test output vector through a decoder network to obtain an output image, and compare the output image with The target butterfly images used for testing are compared to get the accuracy of the training network for butterfly recognition.
  • Each module in the above-mentioned butterfly recognition network construction device may be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above-mentioned modules may be embedded in the hardware in or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 7.
  • the computer device includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer-readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in a non-volatile storage medium.
  • the computer equipment database is used to store the original butterfly image.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instructions are executed by a processor to implement a method for constructing a butterfly recognition network.
  • a computer device including a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor.
  • the processor executes the computer-readable instructions
  • the butterfly recognition of the foregoing embodiment is implemented. Steps of the network construction method, for example, steps S1 to S6 shown in FIG. 2 or, when the processor executes computer-readable instructions, the functions of each module / unit of the butterfly recognition network construction device in the above embodiment are implemented, as shown in FIG. 6 Modules 61 to 66 function. To avoid repetition, we will not repeat them here.
  • one or more non-volatile readable storage media are provided, and computer-readable instructions are stored thereon.
  • the computer-readable instructions are executed by one or more processors, the butterfly in the foregoing method embodiment is implemented.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

Disclosed are a butterfly identification network construction method and apparatus, and a computer device and a storage medium. The method comprises: resampling an original butterfly image to obtain a target butterfly image for training; if a loss function value, calculated in a loss function layer, of an output vector that is obtained by means of first convolutional calculation of a convolution layer of a capsule network and second convolutional calculation of a capsule layer is not more than a preset threshold, using the capsule network as a training network for butterfly identification, otherwise, updating each capsule neuron in the capsule network by means of back propagation to obtain an updated capsule network; and performing the first convolutional calculation, the second convolutional calculation and the loss function calculation on the target butterfly image for training again in the updated capsule network until the loss function value is not more than the loss threshold, so that the ambiguity expression of butterfly images is realized, that is, the same butterfly species from different angles of view can be distinguished, and the accuracy of butterfly identification by the capsule network is improved.

Description

蝴蝶识别网络构建方法、装置、计算机设备及存储介质Method and device for constructing butterfly recognition network, computer equipment and storage medium
本申请以2018年7月6日提交的申请号为201810735895.1,名称为“蝴蝶识别网络构建方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。This application is based on a Chinese invention patent application filed on July 6, 2018 with application number 201810735895.1, entitled "Butterfly recognition network construction method, device, computer equipment, and storage medium", and claims its priority.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种蝴蝶识别网络构建方法、装置、计算机设备及存储介质。The present application relates to the field of computer technology, and in particular, to a method, a device, a computer device, and a storage medium for constructing a butterfly recognition network.
背景技术Background technique
近几年,随着人工智能的发展,深度学习在语音识别、自然语言处理以及图像与视频分析等诸多领域获得了巨大的成功。目前,深度学习是一种从端到端机器学习系统,深度学习方法中的卷积神经网络(convolutional neural network,CNN)模型在大规模图像识别任务中表现出色,与传统模式识别方法最大不同在于它从图像中能自动逐层提取特征,可以包含成千上万的参数,这些良好的特征表达在深度学习中起到至关重要的作用。In recent years, with the development of artificial intelligence, deep learning has achieved great success in many areas such as speech recognition, natural language processing, and image and video analysis. At present, deep learning is an end-to-end machine learning system. Convolutional neural network (CNN) models in deep learning methods perform well in large-scale image recognition tasks. The biggest difference from traditional pattern recognition methods is that It can automatically extract features from the image layer by layer, and can contain thousands of parameters. These good feature expressions play a vital role in deep learning.
提高蝴蝶识别率对实际的生物研究有着很大的实际意义,例如通过蝴蝶识别可用作生物多样性的学习和物种的分析等。由于目前已有的影像数据库中存在的蝴蝶影像数量有限,蝴蝶种类少,蝴蝶影像的尺寸太小,不利于传统卷积神经网络对蝴蝶进行识别。因为传统卷积神经网络需要大量的训练影像,而且缺少观测位置和视角信息,即不能很好地处理图像的多义性表达。因为传统卷积神经网络无法根据同一种蝴蝶的不同视角去区分得到同一蝴蝶种类的分类结果,所以导致蝴蝶识别准确率低。Improving the butterfly recognition rate has great practical significance for practical biological research, for example, butterfly recognition can be used as a study of biological diversity and species analysis. Due to the limited number of butterfly images in the existing image databases, there are few butterfly species, and the size of butterfly images is too small, which is not conducive to traditional convolutional neural networks to identify butterflies. Because the traditional convolutional neural network requires a large number of training images, and lacks the observation position and perspective information, that is, it cannot handle the polysemous expression of the image well. Because the traditional convolutional neural network cannot distinguish the same butterfly species based on different perspectives of the same butterfly, the accuracy of butterfly recognition is low.
发明内容Summary of the invention
本申请实施例提供一种蝴蝶识别网络构建的方法、装置、计算机设备及存储介质,以解决由于传统卷积神经网络将不同视角的同一类蝴蝶识别为不同种类的蝴蝶,而导致识别蝴蝶准确率低的问题。The embodiments of the present application provide a method, a device, a computer device, and a storage medium for constructing a butterfly recognition network, so as to solve the problem that the traditional butterfly convolutional neural network recognizes the same type of butterflies from different perspectives as different kinds of butterflies, resulting in the accuracy of butterfly recognition Low problem.
一种蝴蝶识别网络构建方法,包括:A method for constructing a butterfly recognition network includes:
从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;Obtain the original butterfly image corresponding to each butterfly species from a preset butterfly database;
对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;Performing resampling processing on the original butterfly image to obtain a target butterfly image;
针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;For each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network, and passes through a first convolution calculation of a convolution layer of the capsule network and the capsule network. Calculation of the second convolution of the capsule layer to obtain the output vector of the butterfly species;
在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;Performing a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;When the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, using the capsule network as a training network for identifying butterflies;
当所述损失函数值大于所述预设的损失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。When the value of the loss function is greater than the preset loss threshold, each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and each type of the butterfly species is updated. The target butterfly image used in training is re-input to the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function The value is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
一种蝴蝶识别网络构建装置,包括:A butterfly recognition network construction device includes:
获取模块,用于从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;An acquisition module for acquiring an original butterfly image corresponding to each butterfly species from a preset butterfly database;
重采样模块,用于对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;A resampling module for resampling the original butterfly image to obtain a target butterfly image;
卷积模块,用于针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;A convolution module, for each of the butterfly species, inputting the target butterfly image used for training in the butterfly species into a capsule network, and passing a first convolution calculation of a convolution layer of the capsule network And a second convolution calculation of a capsule layer of the capsule network to obtain an output vector of the butterfly species;
计算损失模块,用于在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;A loss calculation module, configured to perform a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
训练模块,用于当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;A training module, configured to use the capsule network as a training network for identifying a butterfly when the loss function value of each of the output vectors is less than or equal to a preset loss threshold;
更新模块,用于当所述损失函数值大于所述预设的损失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。An update module is configured to update each capsule neuron in the capsule network by back propagation when the loss function value is greater than the preset loss threshold, obtain the updated capsule network, and update each capsule network. The target butterfly image used for training among the butterfly species is re-input into the updated capsule network, and performs the first convolution calculation, the second convolution calculation, and the loss function calculation, Until the value of the loss function is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述蝴蝶识别网络构建方法的步骤。A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor implements the computer-readable instructions to implement the above-mentioned butterfly recognition network construction Method steps.
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行上述蝴蝶识别网络构建方法的步骤。One or more non-volatile readable storage media storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to execute the butterfly recognition network described above Steps in building the method.
本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。Details of one or more embodiments of the present application are set forth in the accompanying drawings and description below, and other features and advantages of the present application will become apparent from the description, the drawings, and the claims.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the drawings used in the description of the embodiments of the application will be briefly introduced below. Obviously, the drawings in the following description are just some embodiments of the application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without paying creative labor.
图1是本申请一实施例中蝴蝶识别网络构建方法的一应用环境示意图;1 is a schematic diagram of an application environment of a method for constructing a butterfly recognition network according to an embodiment of the present application;
图2是本申请一实施例中蝴蝶识别网络构建方法的实现流程图;2 is an implementation flowchart of a method for constructing a butterfly recognition network according to an embodiment of the present application;
图3是本申请一实施例中蝴蝶识别网络构建方法中步骤S2的一实现流程图;3 is an implementation flowchart of step S2 in a method for constructing a butterfly recognition network according to an embodiment of the present application;
图4是本申请一实施例中蝴蝶识别网络构建方法中步骤S3的的一实现图;4 is an implementation diagram of step S3 in a method for constructing a butterfly recognition network according to an embodiment of the present application;
图5是本申请一实施例中蝴蝶识别网络构建方法中测试识别蝴蝶的训练网络的一实现图;5 is an implementation diagram of a training network for testing and identifying butterflies in a method for constructing a butterfly recognition network according to an embodiment of the present application;
图6是本申请一实施例中蝴蝶识别网络构建装置的一示意图;6 is a schematic diagram of an apparatus for constructing a butterfly recognition network according to an embodiment of the present application;
图7是本申请一实施例中计算机设备的一示意图。FIG. 7 is a schematic diagram of a computer device in an embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In the following, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
本申请提供的蝴蝶识别网络构建方法,可应用在如图1的应用环境中,其中,服务端和客户端之间通过网络进行连接,服务端将目标蝴蝶影像在胶囊网络中执行第一卷积计算,第二卷积计算以及损失函数计算处理得到识别蝴蝶的训练网络,用户通过客户端修 改胶囊网络的训练参数,客户端具体可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备,服务端具体可以用独立的服务器或者多个服务器组成的服务器集群实现。The method for constructing a butterfly recognition network provided in this application can be applied in the application environment shown in FIG. 1, in which a server and a client are connected through a network, and the server performs a first convolution of a target butterfly image in a capsule network The training, the second convolution calculation, and the loss function calculation process are used to obtain the training network for identifying the butterfly. The user modifies the training parameters of the capsule network through the client. The client can specifically, but not limited to, various personal computers, laptops, smartphones, tablets For computers and portable wearable devices, the server can be implemented by an independent server or a server cluster composed of multiple servers.
在一实施例中,如图2所示,提供一种蝴蝶识别网络构建方法,以该方法应用在图1中的服务器为例进行说明,包括如下步骤:In an embodiment, as shown in FIG. 2, a method for constructing a butterfly recognition network is provided. The method is applied to the server in FIG. 1 as an example, and includes the following steps:
S1:从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像。S1: Obtain the original butterfly image corresponding to each butterfly type from a preset butterfly database.
具体地,预设的蝴蝶数据库存储着现有的蝴蝶数据库中的所有原始蝴影像,预设的蝴蝶数据库包括但不限于Leeds(利兹)蝴蝶数据库、Ecuador(厄瓜多尔)蝴蝶数据库、以及Costarica(哥斯达黎加)蝴蝶数据库。另外,预设的蝴蝶数据库还可以采用Fine-Grained(细粒度)蝴蝶数据库,其中,Leeds(利兹)蝴蝶数据库包括636个蝴蝶种类对应的14270张原始蝴蝶影像、Ecuador(厄瓜多尔)蝴蝶数据库包括10个蝴蝶种类蝴蝶种类对应的832张原始蝴蝶影像、Costarica(哥斯达黎加)包括675个蝴蝶种类对应的2120张原始蝴蝶影像、Fine-Grained(细粒)蝴蝶数据库包括331个蝴蝶种类对应的3224张原始蝴蝶影像,此处蝴蝶数据库不做限制。Specifically, the preset butterfly database stores all original butterfly images in the existing butterfly database. The preset butterfly database includes, but is not limited to, the Leeds butterfly database, the Ecuador butterfly database, and Costarica (Costa Rica). Butterfly database. In addition, the preset butterfly database can also use the Fine-Grained (fine-grained) butterfly database, of which the Leeds butterfly database includes 14,270 original butterfly images corresponding to 636 butterfly species, and the Ecuador butterfly database includes 10 Butterfly types: 832 original butterfly images corresponding to butterfly types, Costarica (Costa Rica) includes 2120 original butterfly images corresponding to 675 butterfly types, and Fine-Grained (fine-grained) butterfly database includes 3,224 original butterfly images corresponding to 331 butterfly types The butterfly database is not limited here.
S2:对原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像。S2: Resampling the original butterfly image to obtain the target butterfly image.
具体地,在图像领域中,重采样是对采样后形成的由离散数据组成的数字图像按照预设的像元位置或像元间距重新采样,以构成几何变换后的新图像。Specifically, in the image field, resampling is resampling a digital image composed of discrete data formed after sampling according to a preset pixel position or pixel interval to form a new image after geometric transformation.
对每张原始蝴蝶影像进行重采样处理,并将得到的目标蝴蝶影像分成两部分,其中,一部分目标蝴蝶影像用作训练胶囊网络的训练样本数据,另一部分目标蝴蝶影像用作测试识别蝴蝶的训练网络的测试样本数据。Resampling each original butterfly image and dividing the obtained target butterfly image into two parts, one part of the target butterfly image is used as training sample data for training the capsule network, and the other part of the butterfly image is used for training to identify the butterfly Test sample data for the network.
进一步地,原始蝴蝶影像经过重采样处理后得到尺寸大小一致的目标蝴蝶影像,并且目标蝴蝶影像都携带对应的蝴蝶种类标记,利于后续训练或者测试识别蝴蝶的训练网络时得到的输出结果与原来输入的目标蝴蝶影像携带对应的蝴蝶种类标记进行比较,以便判断输出结果是否正确。Further, after resampling the original butterfly image, a target butterfly image of the same size is obtained, and the target butterfly image carries the corresponding butterfly type mark, which is beneficial for subsequent training or testing the training network that recognizes the butterfly. The output result and the original input are obtained. The target butterfly image is compared with the corresponding butterfly species mark to determine whether the output result is correct.
S3:针对每种蝴蝶种类,将该蝴蝶种类中用作训练的目标蝴蝶影像输入到胶囊网络中,并经过胶囊网络的卷积层的第一卷积计算和胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量。S3: For each butterfly type, the target butterfly image used for training in this butterfly type is input into the capsule network, and passes through the first convolution calculation of the convolution layer of the capsule network and the second volume of the capsule layer of the capsule network. Product calculation to get the output vector of this butterfly species.
具体地,胶囊网络由解析树组成。胶囊网络中的每一层神经元层的神经元将会被划分为多个神经元组,每一个神经元组称为胶囊(capsule),解析树的每一个节点将对应于一个激活的胶囊(active capsule)。一个激活的胶囊中由多个激活的胶囊神经元组成,每个胶囊神经元包含了卷积核,卷积核是一种滤波器((filter))矩阵或者叫特征检测器(feature detector),卷积核中的权值是属性的特征表达,也就是说胶囊神经元代表了某个蝴蝶种类的属性,其中,属性可是不同角度、位置以及方向等每种蝴蝶种类对应的不同视角。总而言之,识别蝴蝶的训练网络是通过不断修改胶囊神经元中的卷积核中的权值以及其他训练参数来提高识别蝴蝶的准确率,其中,其他训练参数包括耦合系数。Specifically, the capsule network consists of a parse tree. The neurons in each layer of the neuron layer in the capsule network will be divided into multiple neuron groups. Each neuron group is called a capsule. Each node in the parse tree will correspond to an activated capsule ( active capsule). An activated capsule is composed of multiple activated capsule neurons. Each capsule neuron contains a convolution kernel. The convolution kernel is a type of (filter) matrix or feature detector. The weight in the convolution kernel is the characteristic expression of the attribute, that is, the capsule neuron represents the attribute of a certain butterfly species, among which the attributes can be different perspectives corresponding to each butterfly species such as different angles, positions and directions. In summary, the training network for butterfly recognition improves the accuracy of butterfly recognition by continuously modifying the weights in the convolution kernel in the capsule neurons and other training parameters, among which other training parameters include coupling coefficients.
进一步地,针对每种蝴蝶种类,将用作训练的该蝴蝶种类的目标蝴蝶影像输入到胶囊网络中的卷积层中执行第一卷积计算。其中,第一卷积计算是将目标蝴蝶影像与卷积层中的卷积核计算,卷积核计算是指将卷积核中的每个位置上的元素值与目标蝴蝶图像上对应的点的元素值相乘累加,即两个矩阵间的点的元素值分别进行相乘叠加后,得到输出矩阵中的每一个元素的值,并将第一卷积计算得到的结果在胶囊网络的胶囊层中执行第二卷积计算,其中,第二卷积计算是将第一卷积计算得到的结果与激活的胶囊神经元进行卷积计算,得到该蝴蝶种类的输出向量。Further, for each butterfly species, a target butterfly image of the butterfly species used for training is input to a convolution layer in a capsule network to perform a first convolution calculation. The first convolution calculation is to calculate the target butterfly image and the convolution kernel in the convolution layer. The convolution kernel calculation refers to the element value at each position in the convolution kernel and the corresponding point on the target butterfly image. Multiply and accumulate the element values of, that is, the element values of the points between the two matrices are multiplied and superimposed separately to obtain the value of each element in the output matrix, and the result of the first convolution calculation is obtained in the capsule of the capsule network A second convolution calculation is performed in the layer, where the second convolution calculation is a convolution calculation of the result obtained by the first convolution calculation with the activated capsule neuron to obtain an output vector of the butterfly species.
需要说明的是,输出向量中的向量长度表示目标蝴蝶影像在胶囊网络中被识别为对应蝴蝶种类的概率,输出向量的向量方向表示蝴蝶种类的属性,例如蝴蝶的不同视角。It should be noted that the vector length in the output vector indicates the probability that the target butterfly image is recognized as the corresponding butterfly type in the capsule network, and the vector direction of the output vector indicates the attributes of the butterfly type, such as different perspectives of the butterfly.
S4:在胶囊网络中的损失函数层中,对每种蝴蝶种类的输出向量进行损失函数计 算,得到每个输出向量的损失函数值。S4: In the loss function layer in the capsule network, perform a loss function calculation on the output vector of each butterfly species to obtain the loss function value of each output vector.
具体地,损失函数(loss function)是描述训练模型在不同参数(parameter)值之下的损失,用来估量训练模型的预测值与真实值的不一致程度。对每种蝴蝶种类的输出向量执行损失函数计算,得到输出向量的损失函数值是一个非负函数值。根据损失函数值的大小,调整识别蝴蝶的训练网络的训练参数,能使损失函数值变小,损失函数值越小,识别蝴蝶的训练网络的鲁棒性越好,其中,训练参数包括卷积核中的权值。Specifically, the loss function describes the loss of the training model under different parameter values, and is used to estimate the degree of inconsistency between the predicted value and the true value of the training model. The loss function calculation is performed on the output vector of each butterfly species, and the loss function value of the output vector is a non-negative function value. According to the size of the loss function value, adjusting the training parameters of the training network for identifying the butterfly can reduce the value of the loss function. The smaller the value of the loss function, the better the robustness of the training network for identifying the butterfly. The training parameters include convolution. Weights in the kernel.
S5:当每个输出向量的损失函数值均小于或者等于预设的损失阈值时,将胶囊网络作为识别蝴蝶的训练网络。S5: When the loss function value of each output vector is less than or equal to a preset loss threshold, the capsule network is used as a training network for identifying butterflies.
具体地,根据步骤S4中得到每个输出向量的的损失函数值均小于或者等于预设的损失阈值时,即此时的识别蝴蝶的训练网络的鲁棒性达到了预期的识别蝴蝶的效果,将当前的胶囊网络作为最终识别蝴蝶的训练网络。其中,预设的损失阈值可以是0.3或者是0至1的小数。Specifically, when the loss function value of each output vector obtained in step S4 is less than or equal to a preset loss threshold, that is, the robustness of the training network for butterfly recognition at this time has reached the expected effect of butterfly recognition, The current capsule network is used as the training network for the final recognition of butterflies. The preset loss threshold may be 0.3 or a decimal from 0 to 1.
S6:当损失函数值大于预设的损失阈值时,通过反向传播更新胶囊网络中的每个胶囊神经元,得到更新后的胶囊网络,并将每种蝴蝶种类中用作训练的目标蝴蝶影像重新输入到更新后的胶囊网络中,进行第一卷积计算、第二卷积计算和损失函数计算,直到损失函数值小于或者等于预设的损失阈值为止,其中,胶囊神经元代表蝴蝶种类的属性。S6: When the value of the loss function is greater than a preset loss threshold, each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and the butterfly image used as a training target in each butterfly species Re-enter the updated capsule network and perform the first convolution calculation, the second convolution calculation, and the loss function calculation until the loss function value is less than or equal to the preset loss threshold, where the capsule neuron represents the butterfly species. Attributes.
具体地,当根据步骤S4中得到的损失函数值大于损失阈值时,通过反向传播更新胶囊网络中的每个胶囊神经元,其中,反向传播是通过逐层求出损失函数对各神经元权值的偏导数,从而得到损失函数对输出向量的梯量,将梯量作为修改每个胶囊神经元中的的权值的依据,使开发人员根据梯量调整胶囊网络中的各个胶囊神经元的权值,从而更新了胶囊网络,并将每种蝴蝶种类中用作训练的目标蝴蝶影像重新输入到更新后的胶囊网络中,并继续执行步骤S3,直到损失函数值小于或者等于损失阈值为止,其中,胶囊神经元代表蝴蝶种类的属性包括每个蝴蝶种类对应的不同视角。Specifically, when the value of the loss function obtained in step S4 is greater than the loss threshold, each capsule neuron in the capsule network is updated by back propagation, where the back propagation is to obtain the loss function for each neuron layer by layer. The partial derivative of the weight value, so as to obtain the ladder function of the loss function to the output vector. The ladder function is used as a basis for modifying the weight value in each capsule neuron, so that the developer can adjust each capsule neuron in the capsule network according to the ladder The capsule network is updated, and the target butterfly image used for training in each butterfly species is re-entered into the updated capsule network, and step S3 is continued until the loss function value is less than or equal to the loss threshold. Among them, the attributes of capsule neurons representing butterfly species include different perspectives corresponding to each butterfly species.
本实施例中,通过从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像,将原始蝴蝶影像重采样处理后得到目标蝴蝶影像;将该蝴蝶种类中用作训练的目标蝴蝶影像输入到胶囊网络中,并经过胶囊网络的卷积层的第一卷积计算和胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量经过损失函数计算得到损失函数值;当损失函数值大于预设值时,通过反向传播更新胶囊网络中的每个胶囊神经元,从而得到更新后的胶囊网络,将用作训练的目标蝴蝶影像输入到更新后的胶囊网络中进行第一卷积计算、第二卷积计算和损失函数计算,直到损失函数值小于或者等于损失阈值为止,实现了采用少量的目标蝴蝶影像处理了蝴蝶影像的多义性表达,也就是将目标蝴蝶影像与胶囊网络中表示蝴蝶种类的属性的每个胶囊神经元进行训练处理得到的损失值满足损失阈值时,即无论输入的目标蝴蝶影像的实际属性是否为不同视角,最终得到该目标蝴蝶影像的分类结果对应的蝴蝶种类,从而实现了能分辨不同视角的同一蝴蝶种类,从而提高了胶囊网络识别蝴蝶的准确率。In this embodiment, the original butterfly image corresponding to each butterfly type is obtained from a preset butterfly database, and the original butterfly image is resampled to obtain a target butterfly image; the target butterfly image used for training in this butterfly type is input Into the capsule network, and after the first convolution calculation of the convolution layer of the capsule network and the second convolution calculation of the capsule layer of the capsule network, the output vector of the butterfly species is calculated by the loss function to obtain the loss function value; when the loss When the function value is greater than a preset value, each capsule neuron in the capsule network is updated by back propagation, thereby obtaining an updated capsule network. The target butterfly image used as training is input to the updated capsule network for the first time. Convolution calculation, second convolution calculation, and loss function calculation, until the loss function value is less than or equal to the loss threshold, realizes the use of a small number of target butterfly images to process the ambiguity expression of the butterfly image, that is, the target butterfly image and the Each capsule neuron in the capsule network representing the attributes of the butterfly species is obtained by training processing When the missing value meets the loss threshold, that is, regardless of whether the actual attributes of the input target butterfly image are from different perspectives, the butterfly species corresponding to the classification result of the target butterfly image are finally obtained, thereby realizing the same butterfly species that can distinguish between different perspectives, thereby improving The accuracy of the capsule network to identify butterflies.
在一实施例中,如图3所示,步骤S2中,即原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像,具体包括如下步骤:In an embodiment, as shown in FIG. 3, in step S2, the original butterfly image is resampled to obtain the target butterfly image, which specifically includes the following steps:
S21:根据预设的目标尺寸确定原始蝴蝶影像的缩放比例。S21: Determine the zoom ratio of the original butterfly image according to the preset target size.
具体地,根据预设的目标尺寸确定原始蝴蝶影像的缩放比例,使得获取得到的目标蝴蝶影像具有相同的尺寸,利于胶囊网路对蝴蝶种类的识别,减少因尺寸不一致带来的干扰因素,同时防止过拟合。Specifically, the scaling ratio of the original butterfly image is determined according to a preset target size, so that the obtained target butterfly image has the same size, which is beneficial for the capsule network to identify butterfly species, and reduces interference factors caused by inconsistent size. Prevent overfitting.
例如,将所有原始蝴蝶影像全部重采样得到尺寸为32×32×3的大小,其中,沿行方向32像素,沿列方向32像素,3指RGB三个通道。当一个原始蝴蝶影像为64×64×3时, 得到的缩放比例为
Figure PCTCN2018106395-appb-000001
也就是将该原始蝴蝶影像缩小两倍尺寸大小。
For example, all original butterfly images are resampled to obtain a size of 32 × 32 × 3, where 32 pixels are in the row direction, 32 pixels are in the column direction, and 3 refers to three channels of RGB. When an original butterfly image is 64 × 64 × 3, the resulting zoom ratio is
Figure PCTCN2018106395-appb-000001
That is, the original butterfly image is reduced by two times.
具体地,通道用于表示图像的某种组成。例如,一个标准数字相机拍摄的图像会有三通道——红、绿和蓝,把它们看作是互相堆叠在一起的二维矩阵,每一个通道代表一个颜色,每个通道的像素值在0到255的范围内。Specifically, a channel is used to represent a certain composition of an image. For example, an image taken by a standard digital camera will have three channels-red, green, and blue. Think of them as a two-dimensional matrix stacked on top of each other. Each channel represents a color, and the pixel value of each channel ranges from 0 to In the range of 255.
S22:按照缩放比例,获取对原始蝴蝶影像的原始像素点进行划分,得到目标蝴蝶影像的每个目标像素点在原始蝴蝶影像中对应的原始像素点的集合,并建立每个原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系。S22: According to the scaling ratio, the original pixels of the original butterfly image are divided to obtain a set of original pixels corresponding to each target pixel of the target butterfly image in the original butterfly image, and a set of each original pixel is established. Correspondence with each pixel of the target butterfly image.
具体地,继续引用步骤S21中的例子,从目标影像出发,按照缩放比例2,获取对原始蝴蝶影像的原始像素点进行划分,得到目标蝴蝶影像的每个目标像素点在原始蝴蝶影像中对应的原始像素点的集合,并建立每个原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系,例如,目标影像的左上角第一个像素,对应的是原始蝴蝶影像的左上角为2×2=4个像素,即这4个像素为原始像素点的集合。Specifically, referring to the example in step S21, starting from the target image, the original pixel points of the original butterfly image are divided according to the zoom ratio 2 to obtain each target pixel point of the target butterfly image corresponding to the original butterfly image. A set of original pixels, and establish a correspondence between each set of original pixels and each pixel of the target butterfly image, for example, the first pixel in the upper left corner of the target image corresponds to the original butterfly image The upper left corner of is 2 × 2 = 4 pixels, that is, these 4 pixels are the set of original pixels.
S23:计算原始像素点的集合中的每个原始像素点的平均RGB值,并根据对应关系,将该平均RGB值作为原始像素点的集合对应的目标像素点的RGB值。S23: Calculate the average RGB value of each original pixel in the set of original pixels, and use the average RGB value as the RGB value of the target pixel corresponding to the set of original pixels according to the corresponding relationship.
具体地,根据步骤S22获取的原始像素点的集合,将每个原始像素点的RGB值进行累加求平均得到的平均RGB值,并根据原始像素点与目标蝴蝶影像的每个像素点的对应关系,将平均RGB值作为原始像素点的集合对应的目标像素点的RGB值,其中,平均RGB值为正整数。例如,继续引用步骤S22的例子,若4个像素的RGB值为{215,0,64,0}得平均RGB值为
Figure PCTCN2018106395-appb-000002
Specifically, according to the set of original pixel points obtained in step S22, the RGB values of each original pixel point are accumulated and averaged to obtain an average RGB value, and according to the correspondence between the original pixel point and each pixel point of the target butterfly image , Taking the average RGB value as the RGB value of the target pixel corresponding to the set of original pixels, where the average RGB value is a positive integer. For example, referring to the example of step S22, if the RGB values of 4 pixels are {215,0,64,0}, the average RGB value is
Figure PCTCN2018106395-appb-000002
在本实施例中,根据预设的目标尺寸确定原始蝴蝶影像的缩放比例,获取目标蝴蝶影像的每个目标像素点在原始蝴蝶影像中对应的原始像素点的集合,并计算原始像素点的集合中的每个原始像素点的平均RGB值,并将该平均RGB值作为原始像素点的集合对应的目标像素点的RGB值,实现了将所有不同尺寸的原始蝴蝶影像缩放到统一标准尺寸的目标蝴蝶影像,有利于后续对胶囊网络提供良好的训练样本数据,同时避免了因原始蝴蝶影像的尺寸不同引起的过拟合问题。In this embodiment, the scaling ratio of the original butterfly image is determined according to a preset target size, a set of original pixels corresponding to each target pixel point of the target butterfly image in the original butterfly image is obtained, and the set of original pixels is calculated The average RGB value of each original pixel in the image, and use the average RGB value as the RGB value of the target pixel corresponding to the set of original pixels, to achieve the goal of scaling all original butterfly images of different sizes to a uniform standard size Butterfly images are beneficial to provide good training sample data for the capsule network in the future, and avoid overfitting problems caused by the different sizes of the original butterfly images.
在一实施例中,如图4所示,步骤S3中,即针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量,具体包括如下步骤:In an embodiment, as shown in FIG. 4, in step S3, for each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network and passes through the capsule. The first convolution calculation of the convolution layer of the network and the second convolution calculation of the capsule layer of the capsule network to obtain the output vector of the butterfly species include the following steps:
S31:将输入到蝴蝶种类中用作训练的目标蝴蝶影像在胶囊网络的卷积层中执行第一卷积计算,得到特征向量。S31: Perform the first convolution calculation on the convolution layer of the capsule network by using the target butterfly image input into the butterfly species for training to obtain a feature vector.
具体地,将蝴蝶种类中用作训练的目标蝴蝶影像输入到胶囊网络的卷积层,并将该目标蝴蝶影像与卷积层中每个胶囊神经元的卷积核执行第一卷积计算,第一卷积计算是将卷积核中的每个位置上的元素值与目标蝴蝶图像上对应的点的元素值相乘叠加,得到的特征向量叫做卷积特征(Convolved Feature)或者特征图(Feature Map)。例如,深度为256,卷积窗口大小为9*9,即构建了256个9*9矩阵的卷积核。Specifically, a target butterfly image used for training in a butterfly species is input to a convolution layer of a capsule network, and a first convolution calculation is performed on a convolution kernel of the target butterfly image and each capsule neuron in the convolution layer, The first convolution calculation is to multiply the element value at each position in the convolution kernel with the element value of the corresponding point on the target butterfly image, and the resulting feature vector is called a Convolved Feature or a feature map ( Feature map). For example, the depth is 256 and the convolution window size is 9 * 9, that is, a convolution kernel of 256 9 * 9 matrices is constructed.
需要说明的是,当第一卷积计算过程中出现越界问题时,使用0补充,也叫零填充(Zero-padding)。在目标蝴蝶图像的边缘使用零值进行填充,可以对输入目标蝴蝶图像的边缘进行滤波,方便控制特征图的大小。It should be noted that when an out-of-bounds problem occurs during the first convolution calculation, zero supplementation is used, which is also called zero-padding. Fill the edges of the target butterfly image with zero values to filter the edges of the input target butterfly image to control the size of the feature map.
S32:将特征向量代入到修正线性激活函数中,得到局部特征向量。S32: Substituting the feature vector into a modified linear activation function to obtain a local feature vector.
具体地,修正线性激活函数,即ReLU(Rectified linear unit)激活函数,是一种神经元的激活函数,也是一种分段线性函数,能将特征图中的所有小于0的像素值设置为零,而使其他像素值为正值的值不变,这种操作被称为单侧抑制,从而实现了在稀疏后的胶囊 网络中能够更好地挖掘相关特征,避免过拟合。Specifically, the modified linear activation function, namely the ReLU (Rectified Linear Unit) activation function, is a neuron activation function and a piecewise linear function. It can set all the pixel values less than 0 in the feature map to zero. While leaving other pixels with positive values, this operation is called unilateral suppression, so that the relevant features can be better mined in the sparse capsule network to avoid overfitting.
进一步地,将特征向量代入到修正线性激活函数中,也就是将特征图的像素灰度值转化为局部特征的激活值。Further, the feature vector is substituted into the modified linear activation function, that is, the pixel gray value of the feature map is converted into the activation value of the local feature.
S33:通过使用迭代路由处理方式,将局部特征向量与胶囊网络的胶囊层中的每个胶囊神经元进行第二卷积计算,得到蝴蝶种类的输出向量。S33: By using an iterative routing processing method, a second convolution calculation is performed on the local feature vector and each capsule neuron in the capsule layer of the capsule network to obtain an output vector of the butterfly type.
具体地,在本实施例中的胶囊网络的胶囊层是一个32通道(channels)的胶囊(capsule),每个胶囊(capsule)均包含8个胶囊神经元,每个胶囊神经元包括9×9的卷积核,并且步长(stride)为2。第二卷积计算是指将每个胶囊神经元与卷积层的所有局部特征向量进行卷积计算,并通过采用迭代路由处理方式,最终由32×32×n个胶囊输出,每个胶囊为8维的输出向量,即每个胶囊实质输出的是一组输出向量。Specifically, the capsule layer of the capsule network in this embodiment is a 32-channel capsule, and each capsule includes 8 capsule neurons, and each capsule neuron includes 9 × 9 Convolution kernel with stride of 2. The second convolution calculation refers to the convolution calculation of each capsule neuron and all local feature vectors of the convolution layer, and by using an iterative routing process, it is finally output by 32 × 32 × n capsules, and each capsule is 8-dimensional output vector, that is, each capsule actually outputs a set of output vectors.
进一步地,迭代路由处理方式(iterative dynamic routing process)通过公式(1)至公式(4)可求得输出向量,该输出向量代表了不同视角的每种蝴蝶种类出现的概率大小,具体包括:Further, an iterative routing process (iterative dynamic routing) can obtain an output vector through formulas (1) to (4). The output vector represents the probability of each butterfly species from different perspectives, including:
Figure PCTCN2018106395-appb-000003
Figure PCTCN2018106395-appb-000003
Figure PCTCN2018106395-appb-000004
Figure PCTCN2018106395-appb-000004
Figure PCTCN2018106395-appb-000005
Figure PCTCN2018106395-appb-000005
Figure PCTCN2018106395-appb-000006
Figure PCTCN2018106395-appb-000006
其中,b ij指第i个胶囊神经元和第j个胶囊神经元之间的softmax(柔性最大)激活函数,softmax激活函数是一种将多维向量的每一个值都映射成(0,1)区间的函数,在此处用于分类,c ij为耦合系数,
Figure PCTCN2018106395-appb-000007
为局部特征向量,W ij为权矩阵,S j是所有局部特征向量
Figure PCTCN2018106395-appb-000008
的加权和,V j是第j个胶囊神经元的输出向量。
Among them, b ij refers to the softmax activation function between the i-th capsule neuron and the j-th capsule neuron. A softmax activation function is a method that maps each value of a multidimensional vector into (0, 1) The function of the interval is used for classification here, c ij is the coupling coefficient,
Figure PCTCN2018106395-appb-000007
Is the local feature vector, W ij is the weight matrix, and S j is all the local feature vectors
Figure PCTCN2018106395-appb-000008
Weighted sum, V j is the output vector of the j-th capsule neuron.
c ij是由迭代路由处理决定的耦合系数,Capsule与上一层的capsules之间的耦合系数和为1。该系数和其他权值一同在训练中决定,取决于两个capsules的位置和种类。迭代路由处理初始化时,胶囊层中的每个胶囊神经元对卷积层中的每个胶囊神经元都有相同的耦合系数;胶囊层中的每个胶囊神经元对每一个可能的父节点计算局部特征向量并作为父节点的输入,如果这个局部特征向量和某一个父节点的输出向量的内积很大,那么会通过一个自顶向下的反馈增大这个父节点的耦合系数,同时减小其他父节点的耦合系数,达到动态选择的结果。另外,一个胶囊神经元的所有的耦合系数的和为1。 c ij is the coupling coefficient determined by the iterative routing process. The sum of the coupling coefficient between Capsule and the capsules in the previous layer is 1. This coefficient, along with other weights, is determined during training and depends on the position and type of the two capsules. When the iterative routing process is initialized, each capsule neuron in the capsule layer has the same coupling coefficient to each capsule neuron in the convolution layer; each capsule neuron in the capsule layer is calculated for each possible parent node The local feature vector is used as the input of the parent node. If the inner product of the local feature vector and the output vector of a parent node is large, the coupling coefficient of the parent node will be increased through a top-down feedback, and at the same time it will be reduced. The coupling coefficient of the other parent nodes is small, and the result of dynamic selection is achieved. In addition, the sum of all coupling coefficients of a capsule neuron is 1.
需要说明的是,低级别的胶囊神经元倾向于向与高级别的胶囊神经元,即耦合系数高表示对蝴蝶种类的局部特征的预测倾向大,耦合系数低表示对蝴蝶种类的局部特征预测倾向小。假设胶囊神经元i对胶囊神经元j的的耦合系数c ij为1,由于胶囊神经元i的所有耦合系数和为1,那么该胶囊神经元i对其他胶囊神经元的耦合系数为0了,也就是说, 胶囊神经元i的所有局部特征向量都只传入到胶囊神经元j。 It should be noted that low-level capsule neurons tend to be aligned with high-level capsule neurons, that is, a high coupling coefficient indicates a large tendency to predict the local characteristics of the butterfly species, and a low coupling coefficient indicates a local tendency to predict the butterfly characteristics. small. Assume that the coupling coefficient c ij of capsule neuron i to capsule neuron j is 1. Since all the coupling coefficients of capsule neuron i are 1, the coupling coefficient of capsule neuron i to other capsule neurons is zero. That is, all local feature vectors of the capsule neuron i are only passed to the capsule neuron j.
进一步地,由于向量长度代表了每种蝴蝶种类出现的概率大小,即V j是一个概率值,因此利用一个非线性“挤压”函数来保证将短的输出向量“压缩”成长度接近0、将长的向量“压缩”成长度接近1的值。 Further, because the vector length represents the probability of the occurrence of each butterfly species, that is, V j is a probability value, a non-linear "squeeze" function is used to ensure that the short output vector is "compressed" to a length close to 0, The long vector is "compressed" to a value close to one in length.
在本实施例中,将输入到蝴蝶种类中用作训练的目标蝴蝶影像在在胶囊网络的卷积层中执行第一卷积计算,得到的特征向量代入到修正线性激活函数中,得到局部特征向量;通过使用迭代路由处理方式,将局部特征向量与胶囊网络的胶囊层中的每个胶囊神经元进行第二卷积计算,得到输出向量,利用迭代路由处理方式使得对蝴蝶种类的局部特征的预测倾向更加明显,实现了目标蝴蝶影像的泛化,例如泛化包括似度、方向以及大小等视角信息,从而提高了对同一蝴蝶种类的不同蝴蝶视角的分辨能力。In this embodiment, the target butterfly image inputted into the butterfly species is used for training. The first convolution calculation is performed in the convolution layer of the capsule network, and the obtained feature vector is substituted into the modified linear activation function to obtain local features. Vector; by using an iterative routing process, a second convolution calculation is performed on the local feature vector with each capsule neuron in the capsule layer of the capsule network to obtain an output vector. The prediction tendency is more obvious, and the generalization of the target butterfly image is achieved, for example, the generalization includes perspective information such as likelihood, direction, and size, thereby improving the discrimination ability of different butterfly perspectives of the same butterfly species.
进一步地,在一实施例中,对步骤S4中提及的在胶囊网络中的损失函数层中,对每种蝴蝶种类的输出向量进行损失函数计算,得到输出向量的损失函数值的具体实现过程详述如下:Further, in an embodiment, in the loss function layer in the capsule network mentioned in step S4, a loss function calculation is performed on an output vector of each butterfly species, and a specific implementation process of obtaining a loss function value of the output vector is obtained. Details are as follows:
将每一个输出向量在胶囊网络中的损失函数层中,按照公式(5)计算输出向量的损失函数值:Put each output vector in the loss function layer in the capsule network, and calculate the loss function value of the output vector according to formula (5):
L c=T c max(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2  (5) L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2 (5)
其中,c为蝴蝶种类,L c为损失函数值,T c为蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0和||Vc||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为输出向量V c的向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Among them, c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is taken as 0 and m + -|| V c | | two maximum values in square, max (0, || V c || -m -) 2 is set to 0 and || Vc || -m - the square of the maximum of the two values, m + Is the upper boundary of the preset vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the lower boundary of the preset vector length.
具体地,指示函数又称为特征函数,在本实施例中指示函数是将每个蝴蝶种类各自定义为一个集合,集合中包括蝴蝶种类的各个属性的子集,当蝴蝶种类对应的的目标蝴蝶影像属于该集合中的某一个子集,子集可以是蝴蝶种类的某个属性。Specifically, the indication function is also called a feature function. In this embodiment, the indication function is to customize each butterfly type into a set, and the set includes a subset of various attributes of the butterfly type. When the target butterfly corresponding to the butterfly type The images belong to a certain subset in the collection, and the subset can be a certain attribute of the butterfly species.
进一步地,若指示函数判断输出向量与实际的目标蝴蝶影像一样时,则输出为1,否则为0,例如,用一个列向量的总长度标识为蝴蝶种类的总数,列向量的元素为1的位置代表该位置对应的蝴蝶种类的分类结果,列向量中的0代表不是该蝴蝶种类。当输出向量属于某个子集,并且该子集属于某个蝴蝶种类的集合时,则在该种类对应的列项量为1,然而在实际分类中,列向量中的值是对应的蝴蝶种类的概率大小。例如,胶囊的输出向量||V c||的长度对应于它属于第c种蝴蝶种类的概率。 Further, if the instruction function judges that the output vector is the same as the actual target butterfly image, the output is 1, otherwise it is 0. For example, the total length of a column vector is used to identify the total number of butterfly species, and the element of the column vector is 1. The position represents the classification result of the butterfly species corresponding to the position, and 0 in the column vector indicates that it is not the butterfly species. When the output vector belongs to a certain subset, and the subset belongs to a set of certain butterfly species, the number of column items corresponding to the species is 1, however, in actual classification, the value in the column vector is the corresponding butterfly species. Probability. For example, the length of the output vector || V c || of the capsule corresponds to the probability that it belongs to the c-th butterfly species.
在本申请实施例中,通过将每一个输出向量在胶囊网络中的损失函数层计算得到损失函数值,根据损失函数值的大小来衡量胶囊网络对蝴蝶种类的预测效果好坏,有利于进一步调整胶囊网络中的参数。In the embodiment of the present application, the loss function value is calculated by calculating the loss function layer of each output vector in the capsule network, and the prediction effect of the capsule network on the butterfly species is measured according to the size of the loss function value, which is beneficial to further adjustment. Parameters in the capsule network.
在一实施例中,如图5所示,步骤S6之后,该蝴蝶识别网络构建方法还包括如下步骤:In an embodiment, as shown in FIG. 5, after step S6, the method for constructing a butterfly recognition network further includes the following steps:
S7:将用作测试的目标蝴蝶影像输入到识别蝴蝶的训练网络中,并通过第一卷积计算、第二卷积计算以及损失函数计算,得到测试输出向量的损失函数值。S7: The target butterfly image used as a test is input into a training network for recognition of a butterfly, and the loss function value of the test output vector is obtained through the first convolution calculation, the second convolution calculation, and the loss function calculation.
具体地,将用作测试的目标蝴蝶影像,也就是将测试样本数据输入到由步骤S1至步骤S5中得到的识别蝴蝶的训练网络中,并根据步骤S3,通过第一卷积计算、第二卷积计 算以及损失函数计算,输出测试输出向量的损失函数值。Specifically, the target butterfly image used as the test, that is, the test sample data is input into the training network for identifying the butterfly obtained in steps S1 to S5, and according to step S3, the first convolution calculation, the second Convolution calculation and loss function calculation, output the loss function value of the test output vector.
S8:取大于或者等于预设的向量长度上边界的损失函数值对应的测试输出向量,并通过解码器网络将测试输出向量进行重构,得到输出图像,并将输出图像与用作测试的目标蝴蝶影像进行比较,得到识别蝴蝶的训练网络的准确率。S8: Take a test output vector corresponding to a loss function value that is greater than or equal to a preset upper boundary of the vector length, and reconstruct the test output vector through the decoder network to obtain an output image, and use the output image as the test target. The butterfly images are compared to get the accuracy of the training network for butterfly recognition.
具体地,获取大于或者等于预设的向量长度上边界的损失函数值对应的测试输出向量,例如,若存在第c类蝴蝶种类,规定预设的向量长度为0.9,则第c类蝴蝶种类的输出一个向量长度至少为0.9的输出向量时,才能表示该输出向量对应的目标蝴蝶影像属于第c类蝴蝶种类,其中,0.9表示向量长度上边界。Specifically, a test output vector corresponding to a loss function value that is greater than or equal to a preset upper boundary of the vector length is obtained. For example, if a type c butterfly type exists and the preset vector length is 0.9, the type c butterfly type When an output vector with a vector length of at least 0.9 is output, it can be indicated that the target butterfly image corresponding to the output vector belongs to the type c butterfly category, where 0.9 represents the upper boundary of the vector length.
进一步地,将测试输出向量通过解码器网络进行重构,解码器网络由3个全连接层组成,通过解码器网络重构得到输出图像。重构是指将测试输出向量重新构建出与该测试输出向量对应的实际图像,从而构建一个完整的输出图像。根据重构的方式,将所有测试输出向量通过解码器网络得到输出图像,并采用图像比较方式,筛选出与用作测试的目标蝴蝶影像相同的输出图像,其中,图像比较方式包括但不限于感知哈希算法、灰度直方图相似比较法或者PSNR(峰值信噪比)方法,并计算筛选出的与用作测试的目标蝴蝶影像相同的输出图像的总数与用作测试的目标蝴蝶影像的总量的占比值,该占比值就是就是识别蝴蝶的训练网络的准确率,若得到的准确率小于预设的准确率,则说明识别蝴蝶的训练网络的识别效果不佳,需要进一步改进该识别蝴蝶的训练网络,否则,无需对识别蝴蝶的训练网络进行调整。其中,预设的准确率可以设置为95%或者95%以上的百分比值。Further, the test output vector is reconstructed through a decoder network. The decoder network is composed of three fully connected layers, and an output image is obtained through the decoder network reconstruction. Reconstruction refers to reconstructing a test output vector into an actual image corresponding to the test output vector, thereby constructing a complete output image. According to the reconstruction method, all test output vectors are obtained through the decoder network to obtain the output image, and the image comparison method is used to filter out the same output image as the target butterfly image used for testing. The image comparison method includes but is not limited to perception Hash algorithm, gray-scale histogram similarity comparison method, or PSNR (Peak Signal-to-Noise Ratio) method, and calculate the total number of output images that are the same as the target butterfly image used for testing and the total of the target butterfly image used for testing The proportion of the amount is the accuracy rate of the training network for butterfly recognition. If the accuracy rate obtained is less than the preset accuracy rate, it indicates that the recognition effect of the training network for butterfly recognition is not good, and the recognition butterfly needs to be further improved. Otherwise, there is no need to adjust the training network for butterfly recognition. The preset accuracy rate can be set to 95% or a percentage value greater than 95%.
在本实施例中,将用作测试的目标蝴蝶影像输入到识别蝴蝶的训练网络中进行测试,并取得大于或者等于向量长度上边界的损失函数值对应的测试输出向量,通过解码器网络将该测试输出向量进行重构,得到输出图像,进而得到识别蝴蝶的训练网络的准确率,通过准确率能直观地判断该识别蝴蝶的训练网络对蝴蝶种类的识别效果,根据识别效果决定是否对识别蝴蝶的训练网络做进一步的改进。In this embodiment, a target butterfly image used as a test is input to a training network that recognizes butterflies, and a test output vector corresponding to a loss function value that is greater than or equal to the upper boundary of the vector length is obtained. The test output vector is reconstructed to obtain the output image, and then the accuracy rate of the training network for butterfly recognition is obtained. The accuracy rate can intuitively determine the recognition effect of the butterfly recognition training network on the butterfly species, and determine whether to recognize the butterfly based on the recognition effect. Training network to make further improvements.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
在一实施例中,提供一种蝴蝶识别网络构建的装置,该蝴蝶识别网络构建装置与上述实施例中蝴蝶识别网络构建方法一一对应。如图6所示,该蝴蝶识别网络构建装置包括获取模块61、重采样模块62、卷积模块63、计算模块64、训练模块65和更新模块66。各功能模块详细说明如下:In one embodiment, a device for constructing a butterfly recognition network is provided. The device for constructing a butterfly recognition network corresponds to the method for constructing a butterfly recognition network in the above-mentioned embodiment. As shown in FIG. 6, the apparatus for constructing a butterfly recognition network includes an acquisition module 61, a resampling module 62, a convolution module 63, a calculation module 64, a training module 65, and an update module 66. The detailed description of each function module is as follows:
获取模块61,用于从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;An obtaining module 61, configured to obtain an original butterfly image corresponding to each butterfly type from a preset butterfly database;
重采样模块62,用于对原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;A resampling module 62, configured to resample the original butterfly image to obtain a target butterfly image;
卷积模块63,用于针对每种蝴蝶种类,将该蝴蝶种类中用作训练的目标蝴蝶影像输入到胶囊网络中,并经过胶囊网络的卷积层的第一卷积计算和胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;A convolution module 63, for each butterfly species, inputs a butterfly image used for training in the butterfly species into a capsule network, and passes the first convolution calculation of the convolution layer of the capsule network and the capsules of the capsule network The second convolution calculation of the layer to obtain the output vector of the butterfly species;
计算损失模块64,用于在胶囊网络中的损失函数层中,对每种蝴蝶种类的输出向量进行损失函数计算,得到每个输出向量的损失函数值;A loss calculation module 64 is configured to perform a loss function calculation on an output vector of each butterfly species in a loss function layer in the capsule network to obtain a loss function value of each output vector;
训练模块65,用于当每个输出向量的损失函数值均小于或者等于预设的损失阈值时,将胶囊网络作为识别蝴蝶的训练网络;A training module 65, configured to use the capsule network as a training network for identifying butterflies when the loss function value of each output vector is less than or equal to a preset loss threshold;
更新模块66,用于当损失函数值大于预设的损失阈值时,通过反向传播更新胶囊网络中的每个胶囊神经元,得到更新后的胶囊网络,并将每种蝴蝶种类中用作训练的目标蝴蝶影像重新输入到更新后的胶囊网络中,进行第一卷积计算、第二卷积计算和损失函数计算,直到损失函数值小于或者等于预设的损失阈值为止,其中,胶囊神经元代表蝴蝶种类的属性。An update module 66 is configured to update each capsule neuron in the capsule network by back propagation when the loss function value is greater than a preset loss threshold, to obtain the updated capsule network, and use each butterfly species as training The target butterfly image is re-input into the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function value is less than or equal to a preset loss threshold, where the capsule neuron Attributes representing butterfly species.
进一步地,重采样模块62包括:Further, the resampling module 62 includes:
缩放单元621,用于根据预设的目标尺寸确定原始蝴蝶影像的缩放比例;A scaling unit 621, configured to determine a scaling ratio of the original butterfly image according to a preset target size;
获取单元622,用于按照缩放比例,获取对原始蝴蝶影像的原始像素点进行划分,得到目标蝴蝶影像的每个目标像素点在原始蝴蝶影像中对应的原始像素点的集合,并建立每个原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系;An obtaining unit 622 is configured to obtain the original pixel points of the original butterfly image according to the scaling ratio, obtain a set of original pixel points corresponding to each target pixel point of the target butterfly image in the original butterfly image, and establish each original pixel point. A correspondence between a set of pixels and each pixel of the target butterfly image;
计算单元623,用于计算原始像素点的集合中的每个原始像素点的平均RGB值,并根据对应关系,将该平均RGB值作为原始像素点的集合对应的目标像素点的RGB值。A calculation unit 623 is configured to calculate an average RGB value of each original pixel in the set of original pixels, and use the average RGB value as an RGB value of a target pixel corresponding to the set of original pixels according to a corresponding relationship.
进一步地,卷积模块63包括:Further, the convolution module 63 includes:
第一卷积单元631,用于将输入到蝴蝶种类中用作训练的目标蝴蝶影像在胶囊网络的卷积层中执行第一卷积计算,得到特征向量;A first convolution unit 631, configured to perform a first convolution calculation in a convolution layer of a capsule network on a target butterfly image input into a butterfly species for training, to obtain a feature vector;
激活单元632,用于将特征向量代入到修正线性激活函数中,得到局部特征向量;An activation unit 632, configured to substitute the feature vector into a modified linear activation function to obtain a local feature vector;
第二卷积单元633,用于通过使用迭代路由处理方式,将局部特征向量与胶囊网络的胶囊层中的每个胶囊神经元进行第二卷积计算,得到蝴蝶种类的输出向量。A second convolution unit 633 is configured to perform a second convolution calculation using a local feature vector with each capsule neuron in a capsule layer of the capsule network by using an iterative routing processing method to obtain an output vector of a butterfly type.
进一步地,计算损失模块64包括:Further, the calculation loss module 64 includes:
公式单元641,用于将每一个输出向量在胶囊网络中的损失函数层中,按照公式(6)计算输出向量的损失函数值:A formula unit 641 is configured to calculate each loss vector of the output vector in a loss function layer in the capsule network according to formula (6):
L c=T c max(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2  公式(6) L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2 Equation (6)
其中,c为蝴蝶种类,L c为损失函数值,T c为蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0和||V c||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为输出向量V c的向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Among them, c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is taken as 0 and m + -|| V c | | square of the maximum of two numbers, max (0, || V c || -m -) 2 is taken and || -m 0 || V c - the square of the maximum of the two values, m + Is the upper boundary of the preset vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the lower boundary of the preset vector length.
进一步地,蝴蝶识别网络构建装置还包括:Further, the apparatus for constructing a butterfly recognition network further includes:
测试计算模块67,用于将用作测试的目标蝴蝶影像输入到识别蝴蝶的训练网络中,并通过第一卷积计算、第二卷积计算以及损失函数计算,得到测试输出向量的损失函数值;A test calculation module 67 is configured to input a target butterfly image used as a test into a training network for recognition of a butterfly, and obtain a loss function value of a test output vector through a first convolution calculation, a second convolution calculation, and a loss function calculation. ;
重构模块68,用于取大于或者等于预设的向量长度上边界的损失函数值对应的测试输出向量,并通过解码器网络将测试输出向量进行重构,得到输出图像,并将输出图像与用作测试的目标蝴蝶影像进行比较,得到识别蝴蝶的训练网络的准确率。A reconstruction module 68 is configured to take a test output vector corresponding to a loss function value that is greater than or equal to a preset upper boundary of the vector length, and reconstruct the test output vector through a decoder network to obtain an output image, and compare the output image with The target butterfly images used for testing are compared to get the accuracy of the training network for butterfly recognition.
关于蝴蝶识别网络构建装置的具体限定可以参见上文中对于蝴蝶识别网络构建方法的限定,在此不再赘述。上述蝴蝶识别网络构建装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。Regarding the specific definition of the device for constructing the butterfly recognition network, please refer to the limitation on the method for constructing the butterfly recognition network mentioned above, which will not be repeated here. Each module in the above-mentioned butterfly recognition network construction device may be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules may be embedded in the hardware in or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图7所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储原始蝴蝶影像。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种 蝴蝶识别网络构建方法。In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. 7. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer-readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in a non-volatile storage medium. The computer equipment database is used to store the original butterfly image. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer-readable instructions are executed by a processor to implement a method for constructing a butterfly recognition network.
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现上述实施例蝴蝶识别网络构建方法的步骤,例如图2所示的步骤S1至步骤S6或者,处理器执行计算机可读指令时实现上述实施例中蝴蝶识别网络构建装置的各模块/单元的功能,例如图6所示模块61至模块66功能。为避免重复,这里不再赘述。In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor. When the processor executes the computer-readable instructions, the butterfly recognition of the foregoing embodiment is implemented. Steps of the network construction method, for example, steps S1 to S6 shown in FIG. 2 or, when the processor executes computer-readable instructions, the functions of each module / unit of the butterfly recognition network construction device in the above embodiment are implemented, as shown in FIG. 6 Modules 61 to 66 function. To avoid repetition, we will not repeat them here.
在一个实施例中,提供了一个或多个非易失性可读存储介质,其上存储有计算机可读指令,计算机可读指令被一个或多个处理器执行时实现上述方法实施例中蝴蝶识别网络构建方法,或者,该计算机可读指令被一个或多个处理器执行时实现上述装置实施例中蝴蝶识别网络构建装置中各模块/单元的功能。为避免重复,这里不再赘述。In one embodiment, one or more non-volatile readable storage media are provided, and computer-readable instructions are stored thereon. When the computer-readable instructions are executed by one or more processors, the butterfly in the foregoing method embodiment is implemented. The identification network construction method, or when the computer-readable instructions are executed by one or more processors, the functions of each module / unit in the butterfly identification network construction device in the above device embodiment are implemented. To avoid repetition, we will not repeat them here.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一个或多个非易失性可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by using computer-readable instructions to instruct related hardware. The computer-readable instructions can be stored in one or more non-easy instructions. In the volatile readable storage medium, the computer-readable instructions, when executed, may include the processes of the embodiments of the methods described above. Wherein, any reference to the storage, storage, database, or other media used in the embodiments provided in this application may include non-volatile and / or volatile storage. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。Those skilled in the art can clearly understand that, for the convenience and brevity of the description, only the above-mentioned division of functional units and modules is used as an example. In practical applications, the above functions can be assigned by different functional units, Module completion, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above embodiments are only used to describe the technical solutions of the present application, and are not limited thereto. 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 apply the foregoing embodiments. The recorded technical solutions are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of this application, and shall be included in this application. Within the scope of protection.

Claims (20)

  1. 一种蝴蝶识别网络构建方法,其特征在于,包括:A method for constructing a butterfly recognition network, comprising:
    从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;Obtain the original butterfly image corresponding to each butterfly species from a preset butterfly database;
    对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;Performing resampling processing on the original butterfly image to obtain a target butterfly image;
    针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;For each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network, and passes through a first convolution calculation of a convolution layer of the capsule network and the capsule network. Calculation of the second convolution of the capsule layer to obtain the output vector of the butterfly species;
    在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;Performing a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
    当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;When the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, using the capsule network as a training network for identifying butterflies;
    当所述损失函数值大于所述预设的损失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。When the value of the loss function is greater than the preset loss threshold, each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and each type of the butterfly species is updated. The target butterfly image used in training is re-input to the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function The value is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  2. 如权利要求1所述的蝴蝶识别网络构建方法,其特征在于,所述对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像包括:The method for constructing a butterfly recognition network according to claim 1, wherein the resampling the original butterfly image to obtain a target butterfly image comprises:
    根据预设的目标尺寸确定所述原始蝴蝶影像的缩放比例;Determining a scaling ratio of the original butterfly image according to a preset target size;
    按照所述缩放比例对所述原始蝴蝶影像的原始像素点进行划分,得到原始像素点的集合,并建立每个所述原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系;Dividing the original pixel points of the original butterfly image according to the scaling ratio to obtain a set of original pixel points, and establishing a distance between each of the original pixel point sets and each pixel point of the target butterfly image Correspondence
    计算所述原始像素点的集合中的每个所述原始像素点的平均RGB值,并根据所述对应关系,将该平均RGB值作为所述原始像素点的集合对应的所述目标像素点的RGB值。Calculate an average RGB value of each of the original pixel points in the set of original pixel points, and use the average RGB value as the target pixel point corresponding to the set of original pixel points according to the correspondence relationship RGB value.
  3. 如权利要求1所述的蝴蝶识别网络构建的方法,其特征在于,所述针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量包括:The method for constructing a butterfly recognition network according to claim 1, wherein, for each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network and passed through The first convolution calculation of the convolution layer of the capsule network and the second convolution calculation of the capsule layer of the capsule network, and the output vector of the butterfly species includes:
    将输入到所述蝴蝶种类中用作训练的所述目标蝴蝶影像在所述胶囊网络的所述卷积层中执行所述第一卷积计算,得到特征向量;Performing the first convolution calculation in the convolution layer of the capsule network on the target butterfly image input into the butterfly species for training, to obtain a feature vector;
    将所述特征向量代入到修正线性激活函数中,得到局部特征向量;Substituting the feature vector into a modified linear activation function to obtain a local feature vector;
    通过使用迭代路由处理方式,将所述局部特征向量与所述胶囊网络的所述胶囊层中的每个所述胶囊神经元进行所述第二卷积计算,得到所述蝴蝶种类的输出向量。By using an iterative routing processing method, the local feature vector is subjected to the second convolution calculation with each of the capsule neurons in the capsule layer of the capsule network to obtain an output vector of the butterfly species.
  4. 如权利要求1所述的蝴蝶识别网络构建方法,其特征在于,所述在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值包括:The method for constructing a butterfly recognition network according to claim 1, wherein in the loss function layer in the capsule network, a loss function calculation is performed on the output vector of each butterfly species to obtain each The loss function values of the output vectors include:
    将每一个所述输出向量在所述胶囊网络中的损失函数层中,按照如下公式计算所述输出向量的所述损失函数值:Calculate each of the output vectors in the loss function layer in the capsule network according to the following formula:
    L c=T cmax(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2 L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2
    其中,c为所述蝴蝶种类,L c为所述损失函数值,T c为所述蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0 和||V c||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为所述输出向量V c的所述向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Where c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is 0 and m + - the maximum value of the square of the two values of || V c ||, max (0, || V c || -m -) 2 is set to 0 and || V c || -m - of the two values The square of the maximum value, m + is the preset upper bound of the vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the preset vector length Lower border.
  5. 如权利要求4所述的蝴蝶识别网络构建方法,其特征在于,所述当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络之后,所述方法还包括:The method for constructing a butterfly recognition network according to claim 4, wherein, when the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, the capsule network is used as recognition After training the butterfly network, the method further includes:
    将用作测试的所述目标蝴蝶影像输入到所述识别蝴蝶的训练网络中,并通过所述第一卷积计算、所述第二卷积计算以及所述损失函数计算,得到测试输出向量的所述损失函数值;Inputting the target butterfly image used as a test into the training network for identifying the butterfly, and obtaining the test output vector by the first convolution calculation, the second convolution calculation, and the loss function calculation The loss function value;
    取大于或者等于所述预设的向量长度上边界的所述损失函数值对应的所述测试输出向量,并通过解码器网络将所述测试输出向量进行重构,得到输出图像,并将所述输出图像与所述用作测试的所述目标蝴蝶影像进行比较,得到所述识别蝴蝶的训练网络的准确率。Taking the test output vector corresponding to the loss function value on the upper boundary of the preset vector length and reconstructing the test output vector through a decoder network to obtain an output image, and The output image is compared with the target butterfly image used as a test to obtain the accuracy of the training network for identifying the butterfly.
  6. 一种蝴蝶识别网络构建装置,其特征在于,所述蝴蝶识别网络构建装置包括:A butterfly recognition network construction device, characterized in that the butterfly recognition network construction device includes:
    获取模块,用于从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;An acquisition module for acquiring an original butterfly image corresponding to each butterfly species from a preset butterfly database;
    重采样模块,用于对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;A resampling module for resampling the original butterfly image to obtain a target butterfly image;
    卷积模块,用于针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;A convolution module, for each of the butterfly species, inputting the target butterfly image used for training in the butterfly species into a capsule network, and passing a first convolution calculation of a convolution layer of the capsule network And a second convolution calculation of a capsule layer of the capsule network to obtain an output vector of the butterfly species;
    计算损失模块,用于在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;A loss calculation module, configured to perform a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
    训练模块,用于当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;A training module, configured to use the capsule network as a training network for identifying a butterfly when the loss function value of each of the output vectors is less than or equal to a preset loss threshold;
    更新模块,用于当所述损失函数值大于所述损预设的失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。An update module is configured to update each capsule neuron in the capsule network by back propagation when the loss function value is greater than a preset loss threshold of the loss, to obtain the updated capsule network, and The target butterfly image used for training in each of the butterfly species is re-input into the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed. Until the value of the loss function is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  7. 如权利要求6所述的蝴蝶识别网络构建装置,其特征在于,所述重采样模块包括:The apparatus for constructing a butterfly recognition network according to claim 6, wherein the resampling module comprises:
    缩放单元,用于根据预设的目标尺寸确定所述原始蝴蝶影像的缩放比例;A scaling unit, configured to determine a scaling ratio of the original butterfly image according to a preset target size;
    获取单元,用于按照所述缩放比例,获取对所述原始蝴蝶影像的原始像素点进行划分,得到目标蝴蝶影像的每个目标像素点在所述原始蝴蝶影像中对应的原始像素点的集合,并建立每个所述原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系;An obtaining unit, configured to obtain the original pixel points of the original butterfly image according to the scaling ratio, to obtain a set of original pixel points corresponding to each target pixel point of the target butterfly image in the original butterfly image, And establish a correspondence between each set of the original pixel points and each pixel point of the target butterfly image;
    计算单元,用于计算所述原始像素点的集合中的每个所述原始像素点的平均RGB值,并根据所述对应关系,将该平均RGB值作为所述原始像素点的集合对应的所述目标像素点的RGB值。A calculation unit, configured to calculate an average RGB value of each of the original pixel points in the set of original pixel points, and use the average RGB value as a corresponding value of the original pixel point set according to the correspondence relationship; Describe the RGB value of the target pixel.
  8. 如权利要求6所述的蝴蝶识别网络构建装置,其特征在于,所述卷积模块包括:The apparatus for constructing a butterfly recognition network according to claim 6, wherein the convolution module comprises:
    第一卷积单元,用于将输入到所述蝴蝶种类中用作训练的所述目标蝴蝶影像在所述胶囊网络的所述卷积层中执行所述第一卷积计算,得到特征向量;A first convolution unit, configured to perform the first convolution calculation in the convolution layer of the capsule network on the target butterfly image input into the butterfly species for training, to obtain a feature vector;
    激活单元,用于将所述特征向量代入到修正线性激活函数中,得到局部特征向量;An activation unit, configured to substitute the feature vector into a modified linear activation function to obtain a local feature vector;
    第二卷积单元,用于通过使用迭代路由处理方式,将所述局部特征向量与所述胶囊网络的所述胶囊层中的每个所述胶囊神经元进行所述第二卷积计算,得到所述蝴蝶种类的输出向量。A second convolution unit, configured to perform the second convolution calculation by using the iterative routing processing method to perform the second convolution calculation with the local feature vector and each of the capsule neurons in the capsule layer of the capsule network The output vector of the butterfly species.
  9. 如权利要求6所述的蝴蝶识别网络构建装置,其特征在于,所述计算损失模块包 括:The apparatus for constructing a butterfly recognition network according to claim 6, wherein the calculation loss module comprises:
    公式单元,用于将每一个所述输出向量在所述胶囊网络中的损失函数层中,按照如下公式计算所述输出向量的所述损失函数值:A formula unit, configured to calculate each of the output vectors in a loss function layer in the capsule network according to the following formula:
    L c=T cmax(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2 L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2
    其中,c为所述蝴蝶种类,L c为所述损失函数值,T c为所述蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0和||V c||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为所述输出向量V c的所述向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Where c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is 0 and m + - the maximum value of the square of the two values of || V c ||, max (0, || V c || -m -) 2 is set to 0 and || V c || -m - of the two values The square of the maximum value, m + is the preset upper bound of the vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the preset vector length Lower border.
  10. 如权利要求9所述的蝴蝶识别网络构建装置,其特征在于,所述蝴蝶识别网络构建装置还包括:The apparatus for constructing a butterfly recognition network according to claim 9, wherein the apparatus for constructing a butterfly recognition network further comprises:
    测试计算模块,用于将用作测试的所述目标蝴蝶影像输入到所述识别蝴蝶的训练网络中,并通过所述第一卷积计算、所述第二卷积计算以及所述损失函数计算,得到测试输出向量的所述损失函数值;A test calculation module, configured to input the target butterfly image used as a test into the training network for recognizing butterflies, and calculate the first convolution calculation, the second convolution calculation, and the loss function calculation To obtain the loss function value of the test output vector;
    重构模块,用于取大于或者等于所述预设的向量长度上边界的所述损失函数值对应的所述测试输出向量,并通过解码器网络将所述测试输出向量进行重构,得到输出图像,并将所述输出图像与所述用作测试的所述目标蝴蝶影像进行比较,得到所述识别蝴蝶的训练网络的准确率。A reconstruction module, configured to take the test output vector corresponding to the loss function value that is greater than or equal to the preset upper boundary of the vector length, and reconstruct the test output vector through a decoder network to obtain an output Image, and comparing the output image with the target butterfly image used as a test to obtain the accuracy of the training network for identifying the butterfly.
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and is characterized in that the processor implements the computer-readable instructions as follows step:
    从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;Obtain the original butterfly image corresponding to each butterfly species from a preset butterfly database;
    对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;Performing resampling processing on the original butterfly image to obtain a target butterfly image;
    针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;For each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network, and passes through a first convolution calculation of a convolution layer of the capsule network and the capsule network. Calculation of the second convolution of the capsule layer to obtain the output vector of the butterfly species;
    在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;Performing a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
    当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;When the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, using the capsule network as a training network for identifying butterflies;
    当所述损失函数值大于所述预设的损失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。When the value of the loss function is greater than the preset loss threshold, each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and each type of the butterfly species is updated. The target butterfly image used in training is re-input to the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function The value is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  12. 如权利要求11所述的计算机设备,其特征在于,所述对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像包括:The computer device according to claim 11, wherein the resampling the original butterfly image to obtain the target butterfly image comprises:
    根据预设的目标尺寸确定所述原始蝴蝶影像的缩放比例;Determining a scaling ratio of the original butterfly image according to a preset target size;
    按照所述缩放比例对所述原始蝴蝶影像的原始像素点进行划分,得到原始像素点的集合,并建立每个所述原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系;Dividing the original pixel points of the original butterfly image according to the scaling ratio to obtain a set of original pixel points, and establishing a distance between each of the original pixel point sets and each pixel point of the target butterfly image Correspondence
    计算所述原始像素点的集合中的每个所述原始像素点的平均RGB值,并根据所述对应关系,将该平均RGB值作为所述原始像素点的集合对应的所述目标像素点的RGB值。Calculate an average RGB value of each of the original pixel points in the set of original pixel points, and use the average RGB value as the target pixel point corresponding to the set of original pixel points according to the correspondence relationship RGB value.
  13. 如权利要求11所述的计算机设备,其特征在于,所述针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量包括:The computer device according to claim 11, characterized in that, for each of said butterfly species, said target butterfly image used for training in said butterfly species is input into a capsule network and passes through said capsule network The first convolution calculation of the convolution layer and the second convolution calculation of the capsule layer of the capsule network, and the output vector of the butterfly species includes:
    将输入到所述蝴蝶种类中用作训练的所述目标蝴蝶影像在所述胶囊网络的所述卷积层中执行所述第一卷积计算,得到特征向量;Performing the first convolution calculation in the convolution layer of the capsule network on the target butterfly image input into the butterfly species for training, to obtain a feature vector;
    将所述特征向量代入到修正线性激活函数中,得到局部特征向量;Substituting the feature vector into a modified linear activation function to obtain a local feature vector;
    通过使用迭代路由处理方式,将所述局部特征向量与所述胶囊网络的所述胶囊层中的每个所述胶囊神经元进行所述第二卷积计算,得到所述蝴蝶种类的输出向量。By using an iterative routing processing method, the local feature vector is subjected to the second convolution calculation with each of the capsule neurons in the capsule layer of the capsule network to obtain an output vector of the butterfly species.
  14. 如权利要求11所述的计算机设备,其特征在于,所述在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值包括:The computer device according to claim 11, wherein in the loss function layer in the capsule network, a loss function calculation is performed on the output vector of each of the butterfly species to obtain each of the butterfly vectors. The loss function values of the output vector include:
    将每一个所述输出向量在所述胶囊网络中的损失函数层中,按照如下公式计算所述输出向量的所述损失函数值:Calculate each of the output vectors in the loss function layer in the capsule network according to the following formula:
    L c=T cmax(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2 L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2
    其中,c为所述蝴蝶种类,L c为所述损失函数值,T c为所述蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0和||V c||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为所述输出向量V c的所述向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Where c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is 0 and m + - the maximum value of the square of the two values of || V c ||, max (0, || V c || -m -) 2 is set to 0 and || V c || -m - of the two values The square of the maximum value, m + is the preset upper bound of the vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the preset vector length Lower border.
  15. 如权利要求14所述的计算机设备,其特征在于,所述当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络之后,所述处理器执行所述计算机可读指令时还实现如下步骤:The computer device according to claim 14, wherein when the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, the capsule network is used as training for identifying a butterfly After the network, when the processor executes the computer-readable instructions, the following steps are further implemented:
    将用作测试的所述目标蝴蝶影像输入到所述识别蝴蝶的训练网络中,并通过所述第一卷积计算、所述第二卷积计算以及所述损失函数计算,得到测试输出向量的所述损失函数值;Inputting the target butterfly image used as a test into the training network for identifying the butterfly, and obtaining the test output vector by the first convolution calculation, the second convolution calculation, and the loss function calculation The loss function value;
    取大于或者等于所述预设的向量长度上边界的所述损失函数值对应的所述测试输出向量,并通过解码器网络将所述测试输出向量进行重构,得到输出图像,并将所述输出图像与所述用作测试的所述目标蝴蝶影像进行比较,得到所述识别蝴蝶的训练网络的准确率。Taking the test output vector corresponding to the loss function value on the upper boundary of the preset vector length and reconstructing the test output vector through a decoder network to obtain an output image, and The output image is compared with the target butterfly image used as a test to obtain the accuracy of the training network for identifying the butterfly.
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:One or more non-volatile readable storage media storing computer readable instructions, characterized in that when the computer readable instructions are executed by one or more processors, the one or more processors are caused to execute The following steps:
    从预设的蝴蝶数据库中获取每种蝴蝶种类对应的原始蝴蝶影像;Obtain the original butterfly image corresponding to each butterfly species from a preset butterfly database;
    对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像;Performing resampling processing on the original butterfly image to obtain a target butterfly image;
    针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量;For each of the butterfly species, the target butterfly image used for training in the butterfly species is input into a capsule network, and passes through a first convolution calculation of a convolution layer of the capsule network and the capsule network. Calculation of the second convolution of the capsule layer to obtain the output vector of the butterfly species;
    在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值;Performing a loss function calculation on the output vector of each of the butterfly species in a loss function layer in the capsule network to obtain a loss function value of each of the output vectors;
    当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络;When the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, using the capsule network as a training network for identifying butterflies;
    当所述损失函数值大于所述预设的损失阈值时,通过反向传播更新所述胶囊网络中的每个胶囊神经元,得到更新后的所述胶囊网络,并将每种所述蝴蝶种类中用作训练的所述目标蝴蝶影像重新输入到更新后的所述胶囊网络中,进行所述第一卷积计算、所述第二卷积计算和所述损失函数计算,直到所述损失函数值小于或者等于所述预设的损失阈值为止,其中,所述胶囊神经元代表所述蝴蝶种类的属性。When the value of the loss function is greater than the preset loss threshold, each capsule neuron in the capsule network is updated by back propagation to obtain the updated capsule network, and each type of the butterfly species is updated. The target butterfly image used in training is re-input to the updated capsule network, and the first convolution calculation, the second convolution calculation, and the loss function calculation are performed until the loss function The value is less than or equal to the preset loss threshold, wherein the capsule neuron represents the attribute of the butterfly species.
  17. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述对所述原始蝴蝶影像进行重采样处理,得到目标蝴蝶影像包括:The non-volatile readable storage medium of claim 16, wherein the resampling the original butterfly image to obtain a target butterfly image comprises:
    根据预设的目标尺寸确定所述原始蝴蝶影像的缩放比例;Determining a scaling ratio of the original butterfly image according to a preset target size;
    按照所述缩放比例对所述原始蝴蝶影像的原始像素点进行划分,得到原始像素点的集合,并建立每个所述原始像素点的集合与所述目标蝴蝶影像的每个像素点之间的对应关系;Dividing the original pixel points of the original butterfly image according to the scaling ratio to obtain a set of original pixel points, and establishing a distance between each of the original pixel point sets and each pixel point of the target butterfly image Correspondence
    计算所述原始像素点的集合中的每个所述原始像素点的平均RGB值,并根据所述对应关系,将该平均RGB值作为所述原始像素点的集合对应的所述目标像素点的RGB值。Calculate an average RGB value of each of the original pixel points in the set of original pixel points, and use the average RGB value as the target pixel point corresponding to the set of original pixel points according to the correspondence relationship RGB value.
  18. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述针对每种所述蝴蝶种类,将该蝴蝶种类中用作训练的所述目标蝴蝶影像输入到胶囊网络中,并经过所述胶囊网络的卷积层的第一卷积计算和所述胶囊网络的胶囊层的第二卷积计算,得到该蝴蝶种类的输出向量包括:The non-volatile readable storage medium according to claim 16, wherein for each of said butterfly species, said target butterfly image used for training in said butterfly species is input into a capsule network, After passing the first convolution calculation of the convolution layer of the capsule network and the second convolution calculation of the capsule layer of the capsule network, the output vector of the butterfly species includes:
    将输入到所述蝴蝶种类中用作训练的所述目标蝴蝶影像在所述胶囊网络的所述卷积层中执行所述第一卷积计算,得到特征向量;Performing the first convolution calculation in the convolution layer of the capsule network on the target butterfly image input into the butterfly species for training, to obtain a feature vector;
    将所述特征向量代入到修正线性激活函数中,得到局部特征向量;Substituting the feature vector into a modified linear activation function to obtain a local feature vector;
    通过使用迭代路由处理方式,将所述局部特征向量与所述胶囊网络的所述胶囊层中的每个所述胶囊神经元进行所述第二卷积计算,得到所述蝴蝶种类的输出向量。By using an iterative routing processing method, the local feature vector is subjected to the second convolution calculation with each of the capsule neurons in the capsule layer of the capsule network to obtain an output vector of the butterfly species.
  19. 如权利要求16所述的非易失性可读存储介质,其特征在于,所述在所述胶囊网络中的损失函数层中,对每种所述蝴蝶种类的所述输出向量进行损失函数计算,得到每个所述输出向量的损失函数值包括:The non-volatile readable storage medium according to claim 16, wherein in the loss function layer in the capsule network, a loss function calculation is performed on the output vector of each butterfly species To obtain the loss function value of each of the output vectors includes:
    将每一个所述输出向量在所述胶囊网络中的损失函数层中,按照如下公式计算所述输出向量的所述损失函数值:Calculate each of the output vectors in the loss function layer in the capsule network according to the following formula:
    L c=T cmax(0,m +-||V c||) 2+λ(1-T c)max(0,||V c||-m -) 2 L c = T c max (0 , m + - || V c ||) 2 + λ (1-T c) max (0, || V c || -m -) 2
    其中,c为所述蝴蝶种类,L c为所述损失函数值,T c为所述蝴蝶种类的指示函数,max(0,m +-||V c||) 2为取0和m +-||V c||两个数值中的最大值的平方,max(0,||V c||-m -) 2为取0和||V c||-m -两个数值中的最大值的平方,m +为预设的向量长度上边界,||V c||为所述输出向量V c的所述向量长度,λ为预设参数值,m -为预设的向量长度下边界。 Where c is the butterfly type, L c is the loss function value, T c is the indicator function of the butterfly type, and max (0, m + -|| V c ||) 2 is 0 and m + - the maximum value of the square of the two values of || V c ||, max (0, || V c || -m -) 2 is set to 0 and || V c || -m - of the two values The square of the maximum value, m + is the preset upper bound of the vector length, || V c || is the vector length of the output vector V c , λ is the preset parameter value, and m - is the preset vector length Lower border.
  20. 如权利要求19所述的非易失性可读存储介质,其特征在于,所述当每个所述输出向量的所述损失函数值均小于或者等于预设的损失阈值时,将所述胶囊网络作为识别蝴蝶的训练网络之后,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:The non-volatile readable storage medium according to claim 19, wherein when the value of the loss function of each of the output vectors is less than or equal to a preset loss threshold, the capsule is After the network is used as a training network for butterfly recognition, when the computer-readable instructions are executed by one or more processors, the one or more processors further perform the following steps:
    将用作测试的所述目标蝴蝶影像输入到所述识别蝴蝶的训练网络中,并通过所述第一卷积计算、所述第二卷积计算以及所述损失函数计算,得到测试输出向量的所述损失函数 值;Inputting the target butterfly image used as a test into the training network for identifying the butterfly, and obtaining the test output vector by the first convolution calculation, the second convolution calculation, and the loss function calculation The loss function value;
    取大于或者等于所述预设的向量长度上边界的所述损失函数值对应的所述测试输出向量,并通过解码器网络将所述测试输出向量进行重构,得到输出图像,并将所述输出图像与所述用作测试的所述目标蝴蝶影像进行比较,得到所述识别蝴蝶的训练网络的准确率。Taking the test output vector corresponding to the loss function value on the upper boundary of the preset vector length and reconstructing the test output vector through a decoder network to obtain an output image, and The output image is compared with the target butterfly image used as a test to obtain the accuracy of the training network for identifying the butterfly.
PCT/CN2018/106395 2018-07-06 2018-09-19 Butterfly identification network construction method and apparatus, and computer device and storage medium WO2020006881A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810735895.1 2018-07-06
CN201810735895.1A CN109063742B (en) 2018-07-06 2018-07-06 Butterfly identification network construction method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2020006881A1 true WO2020006881A1 (en) 2020-01-09

Family

ID=64818940

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/106395 WO2020006881A1 (en) 2018-07-06 2018-09-19 Butterfly identification network construction method and apparatus, and computer device and storage medium

Country Status (2)

Country Link
CN (1) CN109063742B (en)
WO (1) WO2020006881A1 (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111626361A (en) * 2020-05-28 2020-09-04 辽宁大学 Bearing sub-health identification method for improving capsule network optimization layered convolution
CN111814592A (en) * 2020-03-31 2020-10-23 同济大学 Plant leaf identification method based on superposable capsule network
CN112348038A (en) * 2020-11-30 2021-02-09 江苏海洋大学 Visual positioning method based on capsule network
CN112633362A (en) * 2020-12-21 2021-04-09 华中科技大学 Self-adaptive fault diagnosis method, device, equipment and medium for rotary machine
CN113011243A (en) * 2021-01-13 2021-06-22 苏州元启创人工智能科技有限公司 Facial expression analysis method based on capsule network
US20210374471A1 (en) * 2020-05-27 2021-12-02 Hon Hai Precision Industry Co., Ltd. Image recognition method and computing device
CN114217014A (en) * 2021-11-18 2022-03-22 广州杰赛科技股份有限公司 Method, device, medium and equipment for positioning pollution source of atmospheric pollutant
CN114338093A (en) * 2021-12-09 2022-04-12 上海大学 Method for transmitting multi-channel secret information through capsule network
CN114638984A (en) * 2022-02-17 2022-06-17 南京邮电大学 Malicious website URL detection method based on capsule network
US20220277502A1 (en) * 2018-11-15 2022-09-01 Preferred Networks, Inc. Apparatus and method for editing data and program

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110020624B (en) * 2019-04-08 2023-04-18 石家庄铁道大学 Image recognition method, terminal device and storage medium
CN110084320A (en) * 2019-05-08 2019-08-02 广东工业大学 Thyroid papillary carcinoma Ultrasound Image Recognition Method, device, system and medium
CN112784652A (en) 2019-11-11 2021-05-11 中强光电股份有限公司 Image recognition method and device
CN111340096A (en) * 2020-02-24 2020-06-26 北京工业大学 Weakly supervised butterfly target detection method based on confrontation complementary learning
CN112235434B (en) * 2020-10-16 2021-10-26 重庆理工大学 DGA network domain name detection and identification system fusing k-means and capsule network thereof
CN112465141B (en) * 2020-12-18 2024-06-28 平安科技(深圳)有限公司 Model compression method, device, electronic equipment and medium
CN113408488B (en) * 2021-07-19 2022-11-25 中南大学 Capsule network-based flame target identification method, device and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008980A (en) * 2007-02-01 2007-08-01 沈佐锐 Method and system for automatic identifying butterfly
WO2017055412A1 (en) * 2015-09-30 2017-04-06 Siemens Healthcare Gmbh Method and system for classification of endoscopic images using deep decision networks
CN106778657A (en) * 2016-12-28 2017-05-31 南京邮电大学 Neonatal pain expression classification method based on convolutional neural networks
CN108229543A (en) * 2017-12-22 2018-06-29 中国科学院深圳先进技术研究院 Image classification design methods and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108229298A (en) * 2017-09-30 2018-06-29 北京市商汤科技开发有限公司 The training of neural network and face identification method and device, equipment, storage medium
CN108229379A (en) * 2017-12-29 2018-06-29 广东欧珀移动通信有限公司 Image-recognizing method, device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008980A (en) * 2007-02-01 2007-08-01 沈佐锐 Method and system for automatic identifying butterfly
WO2017055412A1 (en) * 2015-09-30 2017-04-06 Siemens Healthcare Gmbh Method and system for classification of endoscopic images using deep decision networks
CN106778657A (en) * 2016-12-28 2017-05-31 南京邮电大学 Neonatal pain expression classification method based on convolutional neural networks
CN108229543A (en) * 2017-12-22 2018-06-29 中国科学院深圳先进技术研究院 Image classification design methods and device

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220277502A1 (en) * 2018-11-15 2022-09-01 Preferred Networks, Inc. Apparatus and method for editing data and program
CN111814592A (en) * 2020-03-31 2020-10-23 同济大学 Plant leaf identification method based on superposable capsule network
CN111814592B (en) * 2020-03-31 2024-04-26 同济大学 Plant leaf identification method based on stackable capsule network
US11948081B2 (en) * 2020-05-27 2024-04-02 Hon Hai Precision Industry Co., Ltd. Image recognition method and computing device
US20210374471A1 (en) * 2020-05-27 2021-12-02 Hon Hai Precision Industry Co., Ltd. Image recognition method and computing device
CN111626361A (en) * 2020-05-28 2020-09-04 辽宁大学 Bearing sub-health identification method for improving capsule network optimization layered convolution
CN111626361B (en) * 2020-05-28 2023-08-11 辽宁大学 Bearing sub-health identification method for improving capsule network optimization hierarchical convolution
CN112348038A (en) * 2020-11-30 2021-02-09 江苏海洋大学 Visual positioning method based on capsule network
CN112633362A (en) * 2020-12-21 2021-04-09 华中科技大学 Self-adaptive fault diagnosis method, device, equipment and medium for rotary machine
CN112633362B (en) * 2020-12-21 2024-03-29 华中科技大学 Rotary machine self-adaptive fault diagnosis method, device, equipment and medium
CN113011243A (en) * 2021-01-13 2021-06-22 苏州元启创人工智能科技有限公司 Facial expression analysis method based on capsule network
CN114217014A (en) * 2021-11-18 2022-03-22 广州杰赛科技股份有限公司 Method, device, medium and equipment for positioning pollution source of atmospheric pollutant
CN114338093A (en) * 2021-12-09 2022-04-12 上海大学 Method for transmitting multi-channel secret information through capsule network
CN114338093B (en) * 2021-12-09 2023-10-20 上海大学 Method for transmitting multi-channel secret information through capsule network
CN114638984A (en) * 2022-02-17 2022-06-17 南京邮电大学 Malicious website URL detection method based on capsule network
CN114638984B (en) * 2022-02-17 2024-03-15 南京邮电大学 Malicious website URL detection method based on capsule network

Also Published As

Publication number Publication date
CN109063742A (en) 2018-12-21
CN109063742B (en) 2023-04-18

Similar Documents

Publication Publication Date Title
WO2020006881A1 (en) Butterfly identification network construction method and apparatus, and computer device and storage medium
US11551333B2 (en) Image reconstruction method and device
WO2020228446A1 (en) Model training method and apparatus, and terminal and storage medium
WO2019228317A1 (en) Face recognition method and device, and computer readable medium
WO2021114625A1 (en) Network structure construction method and apparatus for use in multi-task scenario
JP7512262B2 (en) Facial keypoint detection method, device, computer device and computer program
WO2021227726A1 (en) Methods and apparatuses for training face detection and image detection neural networks, and device
WO2021073493A1 (en) Image processing method and device, neural network training method, image processing method of combined neural network model, construction method of combined neural network model, neural network processor and storage medium
WO2020228525A1 (en) Place recognition method and apparatus, model training method and apparatus for place recognition, and electronic device
WO2020056791A1 (en) Method and apparatus for super-resolution reconstruction of multi-scale dilated convolution neural network
WO2021184902A1 (en) Image classification method and apparatus, training method and apparatus, device, and medium
WO2022001805A1 (en) Neural network distillation method and device
WO2018036462A1 (en) Image segmentation method, computer apparatus, and computer storage medium
WO2022042123A1 (en) Image recognition model generation method and apparatus, computer device and storage medium
CN111368672A (en) Construction method and device for genetic disease facial recognition model
CN108229347A (en) For the method and apparatus of the deep layer displacement of the plan gibbs structure sampling of people's identification
WO2021051987A1 (en) Method and apparatus for training neural network model
WO2023178793A1 (en) Method and apparatus for training dual-perspective graph neural network model, device, and medium
WO2022206729A1 (en) Method and apparatus for selecting cover of video, computer device, and storage medium
WO2021159748A1 (en) Model compression method and apparatus, computer device, and storage medium
CN115797781A (en) Crop identification method and device, computer equipment and storage medium
WO2020187029A1 (en) Image processing method and device, neural network training method, and storage medium
WO2024001139A1 (en) Video classification method and apparatus and electronic device
WO2022127603A1 (en) Model processing method and related device
WO2022266888A1 (en) Congestion prediction model training method, image processing 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: 18925633

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

Country of ref document: EP

Kind code of ref document: A1