Training data segmentation method and electronic device
By using the encoder of the pre-trained model to obtain feature vectors and evaluate similarity, training images with unique features are selected, which solves the problem of insufficient data caused by random sampling and improves the robustness and generalization ability of the model, especially for effectively training unique disease features in the field of medical imaging.
Patent Information
- Application Number
- CN202410343073.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2025-09-26
AI Technical Summary
The existing random sampling method in training data segmentation may result in a small number of training samples with unique features not being included in the training set, resulting in the machine learning model being unable to effectively learn these unique features, reducing the robustness and generalization of the model, especially in the field of medical imaging.
By using the encoder of the pre-trained model to obtain the feature vectors of the training images and evaluating the feature similarity, target training images with unique features are selected and divided into the training set to improve the data diversity of the training set.
It improves the generalization ability of machine learning models, reduces the risk of overfitting, improves the robustness of models, and enables better learning of features, especially effective training of unique disease features in medical images.
Smart Images

Figure CN120707978A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a training method for a deep learning model, and in particular to a training data segmentation method and an electronic device. Background Art
[0002] During machine learning model training, the training data is typically divided into three parts: a training set, a validation set, and a test set. First, the training set is the primary source of model learning, used to train the model's weights and parameters. Through the training set, the machine learning model learns patterns, features, and predictive power from the data. Second, the validation set is used to adjust the model's hyperparameters to avoid overfitting to the training data. During this process, the machine learning model's performance is evaluated on the validation set, and based on the results, its architecture or parameters are adjusted to improve generalization. This helps ensure that the model is more robust on unseen data. Finally, the test set is used to evaluate the model's performance in real-world application scenarios. The test set, which is new to the machine learning model during training, provides an objective assessment of the model's generalization capabilities. Testing on the test set ensures that the machine learning model achieves the expected results in real-world applications and confirms that it meets project requirements. In summary, the training set is used for model learning, the validation set is used for parameter adjustment, and the test set is used for final performance evaluation. This method of segmenting data helps ensure the reliability and generalization ability of machine learning models, making them more trustworthy in real-world applications.
[0003] Currently, existing methods for segmenting datasets are largely based on random sampling. However, when the training data includes a small number of training examples with unique characteristics, using random sampling to segment data may result in these few training examples not being included in the training set. This can prevent the machine learning model from learning based on the unique characteristics of these few training examples, thereby reducing the model's robustness and generalization. This is particularly true for machine learning in the medical field, where medical images with unique disease characteristics are often rare and difficult to obtain. Summary of the Invention
[0004] In view of this, the present invention provides a training data segmentation method and an electronic device, which can solve the above technical problems.
[0005] An embodiment of the present invention provides a training data segmentation method comprising the following steps: obtaining training data comprising a plurality of training images; obtaining a plurality of feature vectors of the plurality of training images using an encoder of a pre-trained model; evaluating feature similarity between any two of the plurality of feature vectors; selecting a plurality of target training images from the plurality of training images based on the feature similarities associated with the respective feature vectors; and dividing the training data into a training set and a validation set comprising the plurality of target training images, wherein the training set and the validation set are used to train a machine learning model.
[0006] An embodiment of the present invention provides an electronic device comprising a storage device and a processor. The storage device stores a plurality of instructions. The processor is coupled to the storage device and accesses the instructions to perform the following operations. Training data comprising a plurality of training images is obtained. A plurality of feature vectors of the plurality of training images is obtained using an encoder of a pre-trained model. The feature similarity between any two of the plurality of feature vectors is evaluated. Based on the feature similarity associated with each feature vector, a plurality of target training images are selected from the plurality of training images. The training data is divided into a training set and a validation set comprising a plurality of target training images, wherein the training set and the validation set are used to train a machine learning model.
[0007] Based on the above, in embodiments of the present invention, the encoder of a pre-trained model can first be used to obtain the corresponding feature vectors for each training image and calculate the feature similarity between each feature vector and the other feature vectors. Based on the feature similarity between each feature vector and the other feature vectors, multiple target training images that may have unique features can be selected from the multiple training images. By dividing these target training images into a training set, the data diversity of the training set can be increased, thereby improving the generalization ability of the machine learning model. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 is a schematic diagram of an electronic device according to an embodiment of the present invention;
[0009] Figure 2 is a flow chart of a training data segmentation method according to an embodiment of the present invention;
[0010] Figure 3 is a schematic diagram of a pre-training model according to an embodiment of the present invention;
[0011] Figure 4 is a flowchart illustrating the method of dividing a training set and a validation set according to an embodiment of the present invention;
[0012] Figure 5 is a schematic diagram illustrating a training machine learning model according to an embodiment of the present invention;
[0013] Figure 6is a flow chart of a training data segmentation method according to an embodiment of the present invention;
[0014] Figure 7 is a schematic diagram illustrating obtaining a sum of similarities according to an embodiment of the present invention;
[0015] Figure 8 is a flow chart illustrating a method for identifying multiple outlier feature vectors according to an embodiment of the present invention;
[0016] Figure 9 FIG. 4 is a schematic diagram illustrating a training data segmentation method according to an embodiment of the present invention.
[0017] Description of Reference Numerals
[0018] 100: electronic device;
[0019] 102: storage device;
[0020] 104: processor;
[0021] 106: transceiver;
[0022] Img_ori: original image;
[0023] Img_mask: mask image;
[0024] Img_Re: reconstructed image;
[0025] preM1: pre-training model;
[0026] E1: encoder;
[0027] D1: decoder;
[0028] F1, F_1~F_N: feature vector;
[0029] Img_t1~Img_tN: training images;
[0030] 51: original training data;
[0031] 511: training set;
[0032] 512: validation set;
[0033] 513:test set;
[0034] S1, S2, S3: operation;
[0035] TM1: Machine learning models;
[0036] LC1: positive sample category;
[0037] LC2: negative sample category;
[0038] Img_91: the first type of training image;
[0039] Img_92: second category training image;
[0040] F1_1~F1_X: first-class eigenvectors;
[0041] F2_1~F2_Y: second type eigenvector;
[0042] F_M1, F_M2: feature similarity matrix;
[0043] Img_93: first target training image;
[0044] Img_94: second target training image;
[0045] Img_95: the first remaining training image;
[0046] Img_96: the second remaining training image;
[0047] TS91: training set;
[0048] S210~S260, S410~S430, S610~S660, S810~S830: steps. DETAILED DESCRIPTION
[0049] Reference will now be made in detail to exemplary embodiments of the present invention, examples of which are illustrated in the accompanying drawings. Whenever possible, the same reference numerals are used in the drawings and the description to refer to the same or like parts.
[0050] Please refer to Figure 1 , which is a schematic diagram of an electronic device according to an embodiment of the present invention. In different embodiments, the electronic device 100 is, for example, various computer devices, server devices or a combination thereof, but is not limited thereto. Figure 1 As shown, the electronic device 100 may include a transceiver 106 , a storage device 102 , and a processor 104 .
[0051] The storage device 102 is, for example, any type of fixed or removable random access memory (RAM), read-only memory (ROM), flash memory, hard disk or other similar devices or a combination of these devices, and can be used to record multiple program codes or software modules.
[0052] The transceiver 106 transmits and receives signals wirelessly or wired. The transceiver 130 may also perform operations such as low-noise amplification, impedance matching, frequency mixing, up- or down-conversion, filtering, amplification, and the like. The transceiver 106 may also receive data from an external device.
[0053] The processor 104 is coupled to the memory device 102 and the transceiver 106 and can be a general-purpose processor, a special-purpose processor, a conventional processor, a digital signal processor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, a controller, a microcontroller, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), any other type of integrated circuit, a state machine, an Advanced RISC Machine (ARM)-based processor, and the like.
[0054] In an embodiment of the present invention, the processor 104 may access the software modules, program codes or instructions recorded in the storage device 102 to implement the training data segmentation method proposed in the present invention, the details of which are described below.
[0055] Please refer to Figure 2 , which is a flow chart of a training data segmentation method according to an embodiment of the present invention. The method of this embodiment can be Figure 1 The electronic device 100 is executed as follows: Figure 1 Description of components shown Figure 2 Details of each step.
[0056] First, in step S210, the processor 104 obtains training data including a plurality of training images. The aforementioned training data is used to train a machine learning model. This machine learning model is, for example, a U-Net model, a Fully Convolutional Networks (FCN) model, a SegNet model, a Mask R-CNN model, a Generative Adversarial Network (GAN) model or a Transformer model, etc., and the present invention is not limited to this. From another point of view, this machine learning model may be a classification model or an image segmentation model, and the present invention is not limited to this. In different embodiments, the training data may include a plurality of training images that are labeled or unlabeled.
[0057] In step S220, the processor 104 uses an encoder of a pre-trained model to obtain multiple feature vectors of multiple training images. In some embodiments, this pre-trained model is established based on machine learning using a self-supervised learning (SSL) algorithm. The pre-trained model can be pre-trained using a large-scale image data set to learn common features in the image. Once the pre-training is completed, the pre-trained model can be fine-tuned to adapt to specific applications, such as object detection, image classification, image generation, etc. In an embodiment of the present invention, the pre-trained model may include an encoder and an encoder, and the processor 104 uses the encoder to obtain the feature vector corresponding to each training image.
[0058] To make the concept of this operation easier to understand, the following will be supplemented by Figure 3 For further explanation. Figure 3 , which is a schematic diagram of a pre-training model according to an embodiment of the present invention. During the pre-training process of the pre-training model preM1, the processor 104 may first collect a large number of unlabeled original images Img_ori. Then, for each unlabeled original image Img_ori, the processor 104 may mask a portion of the original image Img_ori to generate a corresponding mask image Img_mask. The training goal of the pre-training model preM1 is to correctly predict the masked blocks to restore the image content. Based on this, the processor 104 inputs these mask images Img_mask into the pre-training model preM1 to generate corresponding reconstructed images Img_Re, and may calculate the loss value based on the reconstructed image Img_Re and adjust the model parameters of the pre-training model preM1 based on the loss value. The processor 104 may calculate the above-mentioned loss value according to the L1 loss function, the L2 loss function, or the adversarial loss function, for example, but is not limited thereto. In some embodiments, the pre-trained model preM1 may be, for example, a Masked Autoencoder (MAE) model. For details of the pre-trained model preM1 and its encoder E1, reference may be made to relevant technical literature (e.g., the retinal foundation model titled RETFound, published in the journal Nature in September 2023).
[0059] More specifically, the pre-trained model preM1 includes an encoder E1 and a decoder D1. During the pre-training phase, each mask image Img_mask is input to encoder E1. Encoder E1 extracts the corresponding feature vector F1 from each mask image Img_mask. Decoder D1 generates the corresponding reconstructed image Img_RE based on each feature vector F1.
[0060] like Figure 3As shown, in this embodiment of the present invention, after the pre-training phase is completed, decoder D1 is no longer needed, and the trained encoder E1 can be used as a feature extractor to generate N feature vectors F_1 to F_N for N training images Img_t1 to Img_tN. More specifically, processor 104 can input the N training images Img_t1 to Img_tN one by one into encoder E1 to sequentially generate N feature vectors F_1 to F_N.
[0061] Please return Figure 2 In step S230, the processor 104 evaluates the feature similarity between any two of the plurality of feature vectors. For example, the processor 104 may calculate the cosine similarity, Euclidean distance, or Manhattan distance between a feature vector and another feature vector to generate the feature similarity between the two feature vectors. In some embodiments, the processor 104 may calculate multiple feature similarities between each feature vector and all other feature vectors.
[0062] In step S240, processor 104 selects multiple target training images from the multiple training images based on the feature similarities associated with each feature vector. Based on the feature similarities between each feature vector and the other feature vectors, processor 104 can identify outlier feature vectors that differ significantly from the majority of feature vectors. Processor 104 can then select multiple target training images corresponding to these outlier feature vectors from the multiple training images. Specifically, these target training images corresponding to these outlier feature vectors exhibit relatively unique image features, so processor 104 can add these target training images to the training set to increase the data diversity of the training set.
[0063] In step S250 , the processor 104 divides the training data into a training set and a validation set including a plurality of target training images, wherein the training set and the validation set are used to train the machine learning model.
[0064] Please refer to Figure 4 , which is a flowchart illustrating the process of dividing a training set and a validation set according to an embodiment of the present invention. In some embodiments, step S250 can be implemented as steps S410 to S430.
[0065] In step S410, processor 104 determines the amount of training data in the training set and the amount of validation data in the validation set based on a dataset split ratio. For example, the dataset split ratio between the training set and the validation set may be 7:3, 8:2, or 9:1, but is not limited thereto. That is, the ratio between the amount of training data in the training set and the amount of validation data in the validation set is 7:3, 8:2, or 9:1. However, the dataset split ratio may be set based on actual applications and is not a limitation of the present invention.
[0066] In step S420, the processor 104 selects a plurality of remaining training images from the training data excluding the plurality of target training images based on the amount of training data and the number of the plurality of target training images. In step S430, the processor 104 adds the plurality of target training images and the plurality of remaining training images to the training set.
[0067] For example, assuming the training data includes 1,000 training images, processor 104 may determine, based on the dataset partitioning ratio, that the training set contains 700 training images and the validation set contains 300 validation images. Therefore, assuming that processor 104 obtains 100 target training images based on the feature similarity associated with each feature vector, processor 104 may randomly sample the remaining 600 training images from the training data excluding the 100 target training images (i.e., 900 training images). Processor 104 may add the 100 target training images and the remaining 600 training images to the training set and add the 300 training images not randomly sampled to the validation set.
[0068] However, in other embodiments, processor 104 may select multiple validation training images by randomly sampling from the training data excluding multiple target training images based on the amount of validation data and the number of target training images. Processor 104 may then add these validation training images to the validation set. Furthermore, processor 104 may add training images that were not randomly sampled and target training images to the training set.
[0069] Please refer to Figure 5 , which is a schematic diagram of training a machine learning model according to an embodiment of the present invention. The processor 104 may first randomly sample a test set 513 from the original training data 51. In some embodiments, the processor 104 may perform stratified sampling to extract the test set 513, that is, the processor 104 may randomly sample training data of different sample categories. Then, the processor 104 may determine the training set 511 and the validation set 512 based on the relevant operations of the aforementioned embodiments. Based on this, the original training data 51 will be divided into a training set 511, a validation set 512, and a test set 513 by the processor 104.
[0070] In operation S1, the processor 104 may use the training set 511 and a machine learning algorithm to perform model training. In some embodiments, the processor 104 may perform backpropagation on the machine learning model based on the loss value, thereby adjusting the model parameters of the machine learning model using the gradient descent algorithm. In operation S2, the processor 104 may use the validation set 512 to validate the trained machine learning model and adjust hyperparameters (such as the learning rate, convolution kernel size, or number of convolution kernels) to improve model performance. The processor 104 may repeatedly perform operations S1 and S2 using the training set 511 and validation set 512 until the final machine learning model TM1 achieves the desired performance. Furthermore, each time the processor 104 validates the trained machine learning model using the validation set 512, it obtains evaluation metrics (such as accuracy or F1-score). The processor 104 may then determine the final machine learning model TM1 based on the evaluation metrics generated during each validation. Finally, the processor 104 may use the test set 513 to test the machine learning model TM1 to ultimately evaluate the generalization performance of the machine learning model TM1.
[0071] It should be noted that, in the embodiment of the present invention, since the processor 104 can use the training set 511 including the target training image to perform model training, the model training can be performed based on more unique image features, thereby improving the model generalization ability.
[0072] Please refer to Figure 6 , which is a flow chart of a training data segmentation method according to an embodiment of the present invention. The method of this embodiment can be Figure 1 The electronic device 100 is executed as follows: Figure 1 Description of components shown Figure 6 Details of each step.
[0073] First, in step S610, processor 104 extracts a testing set from the original training data to obtain training data that excludes the testing set and includes multiple training images. In step S620, processor 104 utilizes an encoder of a pre-trained model to obtain multiple feature vectors for the multiple training images. In step S630, processor 104 evaluates the feature similarity between any two of the multiple feature vectors. The details of these steps can be found in the previous embodiments and are not detailed here.
[0074] In step S640, the processor 104 normalizes the feature similarity. Specifically, the processor 104 may normalize the feature similarity to be within a specific numerical range. For example, the processor 104 may normalize the feature similarity to be between 0 and 1.
[0075] In some embodiments, feature similarity is inversely correlated with the degree of similarity between two feature vectors. That is, a smaller feature similarity indicates that the two feature vectors are more similar. Conversely, a larger feature similarity indicates that the two feature vectors are more different. In some embodiments, when processor 104 uses cosine similarity to calculate the feature similarity between two feature vectors, processor 104 may calculate the feature similarity based on the following equation (1).
[0076] Among them, cosθ is the cosine similarity between two eigenvectors, which is between -1 and 1.
[0077] In step S650 , the processor 104 selects a plurality of target training images from the plurality of training images based on the feature similarity associated with each feature vector. Here, step S650 may be implemented as steps S651 to S653 .
[0078] In step S651, the processor 104 calculates the sum of the similarities between each feature vector and a plurality of other feature vectors. Figure 7 For further explanation. Figure 7 , which is a schematic diagram showing how to obtain the sum of similarities according to an embodiment of the present invention.
[0079] Assume that the processor 104 can obtain training data including N training images. Therefore, the processor 104 can use the encoder of the pre-trained model to obtain N feature vectors #1 to #N of the N training images. The processor 104 can calculate the feature similarities s2-1, s3-1, ..., sN-1 between the feature vector #1 and other feature vectors #2 to #N. In addition, the processor 104 can calculate the feature similarity s1-1 between the feature vector #1 and its own feature vectors. Then, the processor 104 can calculate the feature similarities s1-2, s3-2, ..., sN-2 between the feature vector #2 and other feature vectors #1, #3 to #N. In addition, the processor 104 can calculate the feature similarity s2-2 between the feature vector #2 and its own feature vectors. It can be seen that based on the Euclidean distance or cosine similarity, the feature similarities s1-1 and s2-2 are 0. Repeat the above operation of calculating feature similarity for feature vectors #3 to #N, and the processor 104 can obtain the following. Figure 7The feature similarity matrix (NxN) shown is a feature similarity matrix in which each matrix element represents the feature similarity between two feature vectors #1 to #N.
[0080] Next, processor 104 may sum all matrix elements corresponding to the row (column) of eigenvector #1 to obtain the summed similarity A1 corresponding to eigenvector #1. Similarly, processor 104 may sum all matrix elements corresponding to the row (column) of eigenvector #2 to obtain the summed similarity A2 corresponding to eigenvector #2. Following a similar operation, processor 104 may obtain the summed similarities A3-AN corresponding to eigenvectors #3-#N, respectively.
[0081] In step S652, the processor 104 identifies a plurality of outlier feature vectors from the plurality of feature vectors according to the sum of similarities corresponding to the respective feature vectors. Figure 7 As shown, N feature vectors #1 to #N correspond to N similarity sums A1 to AN respectively.
[0082] In some embodiments, the processor 104 may sort the sums of similarities corresponding to the feature vectors and determine multiple outlier feature vectors based on the sorting results. For example, the feature vectors corresponding to the top few sums of similarities may be identified as multiple outlier feature vectors.
[0083] In some embodiments, the sum of similarities of the outlier feature vectors is compared to a threshold value to determine that the outlier condition is met. In some embodiments, the outlier condition is that the sum of similarities is greater than the threshold value. In other words, when the sum of similarities corresponding to a feature vector is greater than the threshold value, the processor 104 identifies the feature vector as an outlier feature vector.
[0084] Please refer to Figure 8 , which is a flow chart illustrating a method for identifying multiple outlier feature vectors according to an embodiment of the present invention. In some embodiments, step S652 may be implemented as steps S810 to S830.
[0085] In step S810, the processor 104 performs a statistical analysis on the sums of similarities corresponding to the plurality of feature vectors to determine a threshold value for filtering out outliers. In some embodiments, the processor 104 may calculate the first quartile (Q1) and the third quartile (Q3) of the sums of similarities corresponding to the plurality of feature vectors, and determine the interquartile range (IQR) based on the difference between the first quartile and the third quartile. The processor 104 may then determine the threshold value according to the following equation (2).
[0086] Threshold value = third quartile + 1.5 * interquartile range (2)
[0087] In step S820, the processor 104 compares the sum of similarities corresponding to each feature vector with a threshold value. In some embodiments, the processor 104 determines whether the sum of similarities corresponding to each feature vector is greater than the threshold value.
[0088] In step S830, in response to the comparison result of the sum of similarities of each outlier feature vector in the plurality of feature vectors with the threshold value meeting the outlier condition, the processor 104 identifies a plurality of outlier feature vectors from the plurality of feature vectors. In some embodiments, if the sum of similarities corresponding to a feature vector is greater than the threshold value, the comparison result meets the outlier condition, and the feature vector is identified as an outlier feature vector.
[0089] Please return Figure 6 In step S653, processor 104 selects multiple target training images corresponding to multiple outlier feature vectors from the multiple training images. Subsequently, in step S660, processor 104 divides the training data into a training set comprising the multiple target training images and a validation set. Detailed descriptions of this step can be found in the previous embodiment and are not repeated here.
[0090] It should also be noted that in some embodiments, when the training data is used to train a classification model, processor 104 may first classify the feature vectors into different feature groups based on the sample categories of the training data. The present invention does not limit the number of sample categories, which may be determined based on the actual application. Processor 104 then sequentially obtains training set data and validation set data corresponding to each sample category based on the different feature groups.
[0091] In some embodiments, the plurality of training images include a plurality of first-category training images belonging to a first sample category and a plurality of second-category training images belonging to a second sample category. In other words, the first-category training images are labeled as belonging to the first sample category, and the second-category training images are labeled as belonging to the second sample category.
[0092] In some embodiments, the processor 104 may classify the plurality of feature vectors into a plurality of first-category feature vectors and a plurality of second-category feature vectors based on the sample category of each training image. That is, the feature vectors of the first-category training images are first-category feature vectors, and the feature vectors of the second-category training images are second-category feature vectors.
[0093] In some embodiments, the processor 104 may evaluate the first feature similarity between any two of the plurality of first-category feature vectors, and evaluate the second feature similarity between any two of the plurality of second-category feature vectors. The detailed operations for evaluating the first feature similarity and the second feature similarity can be found in the description of the aforementioned embodiments and are not further described here.
[0094] Subsequently, processor 104 may select multiple first target training images from the multiple first-category training images based on the first feature similarities associated with each first-category feature vector. Furthermore, processor 104 may select multiple second target training images from the multiple second-category training images based on the second feature similarities associated with each second-category feature vector. The detailed operations for selecting the first target training images and the second target training images can be found in the aforementioned embodiments and are not further described here. Accordingly, the training set may include multiple first target training images belonging to the first sample category and multiple second target training images belonging to the second sample category.
[0095] For example, Figure 9 FIG is a schematic diagram showing a method for segmenting training data according to an embodiment of the present invention. Figure 9 The plurality of training images includes X first-category training images Img_91 belonging to the positive sample class LC1 and Y second-category training images Img_92 belonging to the negative sample class LC2. In other words, the first-category training images Img_91 are labeled as positive samples, while the second-category training images Img_92 are labeled as negative samples.
[0096] Afterwards, the processor 104 sequentially inputs X first-category training images Img_91 into the encoder E1 to obtain X first-category feature vectors F1_1 to F1_X, and then generates the first-category feature vectors F1_1 to F1_X according to the first-category feature vectors F1_1 to F1_X. Figure 7 Based on the principle shown, a feature similarity matrix F_M1 is generated based on the first-category eigenvectors F1_1 to F1_X. Processor 104 can then select a number of first target training images Img_93 from the X first-category training images Img_91 based on feature similarity matrix F_M1. Processor 104 can then select first remaining training images Img_95 through random sampling based on the number of first target training images Img_93 and the data set partitioning ratio.
[0097] For example, assuming X is 800, the number of first target training images Img_93 is 100, and the data set split ratio between the training set and the validation set is 7:3, processor 104 may randomly select 460 first remaining training images Img_95 from the 700 first-category training images Img_91 excluding the first target training image Img_93 (i.e., 700 = 800 - 100), and add the 100 first target training images Img_93 and the 460 first remaining training images Img_95 to the training set TS91. Furthermore, processor 104 adds the remaining 240 first-category training images Img_91 (i.e., 240 = 800 - 100 - 460) to the validation set.
[0098] On the other hand, the processor 104 sequentially inputs Y second-category training images Img_92 to the encoder E1 to obtain Y second-category feature vectors F2_1 to F2_Y, and Figure 7 Based on the principle shown, a feature similarity matrix F_M2 is generated based on the second-category eigenvectors F2_1 to F2_Y. Processor 104 can then select a number of second target training images Img_94 from the Y second-category training images Img_92 using feature similarity matrix F_M2. Processor 104 can then select second remaining training images Img_96 through random sampling based on the number of second target training images Img_94 and the dataset partition ratio.
[0099] For example, assuming Y is 1000, the number of second target training images Img_94 is 120, and the data set split ratio between the training set and the validation set is 7:3, processor 104 may randomly select 580 second remaining training images Img_96 from the 880 second-category training images Img_92 excluding the second target training image Img_94 (i.e., 880 = 1000 - 120), and add the 120 second target training images Img_94 and the 580 second remaining training images Img_96 to training set TS91. Furthermore, processor 104 adds the remaining 300 second-category training images Img_92 (i.e., 300 = 1000 - 120 - 580) to the validation set.
[0100] Therefore, the processor 104 may eventually obtain a training set TS91 including the first target training image Img_93 , the first remaining training image Img_95 , the second target training image Img_94 , and the second remaining training image Img_96 .
[0101] In summary, in an embodiment of the present invention, the encoder of the pre-trained model can be used to first obtain the corresponding feature vectors of each training image, and the feature similarity between each feature vector and other feature vectors can be calculated. Based on the feature similarity between each feature vector and other feature vectors, multiple target training images that may have unique features can be selected from multiple training images. Therefore, by dividing these target training images into training sets, the data diversity of the training sets can be effectively improved, thereby improving the generalization ability of the machine learning model, reducing the risk of overfitting, improving the robustness of the model, and obtaining better feature learning results. The trained machine learning model can perform well in various application scenarios. In particular, in the field of imaging medicine, where medical images with unique disease characteristics are difficult to obtain, the embodiment of the present invention can effectively train the machine learning model for unique disease characteristics so that the prediction results of the model meet expectations.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A training data segmentation method, characterized in that: include: Obtaining training data including a plurality of training images; Obtaining a plurality of feature vectors of the plurality of training images using an encoder of a pre-trained model; Evaluating feature similarity between any two of the plurality of feature vectors; selecting a plurality of target training images from the plurality of training images based on the feature similarities associated with each of the plurality of feature vectors; as well as The training data is divided into a training set and a validation set including the multiple target training images, wherein the training set and the validation set are used to train a machine learning model.
2. The training data segmentation method according to claim 1, characterized in that The pre-training model is established by performing machine learning based on a self-supervised learning algorithm.
3. The training data segmentation method according to claim 1, wherein: The step of acquiring the training data including the plurality of training images comprises: A test set is extracted from the original training data to obtain the training data excluding the test set.
4. The training data segmentation method according to claim 1, wherein: After the step of evaluating the feature similarity between any two of the plurality of feature vectors, the method further comprises: The feature similarity is normalized.
5. The training data segmentation method according to claim 1, wherein: The step of selecting the plurality of target training images from the plurality of training images according to the feature similarities associated with each of the plurality of feature vectors comprises: Calculating a sum of similarities of the plurality of feature similarities between each of the plurality of feature vectors and a plurality of other feature vectors; identifying a plurality of outlier feature vectors from the plurality of feature vectors according to the sum of the similarities corresponding to each of the plurality of feature vectors; and The plurality of target training images corresponding to the plurality of outlier feature vectors are selected from the plurality of training images.
6. The training data segmentation method according to claim 5, characterized in that: A comparison result of the sum of the similarities of each of the plurality of outlier feature vectors with a threshold value meets an outlier condition.
7. The training data segmentation method according to claim 6, characterized in that: The step of identifying the plurality of outlier feature vectors from the plurality of feature vectors comprises: Performing statistical analysis on the sums of the similarities corresponding to the plurality of feature vectors to determine the threshold value for filtering out outliers; comparing the sum of the similarities corresponding to each of the plurality of feature vectors with the threshold value; and In response to a comparison result of the sum of the similarities of each of the plurality of outlier feature vectors in the plurality of feature vectors with the threshold value meeting the outlier condition, the plurality of outlier feature vectors are identified from the plurality of feature vectors.
8. The training data segmentation method according to claim 6, characterized in that: The outlier condition is that the sum of the similarities is greater than the threshold value.
9. The training data segmentation method according to claim 1, wherein: The step of dividing the training data into the training set and the validation set including the plurality of target training images comprises: Determine the amount of training data for the training set and the amount of verification data for the verification set according to the data set segmentation ratio; selecting a plurality of remaining training images from the training data excluding the plurality of target training images based on the amount of the training data and the number of the plurality of target training images; and The plurality of target training images and the plurality of remaining training images are added to the training set.
10. The training data segmentation method according to claim 1, wherein: The step of evaluating the feature similarity between any two of the plurality of feature vectors comprises: Classifying the plurality of feature vectors into a plurality of first-category feature vectors and a plurality of second-category feature vectors according to the sample categories of the plurality of training images; and A first feature similarity between any two of the plurality of first-category feature vectors is evaluated, and a second feature similarity between any two of the plurality of second-category feature vectors is evaluated.
11. The training data segmentation method according to claim 10, characterized in that: The plurality of training images include a plurality of first-category training images belonging to a first sample category and a plurality of second-category training images belonging to a second sample category, and the step of selecting the plurality of target training images from the plurality of training images based on the feature similarity associated with each of the plurality of feature vectors includes: selecting a plurality of first target training images from the plurality of first-category training images according to the first feature similarities associated with each of the plurality of first-category feature vectors; and selecting a plurality of second target training images from the plurality of second type training images according to the second feature similarities associated with each of the plurality of second type feature vectors, The training set includes the plurality of first target training images belonging to the first sample category and the plurality of second target training images belonging to the second sample category.
12. An electronic device, characterized in that: include: a storage device storing a plurality of instructions; as well as a processor coupled to the storage device and configured to: Obtaining training data including a plurality of training images; Obtaining a plurality of feature vectors of the plurality of training images using an encoder of a pre-trained model; Evaluating feature similarity between any two of the plurality of feature vectors; selecting a plurality of target training images from the plurality of training images based on the feature similarities associated with each of the plurality of feature vectors; as well as The training data is divided into a training set and a validation set including the multiple target training images, wherein the training set and the validation set are used to train a machine learning model.
Citation Information
Cited By
Training data splitting method and electronic device
US20250252718A1