CN118157999B - Model training method, device, terminal and storage medium - Google Patents
Model training method, device, terminal and storage medium Download PDFInfo
- Publication number
- CN118157999B CN118157999B CN202410579372.8A CN202410579372A CN118157999B CN 118157999 B CN118157999 B CN 118157999B CN 202410579372 A CN202410579372 A CN 202410579372A CN 118157999 B CN118157999 B CN 118157999B
- Authority
- CN
- China
- Prior art keywords
- model
- network intrusion
- network
- data
- parameter
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 50
- 238000012549 training Methods 0.000 title claims abstract description 50
- 238000001514 detection method Methods 0.000 claims abstract description 76
- 230000006870 function Effects 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 5
- 238000013473 artificial intelligence Methods 0.000 abstract description 2
- 238000004891 communication Methods 0.000 description 11
- 238000012360 testing method Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 6
- 230000003993 interaction Effects 0.000 description 3
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 2
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000010606 normalization Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 1
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 1
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004140 cleaning Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/14—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
- H04L63/1408—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N10/00—Quantum computing, i.e. information processing based on quantum-mechanical phenomena
- G06N10/40—Physical realisations or architectures of quantum processors or components for manipulating qubits, e.g. qubit coupling or qubit control
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N20/00—Machine learning
- G06N20/20—Ensemble learning
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/14—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
- H04L63/1441—Countermeasures against malicious traffic
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/40—Network security protocols
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- General Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- Theoretical Computer Science (AREA)
- Signal Processing (AREA)
- Computer Networks & Wireless Communication (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Evolutionary Computation (AREA)
- Computer Hardware Design (AREA)
- Data Mining & Analysis (AREA)
- Artificial Intelligence (AREA)
- Medical Informatics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Mathematical Analysis (AREA)
- Condensed Matter Physics & Semiconductors (AREA)
- Computational Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Information Transfer Between Computers (AREA)
Abstract
Description
技术领域Technical Field
本申请实施例涉及人工智能技术领域,尤其涉及一种模型训练方法、装置、终端及存储介质。The embodiments of the present application relate to the field of artificial intelligence technology, and in particular to a model training method, device, terminal and storage medium.
背景技术Background Art
相关技术中的网络入侵模型的训练方案,通常是从大量的客户端收集流量数据,然后将收集到的流量数据上传到服务器,以便服务器基于收集到的流量数据作为训练样本对网络入侵模型进行训练。然而,在将客户端的流量数据上传到服务器的过程中,用户的隐私数据也容易被上传至服务器,导致流量数据的上传过程中容易出现隐私泄露的风险。The training scheme of network intrusion models in related technologies usually collects traffic data from a large number of clients and then uploads the collected traffic data to a server so that the server can train the network intrusion model based on the collected traffic data as training samples. However, in the process of uploading the client's traffic data to the server, the user's private data is also easily uploaded to the server, resulting in the risk of privacy leakage in the process of uploading traffic data.
发明内容Summary of the invention
本申请实施例提供一种模型训练方法、装置、终端及存储介质,以解决相关技术中的网络入侵模型的训练方案存在的隐私泄露的问题。The embodiments of the present application provide a model training method, device, terminal and storage medium to solve the problem of privacy leakage in the training scheme of the network intrusion model in the related art.
为解决上述问题,本申请是这样实现的:To solve the above problems, this application is implemented as follows:
第一方面,本申请实施例提供了一种模型训练方法,用于终端,包括:In a first aspect, an embodiment of the present application provides a model training method for a terminal, comprising:
获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;Obtaining a first model parameter, where the first model parameter is a model parameter corresponding to a first network intrusion model after training based on a target sample, where the target sample includes image network data or text network data, where the first network intrusion model is a model obtained by updating a preset initial model in the i-th iteration, and where the preset initial model is a model for performing network intrusion detection on network data, and i is a positive integer;
向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;Sending the first model parameter and the detection accuracy value of the first network intrusion model to a server;
接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;receiving a second model parameter sent by the server, where the second model parameter is a model parameter calculated by a global network intrusion model of the server based on the first model parameter and the detection accuracy value;
基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;Based on the second model parameters, the model parameters of the first network intrusion model are updated to obtain a second network intrusion model;
其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。The second network intrusion model is a model obtained by updating the preset initial model in the i+1th iteration.
第二方面,本申请实施例提供了一种模型训练装置,用于终端,包括:In a second aspect, an embodiment of the present application provides a model training device for a terminal, comprising:
获取模块,用于获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;An acquisition module is used to acquire a first model parameter, wherein the first model parameter is a model parameter corresponding to a first network intrusion model after training based on a target sample, wherein the target sample includes image network data or text network data, and the first network intrusion model is a model obtained by updating a preset initial model in the i-th iteration, and the preset initial model is a model for performing network intrusion detection on network data, and i is a positive integer;
发送模块,用于向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;A sending module, used for sending the first model parameter and the detection accuracy value of the first network intrusion model to a server;
接收模块,用于接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;A receiving module, configured to receive a second model parameter sent by the server, where the second model parameter is a model parameter calculated by a global network intrusion model of the server based on the first model parameter and the detection accuracy value;
更新模块,用于基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;An updating module, configured to update the model parameters of the first network intrusion model based on the second model parameters to obtain a second network intrusion model;
其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。The second network intrusion model is a model obtained by updating the preset initial model in the i+1th iteration.
第三方面,本申请实施例还提供一种终端,包括:收发机、存储器、处理器及存储在所述存储器上并可在所述处理器上运行的程序;所述处理器,用于读取存储器中的程序实现如前述第一方面所述方法中的步骤。In a third aspect, an embodiment of the present application further provides a terminal, comprising: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor; the processor is used to read the program in the memory to implement the steps of the method described in the first aspect above.
第四方面,本申请实施例还提供一种可读存储介质,用于存储程序,所述程序被处理器执行时实现如前述第一方面所述方法中的步骤。In a fourth aspect, an embodiment of the present application further provides a readable storage medium for storing a program, which, when executed by a processor, implements the steps in the method described in the first aspect above.
第五方面,提供一种计算机程序产品,包括计算机指令,所述计算机指令被处理器执行时实现如前述第一方面所述方法中的步骤。According to a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the method described in the first aspect.
在本申请实施例中,通过获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。这样在模型的训练过程中,终端和服务器之间仅是进行模型参数的交互,并未涉及到具体的流量数据的交互,相对于常规方案中需要从各终端收集流量数据,并基于收集到的流量数据对全局网络入侵模型进行训练,不仅可以避免用户隐私数据泄密的问题,还可以降低服务器在模型训练过程中的计算成本。In an embodiment of the present application, by obtaining a first model parameter, the first model parameter is a model parameter corresponding to the first network intrusion model after training based on a target sample, the target sample includes image network data or text network data, the first network intrusion model is a model obtained by updating the preset initial model at the i-th iteration, and the preset initial model is a model for performing network intrusion detection on network data, i is a positive integer; sending the first model parameter and the detection accuracy value of the first network intrusion model to the server; receiving a second model parameter sent by the server, the second model parameter is a model parameter calculated by the global network intrusion model of the server based on the first model parameter and the detection accuracy value; updating the model parameter of the first network intrusion model based on the second model parameter to obtain a second network intrusion model; wherein the second network intrusion model is a model updated at the i+1th iteration of the preset initial model. In this way, during the model training process, the terminal and the server only interact with the model parameters, and do not involve the interaction of specific traffic data. Compared with the conventional solution that requires collecting traffic data from each terminal and training the global network intrusion model based on the collected traffic data, it can not only avoid the problem of user privacy data leakage, but also reduce the computing cost of the server during the model training process.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1是本申请实施例提供的模型训练方法的流程示意图;FIG1 is a schematic diagram of a flow chart of a model training method provided in an embodiment of the present application;
图2是本申请实施例提供的联邦量子学习框架的结构示意图;FIG2 is a schematic diagram of the structure of a federated quantum learning framework provided in an embodiment of the present application;
图3是本申请实施例提供的模型训练装置的结构示意图;FIG3 is a schematic diagram of the structure of a model training device provided in an embodiment of the present application;
图4是本申请实施例提供的终端的结构示意图。FIG4 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
本申请实施例中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。此外,本申请中使用“和/或”表示所连接对象的至少其中之一,例如A和/或B和/或C,表示包含单独A,单独B,单独C,以及A和B都存在,B和C都存在,A和C都存在,以及A、B和C都存在的7种情况。The terms "first", "second" etc. in the embodiments of the present application are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. In addition, the terms "include" and "have" and any variation thereof are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units need not be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. In addition, "and/or" is used in the present application to represent at least one of connected objects, such as A and/or B and/or C, representing the inclusion of separate A, separate B, separate C, and A and B all exist, B and C all exist, A and C all exist, and 7 situations that A, B and C all exist.
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
以下对本申请实施例提供的模型训练方法进行说明。The model training method provided in the embodiments of the present application is described below.
参见图1,图1是本申请实施例提供的模型训练方法的流程示意图。图1所示的模型训练方法可以由终端执行。Referring to Figure 1, Figure 1 is a flow chart of a model training method provided in an embodiment of the present application. The model training method shown in Figure 1 can be executed by a terminal.
如图1所示,模型训练方法可以包括以下步骤:As shown in FIG1 , the model training method may include the following steps:
步骤101、获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数。Step 101: Obtain first model parameters, where the first model parameters are model parameters corresponding to a first network intrusion model after training based on a target sample.
其中,上述目标样本包括图像网络数据或文本网络数据,上述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数。Among them, the above-mentioned target sample includes image network data or text network data, the above-mentioned first network intrusion model is a model obtained by updating the preset initial model in the i-th iteration, and the preset initial model is a model for network intrusion detection on network data, and i is a positive integer.
由于预设初始模型为用于对网络数据进行网络入侵检测的模型,因此基于预设初始模型迭代生成的第一网络入侵模型也可以实现对网络数据进行网络入侵检测。Since the preset initial model is a model used for performing network intrusion detection on network data, the first network intrusion model iteratively generated based on the preset initial model can also realize network intrusion detection on network data.
可以理解的是,用于对第一网络入侵模型进行训练的目标样本可以是网络入侵数据,通过利用网络入侵数据对第一网络入侵模型进行训练,可以提升网络入侵模型的收敛速度和网络入侵检测精度。It is understandable that the target sample used to train the first network intrusion model may be network intrusion data. By using the network intrusion data to train the first network intrusion model, the convergence speed of the network intrusion model and the accuracy of network intrusion detection may be improved.
上述目标样本可以是终端的本地网络数据,并可以直接基于本地网络数据在终端侧对网络入侵模型进行训练,避免了将本地网络数据上传到服务器导致的隐私泄密问题,提升了用户的隐私数据的私密性。The above-mentioned target samples can be the local network data of the terminal, and the network intrusion model can be trained directly on the terminal side based on the local network data, avoiding the privacy leakage problem caused by uploading the local network data to the server, and improving the privacy of the user's private data.
步骤102、向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值。Step 102: Send the first model parameters and the detection accuracy value of the first network intrusion model to a server.
本实施例中,可以通过将测试数据输入到第一网络入侵模型,得到网络入侵检测结果,并基于得到的网络入侵检测结果确定第一网络入侵模型的检测精度值。In this embodiment, the test data may be input into the first network intrusion model to obtain a network intrusion detection result, and the detection accuracy value of the first network intrusion model may be determined based on the obtained network intrusion detection result.
例如,将测试数据A输入到第一网络入侵模型,得到的网络入侵检测结果为测试数据A为网络入侵数据的概率为0.7,则可以确定第一网络入侵模型的检测精度值为0.7。For example, when the test data A is input into the first network intrusion model and the obtained network intrusion detection result is that the probability that the test data A is network intrusion data is 0.7, it can be determined that the detection accuracy value of the first network intrusion model is 0.7.
在实际应用中,可以将多组测试数据输入第一网络入侵模型中,并得到多个网络入侵检测结果,并求取多个网络入侵检测结果对应的检测精度平均值,最后将平均值确定为第一网络入侵模型的检测精度值。In practical applications, multiple groups of test data can be input into the first network intrusion model to obtain multiple network intrusion detection results, and the average detection accuracy corresponding to the multiple network intrusion detection results can be calculated, and finally the average value is determined as the detection accuracy value of the first network intrusion model.
例如,针对测试数据A、测试数据B和测试数据C,其在第一网络入侵模型中的检测精度值分别为0.65、0.7、0.75,则可以将第一网络入侵模型的检测精度值确定为(0.65+0.7+0.75)/3,即可以得到第一网络入侵模型的检测精度值0.70。For example, for test data A, test data B, and test data C, their detection accuracy values in the first network intrusion model are 0.65, 0.7, and 0.75, respectively. The detection accuracy value of the first network intrusion model can be determined as (0.65+0.7+0.75)/3, that is, the detection accuracy value of the first network intrusion model can be obtained as 0.70.
步骤103、接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数。Step 103: Receive second model parameters sent by the server, where the second model parameters are model parameters calculated by the global network intrusion model of the server based on the first model parameters and the detection accuracy value.
上述全局网络入侵模型可以理解为服务器侧的网络入侵模型,其可以接收来自不同的终端发送的第一模型参数和检测精度值,并综合接收到的第一模型参数和检测精度值,对全局网络入侵模型的模型参数进行更新,并将更新得到的模型参数确定为第二模型参数。The above-mentioned global network intrusion model can be understood as a network intrusion model on the server side, which can receive first model parameters and detection accuracy values sent from different terminals, and comprehensively update the model parameters of the global network intrusion model based on the received first model parameters and detection accuracy values, and determine the updated model parameters as the second model parameters.
本实施例中,由于服务器可以接收来自不同终端所发送的第一模型参数和检测精度值,相对于从各终端收集流量数据,并基于收集到的流量数据对全局网络入侵模型进行训练,不仅可以避免用户隐私数据泄密的问题,还可以降低服务器在模型训练过程中的计算成本。In this embodiment, since the server can receive the first model parameters and detection accuracy values sent from different terminals, compared to collecting traffic data from each terminal and training the global network intrusion model based on the collected traffic data, it can not only avoid the problem of user privacy data leakage, but also reduce the computing cost of the server during the model training process.
而且,由于第二模型参数是服务器基于不同的终端发送的第一模型参数和检测精度值所确定的,因此终端侧的第一网络入侵模型在基于第二模型参数进行更新后所得到的网络入侵模型,能够具备全局网络入侵模型的网络入侵检测性能,大幅提高了终端侧的网络入侵模型的网络入侵检测性能。Moreover, since the second model parameters are determined by the server based on the first model parameters and detection accuracy values sent by different terminals, the network intrusion model obtained after the first network intrusion model on the terminal side is updated based on the second model parameters can have the network intrusion detection performance of the global network intrusion model, which greatly improves the network intrusion detection performance of the network intrusion model on the terminal side.
进一步地的,由于终端与服务器的信息交互主要是模型参数的交互,相对于常规方案中需要上传大量的流量数据,可以有效降低终端和服务器之间的通信压力。Furthermore, since the information interaction between the terminal and the server is mainly the interaction of model parameters, compared with the conventional solution that requires uploading a large amount of traffic data, the communication pressure between the terminal and the server can be effectively reduced.
步骤104、基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型。Step 104: Update the model parameters of the first network intrusion model based on the second model parameters to obtain a second network intrusion model.
其中,上述第二网络入侵模型可以理解为上述预设初始模型在第i+1次迭代更新得到的模型。The second network intrusion model can be understood as a model obtained by updating the preset initial model in the i+1th iteration.
在一个实施例中,所述获取第一模型参数,包括:In one embodiment, obtaining the first model parameter includes:
获取目标样本;Obtain target samples;
获取所述第一网络入侵模型的公平系数;Obtaining a fairness coefficient of the first network intrusion model;
基于所述公平系数确定所述第一网络入侵模型的模型参数;Determining model parameters of the first network intrusion model based on the fairness coefficient;
使用所述目标样本对所述第一网络入侵模型进行训练,以对所述第一网络入侵模型的模型参数进行更新,并将更新后的所述第一网络入侵模型的模型参数确定为第一模型参数。The first network intrusion model is trained using the target sample to update the model parameters of the first network intrusion model, and the updated model parameters of the first network intrusion model are determined as the first model parameters.
本实施例中,可以获取第一网络入侵模型的公平系数,并基于其公平参数对其模型参数进行更新,降低了异常样本对模型训练的影响。In this embodiment, the fairness coefficient of the first network intrusion model can be obtained, and its model parameters are updated based on its fairness parameter, thereby reducing the impact of abnormal samples on model training.
上述目标样本可以理解为终端侧所检测到的网络入侵数据,包括但不限于图片、文字等网络入侵内容。The above-mentioned target samples can be understood as network intrusion data detected on the terminal side, including but not limited to network intrusion content such as pictures and texts.
在一个实施例中,所述获取所述第一网络入侵模型的公平系数,包括:In one embodiment, obtaining the fairness coefficient of the first network intrusion model includes:
获取所述第一网络入侵模型和第三网络入侵模型的距离系数,所述第三网络入侵模型为所述预设初始模型在第i-1次迭代更新得到的模型,所述距离系数用于表征模型的变化程度;Obtaining a distance coefficient between the first network intrusion model and a third network intrusion model, wherein the third network intrusion model is a model obtained by updating the preset initial model at the i-1th iteration, and the distance coefficient is used to characterize the degree of change of the model;
基于所述距离系数和预设常数项计算得到所述第一网络入侵模型的公平系数。The fairness coefficient of the first network intrusion model is calculated based on the distance coefficient and a preset constant term.
上述第一网络入侵模型可以理解为当前时刻的网络入侵模型,上述第三网络入侵模型可以理解为上一时刻的网络入侵模型。The first network intrusion model can be understood as a network intrusion model at the current moment, and the third network intrusion model can be understood as a network intrusion model at the previous moment.
本实施例中,可以通过获取第一网络入侵模型和第三网络入侵模型的距离系数,以确定模型的变化程度,进而记忆模型的变化程度计算得到第一网络入侵模型的公平系数,从而降低异常样本对模型训练的影响。In this embodiment, the distance coefficients between the first network intrusion model and the third network intrusion model can be obtained to determine the degree of change of the model, and then the degree of change of the model can be memorized to calculate the fairness coefficient of the first network intrusion model, thereby reducing the impact of abnormal samples on model training.
例如,可以基于公式:For example, based on the formula:
计算距离系数dk,式中,dk表示第一网络入侵模型和第三网络入侵模型的距离系数,且dk越小说明模型的变化程度越大,wr-1表示第三网络入侵模型的模型参数,wr表示第一网络入侵模型的模型参数,k可以理解为终端侧的网络模型,r可以理解为终端和服务器之间的第几次通信,且r=1,2,3…。Calculate the distance coefficient d k , where d k represents the distance coefficient between the first network intrusion model and the third network intrusion model, and the smaller d k is , the greater the degree of change of the model is, w r-1 represents the model parameters of the third network intrusion model, w r represents the model parameters of the first network intrusion model, k can be understood as the network model on the terminal side, r can be understood as the number of communications between the terminal and the server, and r=1,2,3….
在确定距离系数dk后,可以基于公式:After determining the distance coefficient d k , it can be based on the formula:
计算第一网络入侵模型的公平系数qk,式中,表示常数项,其可以为预设值。Calculate the fairness coefficient q k of the first network intrusion model, where: Represents a constant term, which can be a preset value.
在确定公平系数qk后,可以基于公式:After determining the fairness coefficient q k , it can be based on the formula:
计算公平系数区平均值得到qave和第一网络入侵模型的损失函数Loss(Wr)。The fairness coefficient area average is calculated to obtain q ave and the loss function Loss(W r ) of the first network intrusion model.
在确定第一网络入侵模型的损失函数Loss(Wr)后,可以基于第一网络入侵模型的模型参数wr和损失函数Loss(Wr)计算得到上述第一模型参数wr+1。具体地,可以基于公式:After determining the loss function Loss(W r ) of the first network intrusion model, the first model parameter w r+1 can be calculated based on the model parameter w r of the first network intrusion model and the loss function Loss(W r ). Specifically, it can be based on the formula:
式中,n表示学习率。Where n represents the learning rate.
通过上述过程可以实现公平系数对第一网络入侵模型的模型参数进行更新,进而得到上述第一模型参数。Through the above process, the fairness coefficient can be used to update the model parameters of the first network intrusion model, thereby obtaining the above first model parameters.
在一个实施例中,所述获取目标样本,包括:In one embodiment, obtaining a target sample includes:
获取所述终端的目标网络数据,所述目标网络数据为所述终端的本地网络入侵数据;Acquire target network data of the terminal, where the target network data is local network intrusion data of the terminal;
基于量子生成对抗网络生成与所述目标网络数据对应的假数据;Generate false data corresponding to the target network data based on a quantum generative adversarial network;
将所述目标网络数据和所述假数据进行乱序合并处理,得到目标样本。The target network data and the false data are merged in random order to obtain a target sample.
本实施例中,可以基于量子生成对抗网络生成与目标网络数据对应的假数据,进而对目标网络数据和假数据进行乱序合并处理以得到目标样本,从而扩充目标样本的数量。In this embodiment, false data corresponding to the target network data can be generated based on the quantum generative adversarial network, and then the target network data and the false data are randomly merged to obtain a target sample, thereby expanding the number of target samples.
在一个实施例中,针对获取的目标网络数据,可以先对目标网络数据进行预处理,预处理包括但不限于数据清洗、数值化、归一化、数据乱序拆分等处理方式。In one embodiment, the acquired target network data may be preprocessed first, and the preprocessing includes but is not limited to data cleaning, digitization, normalization, data random splitting and other processing methods.
而且,在获取的目标网络数据较少的情况下,即样本数量不够的情况下,还可以应用量子生成对抗网络(Quantum Generative Adversarial Networks,QGAN)进行样本数据扩充,解决了数据样本小和分布不平衡的问题,并提高了终端侧的网络入侵模型更新的效率和入侵检测模型的健壮性,以及改善了样本数据的不平衡性。Moreover, when the target network data obtained is small, that is, the number of samples is insufficient, quantum generative adversarial networks (QGAN) can be used to expand the sample data, which solves the problems of small data samples and unbalanced distribution, improves the efficiency of updating the network intrusion model on the terminal side and the robustness of the intrusion detection model, and improves the imbalance of sample data.
其中,应用QGAN进行样本数据扩充包括以下步骤:Among them, applying QGAN to expand sample data includes the following steps:
步骤a、对QGAN进行初始化处理,且量子生成对抗网络包括生成器G、鉴别器D和一个条件标签。Step a: Initialize QGAN, and the quantum generative adversarial network includes a generator G, a discriminator D and a conditional label .
步骤b、训练QGAN ,对于迭代次数,包括:Step b: Train QGAN, for the number of iterations ,include:
对于攻击类型,有:For attack type ,have:
特征值归一化:每条网络数据有K个特征 ,每个特征值为,为了更好的将数据输入量子生成对抗网络,有Eigenvalue normalization: Each network data has K features, and each eigenvalue is , in order to better input data into the quantum generative adversarial network, there is
式中,所有β值的和为1,q为满足情况下的最小值,则。In the formula, the sum of all β values is 1, and q satisfies The minimum value in the case of .
其中,网络数据作为量子生成对抗网络输入可以表示为:Among them, the network data as the input of the quantum generative adversarial network can be expressed as:
生成器可以基于公式GD(i,a)=Gi(n,la)生成假数据GD(i,a),在生成假数据GD(i,a)后,可以将假数据GD(i,a)与预处理后的数据D'合并,且假数据GD(i,a)的标志可以设置为0,真实数据D'的标志可以设置为1,并可以将假数据GD(i,a)和真实数据D'乱序合并为data(i,a)以得到扩充后的样本数据。The generator can generate fake data GD (i,a) based on the formula GD (i,a) = G i (n,l a ). After generating the fake data GD (i,a) , the fake data GD (i,a) can be merged with the preprocessed data D', and the flag of the fake data GD (i,a) can be set to 0, the flag of the real data D' can be set to 1, and the fake data GD (i,a) and the real data D' can be merged in random order into data (i,a) to obtain the expanded sample data.
在得到扩充后的样本数据data(i,a)后,可以通过鉴别器D鉴定数据,且如果给定的是真实的数据,则返回值为1,否则返回值为0。After obtaining the expanded sample data data (i, a) , the data can be identified by the discriminator D, and if the given data is real, the return value is 1, otherwise the return value is 0.
具体地,可以基于公式:Specifically, it can be based on the formula:
计算QGAN第i次迭代中的目标函数值V(D,G);其中,E G 为生成器的目标函数,E D 为鉴别器的目标函数,D(G(Z))表示鉴别器对生成样本的预测输出,D(x)表示鉴别器对真实样本的预测输出;然后通过判断V(D,G)是否趋于稳定,如果是,则生成假数据;如果否,则令i=i+1,并基于公式:Calculate the objective function value V( D ,G) in the i-th iteration of QGAN; where EG is the objective function of the generator, ED is the objective function of the discriminator, D ( G ( Z )) represents the predicted output of the discriminator for the generated sample, and D ( x ) represents the predicted output of the discriminator for the real sample; then determine whether V(D,G) tends to be stable. If so, generate fake data; if not, set i=i+1, and based on the formula:
计算目标函数值更新学习率n下QGAN模型参数w(QGAN,i+1)。Calculate the objective function value and update the QGAN model parameters w (QGAN,i+1) under the learning rate n.
步骤c、生成器合成假数据。在生成假数据的过程中,βi可以看作是相应特征值的出现概率,量子生成器可以根据此概率分布来生成新数据,经过量子生成对抗网络的迭代训练,合成数据不断向真实数据靠近,其中生成器合成的数据如下:Step c: The generator synthesizes fake data. In the process of generating fake data, β i can be regarded as the probability of occurrence of the corresponding eigenvalue. The quantum generator can generate new data according to this probability distribution. After iterative training of the quantum generative adversarial network, the synthesized data Constantly looking to real data Close to where the data synthesized by the generator as follows:
在一个实施例中,所述向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值,包括:In one embodiment, sending the first model parameter and the detection accuracy value of the first network intrusion model to the server includes:
获取所述第一网络入侵模型的检测精度值;Obtaining a detection accuracy value of the first network intrusion model;
在所述检测精度值大于或等于预设精度值的情况下,向服务器发送所述第一模型参数和所述检测精度值;When the detection accuracy value is greater than or equal to a preset accuracy value, sending the first model parameter and the detection accuracy value to a server;
其中,所述预设精度值为基于最高精度值和最低精度值确定的。The preset precision value is determined based on the highest precision value and the lowest precision value.
本实施例中,通过设置发送条件,即判定检测精度值是否大于或等于预设精度值,以确定是否向服务器发送第一模型参数和检测精度值,避免了无效数据对服务器侧的全局网络入侵模型的影响,同时也避免了服务器侧的全局网络入侵模型对无效数据的处理,降低了服务器的运算成本。In this embodiment, by setting the sending condition, that is, determining whether the detection accuracy value is greater than or equal to the preset accuracy value, to determine whether to send the first model parameter and the detection accuracy value to the server, the influence of invalid data on the global network intrusion model on the server side is avoided, and the processing of invalid data by the global network intrusion model on the server side is also avoided, thereby reducing the computing cost of the server.
在一个实施例中,可以基于联邦量子学习(Federated Quantum Learning,FQL)框架对模型参数进行更新处理。In one embodiment, the model parameters may be updated based on a Federated Quantum Learning (FQL) framework.
如图2所示的联邦量子学习框架,包括服务器侧的全局网络入侵模型和N个终端侧的本地模型,终端侧的本地模型可以理解为上述第一网络入侵模型。全局网络入侵模型可以将模型参数GW0、学习率ρ、批次大小B、损失函数f、通信回合总数R发送至参与训练的每个本地模型,将data分为独立同分布的N部分,分发至参与训练的每个本地模型。为本地模型通信状态,初始值为1。The federated quantum learning framework shown in Figure 2 includes a global network intrusion model on the server side and N local models on the terminal side. The local model on the terminal side can be understood as the first network intrusion model mentioned above. The global network intrusion model can send model parameters GW 0 , learning rate ρ, batch size B, loss function f, and total number of communication rounds R to each local model participating in the training, and divide the data into N independent and identically distributed parts, and distribute them to each local model participating in the training. It is the local model communication status, and the initial value is 1.
对于通信次数,有:For the number of communications ,have:
计算公平系数,并对本地模型参数进行更新。Calculate the fairness coefficient and update the local model parameters.
全局网络入侵模型可以根据过滤加权策略将部分本地模型参数上传至全局模型。具体地,可以通过计算终端侧的本地网络入侵模型的检测精度Acc,如果检测精度Acc<κ,则将其通信状态设置为错误,赋值,不上传本地模型参数至全局网络入侵模型,并仅有在检测精度Acc≥κ的情况下,并上传本地模型参数至全局网络入侵模型,以降低无效数据对服务器侧的全局网络入侵模型的影响。The global network intrusion model can upload some local model parameters to the global model according to the filtering weighting strategy. Specifically, the detection accuracy Acc of the local network intrusion model on the terminal side can be calculated. If the detection accuracy Acc<κ, its communication state is set to error and the value is assigned , do not upload local model parameters to the global network intrusion model, and only upload local model parameters to the global network intrusion model when the detection accuracy Acc ≥ κ to reduce the impact of invalid data on the global network intrusion model on the server side.
而且,通过这样设置,还可以减少表现不佳的本地模型对全局网络入侵模型的影响,减少了通信开销,提高了入侵检测全局模型性能。Moreover, through such a setting, the impact of poorly performing local models on the global network intrusion model can be reduced, the communication overhead can be reduced, and the performance of the global intrusion detection model can be improved.
其中,常情况下阈值κi默认为κ0。当本地模型出现严重异常,其准确率会和正常客户端准确率相差较大,如果本地模型中最高准确率与最低准确率差值高于0.4时,κ的表达式如下:Among them, under normal circumstances, the threshold κ i defaults to κ 0. When the local model has serious abnormalities, its accuracy will be greatly different from the normal client accuracy. If the difference between the highest accuracy and the lowest accuracy in the local model is higher than 0.4, the expression of κ is as follows:
可以理解的是,本地模型中最高准确率与最低准确率差值也可以高于0.45或者0.35设置,该取值具体可以基于实际需求进行设定。It is understandable that the difference between the highest accuracy and the lowest accuracy in the local model may also be set higher than 0.45 or 0.35, and the specific value may be set based on actual needs.
服务器可以接收状态正确的终端发送的参数集,该参数集包括终端侧的本地模型的模型参数和检测精度值等信息。The server can receive a parameter set sent by a terminal in a correct state, where the parameter set includes information such as model parameters and detection accuracy values of a local model on the terminal side.
其中,可以基于公式:Among them, it can be based on the formula:
计算贡献率,式中,η为接收状态正确客户端数量,且0<η≤N,为第r轮通信中本地终端c的样本数;然后,可以基于公式:Calculate contribution rate , where η is the number of clients with correct receiving status, and 0<η≤N, is the number of samples of the local terminal c in the rth round of communication; then, it can be based on the formula:
计算本地终端在本轮通信中的贡献率,为本地终端在本轮通信中的检测精度值;最后,可以基于公式:Calculate the contribution rate of the local terminal in this round of communication , is the detection accuracy value of the local terminal in this round of communication; finally, based on the formula:
计算得到全局网络入侵模型的模型参数,如得到上述第二模型参数,然后将计算得到的模型参数发生至每个本地终端,以使每个本地终端可以基于接收到的模型参数对本地模型进行更新。The model parameters of the global network intrusion model are calculated, such as the second model parameters, and then the calculated model parameters are sent to each local terminal, so that each local terminal can update the local model based on the received model parameters.
可以理解的是,可以判断r<R,如果是,则设置r=r+1,并将计算得到全局网络入侵模型的模型参数,同时将其通信状态设置为正确,并赋值,以进入下一轮模型训练,直至r=R。并在r=R的情况下,结束训练。It can be understood that r<R can be judged. If so, r=r+1 is set, and the model parameters of the global network intrusion model are calculated, and its communication state is set to correct and assigned , to enter the next round of model training until r = R. And when r = R, the training ends.
本实施例中,用户侧终端可以通过服务器定期交互和汇总模型参数或梯度信息来协作训练全局网络入侵模型,期间不会涉及到用户的敏感数据,有效的避免了用户隐私数据泄露的问题。In this embodiment, the user-side terminal can regularly interact with the server and summarize model parameters or gradient information to collaboratively train the global network intrusion model. During the training, the user's sensitive data will not be involved, effectively avoiding the problem of user privacy data leakage.
本申请实施例提供的模型训练方法,通过获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。这样避免了将终端侧的网络数据上传到服务器导致的隐私泄密问题,提升了用户的隐私数据的私密性。The model training method provided in the embodiment of the present application obtains a first model parameter, wherein the first model parameter is a model parameter corresponding to the first network intrusion model after training based on a target sample, wherein the target sample includes image network data or text network data, wherein the first network intrusion model is a model obtained by updating the preset initial model at the i-th iteration, and the preset initial model is a model for performing network intrusion detection on network data, wherein i is a positive integer; sends the first model parameter and the detection accuracy value of the first network intrusion model to a server; receives a second model parameter sent by the server, wherein the second model parameter is a model parameter calculated by the global network intrusion model of the server based on the first model parameter and the detection accuracy value; updates the model parameter of the first network intrusion model based on the second model parameter to obtain a second network intrusion model; wherein the second network intrusion model is a model obtained by updating the preset initial model at the i+1th iteration. This avoids the problem of privacy leakage caused by uploading the network data on the terminal side to the server, and improves the privacy of the user's private data.
本申请实施例中介绍的多种可选的实施方式,在彼此不冲突的情况下可以相互结合实现,也可以单独实现,对此本申请实施例不作限定。The various optional implementation modes introduced in the embodiments of the present application may be implemented in combination with each other or may be implemented separately if they do not conflict with each other, and the embodiments of the present application are not limited to this.
参见图3,图3是本申请实施例提供的模型训练装置的结构图。如图3所示,模型训练装置300包括:See Figure 3, which is a structural diagram of a model training device provided in an embodiment of the present application. As shown in Figure 3, the model training device 300 includes:
获取模块301,用于获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;The acquisition module 301 is used to acquire a first model parameter, wherein the first model parameter is a model parameter corresponding to a first network intrusion model after training based on a target sample, wherein the target sample includes image network data or text network data, and the first network intrusion model is a model obtained by updating a preset initial model in the i-th iteration, and the preset initial model is a model for performing network intrusion detection on network data, and i is a positive integer;
发送模块302,用于向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;A sending module 302, configured to send the first model parameter and the detection accuracy value of the first network intrusion model to a server;
接收模块303,用于接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;A receiving module 303 is used to receive a second model parameter sent by the server, where the second model parameter is a model parameter calculated by the global network intrusion model of the server based on the first model parameter and the detection accuracy value;
更新模块304,用于基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;An updating module 304, configured to update the model parameters of the first network intrusion model based on the second model parameters to obtain a second network intrusion model;
其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。The second network intrusion model is a model obtained by updating the preset initial model in the i+1th iteration.
可选地,所述获取模块301,具体用于:Optionally, the acquisition module 301 is specifically configured to:
获取目标样本;Obtain target samples;
获取所述第一网络入侵模型的公平系数;Obtaining a fairness coefficient of the first network intrusion model;
基于所述公平系数确定所述第一网络入侵模型的模型参数;Determining model parameters of the first network intrusion model based on the fairness coefficient;
使用所述目标样本对所述第一网络入侵模型进行训练,以对所述第一网络入侵模型的模型参数进行更新,并将更新后的所述第一网络入侵模型的模型参数确定为第一模型参数。The first network intrusion model is trained using the target sample to update the model parameters of the first network intrusion model, and the updated model parameters of the first network intrusion model are determined as the first model parameters.
可选地,所述获取模块301,具体用于:Optionally, the acquisition module 301 is specifically configured to:
获取所述第一网络入侵模型和第三网络入侵模型的距离系数,所述第三网络入侵模型为所述预设初始模型在第i-1次迭代更新得到的模型,所述距离系数用于表征模型的变化程度;Obtaining a distance coefficient between the first network intrusion model and a third network intrusion model, wherein the third network intrusion model is a model obtained by updating the preset initial model at the i-1th iteration, and the distance coefficient is used to characterize the degree of change of the model;
基于所述距离系数和预设常数项计算得到所述第一网络入侵模型的公平系数。The fairness coefficient of the first network intrusion model is calculated based on the distance coefficient and a preset constant term.
可选地,所述获取模块301,具体用于:Optionally, the acquisition module 301 is specifically configured to:
获取所述终端的目标网络数据,所述目标网络数据为所述终端的本地网络入侵数据;Acquire target network data of the terminal, where the target network data is local network intrusion data of the terminal;
基于量子生成对抗网络生成与所述目标网络数据对应的假数据;Generate false data corresponding to the target network data based on a quantum generative adversarial network;
将所述目标网络数据和所述假数据进行乱序合并处理,得到目标样本。The target network data and the false data are merged in random order to obtain a target sample.
可选地,所述发送模块302,具体用于:Optionally, the sending module 302 is specifically configured to:
获取所述第一网络入侵模型的检测精度值;Obtaining a detection accuracy value of the first network intrusion model;
在所述检测精度值大于或等于预设精度值的情况下,向服务器发送所述第一模型参数和所述检测精度值;When the detection accuracy value is greater than or equal to a preset accuracy value, sending the first model parameter and the detection accuracy value to a server;
其中,所述预设精度值为基于最高精度值和最低精度值确定的。The preset precision value is determined based on the highest precision value and the lowest precision value.
模型训练装置300能够实现本申请实施例中图1方法实施例的各个过程,以及达到相同的有益效果,为避免重复,这里不再赘述。The model training device 300 can implement each process of the method embodiment of Figure 1 in the embodiment of the present application, and achieve the same beneficial effects. To avoid repetition, it will not be repeated here.
参见图4,本申请实施例提供的终端的结构示意图。如图4所示,本申请实施例还提供了一种终端,包括总线401、收发机402、天线403、总线接口404、处理器405和存储器406。See Figure 4, which is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. As shown in Figure 4, an embodiment of the present application further provides a terminal, including a bus 401, a transceiver 402, an antenna 403, a bus interface 404, a processor 405 and a memory 406.
所述处理器405,用于:The processor 405 is configured to:
获取第一模型参数,所述第一模型参数为第一网络入侵模型基于目标样本训练后所对应的模型参数,所述目标样本包括图像网络数据或文本网络数据,所述第一网络入侵模型为预设初始模型在第i次迭代更新得到的模型,且所述预设初始模型为用于对网络数据进行网络入侵检测的模型,i为正整数;Obtaining a first model parameter, where the first model parameter is a model parameter corresponding to a first network intrusion model after training based on a target sample, where the target sample includes image network data or text network data, where the first network intrusion model is a model obtained by updating a preset initial model in the i-th iteration, and where the preset initial model is a model for performing network intrusion detection on network data, and i is a positive integer;
向服务器发送所述第一模型参数和所述第一网络入侵模型的检测精度值;Sending the first model parameter and the detection accuracy value of the first network intrusion model to a server;
接收所述服务器发送的第二模型参数,所述第二模型参数为所述服务器的全局网络入侵模型基于所述第一模型参数和所述检测精度值计算得到的模型参数;receiving a second model parameter sent by the server, where the second model parameter is a model parameter calculated by a global network intrusion model of the server based on the first model parameter and the detection accuracy value;
基于所述第二模型参数对所述第一网络入侵模型的模型参数进行更新,得到第二网络入侵模型;Based on the second model parameters, the model parameters of the first network intrusion model are updated to obtain a second network intrusion model;
其中,所述第二网络入侵模型为所述预设初始模型在第i+1次迭代更新得到的模型。The second network intrusion model is a model obtained by updating the preset initial model in the i+1th iteration.
可选地,所述处理器405,用于:Optionally, the processor 405 is configured to:
获取目标样本;Obtain target samples;
获取所述第一网络入侵模型的公平系数;Obtaining a fairness coefficient of the first network intrusion model;
基于所述公平系数确定所述第一网络入侵模型的模型参数;Determining model parameters of the first network intrusion model based on the fairness coefficient;
使用所述目标样本对所述第一网络入侵模型进行训练,以对所述第一网络入侵模型的模型参数进行更新,并将更新后的所述第一网络入侵模型的模型参数确定为第一模型参数。The first network intrusion model is trained using the target sample to update the model parameters of the first network intrusion model, and the updated model parameters of the first network intrusion model are determined as first model parameters.
可选地,所述处理器405,用于:Optionally, the processor 405 is configured to:
获取所述第一网络入侵模型和第三网络入侵模型的距离系数,所述第三网络入侵模型为所述预设初始模型在第i-1次迭代更新得到的模型,所述距离系数用于表征模型的变化程度;Obtaining a distance coefficient between the first network intrusion model and a third network intrusion model, wherein the third network intrusion model is a model obtained by updating the preset initial model in the i-1th iteration, and the distance coefficient is used to characterize a degree of change of the model;
基于所述距离系数和预设常数项计算得到所述第一网络入侵模型的公平系数。The fairness coefficient of the first network intrusion model is calculated based on the distance coefficient and a preset constant term.
可选地,所述处理器405,用于:Optionally, the processor 405 is configured to:
获取所述终端的目标网络数据,所述目标网络数据为所述终端的本地网络入侵数据;Acquire target network data of the terminal, where the target network data is local network intrusion data of the terminal;
基于量子生成对抗网络生成与所述目标网络数据对应的假数据;Generate false data corresponding to the target network data based on a quantum generative adversarial network;
将所述目标网络数据和所述假数据进行乱序合并处理,得到目标样本。The target network data and the false data are merged in random order to obtain a target sample.
可选地,所述处理器405,用于:Optionally, the processor 405 is configured to:
获取所述第一网络入侵模型的检测精度值;Obtaining a detection accuracy value of the first network intrusion model;
在所述检测精度值大于或等于预设精度值的情况下,向服务器发送所述第一模型参数和所述检测精度值;When the detection accuracy value is greater than or equal to a preset accuracy value, sending the first model parameter and the detection accuracy value to a server;
其中,所述预设精度值为基于最高精度值和最低精度值确定的。The preset precision value is determined based on the highest precision value and the lowest precision value.
在图4中,总线架构(用总线401来代表),总线401可以包括任意数量的互联的总线和桥,总线401将包括由处理器405代表的一个或多个处理器和存储器406代表的存储器的各种电路链接在一起。总线401还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路链接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口404在总线401和收发机402之间提供接口。收发机402可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器405处理的数据通过天线403在无线介质上进行传输,进一步,天线403还接收数据并将数据传送给处理器405。In FIG. 4 , a bus architecture (represented by bus 401) is shown. Bus 401 may include any number of interconnected buses and bridges. Bus 401 links various circuits including one or more processors represented by processor 405 and memory represented by memory 406. Bus 401 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 404 provides an interface between bus 401 and transceiver 402. Transceiver 402 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 405 is transmitted on a wireless medium via antenna 403. Further, antenna 403 also receives data and transmits the data to processor 405.
处理器405负责管理总线401和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器406可以被用于存储处理器405在执行操作时所使用的数据。Processor 405 is responsible for managing bus 401 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. Memory 406 can be used to store data used by processor 405 when performing operations.
可选的,处理器405可以是CPU、ASIC、FPGA或CPLD。Optionally, the processor 405 may be a CPU, an ASIC, an FPGA or a CPLD.
本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述模型训练方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。其中,所述的计算机可读存储介质,如只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等。The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned model training method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is such as a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
本申请实施例还提供一种计算机程序产品,包括计算机指令,该计算机指令被处理器执行时实现上述模型训练方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。An embodiment of the present application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, the various processes of the above-mentioned model training method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, they will not be repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410579372.8A CN118157999B (en) | 2024-05-11 | 2024-05-11 | Model training method, device, terminal and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410579372.8A CN118157999B (en) | 2024-05-11 | 2024-05-11 | Model training method, device, terminal and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118157999A CN118157999A (en) | 2024-06-07 |
CN118157999B true CN118157999B (en) | 2024-08-16 |
Family
ID=91289005
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410579372.8A Active CN118157999B (en) | 2024-05-11 | 2024-05-11 | Model training method, device, terminal and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118157999B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116708009A (en) * | 2023-07-18 | 2023-09-05 | 杭州电子科技大学上虞科学与工程研究院有限公司 | Network intrusion detection method based on federal learning |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114819190A (en) * | 2022-06-21 | 2022-07-29 | 平安科技(深圳)有限公司 | Model training method, device, system and storage medium based on federal learning |
US20240086700A1 (en) * | 2022-09-14 | 2024-03-14 | Deargen Inc. | Method Of Training Local Neural Network Model For Federated Learning |
CN116094765A (en) * | 2022-12-19 | 2023-05-09 | 桂林电子科技大学 | Internal User Abnormal Behavior Detection and Evaluation Method Based on Quantum Generative Adversarial Network |
CN115834232A (en) * | 2022-12-20 | 2023-03-21 | 北京邮电大学 | Internet of things intrusion detection model training method and device, personalized detection method |
CN116232694A (en) * | 2023-01-31 | 2023-06-06 | 清华大学深圳国际研究生院 | Lightweight network intrusion detection method and device, electronic equipment and storage medium |
CN117765348A (en) * | 2023-12-20 | 2024-03-26 | 中电信数字城市科技有限公司 | Target detection model deployment method, target detection method and electronic equipment |
-
2024
- 2024-05-11 CN CN202410579372.8A patent/CN118157999B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116708009A (en) * | 2023-07-18 | 2023-09-05 | 杭州电子科技大学上虞科学与工程研究院有限公司 | Network intrusion detection method based on federal learning |
Also Published As
Publication number | Publication date |
---|---|
CN118157999A (en) | 2024-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20240394556A1 (en) | Machine learning model training method, service data processing method, apparatus, and system | |
CN111222628A (en) | Recurrent neural network training optimization method, device, system and readable storage medium | |
WO2021098618A1 (en) | Data classification method and apparatus, terminal device and readable storage medium | |
US20240054354A1 (en) | Federated learning method and apparatus | |
CN112381307A (en) | Meteorological event prediction method and device and related equipment | |
CN108022171B (en) | Data processing method and equipment | |
CN113822315A (en) | Attribute graph processing method and device, electronic equipment and readable storage medium | |
CN114065863A (en) | Method, device and system for federal learning, electronic equipment and storage medium | |
CN110991789B (en) | Method and device for determining confidence interval, storage medium and electronic device | |
CN117529728A (en) | Privacy-aware pruning in machine learning | |
CN117590766B (en) | Control method and device for angle adjustment of channel inlet guide rail | |
CN109658120A (en) | A kind of business data processing method and device | |
CN117061365A (en) | Node selection method, device, equipment and readable storage medium | |
CN110795558B (en) | Label acquisition method and device, storage medium and electronic device | |
CN113077058B (en) | Push model optimization method and device executed by user terminal | |
CN114492849B (en) | Model updating method and device based on federal learning | |
CN118157999B (en) | Model training method, device, terminal and storage medium | |
CN111078891A (en) | Knowledge graph optimization method and device based on particle swarm optimization | |
CN109194504A (en) | Timing link prediction technique and computer readable storage medium towards dynamic network | |
CN116600361B (en) | Unmanned aerial vehicle networking configuration method, unmanned aerial vehicle networking configuration equipment and readable storage medium | |
CN113159332B (en) | Method and equipment for realizing model update | |
CN114648666A (en) | Classification model training and data classification method and device and electronic equipment | |
Huff et al. | DHA-FL: Enabling efficient and effective AIoT via decentralized hierarchical asynchronous federated learning | |
CN110489568B (en) | Method and device for generating event graph, storage medium and electronic equipment | |
CN113779335A (en) | Information generation method and device, electronic equipment and computer readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |