Clustering method, electronic equipment and medium
Through the clustering network of feature learning module and clustering module, the similarity and features between image instances are used to learn correlation, and the parameters of the feature extraction network layer are adjusted, which solves the problem of unsatisfactory clustering accuracy on complex color image data sets, and achieves higher clustering accuracy.
Patent Information
- Application Number
- CN202510264134.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-07-22
AI Technical Summary
The existing clustering method has poor clustering accuracy on complex color image datasets.
The clustering network of feature learning module and clustering module is adopted to extract embedded features through the feature extraction network layer, and the similarity and feature decorrelation learning between image instances are used as constraints to calculate the first loss function, adjust the parameters of the feature extraction network layer, obtain the target feature extraction network layer, and cluster it through the clustering module.
Improve the clustering accuracy on complex color image datasets to obtain feature representations that are more suitable for clustering tasks.
Smart Images

Figure CN120355959A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data clustering, and particularly to a clustering method, an electronic device, and a medium. Background Art
[0002] Currently, mainstream clustering methods, such as K-means based on autoencoders, can achieve ideal accuracy on some simple grayscale image datasets, but the clustering accuracy on some complex color image datasets is not very satisfactory. Summary of the Invention
[0003] The following is an overview of the subject matter described in detail in this article. This overview is not intended to limit the scope of protection of the claims.
[0004] An object of the present application is to solve at least to some extent one of the technical problems existing in the related art. Embodiments of the present application provide a clustering method, an electronic device, and a medium, which can improve the clustering accuracy on complex color image datasets.
[0005] In an embodiment of the first aspect of the present application, a clustering method includes:
[0006] Obtain training image data, and input the embedding features into a clustering network, where the clustering network includes a feature learning module and a clustering module;
[0007] Extract the embedding features of the training image data through a feature extraction network layer of the feature learning module;
[0008] Calculate a first loss function by using the similarity and feature decorrelation learning between image instances as constraints, and adjust the parameters of the feature extraction network layer according to the first loss function to obtain a target feature extraction network layer;
[0009] Extract target embedding features of the image data to be processed through the target feature extraction network layer;
[0010] Perform clustering on the target embedding features through the clustering module to obtain a target clustering result.
[0011] According to certain embodiments of the first aspect of the present application, the extracting the embedding features of the training image data includes:
[0012] Input the training image data into a feature extraction network layer based on a residual neural network, and embed the training image data into a feature space through the residual neural network to obtain embedding features;
[0013] Wherein, the dimension of the embedding features is the same as the dimension of the feature space, and the dimension of the embedding features is the same as the dimension of the training image data.
[0014] According to certain embodiments of the first aspect of the present application, calculating the first loss function by using the similarity and feature decorrelation learning between image instances as constraints includes:
[0015] Determining a sub-constraint based on orthogonal features according to the embedding features;
[0016] Determining the negative log-likelihood value of the training image data according to the sub-constraint;
[0017] Minimizing the negative log-likelihood value to maintain the similarity between image instances;
[0018] Calculating the first loss function according to the negative log-likelihood value.
[0019] According to certain embodiments of the first aspect of the present application, the sub-constraint based on orthogonal features is expressed as: where f l is the l-th embedding feature, Q(l|f l ) is the sub-constraint based on orthogonal features, f l T is the transpose of the l-th embedding feature, is the transpose of the j-th embedding feature, d is the number of embedding features, and τ is a coefficient for controlling the degree of distribution concentration.
[0020] According to certain embodiments of the first aspect of the present application, the negative log-likelihood value is expressed as: where L I represents the negative log-likelihood value, f l is the l-th embedding feature, Q(l|f l ) is the sub-constraint based on orthogonal features, f l T is the transpose of the l-th embedding feature, is the transpose of the j-th embedding feature, d is the number of embedding features, and τ is a coefficient for controlling the degree of distribution concentration.
[0021] According to certain embodiments of the first aspect of the present application, the first loss function is expressed as: L IDFD = L I + αL F ; where L IDFD represents the first loss function, L I represents the negative log-likelihood value, L F represents the loss value corresponding to feature decorrelation learning, and α is a weight coefficient.
[0022] According to certain embodiments of the first aspect of the present application, the loss function of the clustering module is expressed as: where L cluis the loss function of the clustering module, x i is the i-th training image data, f θ (x i ) is the latent feature learned by the feature learning module, W j is the weight of the clustering module, C is the number of weights of the clustering module, and n is the number of training image data.
[0023] According to some embodiments of the first aspect of the present application, the clustering module is a feedforward neural network.
[0024] An embodiment of the second aspect of the present application, an electronic device, includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the clustering method described in the embodiments of the first aspect of the present application is implemented.
[0025] An embodiment of the third aspect of the present application, a computer storage medium stores computer-executable instructions for executing the clustering method described in the embodiments of the second aspect of the present application.
[0026] The above solution has at least the following beneficial effects: extracting the embedded features of the training image data through the feature extraction network layer of the feature learning module; using the similarity and feature decorrelation learning between image instances as constraints to calculate the first loss function, and adjusting the parameters of the feature extraction network layer according to the first loss function to obtain the target feature extraction network layer; extracting the target embedded features of the image data to be processed through the target feature extraction network layer; clustering the target embedded features through the clustering module to obtain the target clustering result; optimizing the neural network parameters through instance discrimination and feature decorrelation to obtain a feature representation more suitable for the clustering task, which can improve the clustering accuracy on complex color image datasets. Description of the Drawings
[0027] The drawings are used to provide a further understanding of the technical solutions of the present application, and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solutions of the present application, and do not constitute a limitation to the technical solutions of the present application.
[0028] Figure 1 is the step diagram of the clustering method;
[0029] Figure 2 is the step diagram of calculating the first loss function by using the similarity and feature decorrelation learning between image instances as constraints;
[0030] Figure 3 is the schematic diagram of the clustering network;
[0031] Figure 4It is a line graph showing the changes in three clustering evaluation metrics of the clustering method on the MNIST dataset;
[0032] Figure 5 It is a line graph showing the changes in three clustering evaluation metrics of the clustering method on the F-MNIST dataset;
[0033] Figure 6 It is a line graph showing the changes in three clustering evaluation metrics of the clustering method on the CIFAR-10 dataset. Specific implementation manners
[0034] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0035] It should be noted that although functional module division is performed in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different module division in the device or a different order in the flowchart. Terms such as "first" and "second" in the specification, claims or the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.
[0036] The following further elaborates on the embodiments of the present application with reference to the accompanying drawings.
[0037] The embodiments of the present application provide a clustering method.
[0038] Referring to Figure 1 , the clustering method includes the following steps:
[0039] Step S100: Obtain training image data and input the embedding features into the clustering network;
[0040] Step S200: Extract the embedding features of the training image data through the feature extraction network layer of the feature learning module;
[0041] Step S300: Calculate the first loss function by using the similarity and feature decorrelation learning between image instances as constraints, and adjust the parameters of the feature extraction network layer according to the first loss function to obtain the target feature extraction network layer;
[0042] Step S400: Extract the target embedding features of the image data to be processed through the target feature extraction network layer;
[0043] Step S500: Cluster the target embedding features through the clustering module to obtain the target clustering result.
[0044] For step S100, obtain training image data and input the embedding features into a clustering network. The training image data is n D-dimensional data samples to be clustered, X = {x1, x2,..., x n} ∈ R D×n . The clustering network includes a feature learning module and a clustering module. The feature learning module is used to learn a feature representation friendly to clustering, and the clustering module is used to cluster the feature representation output by the feature learning module.
[0045] For step S200, extract the embedding features of the training image data through the feature extraction network layer of the feature learning module.
[0046] Extracting the embedding features of the training image data includes the following steps:
[0047] Input the training image data into the feature extraction network layer based on a residual neural network, and embed the training image data into the feature space through the residual neural network to obtain the embedding features;
[0048] Among them, the dimension of the embedding features is the same as the dimension of the feature space, and the dimension of the embedding features is the same as the dimension of the training image data.
[0049] Exemplarily, referring to Figure 3 , select the residual neural network f(.) to embed the data samples of n D-dimensional training image data to be clustered, X = {x1, x2,..., x n} ∈ R D×n into the d-dimensional feature space Z = {z1, z2,..., z n} ∈ R d×n . The residual neural network is a convolutional neural network CNN.
[0050] For step S300, use the similarity between image instances and feature decorrelation learning as constraints to calculate a first loss function, and adjust the parameters of the feature extraction network layer according to the first loss function to obtain a target feature extraction network layer.
[0051] Referring to Figure 2 , using the similarity between image instances and feature decorrelation learning as constraints to calculate a first loss function includes the following steps:
[0052] Step S310, determine a sub-constraint based on orthogonal features according to the embedding features;
[0053] Step S320, determine the negative log-likelihood value of the training image data according to the sub-constraint;
[0054] Step S330, minimize the negative log-likelihood value to maintain the similarity between image instances;
[0055] Step S340, calculate a first loss function based on the negative log-likelihood value.
[0056] Exemplarily, an instance discrimination method is adopted to learn a clustering-friendly feature representation to handle the similarity between instances.
[0057] Assume that each instance represents a different class, that is, the training image data x i The corresponding feature representation is z i , each z i Is then set to a separate class, that is, it can be understood that the data x i Corresponds to the i-th class, and the probability expression that the feature representation z i Is assigned to the i-th class is Where Refers to the matching degree between z i And the j-th class, and τ is a coefficient that controls the degree of distribution concentration. To calculate P(i|z for all image samples i ), set up a feature memory bank to store the feature representation z i .
[0058] The goal of maximizing the joint probability Is equivalent to minimizing the negative log-likelihood of the data set, that is, the negative log-likelihood value is expressed as By minimizing L I The similarity between image instances can be maintained and the performance of nearest neighbor classification can be improved.
[0059] To minimize the correlation between different feature vectors, orthogonalizing the features can better ensure that the feature vectors are independent and eliminate redundant redundant information. The transpose of the embedded feature Z is the feature vector F = {f1, f2,... f d} ∈ R n×d , and there is a sub-constraint based on orthogonal features as And for the goal of maximizing the joint probability Is equivalent to minimizing the negative log-likelihood of the data set, that is, the negative log-likelihood value is expressed as
[0060] Where L I Represents the negative log-likelihood value, f l Is the l-th embedded feature, Q(l|f l ) is the sub-constraint based on orthogonal features, f l T Is the transpose of the l-th embedded feature, Is the transpose of the j-th embedded feature, d is the number of embedded features, and τ is a coefficient that controls the degree of distribution concentration.
[0061] Combining instance discrimination and feature decorrelation learning, define the objective function of the feature learning module as LIDFD = L I + αL F , where L IDFD represents the loss function of the feature learning module, L I represents the negative log-likelihood value, L F represents the loss value corresponding to feature decorrelation learning, and α is the weight coefficient used to balance L I and L F .
[0062] For step S400, the image data to be processed is input into the feature learning module, and the target embedding features of the image data to be processed are extracted through the parameter-tuned target feature extraction network layer.
[0063] For step S500, the feature representation output by the feature learning module is input into the clustering module to obtain a clustering result. The parameters of the clustering module are adjusted according to the clustering result to obtain a target clustering module, and the target embedding features are clustered through the parameter-tuned clustering module to obtain a target clustering result.
[0064] The function of K-means clustering is implemented by a one-layer feedforward neural network. The objective function of K-means clustering is expressed by the following formula: where Ω j represents the j-th cluster centroid, C is the number of clusters, and f θ (x i ) refers to the latent features learned by the feature learning module. The objective function can be split according to the following mathematical formula: Let the weight of the feedforward neural network be W j = 2Ω j , the feature representation ||f θ (x i )|| 2 and the cluster center ||Ω j || 2 are normalized, and the loss function is then transformed into The result output by the neural network layer is mathematically transformed to obtain the clustering loss, and the gradient of the neural network is updated using backpropagation, which can be regarded as the update of the cluster center.
[0065] In a specific embodiment, training is performed under the Pytorch framework on GPU P100. The three clustering evaluation metrics are: ACC ∈ [0, 1]; NMI ∈ [0, 1]; ARI ∈ [-1, 1]. The closer the value is to 1, the better the clustering effect. The three datasets are MNIST, Fashion-MNIST, and CIFAR-10. The sample situations of the datasets are shown in Table 1.
[0066] Table 1 Sample situation table of datasets
[0067]
[0068] The ResNet in the torchvision.models library is selected as the neural network for extracting the features of image data, and the total number of training epochs is set to 2000.
[0069] The change curves of the clustering evaluation metrics on the three datasets with the increase in the number of epochs are as Figure 4 , Figure 5 and Figure 6 shown. Figure 4 is the change curve graph of the three clustering evaluation metrics of the clustering method on the MNIST dataset; Figure 5 is the change curve graph of the three clustering evaluation metrics of the clustering method on the F-MNIST dataset; Figure 6 is the change curve graph of the three clustering evaluation metrics of the clustering method on the CIFAR-10 dataset.
[0070] The optimal clustering results obtained within the set number of epochs are shown in Table 2.
[0071] Table 2 Optimal Clustering Results Table
[0072] Dataset NMI ARI ACC MNIST 0.8464 0.78134 0.8156 Fashion - MNIST 0.6835 0.53994 0.6344 CIFAR - 10 0.7345 0.68797 0.8284
[0073] The encoder part in the pre-trained autoencoder is used as the representation feature learning module, and the clustering module is also implemented by using a one-layer feedforward neural network.
[0074] The optimal clustering results obtained by the neural network clustering method based on the autoencoder on the three datasets are shown in Table 3.
[0075] Table 3 Optimal Clustering Results Table (II)
[0076] Dataset NMI ARI ACC MNIST 0.84346 0.82459 0.9121 Fashion - MNIST 0.59075 0.416 0.54462 CIFAR - 10 0.06257 0.04707 0.17303
[0077] It can be seen from Table 2 and Table 3 that the instance discrimination and feature decorrelation-based representation learning method can obtain better clustering results than the autoencoder-based method on complex datasets. Although the accuracy on the MNIST dataset slightly declines, and the results obtained by the two representation learning methods on the Fashion-MNIST dataset are similar, the feature learning method adopted in the present invention can significantly increase the clustering accuracy on the CIFAR-10 dataset.
[0078] An embodiment of the present application provides an electronic device. The electronic device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above clustering method is implemented.
[0079] The electronic device can be any intelligent terminal including a computer, etc.
[0080] Generally speaking, for the hardware structure of the electronic device, the processor can be implemented in ways such as a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided by the embodiments of the present application.
[0081] The memory can be implemented in forms such as read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM), etc. The memory can store an operating system and other application programs. When implementing the technical solutions provided by the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory and are called by the processor to execute the methods of the embodiments of the present application.
[0082] The input / output interface is used to implement information input and output.
[0083] The communication interface is used to implement communication interaction between this device and other devices, and can implement communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0084] The bus transmits information between the various components of the device (such as the processor, memory, input / output interface, and communication interface). The processor, memory, input / output interface, and communication interface are communicatively connected to each other inside the device through the bus.
[0085] Embodiments of the present application provide a computer storage medium. The computer storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the clustering method as described above.
[0086] Those of ordinary skill in the art can understand that all or some of the steps and systems disclosed above can be implemented as software, firmware, hardware, and their appropriate combinations. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, a communication medium typically contains computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. In the foregoing description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example", or "some embodiments / examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0087] Those of ordinary skill in the art can understand that all or some of the steps, systems, and functional modules / units in the devices disclosed above can be implemented as software, firmware, hardware, and their appropriate combinations.
[0088] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0089] In addition, in each of the embodiments of the present application, the functional units may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0090] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0091] In the several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above-mentioned division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of devices or units can be in electrical, mechanical, or other forms. Although the embodiments of the present application have been shown and described, those of ordinary skill in the art can understand that: various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and purposes of the present application. The scope of the present application is defined by the claims and their equivalents.
[0092] The above has specifically described the preferred embodiments of the present application, but the present application is not limited to the embodiments. Those skilled in the art can make various equivalent deformations or substitutions without departing from the spirit of the present application, and these equivalent deformations or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A clustering method, characterized in that Including: Obtain training image data, and input the embedding features into a clustering network, where the clustering network includes a feature learning module and a clustering module; Extract the embedding features of the training image data through the feature extraction network layer of the feature learning module; Calculate a first loss function using the similarity between image instances and feature decorrelation learning as constraints, and adjust the parameters of the feature extraction network layer according to the first loss function to obtain a target feature extraction network layer; Extract the target embedding features of the image data to be processed through the target feature extraction network layer; Perform clustering on the target embedding features through the clustering module to obtain a target clustering result.
2. The clustering method according to claim 1, wherein The extracting the embedding features of the training image data includes: Input the training image data into the feature extraction network layer based on a residual neural network, and embed the training image data into a feature space through the residual neural network to obtain embedding features; Wherein, the dimension of the embedding features is the same as the dimension of the feature space, and the dimension of the embedding features is the same as the dimension of the training image data.
3. The clustering method according to claim 1, wherein The calculating a first loss function using the similarity between image instances and feature decorrelation learning as constraints includes: Determine a sub-constraint based on orthogonal features according to the embedding features; Determine the negative log-likelihood value of the training image data according to the sub-constraint; Minimize the negative log-likelihood value to maintain the similarity between image instances; Calculate a first loss function according to the negative log-likelihood value.
4. The clustering method according to claim 3, wherein The sub-constraint based on orthogonal features is expressed as: where f l is the l-th embedded feature, Q(l|f l ) is the sub-constraint based on orthogonal features, f l T is the transpose of the l-th embedded feature, is the transpose of the j-th embedded feature, d is the number of embedded features, and τ is a coefficient for controlling the degree of distribution concentration.
5. The clustering method according to claim 3, characterized in that The negative log-likelihood value is expressed as: where L I represents the negative log-likelihood value, f l is the l-th embedded feature, Q(l|f l ) is the sub-constraint based on the orthogonal feature, f l T is the transpose of the l-th embedded feature, is the transpose of the j-th embedded feature, d is the number of embedded features, and τ is the coefficient controlling the concentration degree of the distribution.
6. The clustering method according to claim 3, wherein The first loss function is expressed as: L IDFD = L I + αL F ; where, L IDFD represents the first loss function, L I represents the negative log-likelihood value, and L F represents the loss value corresponding to feature decorrelation learning, and α is the weight coefficient.
7. The clustering method according to claim 3, wherein The loss function of the clustering module is expressed as: where L clu is the loss function of the clustering module, x i is the i-th training image data, f θ (x i ) is the latent feature learned by the feature learning module, W j is the weight of the clustering module, C is the number of weights of the clustering module, and n is the number of training image data.
8. The clustering method according to claim 3, characterized in that The clustering module is a feedforward neural network.
9. An electronic device, characterized in that, Including: A memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, it implements the clustering method according to any one of claims 1 to 8.
10. A computer storage medium, characterized in that, Stored with computer-executable instructions for executing the clustering method according to any one of claims 1 to 8.