Neural network training methods, devices, terminals, and storage media
By using a dongle for authentication and offline training on the terminal, the problem of low data security in neural network training is solved, achieving both data security and reliability of offline training.
Patent Information
- Application Number
- CN202210976621.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-15
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-08-15
AI Technical Summary
Existing technologies have low data security when training neural networks, and sample data is easily leaked during transmission between the terminal and the server.
By using a dongle for authentication in the terminal, sample data can be imported and neural network training is only allowed when a valid dongle connects and passes authentication. The offline training method on the terminal side avoids leakage during data transmission.
It improves data security, reduces the risk of sample data leakage when user accounts and passwords are stolen, and achieves reliability and convenience for offline training of neural networks.
Smart Images

Figure CN115203727B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a neural network training method, apparatus, terminal, and storage medium. Background Technology
[0002] With the development of computer technology, many users are using neural networks to process business tasks, such as image recognition and fault detection. To ensure that the neural network meets business requirements, it needs to be trained.
[0003] In this technology, when training a neural network, the user uploads sample data stored on their device to a cloud server. The server receives the uploaded sample data and trains the neural network based on it.
[0004] When training neural networks using the above methods, data security is not high. Summary of the Invention
[0005] This application provides a neural network training method, apparatus, terminal, and storage medium, which can improve data security during neural network training.
[0006] In a first aspect, embodiments of this application provide a neural network training method, executed by a terminal, comprising:
[0007] Receive training instructions, which instruct the terminal to train a neural network through a model training application;
[0008] Check whether the terminal is connected to the dongle bound to the model training application, and check whether the dongle has passed the validity verification;
[0009] If the terminal is connected to the dongle and the dongle passes the validity verification, the sample data stored in the terminal's local file system is imported into the model training application, and the model training application trains the neural network based on the sample data.
[0010] In some embodiments, detecting whether the dongle has passed legitimacy verification includes:
[0011] The device information of the dongle is verified to be legitimate, and the signature of the dongle is verified to be legitimate.
[0012] If the device information of the dongle passes the validity verification and the signature of the dongle passes the validity verification, the dongle is deemed to have passed the validity verification.
[0013] In some embodiments, detecting whether the signature of the dongle passes the validity verification includes:
[0014] Use the private key stored in the dongle to sign the authentication data to obtain the dongle's signature;
[0015] Send the signature of the dongle to the authentication server associated with the dongle;
[0016] If a verification pass message is received from the authentication server, it is determined that the signature of the dongle has passed the validity verification.
[0017] In some embodiments, before signing the authentication data using the private key stored in the dongle, the method further includes:
[0018] The terminal receives authentication data sent by the authentication server. The authentication data includes a session identifier, a random number, and a timestamp. The session identifier is used to identify the session established between the terminal and the authentication server.
[0019] In some embodiments, detecting whether the device information of the dongle has passed the legitimacy verification includes:
[0020] Send the device information of the dongle to the authentication server associated with the dongle;
[0021] If a verification pass message is received from the authentication server, it is determined that the device information of the dongle has passed the legitimacy verification.
[0022] In some embodiments, the device information includes the dongle's shell number, the dongle's chip number, and the dongle's device certificate.
[0023] In some embodiments, after the application trains the neural network based on the sample data using the model training method, the method further includes:
[0024] The neural network is encapsulated to obtain the corresponding software development kit;
[0025] Output the software development kit.
[0026] Secondly, embodiments of this application provide a neural network training device, located on a terminal, comprising:
[0027] The receiving module is used to receive training instructions, which instruct the terminal to train a neural network through a model training application.
[0028] The detection module is used to detect whether the terminal has been connected to the dongle bound to the model training application, and to detect whether the dongle has passed the legality verification.
[0029] The training module is used to import sample data stored in the local file system of the terminal into the model training application if the terminal is connected to the dongle and the dongle has passed the legality verification, and then train the neural network based on the sample data through the model training application.
[0030] Thirdly, embodiments of this application provide a terminal, which includes a processor and a memory. The memory stores computer program instructions, and the processor executes the computer program instructions to implement the steps in the method described in the first aspect.
[0031] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions that, when executed by a processor, implement the steps of the method described in the first aspect.
[0032] Fifthly, embodiments of this application provide a computer program product, which includes computer program instructions that, when executed by a processor, implement the steps of the method described in the first aspect.
[0033] Therefore, the embodiments of this application have the following beneficial effects:
[0034] When training a neural network, the user must connect the dongle to the terminal, and only after the dongle passes authentication will the user have permission to import sample data and train the neural network. If the user unplugs the dongle from the terminal, or if the dongle connected to the terminal is an unauthorized device, data cannot be uploaded and the neural network cannot be trained, thus reducing the risk of sample data leakage if the user's account and password are stolen. Furthermore, this method supports offline neural network training on the device side, preventing sample data leakage during transmission between the terminal and the server, thereby improving data security. Attached Figure Description
[0035] Figure 1 This is a flowchart of a neural network training method provided in an embodiment of this application;
[0036] Figure 2 This is a schematic diagram of the structure of a neural network training device 200 provided in an embodiment of this application;
[0037] Figure 3 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;
[0038] Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation
[0039] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and embodiments.
[0040] To facilitate understanding of the technical solutions in the embodiments of this application, the technical terms involved in the embodiments of this application will be explained below.
[0041] A dongle, also known as a cryptographic lock, is a hardware and software encryption product used in computers, smart hardware devices, industrial control computers, cloud systems, etc. Software developers use dongles to manage software licensing, prevent unauthorized use, defend against piracy threats, and protect source code and algorithms. For example, a dongle can be a Universal Serial Bus (USB) dongle. A USB dongle is an authentication security tool, similar in size to a USB flash drive, and can be directly plugged into a terminal's USB port. Each dongle has a unique product identification code and an independent, up-to-date encryption algorithm. When a user uses software bound to a dongle on a terminal, login is only allowed after the specific dongle is detected and accurate physical verification is performed. In some embodiments, the dongle is used in conjunction with a model training application. The dongle can encrypt and authorize the model training application; the dongle must be inserted to run the application. Specifically, the user must insert the dongle into the terminal to import sample data and train the neural network, thus gaining the permission to do so. If the user removes the dongle from the terminal, sample data cannot be imported or the neural network cannot be trained. For example, if a company's computers or local area network (LAN) are accidentally infected with malware, the company's backend accounts could be intercepted at any time. However, hackers cannot log in to the backend without a hardware dongle. Therefore, even if the company's account passwords are stolen, it is difficult for the thief to log in to the company's backend from a different location or through the company's computer, as long as they do not have a dongle. In some embodiments, users can also configure the dongle according to their needs, such as limiting the time and number of uses of the model training application, the LAN network lock mode, restricting the functionality of software modules in the model training application, and restricting different user identities. The dongle is portable, simple and convenient, and plug-and-play, ensuring the reliability and convenience of the company's neural network training. In some embodiments, the dongle is a physical medium used for identity authentication. The dongle contains a unique device private key, providing an unforgeable device signature. Each dongle generates a private key and certificate by a built-in security chip before leaving the factory. The hardware has the security features of being uncopyable and the key cannot be exported, making it more difficult to forge authentication.
[0042] Software development kit (SDK): A collection of development tools used to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc.
[0043] Authorization encryption refers to the encryption and protection of authorized content. It aims to protect the security of the authorized content in order to ensure the security of the distributed software. It strives to ensure that authorized users use the software product within the prescribed permissions. Through authorization encryption protection, it prevents unauthorized users from illegally using and abusing the software product.
[0044] USB: is an external bus standard used to regulate the connection and communication between computers and external devices.
[0045] An application programming interface (API) is a calling interface provided by the operating system for applications.
[0046] Figure 1 This is a flowchart of a neural network training method provided in an embodiment of this application. Figure 1 The method shown is executed by the terminal. Figure 1 The method shown includes the following steps S101 to S104.
[0047] Step S101: The terminal receives the training instruction.
[0048] This training instruction directs the terminal to train a neural network using a model training application. In some embodiments, the training instruction is triggered by an operation performed by the user on the terminal. The model training application can be software used to train the neural network.
[0049] Step S102: The terminal detects whether it has been connected to the dongle bound to the model training application and detects whether the dongle has passed the validity verification.
[0050] There are several ways to detect whether a dongle has passed the validity verification. In some embodiments, the terminal detects whether the dongle's device information and signature have passed the validity verification. If both the dongle's device information and signature have passed the validity verification, the dongle is determined to have passed the validity verification. If either the dongle's device information or signature has failed the validity verification, the dongle is determined to have failed the validity verification.
[0051] In some embodiments, the device information of the dongle is used to identify the dongle. For example, the device information of the dongle includes the dongle's shell number, the dongle's chip number, and the dongle's device certificate. The chip number identifies the security chip installed in the dongle. The dongle's device certificate stores the dongle's public key.
[0052] There are several ways to verify the validity of a dongle's signature. In some embodiments, the terminal interacts with an authentication server associated with the dongle. The terminal uses the private key stored in the dongle to sign the authentication data, obtaining the dongle's signature. The terminal then sends the dongle's signature to the authentication server. The authentication server receives the dongle's signature and verifies it. If the authentication server verifies the dongle's signature successfully, it generates a verification success message and sends it to the terminal. If the terminal receives the verification success message from the authentication server, it determines that the dongle's signature has passed the validity verification.
[0053] In some embodiments, authentication data includes a session identifier, a random number, and a timestamp. The session identifier identifies the session established between the terminal and the authentication server; for example, the session identifier is a globally unique identifier (GUID) for the session. In some embodiments, the authentication server generates authentication data and sends it to the terminal. The terminal receives the authentication data sent by the server. By using a combination of session identifier, random number, and timestamp as authentication data, the authentication data possesses uniqueness and replay resistance, thereby improving the security of the authentication data. Uniqueness means that the authentication data is unique for each terminal. Replay resistance means that the authentication data is only valid once, expires, and is immediately deleted after verification, preventing the authentication data from being reused.
[0054] Regarding the signature verification process of the authentication server on the dongle, in some embodiments, the authentication server obtains the dongle's certificate, which contains the dongle's public key. The authentication server uses the dongle's public key to decrypt the dongle's signature, obtaining authentication data. The authentication server determines whether the decrypted authentication data matches the authentication data previously sent to the terminal. If the decrypted authentication data matches the previously sent authentication data, the authentication server's signature verification of the dongle is successful.
[0055] In some embodiments, the process of verifying the legitimacy of device information involves interaction between the terminal and the authentication server. Specifically, the terminal obtains the device information of the dongle and sends this information to the authentication server associated with the dongle. The authentication server receives the device information and verifies it. If the authentication server verifies the device information successfully, it sends a verification success message to the terminal. If the terminal receives the verification success message from the authentication server, it determines that the dongle's device information has passed the legitimacy verification.
[0056] There are several ways an authentication server verifies the device information of a dongle. In some embodiments, device information for each dongle sold is stored in a database. After receiving the device information of the dongle sent by the terminal, the authentication server queries the database for the stored device information and compares it with the device information of the dongle sent by the terminal. If the device information of the dongle sent by the terminal matches the device information of the dongle stored in the database, the authentication server sends a verification success message to the terminal.
[0057] Step S103: If the terminal has connected to the dongle and the dongle has passed the validity verification, the terminal imports the sample data stored in the terminal's local file system into the model training application, and the model training application trains the neural network based on the sample data.
[0058] The sample data described above is used to train the neural network. For example, the sample data may include images, text, audio, and video. The sample data may also be labeled to indicate its type.
[0059] Regarding the specific process of training a neural network, in some implementations, the aforementioned model training application stores an initial neural network and a loss function. After the terminal imports sample data into the model training application, it inputs the sample data into the initial neural network through the model training application. The terminal processes the sample data through the initial neural network and obtains the output result. The terminal calculates the loss value based on the output result of the initial neural network and the label through the model training application. The loss value represents the deviation between the output result of the initial neural network and the label. The terminal updates the parameters of the initial neural network based on the loss value through the model training application. The terminal determines whether the initial neural network has converged; if the initial neural network has not converged, the terminal continues to execute the process of inputting sample data into the initial neural network and updating parameters. If the initial neural network has converged, the terminal ends the training process and uses the current neural network as the trained neural network. For example, initial neural network convergence occurs when the number of training epochs exceeds a threshold, or when the loss value is less than a threshold.
[0060] With the above implementation method, the terminal does not need to upload sample data to the cloud. Instead, it can train the model through the model training application running locally. Therefore, it realizes offline model training on the terminal side, supports sample data and neural networks to not leave the terminal, thereby avoiding the leakage of sample data and models during network transmission and improving data security.
[0061] In some embodiments, if the terminal is not connected to the dongle or the dongle fails the validity verification, the terminal refuses to import the sample data into the model training application and refuses to train the neural network through the model training application.
[0062] In some embodiments, after the terminal trains the neural network, it encapsulates the neural network to obtain a corresponding software development kit (SDK); the terminal then outputs the SSD. In some embodiments, users can perform secondary development on the SSD to meet business needs. In some embodiments, the SSD includes an API interface for further training of the neural network.
[0063] The method provided in this embodiment requires the user to connect a dongle to the terminal when training a neural network. Only after the dongle passes authentication can the user gain permission to import sample data and train the neural network. If the user removes the dongle from the terminal, or if the dongle connected to the terminal is an unauthorized device, data cannot be uploaded and the neural network cannot be trained, thus reducing the risk of sample data leakage if the user's account and password are stolen. Furthermore, this method supports offline neural network training on the device side, preventing sample data leakage during transmission between the terminal and the server, thereby improving data security.
[0064] Figure 2 This is a schematic diagram of a neural network training device 200 provided in an embodiment of this application. The device 200 is located at a terminal and includes:
[0065] The receiving module 201 is used to receive a training instruction, which instructs the terminal to train a neural network through a model training application.
[0066] The detection module 202 is used to detect whether the terminal has been connected to the dongle bound to the model training application, and to detect whether the dongle has passed the legality verification.
[0067] The training module 203 is used to import sample data stored in the local file system of the terminal into the model training application if the terminal has been connected to the dongle and the dongle has passed the legality verification, and then train the neural network based on the sample data through the model training application.
[0068] In some embodiments, the detection module 202 is used to detect whether the device information of the dongle has passed the legality verification and whether the signature of the dongle has passed the legality verification; if the device information of the dongle has passed the legality verification and the signature of the dongle has passed the legality verification, it is determined that the dongle has passed the legality verification.
[0069] In some embodiments, the detection module 202 is used to sign the authentication data using the private key stored in the dongle to obtain the signature of the dongle; send the signature of the dongle to the authentication server associated with the dongle; and if a verification pass message is received from the authentication server, determine that the signature of the dongle has passed the legality verification.
[0070] In some embodiments, the receiving module 201 is further configured to receive the authentication data sent by the authentication server, the authentication data including a session identifier, a random number and a timestamp, the session identifier being used to identify the session established between the terminal and the authentication server.
[0071] In some embodiments, the detection module 202 is used to send the device information of the dongle to the authentication server associated with the dongle; if a verification pass message is received from the authentication server, it is determined that the device information of the dongle has passed the legality verification.
[0072] In some embodiments, the device information includes the dongle's shell number, the dongle's chip number, and the dongle's device certificate.
[0073] In some embodiments, the device 200 further includes: an encapsulation module for encapsulating the neural network to obtain a software development kit corresponding to the neural network;
[0074] The output module is used to output the software development kit.
[0075] It should be noted that the neural network training device provided in the above embodiments is only illustrated by the division of the above functional modules when training a neural network. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the neural network training device can be divided into different functional modules to complete all or part of the functions described above. In addition, the neural network training device and the neural network training method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0076] Figure 3 This is a schematic diagram of the structure of a terminal 300 provided in an embodiment of this application. The terminal 300 includes a processor 301 and a memory 302. The memory 302 stores computer program instructions, and the processor 301 executes the computer program instructions to implement the above-mentioned... Figure 1 The steps in the method shown in the embodiment.
[0077] The terminal 300 can be: a smartphone, tablet computer, MP3 (Moving Picture Experts Group Audio Layer III) player, MP4 (Moving Picture Experts Group Audio Layer IV) player, laptop computer, or desktop computer. The terminal 300 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0078] Processor 301 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 301 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 301 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 301 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 301 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0079] The memory 302 may include one or more computer-readable storage media, which may be non-transitory. The memory 302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices.
[0080] Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium 400 provided in an embodiment of this application. The computer-readable storage medium stores computer program instructions 401, which, when executed by a processor, implement the above-described... Figure 1 The steps in the method shown in the embodiment.
[0081] This application also provides a computer program product, which includes computer program instructions that, when executed by a processor, implement the above-described functionality. Figure 1 The steps in the method shown in the embodiment.
[0082] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0083] It should also be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0084] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0085] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A neural network training method, characterized by, The method is executed by a terminal and comprises: receiving a training instruction, the training instruction being used to instruct the terminal to train a neural network by using a local model training application; detecting whether the terminal has connected a hardware dongle bound to the local model training application and whether the hardware dongle passes a legality verification, the hardware dongle being used to encrypt and authorize the local model training application; if the terminal has connected the hardware dongle and the hardware dongle passes the legality verification, importing sample data saved in a local file system of the terminal into the local model training application, and training a neural network based on the sample data by using the local model training application; packaging the neural network to obtain a software development kit corresponding to the neural network; outputting the software development kit, the software development kit comprising an API interface, the API interface being used to continue training the neural network.
2. The method of claim 1, wherein, The detecting whether the dongle passes the legality verification comprises: detecting whether device information of the dongle passes the legality verification and whether a signature of the dongle passes the legality verification; if the device information of the dongle passes the legality verification and the signature of the dongle passes the legality verification, determining that the dongle passes the legality verification.
3. The method of claim 2, wherein, The detecting whether the signature of the dongle passes the legality verification comprises: using a private key saved by the dongle to sign authentication data to obtain the signature of the dongle; sending the signature of the dongle to an authentication server associated with the dongle; if a verification pass message sent by the authentication server is received, determining that the signature of the dongle passes the legality verification.
4. The method of claim 3, wherein, Before the using the private key saved by the dongle to sign the authentication data, the method further comprises: receiving the authentication data sent by the authentication server, the authentication data comprising a session identifier, a random number and a timestamp, the session identifier being used to identify a session established between the terminal and the authentication server.
5. The method of claim 2, wherein, The detecting whether the device information of the dongle passes the legality verification comprises: sending the device information of the dongle to an authentication server associated with the dongle; if a verification pass message sent by the authentication server is received, determining that the device information of the dongle passes the legality verification.
6. The method according to any one of claims 2 to 5, characterized in that, The device information comprises a dongle shell number, a dongle chip number and a dongle device certificate of the dongle.
7. A neural network training apparatus characterized by comprising: The terminal comprises: a receiving module, configured to receive a training instruction, the training instruction being used to instruct the terminal to train a neural network by using a local model training application; a detecting module, configured to detect whether the terminal has connected a hardware dongle bound to the local model training application and whether the hardware dongle passes a legality verification, the hardware dongle being used to encrypt and authorize the local model training application; a training module, configured to, if the terminal has connected the hardware dongle and the hardware dongle passes the legality verification, import sample data saved in a local file system of the terminal into the local model training application, and train a neural network offline at an end side based on the sample data through the local model training application; a packaging module, configured to package the neural network to obtain a software development kit corresponding to the neural network, and output the software development kit, the software development kit comprising an API interface, the API interface being used for continuous training of the neural network.
8. A terminal, characterized by comprising: The terminal comprises a processor and a memory, and the memory stores computer program instructions. When the processor executes the computer program instructions, the steps in the method according to any one of claims 1-6 are implemented.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions. When the computer program instructions are executed by a processor, the steps in the method according to any one of claims 1-6 are implemented.
Citation Information
Patent Citations
Information verification method and device
CN106713270A