Sample expansion method, device, electronic device and storage medium
By acquiring and expanding samples, adjusting sample weights, and directly using them for model training, the problem of poor model training results caused by fake samples in traditional sample expansion methods is solved, and better model training effects are achieved.
Patent Information
- Application Number
- CN202111394872.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-11-23
AI Technical Summary
The traditional sample expansion method mainly generates fake samples, resulting in unsatisfactory model training results and the expected results cannot be achieved.
By obtaining the source sample and the target sample, sample expansion is performed separately, source expansion sample and target expansion sample are generated, and sample weights are adjusted according to the sample characteristics and weights, and sample weights are integrated to avoid generating fake samples, which are directly used for model training.
The model training effect is improved, the problems caused by false samples are avoided, and the model training effect is improved.
Smart Images

Figure CN114298146B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to a sample expansion method, device, electronic device and storage medium. Background Art
[0002] In the process of model training, we often encounter small sample model training scenarios with insufficient samples. Due to the insufficient number of samples, the model training effect is not ideal and is often not representative. Traditional sample expansion methods mostly generate fake samples and train models based on these fake samples, resulting in the model training effect not meeting the expected effect. Summary of the invention
[0003] In order to solve the technical problem that the above-mentioned traditional sample expansion methods mostly generate false samples, and model training is performed based on these false samples, resulting in the model training effect not achieving the expected effect, the embodiments of the present invention provide a sample expansion method, device, electronic device and storage medium.
[0004] In a first aspect of an embodiment of the present invention, a sample expansion method is first provided, the method comprising:
[0005] Acquire a source sample and a target sample, and perform sample expansion on the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample;
[0006] Determine sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample respectively;
[0007] According to the source sample and the target sample, adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively;
[0008] The source sample, the target sample, and the source expanded sample and the target expanded sample after sample weight adjustment are integrated.
[0009] In an optional implementation, the acquiring of the source sample and the target sample includes:
[0010] Determining a source sample and a target sample to be expanded, and determining a similarity between the source sample and the target sample;
[0011] If the similarity exceeds a preset similarity threshold, the source sample and the target sample are acquired.
[0012] In an optional implementation, the performing sample expansion on the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample includes:
[0013] The source sample and the target sample are respectively copied to generate a source expanded sample and a target expanded sample.
[0014] In an optional implementation, the determining the sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample respectively includes:
[0015] If the source sample has a corresponding first sample weight, determining the first sample weight as the sample weight corresponding to the source expanded sample;
[0016] If the target sample has a corresponding second sample weight, the second sample weight is determined to be the sample weight corresponding to the target expanded sample.
[0017] In an optional implementation, the determining the sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample, respectively, further includes:
[0018] If the source sample does not have a corresponding first sample weight, assigning the source sample and the source expanded sample a consistent sample weight;
[0019] If the target sample does not have a corresponding second sample weight, the target sample and the target expanded sample are given a consistent sample weight.
[0020] In an optional implementation, adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes:
[0021] Determining a target sample feature, wherein both the source expanded sample and the target expanded sample include the target sample feature;
[0022] Inputting the source expanded sample, the target expanded sample, and the target sample features in the source expanded sample and the target expanded sample into a preset weight adjustment model;
[0023] Obtaining target sample weights corresponding to the source expanded samples and the target expanded samples output by the preset weight adjustment model;
[0024] According to the source sample and the target sample, the target sample weights corresponding to the source expanded sample and the target expanded sample are adjusted respectively.
[0025] In an optional implementation, adjusting the target sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes:
[0026] Performing model training on the initial model based on the source sample to obtain a first model, and obtaining a first indicator of the first model;
[0027] Performing model training on the initial model based on the source expanded sample to obtain a second model, and obtaining a second indicator of the second model;
[0028] If the first indicator is greater than the second indicator, reducing the weight of the target sample corresponding to the source augmented sample;
[0029] Performing model training on the initial model based on the target sample to obtain a third model, and obtaining a third indicator of the third model;
[0030] Performing model training on the initial model based on the target expanded sample to obtain a fourth model, and obtaining a fourth indicator of the fourth model;
[0031] If the third indicator is greater than the fourth indicator, the target sample weight corresponding to the target expanded sample is increased.
[0032] In a second aspect of an embodiment of the present invention, a sample expansion device is provided, the device comprising:
[0033] A sample acquisition module is used to acquire source samples and target samples;
[0034] A sample expansion module, used to expand the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample;
[0035] A weight determination module, used to determine the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample respectively;
[0036] A weight adjustment module, used for adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample;
[0037] The sample integration module is used to integrate the source sample, the target sample, and the source expanded sample and the target expanded sample after the sample weights are adjusted.
[0038] In a third aspect of an embodiment of the present invention, there is further provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0039] Memory, used to store computer programs;
[0040] The processor is used to implement the sample expansion method described in the first aspect when executing the program stored in the memory.
[0041] In a fourth aspect of the embodiments of the present invention, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the instructions are executed on a computer, the computer executes the sample expansion method described in the first aspect.
[0042] In a fifth aspect of the embodiments of the present invention, a computer program product comprising instructions is also provided. When the computer program product is run on a computer, the computer executes the sample expansion method described in the first aspect.
[0043] The technical solution provided by the embodiment of the present invention obtains source samples and target samples, performs sample expansion on the source samples and target samples respectively, generates source expanded samples and target expanded samples, determines the sample weights corresponding to the source samples, target samples, source expanded samples and target expanded samples respectively, adjusts the sample weights corresponding to the source expanded samples and target expanded samples respectively according to the source samples and target samples, and integrates the source samples, target samples and the source expanded samples and target expanded samples after the sample weights are adjusted. Sample expansion is performed through the source samples and target samples to generate source expanded samples and target expanded samples, adjusts the sample weights corresponding to the source expanded samples and target expanded samples respectively according to the source samples and target samples, and subsequently integrates the source samples, target samples and the source expanded samples and target expanded samples after the sample weights are adjusted, so as to achieve sample expansion, thereby avoiding the generation of false samples, and performing model training based on the integrated samples, and the effect of model training can achieve the expected effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A schematic diagram of an implementation flow of a sample expansion method shown in an embodiment of the present invention;
[0047] Figure 2 It is a schematic diagram of an implementation flow of a sample weight adjustment method shown in an embodiment of the present invention;
[0048] Figure 3 It is a schematic diagram of input / output of a preset weight adjustment model shown in an embodiment of the present invention;
[0049] Figure 4 is a schematic structural diagram of a sample expansion device shown in an embodiment of the present invention;
[0050] Figure 5 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0053] like Figure 1 FIG. 1 is a schematic diagram of an implementation flow of a sample expansion method provided by an embodiment of the present invention. The method is applied to a processor and may specifically include the following steps:
[0054] S101, obtaining a source sample and a target sample, performing sample expansion on the source sample and the target sample respectively, to generate a source expanded sample and a target expanded sample.
[0055] In an embodiment of the present invention, in order to expand the original modeling data set, source samples and target samples in the original modeling data set are obtained, where the source samples correspond to the source domain, and the target samples correspond to the target domain, and both the source samples and the target samples belong to the original modeling data set.
[0056] Among them, in an embodiment of the present invention, the source sample and the target sample can be obtained specifically in the following manner: determine the source sample and the target sample to be expanded, and determine the similarity between the source sample and the target sample. If the similarity exceeds a preset similarity threshold, the source sample and the target sample are obtained.
[0057] For example, in an embodiment of the present invention, source samples and target samples to be expanded are determined from the original modeling data set, and the similarity between the source samples and the target samples is determined. If the similarity exceeds 95%, the source samples and the target samples can be obtained.
[0058] It should be noted that, for the source sample and the target sample, the similarity between the two exceeds the preset similarity threshold, indicating that the two are basically consistent, and the only difference is that the feature values corresponding to the sample features are different. For example, the feature value corresponding to the sample feature in the source sample is 1, while the feature value corresponding to the sample feature in the target sample is 1.1. The embodiment of the present invention is not limited to this.
[0059] In addition, the number of source samples and target samples corresponding to each other may include one or more, and the number of source samples and target samples corresponding to each other may be equal or unequal, and the source samples and target samples contain the same number of sample features (such as user age). For example, there are 1,000 source samples and 1,000 target samples, or there are 1,000 source samples and 500 target samples.
[0060] In addition, for the similarity between the source sample and the target sample, specific reference may be made to relatively mature algorithms currently available on the market, based on which the similarity between the source sample and the target sample may be determined, and the embodiments of the present invention do not limit this.
[0061] After the above steps, the embodiment of the present invention obtains the source samples and the target samples, and preprocesses the source samples and the target samples. The preprocessing here may specifically include preprocessing operations such as missing value checking and sample feature checking, which are not limited in the embodiment of the present invention.
[0062] For the source sample and the target sample, if the preprocessing passes, the samples are expanded respectively to generate source expanded samples and target expanded samples. Here, the expanded source expanded samples are consistent with the source samples, and the target expanded samples are consistent with the target samples.
[0063] Specifically, in an embodiment of the present invention, the source sample and the target sample are copied respectively to generate a source expansion sample and a target expansion sample, thereby completing the expansion of the original modeling data set, and the sample weights of the samples need to be adjusted subsequently.
[0064] For example, in an embodiment of the present invention, a source sample is copied to generate a source expansion sample corresponding to the source sample. Similarly, a target sample is copied to generate a target expansion sample corresponding to the target sample, and the corresponding sample weights need to be adjusted subsequently.
[0065] S102: Determine sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample respectively.
[0066] In the embodiment of the present invention, for the source sample, the target sample, the source expanded sample corresponding to the source sample and the target expanded sample corresponding to the target sample, their corresponding sample weights are initialized, that is, their respective corresponding sample weights are determined.
[0067] For example, in an embodiment of the present invention, for a source sample, a target sample, a source expanded sample corresponding to the source sample, and a target expanded sample corresponding to the target sample, respective corresponding sample weights are determined, as shown in Table 1 below.
[0068] sample Sample weight Source Sample 1 Target sample 1.5 Source augmentation sample 1 Target expansion sample 1.5
[0069] Table 1
[0070] It should be noted that the sample weight, for example 1, indicates the importance of the source sample, the target sample, the source expanded sample corresponding to the source sample, and the target expanded sample corresponding to the target sample in the model training process, and the embodiment of the present invention is not limited to this.
[0071] In addition, in an embodiment of the present invention, the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample can be determined in the following manner: if the source sample has a corresponding first sample weight, the first sample weight is determined to be the sample weight corresponding to the source expanded sample; if the target sample has a corresponding second sample weight, the second sample weight is determined to be the sample weight corresponding to the target expanded sample.
[0072] For example, in an embodiment of the present invention, for a source sample, if there is a corresponding first sample weight for the source sample, it means that there is a corresponding initial sample weight for the source sample, then the corresponding initial sample weight for the source sample can be assigned to the source expansion sample, that is, the first sample weight is determined to be the sample weight corresponding to the source expansion sample.
[0073] Similarly, in an embodiment of the present invention, for a target sample, if there is a corresponding second sample weight for the target sample, it means that there is a corresponding initial sample weight for the target sample, then the corresponding initial sample weight for the target sample can be assigned to the source expanded sample, that is, the second sample weight is determined to be the sample weight corresponding to the target expanded sample.
[0074] In addition, if the source sample does not have a corresponding first sample weight, the source sample and the source expanded sample are given the same sample weight; if the target sample does not have a corresponding second sample weight, the target sample and the target expanded sample are given the same sample weight.
[0075] For example, for the source sample, if the source sample does not have a corresponding first sample weight, it means that the source sample does not have a corresponding initial sample weight. At this time, the source sample and the source expanded sample can be given the same sample weight, for example, the sample weights of the source sample and the source expanded sample are both 1, as shown in Table 1 above.
[0076] Similarly, for the target sample, if the target sample does not have a corresponding second sample weight, it means that the target sample does not have a corresponding initial sample weight. At this time, the target sample and the target expanded sample can be given the same sample weight, for example, the sample weights of the target sample and the target expanded sample are both 1.5.
[0077] It should be noted that the source sample and the source expanded sample can be assigned consistent sample weights based on empirical values. Similarly, the target sample and the target expanded sample can be assigned consistent sample weights based on empirical values. Of course, other weight assignment methods are also possible, and the embodiments of the present invention are not limited to this.
[0078] S103: According to the source sample and the target sample, adjust the sample weights corresponding to the source expanded sample and the target expanded sample respectively.
[0079] In an embodiment of the present invention, after the above steps, there are corresponding sample weights for the source sample, the target sample, the source expanded sample and the target expanded sample. Here, it is necessary to adjust the sample weights corresponding to the source expanded sample and the target expanded sample, specifically, to adjust the sample weights according to the above source samples and target samples.
[0080] Among them, Figure 2 FIG. 1 is a schematic diagram of an implementation flow of a sample weight adjustment method provided by an embodiment of the present invention. The method is applied to a processor and may specifically include the following steps:
[0081] S201, determining a target sample feature, wherein both the source expanded sample and the target expanded sample include the target sample feature.
[0082] In an embodiment of the present invention, a target sample feature (also referred to as a target variable) is determined, wherein both the source expanded sample and the target expanded sample include the target sample feature, but the difference is that the feature value corresponding to the target sample feature in the source expanded sample is different from the feature value corresponding to the target sample feature in the target expanded sample, which means that there is a difference in the marginal distribution of the source expanded sample and the target expanded sample.
[0083] For example, in an embodiment of the present invention, a user can specify a corresponding target sample feature in the source expanded sample or the target expanded sample according to the importance of the sample feature, so that the embodiment of the present invention can determine a corresponding target sample feature in the source expanded sample or the target expanded sample specified by the user.
[0084] S202: Input the source expanded sample, the target expanded sample, and the target sample features in the source expanded sample and the target expanded sample into a preset weight adjustment model.
[0085] In an embodiment of the present invention, source expanded samples, target expanded samples, and corresponding target sample features in the source expanded samples and the target expanded samples are input into a preset weight adjustment model, so that the sample weights corresponding to the source expanded samples and the target expanded samples are initially adjusted.
[0086] It should be noted that the preset weight adjustment model may specifically contain a fit method, a predict method, a predict_proba method, and a weights attribute, and may be a binary supervised machine learning algorithm, such as a logistic regression algorithm, which is not limited in the embodiments of the present invention.
[0087] For example, in an embodiment of the present invention, the source expanded samples, the target expanded samples, and the corresponding target sample features in the source expanded samples and the target expanded samples are input into a logistic regression model, so that the sample weights corresponding to the source expanded samples and the target expanded samples are initially adjusted.
[0088] S203: Obtain target sample weights corresponding to the source expanded samples and the target expanded samples respectively output by the preset weight adjustment model.
[0089] In an embodiment of the present invention, for a preset weight adjustment model, the sample weights corresponding to the source expanded samples and the target expanded samples can be adjusted respectively, so that the target sample weights corresponding to the source expanded samples and the target expanded samples output by the preset weight adjustment model can be obtained, which means that the sample weights corresponding to the source expanded samples and the target expanded samples are adjusted to the target sample weights.
[0090] For example, in the embodiment of the present invention, for the preset weight adjustment model, the sample weights corresponding to the source expansion sample and the target expansion sample can be adjusted, such as Figure 3 As shown, the target sample weight 1.5 and the sample weight 0.8 corresponding to the target expanded sample output by the preset weight adjustment model are obtained, which means that the sample weight 1 of the source expanded sample is adjusted to the target sample weight 1.5, and the sample weight 1 corresponding to the target expanded sample is adjusted to the target sample weight 0.8.
[0091] S204: According to the source sample and the target sample, adjust the target sample weights corresponding to the source expanded sample and the target expanded sample respectively.
[0092] In the embodiment of the present invention, for the target sample weights corresponding to the source expanded sample and the target expanded sample respectively, the target sample weights corresponding to the source expanded sample and the target expanded sample respectively can be adjusted according to the source sample and the target sample.
[0093] Specifically, the initial model is trained based on the source sample to obtain a first model, and a first indicator of the first model is obtained; the initial model is trained based on the source expansion sample to obtain a second model, and a second indicator of the second model is obtained;
[0094] The first indicator of the first model is compared with the second indicator of the second model. If the first indicator is greater than the second indicator, it means that the target sample weight of the source augmented sample affects the training effect of the model. In this case, the target sample weight corresponding to the source augmented sample can be reduced.
[0095] For example, the initial model is trained based on the source sample to obtain a first model, and a first MSE of the first model is obtained; the initial model is trained based on the source expansion sample to obtain a second model, and a second MSE of the second model is obtained;
[0096] The first MSE of the first model is compared with the second MSE of the second model. If the first MSE is greater than the second MSE, it means that the target sample weight of the source augmented sample affects the training effect of the model. In this case, the target sample weight corresponding to the source augmented sample can be reduced.
[0097] It should be noted that, for the first indicator of the first model, compared with the second indicator of the second model, if the first indicator is much larger than the second indicator, the reduction range of the target sample weight corresponding to the source augmented sample is greater, and the embodiment of the present invention is not limited to this.
[0098] Specifically, if the first indicator is (far) greater than the second indicator, the difference between the first indicator and the second indicator can be calculated and divided by the first indicator to calculate a ratio, and then the target sample weight corresponding to the source expanded sample is reduced according to this ratio. The embodiment of the present invention is not limited to this.
[0099] In addition, the initial model is trained based on the target sample to obtain a third model, and a third indicator of the third model is obtained; the initial model is trained based on the target expanded sample to obtain a fourth model, and a fourth indicator of the fourth model is obtained;
[0100] The third indicator of the third model is compared with the fourth indicator of the fourth model. If the third indicator is greater than the fourth indicator, it means that the target sample weight of the target expansion sample affects the training effect of the model. At this time, the target sample weight corresponding to the target expansion sample can be increased.
[0101] For example, the initial model is trained based on the target sample to obtain a third model, and a third MSE of the third model is obtained; the initial model is trained based on the target expanded sample to obtain a fourth model, and a fourth MSE of the fourth model is obtained;
[0102] The third MSE of the third model is compared with the fourth MSE of the fourth model. If the third MSE is greater than the fourth MSE, it means that the target sample weight of the expanded sample affects the training effect of the model. In this case, the target sample weight corresponding to the target expanded sample can be increased.
[0103] It should be noted that, for the third indicator of the third model, when compared with the fourth indicator of the fourth model, if the third indicator is (far) greater than the fourth indicator, the target sample weight corresponding to the target expansion sample increases more, and the embodiment of the present invention does not limit this.
[0104] Specifically, if the third indicator is (far) greater than the fourth indicator, the difference between the third indicator and the fourth indicator can be calculated and divided by the third indicator to calculate a ratio, and then the target sample weight corresponding to the target expansion sample is increased according to this ratio. The embodiment of the present invention is not limited to this.
[0105] It should be noted that in the embodiment of the present invention, the above steps S201 to S204 may be iteratively executed, and the embodiment of the present invention does not limit this. During this period, the user may adjust the learning rate of the error (i.e., the difference between the first indicator and the second indicator, and the difference between the third indicator and the fourth indicator) according to the response rate of the actual sample.
[0106] The above indicators may specifically be MSE (mean square error), RMSE (root mean square error), MAE (mean absolute error), R-Squared, etc., which are not limited in the embodiments of the present invention.
[0107] S104, integrating the source sample, the target sample, and the source expanded sample and the target expanded sample after sample weight adjustment.
[0108] In the embodiment of the present invention, the source samples, the target samples, and the source expanded samples and the target expanded samples after sample weight adjustment can be integrated, which means that the expanded sample set with sample weights is finally output for the subsequent modeling stage.
[0109] In addition, in the embodiment of the present invention, a ROC graph may be generated, specifically, a ROC graph of source samples, target samples, source expanded samples and target expanded samples after sample weight adjustment, and overall modeling samples.
[0110] Through the above description of the technical solution provided by the embodiment of the present invention, a source sample and a target sample are obtained, sample expansion is performed on the source sample and the target sample respectively, a source expanded sample and a target expanded sample are generated, and the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample are determined. According to the source sample and the target sample, the sample weights corresponding to the source expanded sample and the target expanded sample are adjusted, and the source sample, the target sample and the source expanded sample and the target expanded sample after the sample weights are adjusted are integrated.
[0111] Sample expansion is performed through source samples and target samples to generate source expanded samples and target expanded samples. According to the source samples and target samples, the corresponding sample weights of the source expanded samples and the target expanded samples are adjusted. Subsequently, the source samples, target samples, and the source expanded samples and target expanded samples after the sample weights are adjusted are integrated to achieve sample expansion, thereby avoiding the generation of false samples. Model training is performed based on the integrated samples, and the effect of model training can achieve the expected effect.
[0112] Corresponding to the above method embodiment, the embodiment of the present invention also provides a sample expansion device, such as Figure 4 As shown, the device may include: a sample acquisition module 410, a sample expansion module 420, a weight determination module 430, a weight adjustment module 440, and a sample integration module 450.
[0113] The sample acquisition module 410 is used to acquire source samples and target samples;
[0114] A sample expansion module 420, configured to expand the source sample and the target sample to generate a source expanded sample and a target expanded sample;
[0115] A weight determination module 430 is used to determine the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample respectively;
[0116] A weight adjustment module 440, configured to adjust the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample;
[0117] The sample integration module 450 is used to integrate the source sample, the target sample, and the source expanded sample and the target expanded sample after sample weight adjustment.
[0118] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 51, a communication interface 52, a memory 53 and a communication bus 54, wherein the processor 51, the communication interface 52, and the memory 53 communicate with each other through the communication bus 54.
[0119] A memory 53, for storing computer programs;
[0120] The processor 51 is used to execute the program stored in the memory 53 to implement the following steps:
[0121] A source sample and a target sample are obtained, and sample expansion is performed on the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample; the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample are determined; the sample weights corresponding to the source expanded sample and the target expanded sample are adjusted according to the source sample and the target sample; and the source sample, the target sample and the source expanded sample and the target expanded sample after the sample weights are adjusted are integrated.
[0122] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0123] The communication interface is used for communication between the above electronic device and other devices.
[0124] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0125] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0126] In another embodiment of the present invention, a storage medium is provided. The storage medium stores instructions. When the instructions are executed on a computer, the computer executes the sample expansion method described in any one of the above embodiments.
[0127] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the sample expansion method described in any one of the above embodiments.
[0128] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a storage medium, or transmitted from one storage medium to another storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0129] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0130] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0131] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A sample expansion method, characterized in that: The method comprises: Acquire a source sample and a target sample, and perform sample expansion on the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample; Determine sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample respectively; According to the source sample and the target sample, adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively; Integrating the source sample, the target sample, and the source expanded sample and the target expanded sample after sample weight adjustment; The adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes: Determining a target sample feature, wherein both the source expanded sample and the target expanded sample include the target sample feature; Inputting the source expanded sample, the target expanded sample, and the target sample features in the source expanded sample and the target expanded sample into a preset weight adjustment model; Obtaining target sample weights corresponding to the source expanded samples and the target expanded samples output by the preset weight adjustment model; According to the source sample and the target sample, adjusting the target sample weights corresponding to the source expanded sample and the target expanded sample respectively; The adjusting the target sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes: Performing model training on the initial model based on the source sample to obtain a first model, and obtaining a first indicator of the first model; Performing model training on the initial model based on the source expanded sample to obtain a second model, and obtaining a second indicator of the second model; If the first indicator is greater than the second indicator, reducing the weight of the target sample corresponding to the source augmented sample; Performing model training on the initial model based on the target sample to obtain a third model, and obtaining a third indicator of the third model; Performing model training on the initial model based on the target expanded sample to obtain a fourth model, and obtaining a fourth indicator of the fourth model; If the third indicator is greater than the fourth indicator, the target sample weight corresponding to the target expanded sample is increased.
2. The method according to claim 1, characterized in that The obtaining of source samples and target samples includes: Determining a source sample and a target sample to be expanded, and determining a similarity between the source sample and the target sample; If the similarity exceeds a preset similarity threshold, the source sample and the target sample are acquired.
3. The method according to claim 1, characterized in that The performing sample expansion on the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample includes: The source sample and the target sample are respectively copied to generate a source expanded sample and a target expanded sample.
4. The method according to claim 1, characterized in that The determining the sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample respectively includes: If the source sample has a corresponding first sample weight, determining the first sample weight as the sample weight corresponding to the source expanded sample; If the target sample has a corresponding second sample weight, the second sample weight is determined to be the sample weight corresponding to the target expanded sample.
5. The method according to claim 4, characterized in that The determining of the sample weights corresponding to the source sample, the target sample, the source expanded sample, and the target expanded sample, respectively, further includes: If the source sample does not have a corresponding first sample weight, assigning the source sample and the source expanded sample a consistent sample weight; If the target sample does not have a corresponding second sample weight, the target sample and the target expanded sample are given a consistent sample weight.
6. A sample expansion device, characterized in that: The device comprises: A sample acquisition module is used to acquire source samples and target samples; A sample expansion module, used to expand the source sample and the target sample respectively to generate a source expanded sample and a target expanded sample; A weight determination module, used to determine the sample weights corresponding to the source sample, the target sample, the source expanded sample and the target expanded sample respectively; A weight adjustment module, used for adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample; A sample integration module, used for integrating the source sample, the target sample, and the source expanded sample and the target expanded sample after sample weight adjustment; The adjusting the sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes: Determining a target sample feature, wherein both the source expanded sample and the target expanded sample include the target sample feature; Inputting the source expanded sample, the target expanded sample, and the target sample features in the source expanded sample and the target expanded sample into a preset weight adjustment model; Obtaining target sample weights corresponding to the source expanded samples and the target expanded samples output by the preset weight adjustment model; According to the source sample and the target sample, adjusting the target sample weights corresponding to the source expanded sample and the target expanded sample respectively; The adjusting the target sample weights corresponding to the source expanded sample and the target expanded sample respectively according to the source sample and the target sample includes: Performing model training on the initial model based on the source sample to obtain a first model, and obtaining a first indicator of the first model; Performing model training on the initial model based on the source expanded sample to obtain a second model, and obtaining a second indicator of the second model; If the first indicator is greater than the second indicator, reducing the weight of the target sample corresponding to the source augmented sample; Performing model training on the initial model based on the target sample to obtain a third model, and obtaining a third indicator of the third model; Performing model training on the initial model based on the target expanded sample to obtain a fourth model, and obtaining a fourth indicator of the fourth model; If the third indicator is greater than the fourth indicator, the target sample weight corresponding to the target expanded sample is increased.
7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.
8. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Training sample generation method and device, electronic equipment and storage medium
CN110795552A
Sample expansion method, apparatus and device, and computer readable storage medium
CN111460156A
Sample data generation method for information recommendation and related device
CN111949886A
Cross-subject fatigue driving classification method based on electroencephalogram sample weight adjustment
CN112274154A
Data generation method and device, computer device and storage medium
CN113093967A
