A model training method, device and equipment
By adding noise data to model training and using gradient adversarial attack algorithms, combined with blockchain smart contracts, the problems of model decay and black field attacks are solved, the anti-attack ability and robustness of the model are improved, and performance and security are ensured sex.
Patent Information
- Application Number
- CN202111574537.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-12-21
AI Technical Summary
Models are prone to decline when faced with changes in the external environment and business factors, leading to performance degradation and are difficult to predict. It is necessary to improve the attack resistance and robustness of the model to resist black field attacks.
By obtaining training samples, adding noise data and using gradient-based adversarial attack algorithms to train the model, a model with stronger attack resistance is generated, and smart contracts are deployed in the blockchain system to enhance the traceability and security of the training process. sex.
It significantly improves the attack resistance and robustness of the model, reduces the risk of model decay and blackfield attacks, and ensures the stability and security of model performance.
Smart Images

Figure CN114241268B
Abstract
Description
Technical Field
[0001] This document relates to the field of computer technology, and in particular to a model training method, device and equipment. Background Art
[0002] Models involved in many scenarios (such as risk prevention and control models for business security, etc.) will inevitably face the problem of model decay. The problem of model decay is usually caused by factors such as the external environment, the corresponding business, and black field attacks and defenses. Model decay will cause the model to change over time. Since the above changes are unpredictable and unknown, the performance of the model will decline rapidly. In order to slow down model decay and resist black field attacks, it is necessary to plan ahead when training the model to improve the model's anti-attack ability and robustness. To this end, it is necessary to provide a model training solution that can significantly improve the model's anti-attack ability and robustness. Summary of the invention
[0003] The purpose of the embodiments of this specification is to provide a model training solution that can significantly improve the model's anti-attack capability and robustness.
[0004] In order to implement the above technical solution, the embodiments of this specification are implemented as follows:
[0005] An embodiment of the present specification provides a model training method, the method comprising: obtaining a first number of first training samples. Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples. Based on the remaining first training samples and the second number of second training samples, a target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0006] A model training method provided in an embodiment of this specification is applied to a blockchain system, and the method includes: obtaining training rule information of a target model, using the training rule information of the target model to generate a corresponding smart contract, and deploying the smart contract to the blockchain system. Call the smart contract to obtain a first number of first training samples. Based on the smart contract, select a second number of first training samples from the first number of first training samples, and add corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples. Based on the smart contract, use the remaining first training samples and the second number of second training samples to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0007] The embodiment of the present specification provides a model training device, the device comprising: a sample acquisition module, which acquires a first number of first training samples; a sample processing module, which selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples; a training module, which trains a target model based on the remaining first training samples and the second number of second training samples by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0008] A model training device provided in an embodiment of the present specification is a device in a blockchain system, and the device includes: a contract deployment module, which obtains the training rule information of the target model, generates a corresponding smart contract using the training rule information of the target model, and deploys the smart contract to the blockchain system. A sample acquisition module, which calls the smart contract to obtain a first number of first training samples. A sample processing module, which selects a second number of first training samples from the first number of first training samples based on the smart contract, and adds corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples. A training module, which uses the remaining first training samples and the second number of second training samples based on the smart contract to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0009] A model training device provided in an embodiment of the present specification includes: a processor; and a memory arranged to store computer executable instructions, wherein when the executable instructions are executed, the processor: obtains a first number of first training samples. Selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples. Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0010] A model training device provided in an embodiment of the present specification is a device in a blockchain system, and the model training device includes: a processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to: obtain the training rule information of the target model, generate a corresponding smart contract using the training rule information of the target model, and deploy the smart contract to the blockchain system. The smart contract is called to obtain a first number of first training samples. Based on the smart contract, a second number of first training samples are selected from the first number of first training samples, and corresponding noise data are added to the second number of first training samples, respectively, to obtain the second number of second training samples. Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0011] The embodiment of the present specification also provides a storage medium, wherein the storage medium is used to store computer executable instructions, and the executable instructions implement the following process when executed: obtain a first number of first training samples. Select a second number of first training samples from the first number of first training samples, and add corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples. Based on the remaining first training samples and the second number of second training samples, train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0012] The embodiments of this specification also provide a storage medium, wherein the storage medium is used to store computer executable instructions, and the executable instructions implement the following process when executed: obtain the training rule information of the target model, use the training rule information of the target model to generate a corresponding smart contract, and deploy the smart contract to the blockchain system. Call the smart contract to obtain a first number of first training samples. Based on the smart contract, select a second number of first training samples from the first number of first training samples, and add corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples. Based on the smart contract, use the remaining first training samples and the second number of second training samples to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of this specification 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, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0014] Figure 1 This is an embodiment of a training method for a model in this specification;
[0015] Figure 2 This is a structural diagram of the training-related interface of a model in this manual;
[0016] Figure 3 This is another training method embodiment of a model in this specification;
[0017] Figure 4 This is a schematic diagram of the training process of a model in this manual;
[0018] Figure 5A This is another embodiment of a training method for a model of the present specification;
[0019] Figure 5B This is a schematic diagram of the training process of another model in this manual;
[0020] Figure 6 This is a training device embodiment of a model of this specification;
[0021] Figure 7 This is another model training device embodiment of this specification;
[0022] Figure 8 This is a training device embodiment of a model of this specification. DETAILED DESCRIPTION
[0023] The embodiments of this specification provide a model training method, device and equipment.
[0024] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0025] Embodiment 1
[0026] like Figure 1As shown, an embodiment of this specification provides a model training method, and the execution subject of the method can be a terminal device or a server, wherein the terminal device can be a mobile terminal device such as a mobile phone, a tablet computer, or a personal computer, etc. The server can be an independent server, or a server cluster composed of multiple servers, etc. The server can be a background server for financial services or online shopping services, or a background server for an application, etc. This method can be applied to related scenarios with model training, etc. In this embodiment, the server is used as the execution subject for detailed description. For the case of terminal devices, please refer to the following related content, which will not be repeated here. The method can specifically include the following steps:
[0027] In step S102, a first number of first training samples are obtained.
[0028] The first number can be set according to actual conditions, such as 100,000 or 1,000,000, etc. The first training sample can include multiple types, which can be set according to the model to be trained. For example, if the model to be trained is a facial recognition model, the first training sample can be a facial image. For another example, if the model to be trained is a fingerprint recognition model, the first training sample can be fingerprint data. For another example, if the model to be trained is a risk prevention and control model for a certain business (such as an online transaction business), the first training sample can be the business data of the business (which can include relevant information of the two parties to the transaction, resource information of the transaction, transaction time, transaction location, transaction history data of the two parties to the transaction, etc.).
[0029] In implementation, models involved in many scenarios (such as risk prevention and control models for business security, etc.) will inevitably face the problem of model decay. The problem of model decay is usually caused by factors such as the external environment, the corresponding business, and black field attack and defense. Model decay will cause the model to change over time. Since the above changes are unpredictable and unknown, the performance of the model will decline rapidly. In order to slow down model decay and resist black field attacks, it is necessary to prepare for the model when training it to improve the model's anti-attack ability and robustness. To this end, it is necessary to provide a model training solution that can significantly improve the model's anti-attack ability and robustness. The embodiments of this specification provide an achievable technical solution, which may specifically include the following:
[0030] The first number of first training samples can be obtained in a variety of different ways. For example, an input page for training samples can be pre-set, and the input page can include a data input box for the training samples, a confirmation button, and a cancel button. When a training sample (i.e., the first training sample) needs to be uploaded to the server, the data on the input page can be obtained and the input page can be displayed. Figure 2As shown, the user can enter the data of the first training sample in the data input box of the input page. After the input is completed, the user can click the confirmation button in the input page. At this time, the server can obtain the first training sample, and the first number of first training samples can be obtained in the above manner. Alternatively, the server can record the relevant data of a certain business. When the first training sample needs to be obtained, the data that meets the specified requirements can be obtained from the relevant data of the above business, and the obtained data can be used as the first number of first training samples, etc. In addition to obtaining the first training sample in the above manner, the first number of first training samples can also be obtained in a variety of different ways, which can be set according to actual conditions, and the embodiments of this specification do not limit this.
[0031] In step S104, a second number of first training samples are selected from the first number of first training samples, and corresponding noise data are added to the second number of first training samples respectively to obtain a second number of second training samples.
[0032] Among them, the second number can be set according to actual conditions, and the second number is less than or equal to the first number. For example, the first number can be 100,000, and the second number can be 50,000 or 40,000, etc., which is not limited in this embodiment of the present specification. Noise data can be obtained in a variety of different ways. For example, noise data that meets specified conditions can be generated by a pre-built noise generation mechanism, or random noise data can be obtained in a variety of different ways, etc., which can be set specifically according to actual conditions, which is not limited in this embodiment of the present specification. In addition, the same noise data can be added to the first training samples of the second number, or different noise data can be added separately, etc., which can be set specifically according to actual conditions.
[0033] In implementation, the second number of first training samples can be randomly selected from the first number of first training samples by random selection. In addition, the noise data that needs to be added to each first training sample in the second number of first training samples can be obtained in advance, wherein the noise data added to each first training sample can be the same or different. After selecting the second number of first training samples, the corresponding noise data obtained above can be added to each first training sample in the second training samples, so that the second training samples obtained by adding the corresponding noise data to each first training sample can be obtained. In the above manner, the second number of second training samples can be obtained.
[0034] In step S106, based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0035] Among them, the gradient-based adversarial attack algorithm can be an algorithm that adds a small disturbance (such as noise data, etc.) to the input data, and finally causes the classifier to misclassify. For example, by adding a pre-set disturbance noise to the picture, the classification result finally obtained by the classifier is wrong, or by replacing some words in a sentence with synonyms, the final result of sentiment classification is wrong, etc., which can be set according to the actual situation. The gradient-based adversarial attack algorithm can include a variety of algorithms, such as FGSM (Fast Gradient Sign Method, fast gradient descent algorithm), PGD (Project Gradient Descent, projected gradient descent), MIM (Momentum Iterative Method, momentum iteration method), etc., which can be set according to the actual situation, and the embodiments of this specification do not limit this. The target model can be any model, for example, the target model can be a facial recognition model, a fingerprint recognition model, or a risk prevention and control model constructed for a certain business (such as financial business, etc.) (for example, it can be a risk prevention and control model for fraud risk, etc.), which can be set according to the actual situation, and the embodiments of this specification do not limit this.
[0036] In implementation, after selecting the second number of first training samples from the first number of first training samples in the above manner, the remaining first training samples may be the third number of first training samples, wherein the third number is the difference between the first number and the second number (i.e., the third number = the first number - the second number), so that the third number of first training samples and the second number of second training samples may be used as samples for model training. In addition, in order to improve the anti-attack capability and stability of the model, an adversarial attack algorithm may be pre-set, and the model may be trained by the adversarial attack algorithm. In this embodiment, the pre-set adversarial attack algorithm may be a gradient-based adversarial attack algorithm. Taking the gradient-based adversarial attack algorithm FGSM as an example, a loss function will be set in the training process of the target model. A training sample can be selected from the third number of first training samples or the second number of second training samples, and the selected training sample can be input into the target model. The corresponding gradient of the input training sample is calculated using the loss function of the target model to obtain the adversarial perturbation. Then, the obtained adversarial perturbation can be added to the selected training sample to generate an adversarial sample. The loss function is linearized in the field of the selected training sample, and the maximum value of the precise linearization function is found through the specified algorithm. Then, the corresponding gradient can be obtained, and the parameters in the target model can be updated based on the gradient. Afterwards, other training samples can be processed accordingly in the above manner to update the parameters in the target model, and finally a target function with relatively accurate and convergent parameters can be obtained, that is, the trained target model.
[0037] The embodiments of the present specification provide a model training method, which obtains a first number of first training samples, selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples to obtain a second number of second training samples. Based on the remaining first training samples and the second number of second training samples, a target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a portion of the first training samples. Then, based on the first training samples and the second training samples, and in combination with the gradient-based adversarial attack algorithm, the anti-attack capability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0038] Embodiment 2
[0039] like Figure 3 As shown, an embodiment of this specification provides a model training method, and the execution subject of the method can be a terminal device or a server, wherein the terminal device can be a mobile terminal device such as a mobile phone, a tablet computer, or a personal computer, etc. The server can be an independent server, or a server cluster composed of multiple servers, etc. The server can be a background server for financial services or online shopping services, or a background server for an application, etc. This method can be applied to related scenarios with model training, etc. In this embodiment, the server is used as the execution subject for detailed description. For the case of terminal devices, please refer to the following related content, which will not be repeated here. The method can specifically include the following steps:
[0040] In step S302, a first number of first training samples are obtained.
[0041] In step S304, based on a preset sample selection strategy, a second number of first training samples are selected from the first number of first training samples.
[0042] Among them, the sample selection strategy can be to select training samples that meet specified conditions from a certain number of training samples, wherein the specified conditions can be set according to actual conditions, specifically, for example, the specified condition can be that the ratio between the number of selected training samples and the total number of training samples before selection satisfies a specified proportional relationship, such as the ratio between the number of selected training samples and the total number of training samples before selection is 1:2 or 1:3, etc., which can be set specifically according to actual conditions, or the specified condition can also be to select training samples containing one or more specific information from the training samples, or the specified condition can also be to select training samples of a specified type (such as a type corresponding to a risk of fraud, etc.) from the training samples, etc., which can be set specifically according to actual conditions, and the embodiments of this specification do not limit this. Based on the above content, the second number and the first number meet a preset proportional relationship.
[0043] In implementation, a sample selection strategy can be pre-set according to actual conditions. After obtaining a first number of first training samples, the pre-set sample selection strategy can be obtained, and the content of the sample selection strategy can be analyzed. The first training samples that comply with the sample selection strategy can be selected from the first number of first training samples according to the strategy content involved in the sample selection strategy, thereby obtaining a second number of first training samples. Specifically, for example, a certain number of first training samples can be randomly selected from the first number of first training samples, wherein the ratio of the number of selected first training samples to the first number is 1:2, thereby obtaining a second number (i.e., 1 / 2 of the first number), and obtaining a second number of first training samples.
[0044] In step S306, noise data corresponding to each first training sample in the second number of first training samples is respectively obtained.
[0045] In implementation, Figure 4 As shown, a noise generation mechanism NoiseMaker can be pre-constructed, and corresponding noise data can be generated for each first training sample in the second number of first training samples through the noise generation mechanism NoiseMaker. In practical applications, the above-mentioned process of generating noise data can be implemented through a denoising auto-encoder (Denoising Auto-encoder, DAE), wherein the denoising auto-encoder DAE can be a processing mechanism set up on the basis of the auto-encoder Autoencoder to add noise data to the input data of the input layer of the model (which can be part of the training samples) in order to prevent overfitting problems, and reconstruct the input parameters at the output layer of the model, so that the learned encoder has strong robustness, thereby enhancing the generalization ability of the model.
[0046] The specific processing of the above step S306 can be varied. The following is an optional processing method, which may specifically include the following: randomly generating noise data for each first training sample in the second number of first training samples.
[0047] In implementation, corresponding noise data may be randomly generated for each of the first training samples through a noise generation mechanism NoiseMaker or a noise reduction auto encoder DAE.
[0048] In step S308, based on the acquired noise data, corresponding noise data is added to each first training sample in the second number of first training samples to obtain a second number of second training samples.
[0049] In step S310, based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset first loss function to obtain a representation vector corresponding to each training sample and a first loss information corresponding to the first loss function, and the training samples include the remaining first training samples and the second number of second training samples.
[0050] In implementation, for any training sample in the third number of first training samples and the second number of second training samples (for the convenience of subsequent description, it can be referred to as a target training sample), such as Figure 4 As shown, the target training sample can be vectorized to obtain a representation vector corresponding to the target training sample, that is, an embedding vector. Then, the embedding vector can be input into the target model, and the target training sample is processed by the encoder in the target model (that is, the hidden layer in the target model, etc.) to obtain a corresponding processing result. The processing result can be output through the decoder in the target model (that is, the output layer in the target model, etc.) to obtain a corresponding output result. By linearizing the loss function (that is, the first loss function) in the field of the target training sample, the corresponding loss information (that is, the first loss information) can be obtained. In the above manner, the representation vector corresponding to the target training sample (that is, the embedding vector) and the first loss information corresponding to the first loss function can be obtained.
[0051] In step S312, based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0052] In implementation, the corresponding gradient of the input target training sample can be calculated based on the characterization vector corresponding to the target training sample and the first loss information corresponding to the first loss function, thereby obtaining adversarial perturbation. Then, the obtained adversarial perturbation can be added to the target training sample to generate an adversarial sample. By linearizing the loss function in the field of the target training sample and finding the maximum value of the precise linearization function through a specified algorithm, the corresponding gradient can be obtained, and the parameters in the target model can be updated based on the gradient. Afterwards, other training samples can be processed accordingly in the above manner to update the parameters in the target model, and finally a target function with relatively accurate and convergent parameters can be obtained, that is, a trained target model.
[0053] In practical applications, the above-mentioned gradient-based anti-attack algorithm may include a fast gradient ascent algorithm. Accordingly, the specific processing of the above-mentioned step S312 may also be implemented in the following manner:
[0054] like Figure 4 As shown, after obtaining the representation vector corresponding to the target training sample and the first loss information corresponding to the first loss function in the above manner, the above processing process can be back-propagated to obtain the corresponding first gradient information. Then, the corresponding adversarial perturbation can be calculated based on the representation vector corresponding to the target training sample, and the adversarial perturbation can be added to the representation vector corresponding to the target training sample (i.e., the embedding vector) to obtain the corresponding adversarial sample, and the loss information corresponding to the adversarial sample can be calculated. Then, it is back-propagated to obtain the corresponding second gradient information, and the second gradient information can be accumulated to the first gradient information. After that, the representation vector (i.e., the embedding vector) at this time can be restored to the representation vector (i.e., the embedding vector) corresponding to the target training sample, and the corresponding parameters in the target model can be updated according to the first gradient information accumulated with the second gradient information. After that, other training samples can be processed accordingly in the above manner to update the parameters in the target model, and finally a target function with relatively accurate and convergent parameters can be obtained, i.e., the trained target model.
[0055] In practical applications, the specific processing methods of the above step S312 can be varied. An optional processing method is provided below, which may specifically include the following: based on the characterization vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained through a fast gradient ascent algorithm, and a preset second loss function and a third loss function to obtain a trained target model. The second loss function is a loss function corresponding to whether each training sample is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
[0056] In implementation, Figure 4 As shown, after obtaining the characterization vector corresponding to the target training sample and the first loss information corresponding to the first loss function in the above manner, the above processing process can be back-propagated to obtain the corresponding first gradient information. Then, the corresponding adversarial perturbation can be calculated based on the characterization vector corresponding to the target training sample, and the adversarial perturbation can be added to the characterization vector corresponding to the target training sample (i.e., the embedding vector) to obtain the corresponding adversarial sample. The loss information corresponding to the adversarial sample can be calculated by the second loss function and the third loss function respectively to obtain whether the target training sample is the loss information corresponding to the training sample obtained after the corresponding noise data is added and the predicted target The loss information corresponding to the initial data of the training sample is then back-propagated to obtain the corresponding second gradient information, and the second gradient information can be accumulated on the first gradient information. After that, the characterization vector (i.e., the embedding vector) at this time can be restored to the characterization vector (i.e., the embedding vector) corresponding to the target training sample, and the corresponding parameters in the target model can be updated according to the first gradient information accumulated with the second gradient information. After that, other training samples can be processed accordingly in the above manner to update the parameters in the target model, and finally a target function with relatively accurate and convergent parameters can be obtained, i.e., the trained target model.
[0057] The embodiments of the present specification provide a model training method, which obtains a first number of first training samples, selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples to obtain a second number of second training samples. Based on the remaining first training samples and the second number of second training samples, a target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a portion of the first training samples. Then, based on the first training samples and the second training samples, and in combination with the gradient-based adversarial attack algorithm, the anti-attack capability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0058] Embodiment 3
[0059] like Figure 5A and Figure 5B As shown, the embodiment of this specification provides a model training method, the execution subject of the method can be a blockchain system, and the blockchain system can be composed of terminal devices and / or servers, etc., wherein the terminal device can be a mobile terminal device such as a mobile phone, a tablet computer, or a personal computer, etc. The server can be an independent server, or a server cluster composed of multiple servers, etc. The server can be a background server for financial services or online shopping services, etc., or a background server for an application, etc. The method can be applied to related scenarios with model training, etc., and the method can specifically include the following steps:
[0060] In step S502, the training rule information of the target model is obtained, the corresponding smart contract is generated using the training rule information of the target model, and the smart contract is deployed to the blockchain system.
[0061] Among them, a smart contract can be a computer protocol designed to disseminate, verify or execute a contract in an information-based manner. A smart contract allows trusted interactions without a third party, and the above-mentioned interaction process is traceable and irreversible. A smart contract includes an agreement on which the contract participants can execute the rights and obligations agreed upon by the contract participants.
[0062] In implementation, in order to make the traceability of the training process based on the target model better, a designated blockchain system can be created or added, so that the training of the target model can be performed based on the blockchain system. Specifically, a corresponding application can be installed in the blockchain node, and an input box and / or selection box of the training rule information of the target model can be set in the application, and the corresponding information can be set in the above input box and / or selection box. Then, the blockchain system can receive the training rule information of the target model. The blockchain system can generate a corresponding smart contract based on the training rule information of the target model, and can deploy the smart contract to the blockchain system. In this way, the training rule information of the target model and the corresponding smart contract are stored in the blockchain system, and other users cannot tamper with the training rule information of the target model and the corresponding smart contract. Moreover, the blockchain system performs training on the target model through the smart contract.
[0063] In step S504, the smart contract is called to obtain a first number of first training samples.
[0064] In implementation, relevant rule information for obtaining the first training sample may be set in the smart contract, so that the corresponding processing may be implemented based on the rule information in the smart contract. For details, please refer to the relevant content above, which will not be repeated here.
[0065] In step S506, based on the smart contract, a second number of first training samples are selected from the first number of first training samples, and corresponding noise data are added to the second number of first training samples respectively to obtain a second number of second training samples.
[0066] The second quantity satisfies a preset proportional relationship with the first quantity.
[0067] In implementation, the smart contract may be provided with relevant rule information for selecting a second number of first training samples from a first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively. In this way, the above-mentioned corresponding processing may be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0068] In practical applications, in the above step S506, based on the smart contract, there can be various processing methods for selecting the second number of first training samples from the first number of first training samples. An optional processing method is provided below, which may specifically include the following contents: based on the smart contract, a preset sample selection strategy is adopted to select the second number of first training samples from the first number of first training samples.
[0069] In practical applications, in the above step S506, based on the smart contract, corresponding noise data is added to the second number of first training samples respectively, and there are various processing methods to obtain the second number of second training samples. An optional processing method is provided below, which may specifically include the processing of the following steps A2 and A4.
[0070] In step A2, based on the smart contract, noise data corresponding to each first training sample in the second number of first training samples is obtained respectively.
[0071] In implementation, the smart contract may be provided with relevant rule information for respectively obtaining the noise data corresponding to each first training sample in the second number of first training samples. In this way, the corresponding processing mentioned above may be implemented based on the above rule information in the smart contract. For details, please refer to the above related content and will not be repeated here.
[0072] In practical applications, the processing method of the above step A2 can be various. An optional processing method is provided below, which may specifically include the following: based on a smart contract, randomly generate noise data for each first training sample in the second number of first training samples.
[0073] In implementation, the smart contract may be provided with relevant rule information for randomly generating noise data for each first training sample in the second number of first training samples. In this way, the corresponding processing mentioned above may be implemented based on the above rule information in the smart contract. For details, please refer to the above related content and will not be repeated here.
[0074] In step A4, based on the smart contract, corresponding noise data is added to each first training sample in the second number of first training samples using the acquired noise data to obtain a second number of second training samples.
[0075] In implementation, the smart contract may be provided with relevant rule information for adding corresponding noise data to each first training sample in the second number of first training samples respectively through the acquired noise data. In this way, the above-mentioned corresponding processing may be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0076] In step S508, based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0077] In implementation, the smart contract may be provided with relevant rule information for using the remaining first training samples and the second number of second training samples to train the target model through a preset gradient-based adversarial attack algorithm. In this way, the above-mentioned corresponding processing can be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0078] In practical applications, the target model can be stored in the blockchain system or in other storage devices. For the case where the target model is stored in other storage devices, considering that the target model may need to be updated regularly or irregularly, since the blockchain system has the characteristic of being tamper-proof, if the target model is stored in the blockchain system, it is necessary to frequently upload, delete, and authenticate the uploader of the target model in the blockchain system, which increases the processing pressure of the blockchain system. In order to improve processing efficiency and reduce the processing pressure of the blockchain system, the target model can be stored in a specified storage address of the storage device in advance, and the storage address (i.e., index information) can be uploaded to the blockchain system. Since the storage address can be fixed and stored in the blockchain system, the tamper-proof nature of the data in the blockchain system is guaranteed. At the same time, the target model can also be updated regularly or irregularly in the above-mentioned storage device.
[0079] In practical applications, the processing method of the above step S508 can be various. An optional processing method is provided below, which can specifically include the processing of the following steps B2 and B4.
[0080] In step B2, based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset first loss function to obtain a representation vector corresponding to each training sample and the first loss information corresponding to the first loss function. The training samples include the remaining first training samples and the second number of second training samples.
[0081] In implementation, the smart contract may be provided with relevant rule information for using the remaining first training samples and the second number of second training samples to train the target model through a preset first loss function. In this way, the above-mentioned corresponding processing can be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0082] In step B4, based on the smart contract, the target model is trained using the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0083] Among them, the gradient-based adversarial attack algorithm includes the fast gradient ascent algorithm.
[0084] In implementation, the smart contract may be provided with relevant rule information for training the target model using the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function through a preset gradient-based adversarial attack algorithm. In this way, the above-mentioned corresponding processing can be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0085] In practical applications, the processing methods of the above step B4 can be varied. An optional processing method is provided below, which may specifically include the following: based on a smart contract, the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function are used to train the target model through a fast gradient ascent algorithm, as well as a preset second loss function and a third loss function to obtain a trained target model. The second loss function is a loss function corresponding to whether each training sample is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting the loss function.
[0086] In implementation, the smart contract may be provided with relevant rule information for training the target model using the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function, through the fast gradient ascent algorithm, and the preset second loss function and third loss function. In this way, the above-mentioned corresponding processing can be implemented based on the above-mentioned rule information in the smart contract. For details, please refer to the above-mentioned relevant content, which will not be repeated here.
[0087] In practical applications, the processing method of the above step S508 can be various. An optional processing method is provided below, which can specifically include the processing of the following steps C2 and C4.
[0088] In step C2, based on the smart contract, the index information of the target model is obtained from the blockchain system, and the target model is obtained from the target storage device based on the index information.
[0089] Among them, the index information can be used to record information such as the storage location of the target model. Through the index information, the corresponding target model can be quickly found. After the data corresponding to the index information is stored in the blockchain system, its content is usually not modified, that is, the storage location of the target model corresponding to the index information is usually not changed, thereby preventing the index information from being maliciously tampered with.
[0090] In implementation, in order to ensure the integrity of the index information of the target model and prevent it from being tampered with, the index information of the target model can be uploaded to the blockchain system. Specifically, in order to record the target model, the index information of the target model can be pre-set according to the actual situation, such as pre-setting the target storage device that the target model can store, and then generating the index information based on the target storage device set above. After the index information is set, the index information can be uploaded to the blockchain system.
[0091] In step C4, based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0092] For the specific processing of the above steps S504 to S508, please refer to the relevant contents in the above embodiments 1 to 2, that is, the various processing involved in the above embodiments 1 to 2 can be implemented through the corresponding smart contracts.
[0093] The embodiment of the present specification provides a model training method, which is applied to a blockchain system, obtains training rule information of a target model, generates a corresponding smart contract using the training rule information of the target model, and deploys the smart contract to the blockchain system. Then, the smart contract is called to obtain a first number of first training samples, and based on the smart contract, a second number of first training samples are selected from the first number of first training samples, and corresponding noise data are added to the second number of first training samples respectively to obtain a second number of second training samples. Finally, based on the smart contract, the remaining first training samples and the second number of second training samples can be used to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a part of the first training sample. Then, based on the first training sample and the second training sample, and combined with the gradient-based adversarial attack algorithm, the anti-attack ability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0094] Embodiment 4
[0095] The above is a training method for a model provided in the embodiments of this specification. Based on the same idea, the embodiments of this specification also provide a training device for a model, such as Figure 6 shown.
[0096] The training device of the model includes: a sample acquisition module 601, a sample processing module 602 and a training module 603, wherein:
[0097] A sample acquisition module 601 acquires a first number of first training samples;
[0098] The sample processing module 602 selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples;
[0099] The training module 603 trains the target model based on the remaining first training samples and the second number of second training samples by using a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0100] In the embodiment of this specification, the second quantity and the first quantity satisfy a preset proportional relationship.
[0101] In the embodiment of the present specification, the sample processing module 602 selects a second number of first training samples from the first number of first training samples based on a preset sample selection strategy.
[0102] In the embodiment of this specification, the sample processing module 602 includes:
[0103] A noise acquisition unit, respectively acquiring noise data corresponding to each first training sample in the second number of first training samples;
[0104] The noise adding unit adds corresponding noise data to each first training sample of the second number of first training samples based on the acquired noise data, so as to obtain the second number of second training samples.
[0105] In the embodiment of the present specification, the noise acquisition unit randomly generates noise data for each first training sample in the second number of first training samples.
[0106] In the embodiment of this specification, the training module 603 includes:
[0107] A first training unit trains the target model by using a preset first loss function based on the remaining first training samples and the second number of second training samples to obtain a representation vector corresponding to each training sample and first loss information corresponding to the first loss function, wherein the training samples include the remaining first training samples and the second number of second training samples;
[0108] The second training unit trains the target model through a preset gradient-based adversarial attack algorithm based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function to obtain a trained target model.
[0109] In the embodiments of this specification, the gradient-based adversarial attack algorithm includes a fast gradient ascent algorithm.
[0110] In an embodiment of the present specification, the second training unit trains the target model based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function through the fast gradient ascent algorithm, and the preset second loss function and third loss function to obtain a trained target model, wherein the second loss function is a loss function corresponding to whether each training sample is a training sample obtained after adding corresponding noise data, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
[0111] The embodiment of the present specification provides a model training device, which obtains a first number of first training samples, selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples to obtain a second number of second training samples. Based on the remaining first training samples and the second number of second training samples, a target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a portion of the first training samples, and then, based on the first training samples and the second training samples, and combined with the gradient-based adversarial attack algorithm, the anti-attack capability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0112] Embodiment 5
[0113] Based on the same idea, the embodiment of this specification also provides a model training device, which is a device in the blockchain system, such as Figure 7 shown.
[0114] The training device of the model includes: a contract deployment module 701, a sample acquisition module 702, a sample processing module 703 and a training module 704, wherein:
[0115] The contract deployment module 701 obtains the training rule information of the target model, generates a corresponding smart contract using the training rule information of the target model, and deploys the smart contract into the blockchain system;
[0116] A sample acquisition module 702 calls the smart contract to acquire a first number of first training samples;
[0117] A sample processing module 703 selects a second number of first training samples from the first number of first training samples based on the smart contract, and adds corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples;
[0118] The training module 704 uses the remaining first training samples and the second number of second training samples based on the smart contract to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0119] In the embodiment of this specification, the training module 704 includes:
[0120] A model acquisition unit, which acquires index information of the target model from the blockchain system based on the smart contract, and acquires the target model from a target storage device based on the index information;
[0121] The training unit uses the remaining first training samples and the second number of second training samples based on the smart contract to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0122] In the embodiment of this specification, the second quantity and the first quantity satisfy a preset proportional relationship.
[0123] In the embodiment of this specification, the sample processing module 703 selects a second number of first training samples from the first number of first training samples based on the smart contract and adopts a preset sample selection strategy.
[0124] In the embodiment of this specification, the sample processing module 704 includes:
[0125] A noise acquisition unit, based on the smart contract, respectively acquires noise data corresponding to each first training sample in the second number of first training samples;
[0126] The noise adding unit, based on the smart contract, adds corresponding noise data to each first training sample in the second number of first training samples by using the acquired noise data to obtain the second number of second training samples.
[0127] In the embodiment of the present specification, the noise acquisition unit randomly generates noise data for each first training sample in the second number of first training samples based on the smart contract.
[0128] In the embodiment of this specification, the training module 704 includes:
[0129] A first training unit, based on the smart contract, uses the remaining first training samples and the second number of second training samples to train the target model through a preset first loss function to obtain a representation vector corresponding to each training sample and first loss information corresponding to the first loss function, wherein the training samples include the remaining first training samples and the second number of second training samples;
[0130] The second training unit, based on the smart contract, uses the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0131] In the embodiments of this specification, the gradient-based adversarial attack algorithm includes a fast gradient ascent algorithm.
[0132] In an embodiment of the present specification, the second training unit, based on the smart contract, uses the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function, and trains the target model through the fast gradient ascent algorithm, as well as the preset second loss function and third loss function to obtain a trained target model, wherein the second loss function is a loss function corresponding to whether each training sample is a training sample obtained after adding corresponding noise data, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
[0133] The embodiment of the present specification provides a model training device, which obtains the training rule information of the target model, generates a corresponding smart contract using the training rule information of the target model, and deploys the smart contract to the blockchain system. Then, the smart contract is called to obtain a first number of first training samples, and based on the smart contract, a second number of first training samples are selected from the first number of first training samples, and corresponding noise data are added to the second number of first training samples respectively to obtain a second number of second training samples. Finally, based on the smart contract, the remaining first training samples and the second number of second training samples can be used to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a part of the first training sample. Then, based on the first training sample and the second training sample, and combined with the gradient-based adversarial attack algorithm, the anti-attack ability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0134] Embodiment 6
[0135] The above is a training device for a model provided in the embodiments of this specification. Based on the same idea, the embodiments of this specification also provide a training device for a model, such as Figure 8 shown.
[0136] The training device of the model may provide a terminal device, a server or a device in a blockchain system, etc. for the above-mentioned embodiments.
[0137] The training device of the model may have relatively large differences due to different configurations or performances, and may include one or more processors 801 and memory 802, and one or more storage applications or data may be stored in the memory 802. Among them, the memory 802 can be a short-term storage or a persistent storage. The application stored in the memory 802 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the training device of the model. Furthermore, the processor 801 can be configured to communicate with the memory 802 to execute a series of computer executable instructions in the memory 802 on the training device of the model. The training device of the model may also include one or more power supplies 803, one or more wired or wireless network interfaces 804, one or more input and output interfaces 805, and one or more keyboards 806.
[0138] Specifically in this embodiment, the model training device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the model training device, and the one or more programs are configured to be executed by one or more processors, including the following computer executable instructions:
[0139] Obtaining a first number of first training samples;
[0140] Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples;
[0141] Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0142] In the embodiment of this specification, the second quantity and the first quantity satisfy a preset proportional relationship.
[0143] In the embodiment of this specification, the selecting a second number of first training samples from the first number of first training samples includes:
[0144] Based on a preset sample selection strategy, a second number of first training samples are selected from the first number of first training samples.
[0145] In the embodiment of this specification, respectively adding corresponding noise data to the second number of first training samples to obtain the second number of second training samples includes:
[0146] Respectively obtain noise data corresponding to each first training sample in the second number of first training samples;
[0147] Based on the acquired noise data, corresponding noise data is added to each first training sample in the second number of first training samples to obtain the second number of second training samples.
[0148] In the embodiment of this specification, the step of respectively obtaining noise data corresponding to each first training sample in the second number of first training samples includes:
[0149] Noise data is randomly generated for each first training sample in the second number of first training samples.
[0150] In the embodiment of the present specification, the target model is trained based on the remaining first training samples and the second number of second training samples by using a preset gradient-based adversarial attack algorithm to obtain a trained target model, including:
[0151] Based on the remaining first training samples and the second number of second training samples, training the target model by using a preset first loss function to obtain a representation vector corresponding to each training sample and first loss information corresponding to the first loss function, the training samples including the remaining first training samples and the second number of second training samples;
[0152] Based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0153] In the embodiments of this specification, the gradient-based adversarial attack algorithm includes a fast gradient ascent algorithm.
[0154] In the embodiment of this specification, the target model is trained by a preset gradient-based adversarial attack algorithm based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function to obtain the trained target model, including:
[0155] Based on the characterization vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained through the fast gradient ascent algorithm, and the preset second loss function and third loss function to obtain a trained target model, wherein the second loss function is a loss function corresponding to whether each training sample is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
[0156] In addition, specifically in this embodiment, the model training device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the model training device, and the one or more programs are configured to be executed by one or more processors, including the following computer executable instructions:
[0157] Acquire training rule information of the target model, generate a corresponding smart contract using the training rule information of the target model, and deploy the smart contract into the blockchain system;
[0158] Calling the smart contract to obtain a first number of first training samples;
[0159] Based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples;
[0160] Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0161] In the embodiment of this specification, based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model, including:
[0162] Based on the smart contract, obtain index information of the target model from the blockchain system, and obtain the target model from a target storage device based on the index information;
[0163] Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0164] The embodiment of the present specification provides a model training device, which obtains a first number of first training samples, selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples to obtain a second number of second training samples. Based on the remaining first training samples and the second number of second training samples, a target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, a second training sample is generated by adding noise data to a portion of the first training samples, and then, based on the first training samples and the second training samples, and combined with the gradient-based adversarial attack algorithm, the anti-attack capability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0165] Embodiment 7
[0166] Furthermore, based on the above Figures 1 to 5B In one embodiment, the present specification further provides a storage medium for storing computer executable instruction information. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer executable instruction information stored in the storage medium is executed by the processor, the following process can be implemented:
[0167] Obtaining a first number of first training samples;
[0168] Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples;
[0169] Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0170] In the embodiment of this specification, the second quantity and the first quantity satisfy a preset proportional relationship.
[0171] In the embodiment of this specification, the selecting a second number of first training samples from the first number of first training samples includes:
[0172] Based on a preset sample selection strategy, a second number of first training samples are selected from the first number of first training samples.
[0173] In the embodiment of this specification, respectively adding corresponding noise data to the second number of first training samples to obtain the second number of second training samples includes:
[0174] Respectively obtain noise data corresponding to each first training sample in the second number of first training samples;
[0175] Based on the acquired noise data, corresponding noise data is added to each first training sample in the second number of first training samples to obtain the second number of second training samples.
[0176] In the embodiment of this specification, the step of respectively obtaining noise data corresponding to each first training sample in the second number of first training samples includes:
[0177] Noise data is randomly generated for each first training sample in the second number of first training samples.
[0178] In the embodiment of the present specification, the target model is trained based on the remaining first training samples and the second number of second training samples by using a preset gradient-based adversarial attack algorithm to obtain a trained target model, including:
[0179] Based on the remaining first training samples and the second number of second training samples, training the target model by using a preset first loss function to obtain a representation vector corresponding to each training sample and first loss information corresponding to the first loss function, the training samples including the remaining first training samples and the second number of second training samples;
[0180] Based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0181] In the embodiments of this specification, the gradient-based adversarial attack algorithm includes a fast gradient ascent algorithm.
[0182] In the embodiment of this specification, the target model is trained by a preset gradient-based adversarial attack algorithm based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function to obtain the trained target model, including:
[0183] Based on the characterization vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained through the fast gradient ascent algorithm, and the preset second loss function and third loss function to obtain a trained target model, wherein the second loss function is a loss function corresponding to whether each training sample is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
[0184] In addition, in another specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc., and the computer executable instruction information stored in the storage medium can implement the following process when executed by the processor:
[0185] Acquire training rule information of the target model, generate a corresponding smart contract using the training rule information of the target model, and deploy the smart contract into the blockchain system;
[0186] Calling the smart contract to obtain a first number of first training samples;
[0187] Based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples;
[0188] Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0189] In the embodiment of this specification, based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model, including:
[0190] Based on the smart contract, obtain index information of the target model from the blockchain system, and obtain the target model from a target storage device based on the index information;
[0191] Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
[0192] The embodiment of the present specification provides a storage medium, which obtains a first number of first training samples, selects a second number of first training samples from the first number of first training samples, and adds corresponding noise data to the second number of first training samples to obtain a second number of second training samples, and trains a target model based on the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model. In this way, the second training samples are generated by adding noise data to a part of the first training samples, and then, based on the first training samples and the second training samples, and combined with the gradient-based adversarial attack algorithm, the anti-attack capability of the trained target model can be improved, and the robustness of the target model can be improved, thereby ensuring the performance of the target model, and effectively reducing the probability of model degradation problems, and effectively resisting black field attacks.
[0193] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0194] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0195] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0196] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0197] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing one or more embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0198] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, one or more embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0199] The embodiments of this specification are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable fraud case serial and parallel device to produce a machine, so that the instructions executed by the processor of the computer or other programmable fraud case serial and parallel device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0200] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable fraud case serial and parallel device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0201] These computer program instructions may also be loaded onto a computer or other programmable device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0202] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0203] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0204] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0205] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0206] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, one or more embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0207] One or more embodiments of the present specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0208] Each embodiment in this specification is described in a progressive 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.
[0209] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A model training method, the method comprising: Acquire a first number of first training samples constructed based on business data of transaction business, wherein the business data includes one or more of relevant information of both parties to the transaction, resource information of the transaction, transaction time, transaction location, and transaction history data of both parties to the transaction; Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples; Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the target model is a model for risk prevention and control, and the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
2. According to the method of claim 1, the second quantity satisfies a preset proportional relationship with the first quantity.
3. The method according to claim 2, wherein the step of selecting a second number of first training samples from the first number of first training samples comprises: Based on a preset sample selection strategy, a second number of first training samples are selected from the first number of first training samples.
4. The method according to claim 1, wherein adding corresponding noise data to the second number of first training samples to obtain the second number of second training samples comprises: Respectively obtain noise data corresponding to each first training sample in the second number of first training samples; Based on the acquired noise data, corresponding noise data is added to each first training sample in the second number of first training samples to obtain the second number of second training samples.
5. The method according to claim 4, wherein the step of respectively obtaining noise data corresponding to each first training sample in the second number of first training samples comprises: Noise data is randomly generated for each first training sample in the second number of first training samples.
6. The method according to claim 4, wherein the target model is trained based on the remaining first training samples and the second number of second training samples by using a preset gradient-based adversarial attack algorithm to obtain a trained target model, comprising: Based on the remaining first training samples and the second number of second training samples, training the target model by using a preset first loss function to obtain a representation vector corresponding to each training sample and first loss information corresponding to the first loss function, the training samples including the remaining first training samples and the second number of second training samples; Based on the characterization vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained by a preset gradient-based adversarial attack algorithm to obtain a trained target model.
7. The method of claim 6, wherein the gradient-based adversarial attack algorithm comprises a fast gradient ascent algorithm.
8. The method according to claim 7, wherein the target model is trained by a preset gradient-based adversarial attack algorithm based on the representation vector corresponding to each training sample and the first loss information corresponding to the first loss function to obtain the trained target model, comprising: Based on the characterization vector corresponding to each training sample and the first loss information corresponding to the first loss function, the target model is trained through the fast gradient ascent algorithm, and the preset second loss function and third loss function to obtain a trained target model, wherein the second loss function is a loss function corresponding to whether each training sample is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
9. A model training method, applied to a blockchain system, comprising: Acquire training rule information of the target model, generate a corresponding smart contract using the training rule information of the target model, and deploy the smart contract into the blockchain system; Calling the smart contract to obtain a first number of first training samples; Based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples; Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
10. The method according to claim 9, wherein the method, based on the smart contract, uses the remaining first training samples and the second number of second training samples to train the target model through a preset gradient-based adversarial attack algorithm to obtain a trained target model, comprising: Based on the smart contract, obtain index information of the target model from the blockchain system, and obtain the target model from a target storage device based on the index information; Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm to obtain a trained target model.
11. A model training device, comprising: A sample acquisition module, which acquires a first number of first training samples constructed based on business data of transaction business, wherein the business data includes one or more of relevant information of both parties to the transaction, resource information of the transaction, transaction time, transaction location, and transaction history data of both parties to the transaction; a sample processing module, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples; A training module, based on the remaining first training samples and the second number of second training samples, trains the target model through a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the target model is a model for risk prevention and control, and the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after the corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
12. A model training device, the device being a device in a blockchain system, the device comprising: A contract deployment module, which obtains training rule information of a target model, generates a corresponding smart contract using the training rule information of the target model, and deploys the smart contract into the blockchain system; A sample acquisition module, calling the smart contract to acquire a first number of first training samples; a sample processing module, based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples; A training module, based on the smart contract, uses the remaining first training samples and the second number of second training samples to train the target model through a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after adding corresponding noise data, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
13. A model training device, the model training device comprising: processor; as well as a memory arranged to store computer executable instructions which, when executed, cause the processor to: Acquire a first number of first training samples constructed based on business data of transaction business, wherein the business data includes one or more of relevant information of both parties to the transaction, resource information of the transaction, transaction time, transaction location, and transaction history data of both parties to the transaction; Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples; Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the target model is a model for risk prevention and control, and the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data of each training sample for predicting.
14. A model training device, the device being a device in a blockchain system, the model training device comprising: processor; as well as a memory arranged to store computer executable instructions which, when executed, cause the processor to: Acquire training rule information of the target model, generate a corresponding smart contract using the training rule information of the target model, and deploy the smart contract into the blockchain system; Calling the smart contract to obtain a first number of first training samples; Based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples; Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
15. A storage medium for storing computer executable instructions, wherein the executable instructions implement the following process when executed by a processor: Acquire a first number of first training samples constructed based on business data of transaction business, wherein the business data includes one or more of relevant information of both parties to the transaction, resource information of the transaction, transaction time, transaction location, and transaction history data of both parties to the transaction; Selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples respectively, to obtain the second number of second training samples; Based on the remaining first training samples and the second number of second training samples, the target model is trained by a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the target model is a model for risk prevention and control, and the preset loss function includes: A second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after adding corresponding noise data, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
16. A storage medium for storing computer executable instructions, wherein the executable instructions implement the following process when executed by a processor: Obtaining training rule information of the target model, generating a corresponding smart contract using the training rule information of the target model, and deploying the smart contract into the blockchain system; Calling the smart contract to obtain a first number of first training samples; Based on the smart contract, selecting a second number of first training samples from the first number of first training samples, and adding corresponding noise data to the second number of first training samples, respectively, to obtain the second number of second training samples; Based on the smart contract, the target model is trained using the remaining first training samples and the second number of second training samples through a preset gradient-based adversarial attack algorithm and a preset loss function to obtain a trained target model, wherein the preset loss function includes: a second loss function and a third loss function, wherein the second loss function is a loss function corresponding to whether each training sample in the remaining first training samples and the second number of second training samples is a training sample obtained after corresponding noise data is added, and the third loss function is a loss function corresponding to the initial data for predicting each training sample.
