用户名  找回密码
 立即注册

微信登录

只需一步,快速开始

QQ登录

只需一步,快速开始

帖子
热搜: NVIDIA AI
查看: 460|回复: 0

基于异常行为的海洋气象传感网的入侵检测方法研究

[复制链接]

187

主题

1

回帖

785

积分

管理员

积分
785
发表于 2024-9-25 15:05:20 | 显示全部楼层 |阅读模式
摘要

摘 要:应对海洋气象传感网面临的异常数据流攻击,分析安全机制,针对其复杂庞大的网络结构和节点内分布极端不平衡的数据流,对基于异常行为的海洋气象传感网入侵检测方法进行研究,并搭建入侵检测系统。重点考虑数据集不平衡问题,使用深度生成网络 CVAE-GAN 学习数据集中少数类的分布,实现有效的数据生成。使用基于OPTICS的去噪算法清除多数类中噪声点,清晰化类别边界。从数据角度入手,降低数据集不平衡率,减小不平衡数据集对入侵检测系统的影响,提高分类器对少数类异常流量的识别能力。仿真结果表明,所提系统能够有效识别各类异常流量,尤其是少数类异常流量,所采用的不平衡数据集处理方法对分类器的检测能力有显著提高。
0 引言
海洋气象传感网(MMSN, maritime meteoro logical sensor network)是一个具有检测、预告、服务等功能的大型综合传感器网络,可通过长期连续实时观测海洋气象、水质水文等信息,为海洋气象精准预测和突发性气象灾害应对提供科学的数据支持。MMSN能够促进沿海地区经济发展、提供船舶交通气象服务、支持渔业生产活动和保障远海科学考察等。自 2004 年以来,中国科学院南海海洋研究所联合多个气象单位建立气象站,并部署锚定和漂流浮标等,从而建立起覆盖南海的中尺度MMSN。随着卫星通信、无人驾驶和传感器等技术的发展和气象信息国际交流的加强,MMSN的尺度不断扩大,以实现更高的海洋气象与环境检测时空覆盖度。


近期,网络安全事故频发,网络攻击逐渐工程化、自动化和智能化[[url=]1[/url]]。MMSN所处环境特殊,网络结构复杂,网络中不同类型节点的安全需求不同,部分海洋环境中的节点相较于其他节点更易遭受网络攻击,一旦遭受针对性攻击,MMSN将面临网络拥塞、信息泄露、节点劫持等重大威胁,气象数据的准确性和时效性将受到严重影响,从而导致一系列重大损失。因此,在 MMSN 中部署能够主动识别异常数据并进行反馈预警的入侵检测系统(IDS, intrusion detection system)至关重要。


IDS是一种用于实时监控网络数据流量或主机系统调用,并且主动识别未经授权的恶意活动的工具。在IDS的分类器训练阶段,当训练数据集不平衡时,多数类能够被学习到更充分的特征,而少数类则由于包含特征太少而往往快速过拟合,难以提取规律,因此分类结果通常会错误地倾向于多数类。与物联网(IoT, Internet of things)[[url=]2[/url]-[url=]3[/url]]、工业控制系统(ICS, industry control system)[[url=]4[/url]-[url=]5[/url]]和软件定义网络(SDN, software defined network)[[url=]6[/url]-[url=]7[/url]]等IDS的传统应用领域不同,庞大且复杂的 MMSN 结构增加了建立准确网络安全规范的难度,扩大了零日攻击的范围[[url=]8[/url]],同时MMSN节点内海量数据流意味着正常流量和攻击数据的数目分布差异更悬殊。以上因素放大了 MMSN 环境中的这种由数据不平衡造成的检测难度。而真实世界的MMSN数据流中,仅占极小比例的攻击数据却隐含极大危害性,与正常数据的错误分类相比,攻击数据的错误分类会导致更大损失[[url=]9[/url]]。因此,使用数据分布相似于真实MMSN数据流的不平衡数据集进行训练,消除其不平衡性的影响,得到具有更强的识别能力和更快的反应速度的分类器,已成为MMSN IDS发展的关键需求。


已有的大部分关于IDS的研究仍针对小型网络的入侵检测,关注攻击数据的整体和分类器设计,却没有考虑到 MMSN 的网络结构特性和数据流类别分布的极端失衡[[url=]10[/url]-[url=]11[/url]],忽视了不平衡数据的处理对于分类器性能的改善。针对以上挑战,本文侧重考虑数据集不平衡问题,并提出一种基于异常行为的 MMSN-IDS 和相应的数据集处理方法。本文的主要贡献如下。


1) 与传统无线传感器网络(WSN, wireless sensor network)进行对比,从节点、结构、数据传输量、覆盖范围和部署环境等方面对 MMSN 的特性进行全面、充分的介绍。


2) 分析MMSN的安全机制需求,针对其数据流极端不平衡和复杂庞大的网络结构,提出一种基于异常行为的MMSN-IDS。


3) 针对所提出的 MMSN-IDS,提出一种不平衡数据集处理方法。该方法使用基于对点排序以识别聚类结构(OPTICS, ordering points to identify the clustering structure)的去噪算法对数据集中多数类进行处理,清除噪声点,使分类边界更清晰;使用条件变分自动编码器-生成对抗网络(CVAE-GAN, conditional variational autoencoder-generative adversarial network)模型对少数类进行生成,降低数据集不平衡率。


1 相关工作1.1 入侵检测分类器模型
现有IDS的分类器按照所采用的基本算法可以分为基于传统的机器学习(ML, machine learning)和深度学习(DL, deep learning)2种类型,且每种类型的分类器又可以分别基于非监督式学习和监督式学习2种方法。因此,以下将从非监督式ML和DL算法,以及监督式ML和DL算法这4类分别进行讨论分析。


非监督式ML经典的K-均值(K-means)聚类算法可以从无标签样本中挖掘数据的聚类结构,而偏离这种结构的数据则被判定为异常。文献[[url=]12[/url]]使用一个基于K-means聚类的局部异常值因子模型检测异常数据包,可实现高细粒度的异常检测,但仅依靠聚类进行异常判断的应用场景十分有限。非监督式ML通常结构简单,但入侵检测数据集的多样性和复杂性使其准确性很难保证。常用的监督式ML算法有决策树(DT, decision tree)、随机森林(RF, random forest)、支持向量机(SVM, support vector machine)等。文献[[url=]13[/url]]构建的三层IDS使用DT作为极端梯度提升(XGBoost, extreme gradient boosting)算法和RF算法的基础学习器,利用弱分类器集成和分级检测机制提高检测精度,但所提出的系统对于大型数据集的训练时间较长。文献[[url=]14[/url]]采用 DT 和 SVM 设计对象、角色、代理和分组,建立具有自适应机制的三层分布的 4 个二分类SVM检测器结构,优化了系统训练时间,但是对新攻击、未知攻击和异常攻击的检测准确率较低。ML算法对部署环境的硬件要求相对较低,而大型MMSN内关键节点受资源限制较小,因此该优势不属于重点考虑因素,已有研究表明在入侵检测中DL算法比ML算法更加成功[[url=]15[/url]]。


关于非监督式 DL 算法,文献[[url=]16[/url]]提出了一种基于堆叠式的自动编码器(SAE, stacked autoencoder)流聚类算法,将偏离聚类中心的数据判定为异常值;该算法并不针对入侵检测开发,因此缺乏较强环境适应性。非监督式学习的优势在于对无标记的数据集进行处理和检测,而最新的常用入侵检测数据集大多具备标签信息。因此,相较于非监督式学习,监督式学习的应用场景更加广泛[[url=]17[/url]]。经典的监督式 DL 算法有多层感知机(MLP, multilayer perceptron)、卷积神经网络(CNN, convolutional neural network)和长短期记忆(LSTM, long short-term memory)网络等。文献[[url=]15[/url]]将 CNN 和LSTM网络组合得到混合深度学习方法,以多种DL算法共同作用的方式提高检测精度,但是网络结构庞大,牺牲了时间复杂度且增加了部署难度。文献[[url=]18[/url]]通过构建深度可分离卷积与LSTM级联的结构,增强模型对数据中空间和时间特征的提取能力,提高检测精度,但同样存在网络结构复杂的问题。监督式DL算法虽然具有一定优势,但仍难以兼顾多分类检测精度和检测效率。


数据集不平衡性是导致多分类检测精度不足的重要原因之一,现有方法往往对其考虑不足,导致小样本类别检测结果较差,因此对不平衡数据集进行预处理是有必要的。


1.2 不平衡数据集处理方法
监督式DL算法的学习质量依赖于优质、平衡、清洁的数据集。低质量数据集,尤其是不平衡的数据集,会严重降低IDS性能。常见的研究通常从算法、分类器和数据源3个方面入手消除低质量数据集对IDS的不利影响。在算法方面,添加成本敏感因子或调整代价函数提高少数类样本被错误分类为多数类的损失权重,降低失误分类概率。这类方法对先验知识依赖程度高,实现难度大。在分类器方面,使用集成分类器或根据各类样本的分布特性使用多层分布结构的多种分类器共同检测。这类方法往往会形成复杂的系统结构,增加系统运行成本。在数据源方面,使用欠采样、过采样或数据生成等方式对数据集进行处理,能够有效缓解冗余和噪声问题。综上可知,针对性地使用数据集处理方法是一种相对有效、难度较小,并且应用较广泛的问题解决方式。


现有研究将特征选择方法用于数据集预处理。文献[[url=]19[/url]]使用两层降维算法,即线性判别分析(LDA, linear discriminant analysis)算法和主成分分析(PCA, principal component analysis)进行特征选择和提取,去除了冗余特征,降低了特征之间依赖性,提高了分类器性能。这类方法未能实现少数类样本的扩充,数据集不平衡度没有降低,少数类的检测结果改善有限。混合采样方法也被广泛应用于不平衡数据集处理。文献[[url=]15[/url]]使用合成少数类过采样技术(SMOTE, synthetic minority over-sampling technique)对少数类进行扩充以减轻数据集不平衡度。使用 Tomek-Link 欠采样技术删除类别边界上属于多数类的样本,增强分类边界。实验证实经过预处理的数据集在分类精度上有所提高,但是单纯的线性插值在数据量大、类分布复杂的入侵检测数据集中表现一般,甚至会造成样本重叠和冗余,难以实现有效的数据扩充。深度生成模型也能用于入侵检测的数据集处理,文献[[url=]9[/url]]提出一个扁平辅助分类器GAN(TACGAN, tabular auxiliary classifier GAN)模型以代替传统过采样技术生成攻击样本,该网络是辅助分类器 GAN(ACGAN, auxiliary classifier GAN)的变体,通过在生成器中添加距离损失和余弦相似度构造新的损失函数,强化网络生成能力。类似地,文献[[url=]20[/url]]改进CVAE模型,引入辅助网络以增强样本标签和潜在空间之间的联系,对编码器生成的潜在向量使用边界 SMOTE(BSM, borderline SMOTE)算法扩充,解码器还原得到扩充且分类边界增强的数据集。深度生成模型的强大学习能力通常能够充分学习样本分布特征,实现少数类的有效扩充,对IDS产生较好的提升效果。但是,TCGAN没有完全避免其基础网络GAN训练困难、生成图像真实性低的缺陷,而 CVAE 的基础网络VAE生成图像真实性较高,但存在图像模糊的不足,两者均对少数类样本的生成质量造成影响。


本文提出的数据处理方法将使用CVAE-GAN模型生成少数类样本,该模型结合 VAE 和 GAN这 2 种基础深度生成模型的优势,同时使用样本标签信息条件作为牵引,能够实现良好的数据生成。同时,使用基于 OPTICS 聚类的去噪方法删除多数类中的噪声样本,降低数据集冗余度,清晰化类边界。


2 海洋气象传感网入侵检测系统2.1 MMSN-IDS框架
MMSN结构如图1所示。与传统的结构简单、节点种类单一、覆盖范围较小的 WSN[[url=]21[/url]-[url=]22[/url]]不同, MMSN具有以下特点。


图1

图1   MMSN结构




1) 节点种类多样。MMSN内部节点种类多样,小型节点如气象漂流浮标[[url=]23[/url]]、水下机器人[[url=]24[/url]],大多不具备数据处理能力,采集数据被传输至基站进行汇总与处理;中型节点如各类气象站,自动探测多个气象要素且具有一定的数据处理能力,同时向基站传输气象信息;大型节点如沿海近岸基站和中央数据处理中心[[url=]25[/url]],对数据进行汇总和分析,实现对海洋气象的全天候实时监测。


2) 结构层次复杂。为实现对海面、水体、海床等的立体监测,MMSN内设备通常覆盖高空、低空、远海海面、近海海面、沿海陆地和水下等区域[[url=]26[/url]]。此外,为了提高网络效率、降低冗余度,不同设备的体积大小、计算能力、存储空间、数据交换方式、安全程度、通信协议等也不同,这导致了复杂的MMSN空间和逻辑结构。


3) 数据传输量大。实现海洋气象监测所需采集的环境要素种类较多,并且这些环境要素需要得到全天候、周期性、持续性的观测。因此,MMSN内部用于信息采集和数据处理的设备数目众多,网络节点间的信息交换频繁。此外,为了提高决策可靠性,不仅需要使用实时观测数据不断动态校准海洋气象预测,还需要收集各地气象台的观测数据进行对比。这意味着 MMSN 需要传输和处理的数据量远超传统 WSN,并且这种数据交换过程还在日益增长。


4) 覆盖范围大。为了对海域内气象进行整体掌控,MMSN 的尺度通常从几十千米到几千千米,覆盖范围大,节点分布密度不均匀,部分节点移动性大。


5) 部署环境恶劣。MMSN 中气象设备被部署于海洋环境,面临盐水腐蚀、强紫外线、强风巨浪等恶劣气候条件。


综合考虑 MMSN 特性及入侵检测需求,本文提出的 MMSN-IDS 框架如图2 所示,该框架主要包括三大模块:数据采集模块、入侵检测模块和反馈响应模块。数据采集模块负责收集 MMSN 中流经气象站、基站和中央数据处理中心等关键节点的气象及通信数据流,从中提取相关特征,传递给入侵检测模块。入侵检测模块部署了训练完成之后的分类器,实时处理传入的 MMSN 数据特征并进行检测,识别其中的异常数据和网络攻击,将检测结果传递给反馈响应模块。反馈响应模块首先进行自主响应,检查 MMSN 节点运行情况,隔离异常数据、暂停受攻击节点业务,若超出其处理能力,则触发警报反馈给人工处理。


图2中的入侵检测模块由数据集预处理、数据集平衡化和分类器训练3个部分组成,下文对其各部分功能进行详细介绍。


2.2 数据集预处理
本文提出一种针对 MMSN 入侵检测数据集特性的数据集预处理方法,包含数值化、标准化和PCA降维3个步骤。该方法能够对入侵MMSN的原始数据集进行整理,提取样本主要特征,降低特征冗余、后续计算开销和系统运行成本。


1) 数值化。入侵检测数据集中通常包含字符串类型的离散特征,不可直接用于后续处理。为此,首先使用独热(one-hot)编码将每条样本中字符串类型的特征值转换为数值型特征值,将数据集展开为高维稀疏特征矩阵。


图2

图2   MMSN-IDS框架




2) 标准化。不同维度的特征数量级不一致,将导致降维算法偏离最优值,对数值化后的每个维度进行Z-Score标准化


[size=&quot;normal&quot;>X=x&#x2212;&#x3BC;&#x3C3;&#x3000;&#x3000;&#x3000;&#x3000;<mo]
X=x−μσ    (1)X=x−μσ    (1)



其中,x为原数据集中每个维度的特征值,μ为每一维特征的均值,σ为每一维特征的标准差。将样本的每一维特征分布转换为均值为 0、标准差为 1的标准正态分布,使不同维度的特征度量统一、可比性增强、运算中收敛速度加快。


3) PCA降维。经过处理得到的高维稀疏特征矩阵不利于深度网络训练。因此,使用 PCA 算法降低特征矩阵维度,提取主要特征分量,最大化保持数 据 内 在 信 息。将 所 得 标 准 化 数 据 集<span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="X=[x1,x2,x3,&#x22EF;,xn]" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">X=[x1,x2,x3,⋯,xn]X=[x1,x2,x3,⋯,xn] 映射到k 维空间,其中, <span class="MathJax" id="MathJax-Element-3-Frame" tabindex="0" data-mathml="xi=[x1i,x2i,x3i,&#x22EF;,xmi]T" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xi=[x1i,x2i,x3i,⋯,xmi]Txi=[x1i,x2i,x3i,⋯,xmi]T ,m为样本数目,n为特征维数。计算矩阵<span class="MathJax" id="MathJax-Element-4-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX的协方差矩阵为


[size=&quot;normal&quot;>C=E[<mo]
C=E[(xi−μi)(xi−μi) T]    (2)C=E[(xi−μi)(xi−μi) T]    (2)



其中,<span class="MathJax" id="MathJax-Element-6-Frame" tabindex="0" data-mathml="&#x3BC;i" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">μiμi为每个维度的均值向量,定义为


[size=&quot;normal&quot;>&#x3BC;i=1m<mstyle]μi=1m∑n=1mxni    (3)μi=1m∑n=1mxni    (3)


根据<span class="MathJax" id="MathJax-Element-8-Frame" tabindex="0" data-mathml="Cv=&#x3BB;v" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">Cv=λvCv=λv求得协方差矩阵<span class="MathJax" id="MathJax-Element-9-Frame" tabindex="0" data-mathml="C" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">CC 的特征值λ及对应的特征向量<span class="MathJax" id="MathJax-Element-10-Frame" tabindex="0" data-mathml="v" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">vv,将特征向量根据对应特征值按行降序排列成矩阵,取前k行组成系数矩阵<span class="MathJax" id="MathJax-Element-11-Frame" tabindex="0" data-mathml="" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">P,即保留含有尽可能多的数据分布信息的k维特征。做<span class="MathJax" id="MathJax-Element-12-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX的线性变换<span class="MathJax" id="MathJax-Element-13-Frame" tabindex="0" data-mathml="Y=PX" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">Y=PXY=PX,得到降维后的特征矩阵<span class="MathJax" id="MathJax-Element-14-Frame" tabindex="0" data-mathml="Y" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">YY。


2.3 数据集平衡化
由2.1节所述MMSN特点和引言中所述真实世界MMSN节点中数据流类别分布的极端失衡现象,可知 MMSN-IDS 的数据采集模块所得到的样本不平衡,对系统性能影响较大。结合1.2节中关于不平衡数据集处理方法的研究,为了解决该问题,本文创新性地在 MMSN-IDS 中添加了数据集平衡化过程,提出了一种综合性的数据集平衡化方法。该方法使用混合采样的原理,根据各类别在数据集中所占比例将训练集分为多数类、少数类和其他类,对多数类和少数类分别处理,使数据集各类别达到数目上的相对平衡。针对多数类,基于OPTICS的去噪算法在充分保留多数类样本信息的同时删除类别边界处异常值和噪声点,降低误分类概率;针对少数类,深度生成模型 CVAE-GAN 优越的特征学习能力保证了少数类样本的生成质量。这种综合性的数据平衡化方法是对 MMSN 入侵检测领域的创新性应用,能够有效提高 MMSN 入侵检测数据集质量,进而提高MMSN-IDS性能。


2.3.1 基于OPTICS的去噪算法


MMSN 入侵检测数据集中多数类样本数量较大,噪声样本难以避免,而噪声又会导致较大的计算误差,影响深度网络收敛速度和分类准确率。所提方法基于 OPTICS 的去噪算法对多数类进行处理,将超出OPTICS聚类范围的样本判定为噪声,并将其从原始集合中删除,保证数据的清洁,清晰化数据分布边界,减轻类重叠程度,降低误分类为多数类的可能性,提高分类器检测精度。


OPTICS 是一种基于密度的聚类算法,对异常值不敏感,可以在聚类的同时将异常值标记为噪声。OPTICS 算法不仅可以降低对输入参数ε(邻域半径)的敏感性,还可以提取任意密度的簇以实现聚类,提高分布不均匀数据集的聚类精度。对于数据集<span class="MathJax" id="MathJax-Element-15-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX,给定样本<span class="MathJax" id="MathJax-Element-16-Frame" tabindex="0" data-mathml="p,q&#x2208;X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">p,q∈Xp,q∈X,OPCITS 算法的相关定义如下。


1) ε邻域。样本p的ε邻域表示<span class="MathJax" id="MathJax-Element-17-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中与p的距离不大于ε的子样本集,子样本集中包含的样本个数记为<span class="MathJax" id="MathJax-Element-18-Frame" tabindex="0" data-mathml="|N&#x3B5;(p)|" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|Nε(p)||Nε(p)|。


2) MinPts。MinPts是使样本p成为核心对象所需的ε邻域中最小样本个数。


3) 核心对象(core object)。若样本p的ε邻域内至少包含 MinPts 个样本(包含 p),即<span class="MathJax" id="MathJax-Element-19-Frame" tabindex="0" data-mathml="|N&#x3B5;(p)|&#x2265;MinPts" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|Nε(p)|≥MinPts|Nε(p)|≥MinPts ,那么样本p被称为核心对象。


4) 直接密度可达(directly density-reachable)。若样本 p和q满足 <span class="MathJax" id="MathJax-Element-20-Frame" tabindex="0" data-mathml="q&#x2208;|N&#x3B5;(p)|" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">q∈|Nε(p)|q∈|Nε(p)|且<span class="MathJax" id="MathJax-Element-21-Frame" tabindex="0" data-mathml="|N&#x3B5;(p)|&#x2265;MinPts" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|Nε(p)|≥MinPts|Nε(p)|≥MinPts (p是核心对象),那么称样本q从样本p出发关于ε、MinPts直接密度可达。


5) 密度可达(density-reachable)。若存在一系列样本q1,q2,…,qn,q1= p,qn =q,qi+1从qi出发直接密度可达,则样本q从p出发关于ε、MinPts密度可达。


6) 密度相连(density-connected)。若存在样本<span class="MathJax" id="MathJax-Element-22-Frame" tabindex="0" data-mathml="o&#x2208;X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">o∈Xo∈X,使q和p均从o出发关于ε、MinPts密度可达,那么p和q关于ε、MinPts密度相连。


7) 核心距离(core-distance)。使样本p成为核心对象的最小邻域半径称为p的核心距离,表示为


core−distance(p)=core-distance(p)=






[size=&quot;normal&quot;>N&#x3B5;<mo]
{ Undefined, |Nε(p)|< MinPts distance(p,NMinPtsε(p)) ,|Nε(p)|≥ MinPts    (4){ Undefined, |Nε(p)|< MinPts distance(p,NεMinPts(p)) ,|Nε(p)|≥ MinPts    (4)



其中,<span class="MathJax" id="MathJax-Element-25-Frame" tabindex="0" data-mathml="N&#x3B5;MinPts(p)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">NMinPtsε(p)NεMinPts(p)为<span class="MathJax" id="MathJax-Element-26-Frame" tabindex="0" data-mathml="|N&#x3B5;(p)|" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|Nε(p)||Nε(p)|中距离样本p第MinPts近邻的样本点。


8) 可达距离(reachability-distance)。对于核心对象p,样本q到p的可达距离为样本p的核心距离和p、q之间的实际距离的最大值,表示为


reachability−distance(q,p)=reachability-distance(q,p)=






[size=&quot;normal&quot;>N&#x3B5;<mo]
{Undefined, |Nε(p)|<MinPtsmax(core−distance(p),distance(q,p)),|Nε(p)|≥MinPts  (5){Undefined, |Nε(p)|<MinPtsmax(core-distance(p),distance(q,p)),|Nε(p)|≥MinPts  (5)



OPTICS 算法对ε不敏感,一般将其设定为无限大,该算法并不直接生成聚类结果,而是创建一个有序队列,其顺序为样本被处理的顺序,队列中元素包含样本的核心距离和可达距离。根据这些信息可以创建决策图,从而提取到关于ε取某特定值Eps(Eps≤ε)时的聚类,进而实现去噪的目的。基于OPTICS聚类的去噪算法如算法1所示。


算法1 基于OPTICS聚类的去噪算法


给定 MMSN 数据集<span class="MathJax" id="MathJax-Element-29-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX,定义ε为无限大,初始化MinPts和Eps


1) 根据式(4)计算<span class="MathJax" id="MathJax-Element-30-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中每个核心对象的核心距离


2) for <span class="MathJax" id="MathJax-Element-31-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中每个未标记的核心对象p


3) 将p标记为已处理并输出至有序队列<span class="MathJax" id="MathJax-Element-32-Frame" tabindex="0" data-mathml="R" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">RR


4) 获取p的全部直接密度可达对象,将其中未标记的对象输出至待处理队列<span class="MathJax" id="MathJax-Element-33-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中,根据式(4)和式(5)计算其核心距离和到p的可达距离


5) 将<span class="MathJax" id="MathJax-Element-34-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX按照该可达距离升序排列


6) for <span class="MathJax" id="MathJax-Element-35-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中排在首位的样本q


7) 将q标记为已处理,将q输出至有序队列<span class="MathJax" id="MathJax-Element-36-Frame" tabindex="0" data-mathml="R" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">RR


8) 若q为核心对象,即 <span class="MathJax" id="MathJax-Element-37-Frame" tabindex="0" data-mathml="|N&#x3B5;(q)|&#x2265;MinPts" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|Nε(q)|≥MinPts|Nε(q)|≥MinPts


9) 则获取q的全部直接密度可达对象,将其中未标记的对象输出至待处理队列<span class="MathJax" id="MathJax-Element-38-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中


10) 根据式(4)和式(5)计算<span class="MathJax" id="MathJax-Element-39-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中全部点的核心距离和到q的可达距离


11) 更新待处理队列<span class="MathJax" id="MathJax-Element-40-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX的排列顺序


12) end for


13) end for


14) for <span class="MathJax" id="MathJax-Element-41-Frame" tabindex="0" data-mathml="R" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">RR中样本x


15) if x的可达距离小于Eps 16) 将x判定为当前簇中样本


17) else if x 的可达距离大于 Eps 且<span class="MathJax" id="MathJax-Element-42-Frame" tabindex="0" data-mathml="|NEps(x)|&#x2265;MinPts" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">|NEps(x)|≥MinPts|NEps(x)|≥MinPts


18) 将x判定为新簇中样本


19) else


将x判定为噪声,并从<span class="MathJax" id="MathJax-Element-43-Frame" tabindex="0" data-mathml="X" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">XX中移除


20) end if


21) end for


首个被处理的样本可达距离无定义,将其假设为无限大。手动设定Eps取值,将MMSN数据集每个多数类中一定比例的样本判定为噪声并删除。


2.3.2 基于CVAE-GAN的少数类扩充


MMSN 入侵检测数据集中的少数类通常只有几十到几百个样本[[url=]27[/url]],在分类器的训练过程中提取到的有效特征有限,导致分类器对该类的识别能力弱而产生误判或漏检,检测结果传递给反馈响应模块后得出错误反应,影响MMSN-IDS的整体性能。本文采用 CVAE-GAN 提取少数类的数据特征,建立真实样本与潜在向量的映射,并从潜在向量重建样本。


图3给出了CVAE-GAN模型,该模型包括四部分结构:编码器(E, encoder)、生成器(G, generator)、鉴别器(D, discriminator)、分类器(C, classifier),这 4 个子网络可以无缝级联,进行端到端的训练。图3中,<span class="MathJax" id="MathJax-Element-44-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr为真实样本,<span class="MathJax" id="MathJax-Element-45-Frame" tabindex="0" data-mathml="cr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">crcr为真实类别标签,<span class="MathJax" id="MathJax-Element-46-Frame" tabindex="0" data-mathml="zp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zpzp为随机噪声,<span class="MathJax" id="MathJax-Element-47-Frame" tabindex="0" data-mathml="cp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cpcp为随机类别标签, <span class="MathJax" id="MathJax-Element-48-Frame" tabindex="0" data-mathml="x'" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">x′x'为生成样本,<span class="MathJax" id="MathJax-Element-49-Frame" tabindex="0" data-mathml="c" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cc为分类结果,<span class="MathJax" id="MathJax-Element-50-Frame" tabindex="0" data-mathml="y" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">yy为鉴别结果。与原始GAN和VAE模型相比,CVAE-GAN子网络E、D、C的训练目标基本不变。网络D尝试区分“真实”和“虚假”样本,损失函数采用二分类交叉熵函数


[size=&quot;normal&quot;>x<mo]
LD=−Ex∼Pr[logD(x)]−Ez∼Pz[log(1−D(G(z))]    (6)LD=−Ex∼Pr[logD(x)]−Ez∼Pz[log(1−D(G(z))]    (6)



图3

图3   CVAE-GAN模型




网络C的功能为测量图像是否属于特定类别,即测量每个类别的后验概率<span class="MathJax" id="MathJax-Element-52-Frame" tabindex="0" data-mathml="(c|x)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">(c|x)P(c|x),网络最小化其softmax损失函数


[size=&quot;normal&quot;>c|<mstyle]
LC=−Ex∼Pr[logP(c|x)]    (7)LC=−Ex∼Pr[logP(c|x)]    (7)



网络 E 通过学习分布<span class="MathJax" id="MathJax-Element-54-Frame" tabindex="0" data-mathml="(z|x,c)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">(z|x,c)P(z|x,c)将样本<span class="MathJax" id="MathJax-Element-55-Frame" tabindex="0" data-mathml="x" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xx映射为潜在向量<span class="MathJax" id="MathJax-Element-56-Frame" tabindex="0" data-mathml="z" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zz,其中,<span class="MathJax" id="MathJax-Element-57-Frame" tabindex="0" data-mathml="x" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xx是真实样本,<span class="MathJax" id="MathJax-Element-58-Frame" tabindex="0" data-mathml="c" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cc是样本类别信息。该网络使用KL散度作为损失函数,以减小先验概率<span class="MathJax" id="MathJax-Element-59-Frame" tabindex="0" data-mathml="(z)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">(z)P(z)和建议分布间的差距


[size=&quot;normal&quot;>&#x3BC;T<mstyle]
LKL=12(μTμ+sum(exp(ε)−ε−1))    (8)LKL=12(μTμ+sum(exp(ε)−ε−1))    (8)



其中,<span class="MathJax" id="MathJax-Element-61-Frame" tabindex="0" data-mathml="&#x3BC;" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">μμ和ε为网络E输出的潜在向量的均值和协方差。


网络G通过从分布<span class="MathJax" id="MathJax-Element-62-Frame" tabindex="0" data-mathml="(z|x,c)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">(z|x,c)P(z|x,c)中采样潜在向量,生成样本<span class="MathJax" id="MathJax-Element-63-Frame" tabindex="0" data-mathml="x&#x2032;" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">x′x′,再通过模型其他部分传递的梯度信息学习真实数据分布。由于GAN训练过程中网络G的梯度不稳定,需对其损失函数做出必要调整,使用生成器网络的平均特征匹配目标。该目标要求生成样本的特征中心与真实样本的特征中心匹配,网络G最小化损失函数为


[size=&quot;normal&quot;>x&#x223C;PrfD<mo]
LGD=12∥Ex∼PrfD(x)−Ez∼PzfD(G(z))∥22   (9)LGD=12‖Ex∼PrfD(x)−Ez∼PzfD(G(z))‖22   (9)



其中,fD为网络 D 最后一个全连接层的输入, <span class="MathJax" id="MathJax-Element-65-Frame" tabindex="0" data-mathml="LGD" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGDLGD 衡量生成样本与真实样本的相似程度。网络C使用标准的分类方法测量,通过 softmax函数将输出的k维向量转换为概率。然而,为实现用于条件样本的图像生成,对网络G使用类似于式(3)的交叉熵损失函数,同样会导致梯度不稳定,因此也会使用平均特征匹配目标,令网络G最小化损失为


[size=&quot;140%&quot;]LGC=12∑c∥Ex∼PrfC(x)−Ez∼PzfC(G(z,c))∥22  (10)LGC=12∑c‖Ex∼PrfC(x)−Ez∼PzfC(G(z,c))‖22  (10)


其中,fC是网络C的最后一个全连接层输入,<span class="MathJax" id="MathJax-Element-67-Frame" tabindex="0" data-mathml="LGC" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGCLGC衡量生成样本与同一类别内其他样本的相似程度。


为避免模式坍塌,使用编码器网络E建立潜在空间中潜在向量<span class="MathJax" id="MathJax-Element-68-Frame" tabindex="0" data-mathml="z" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zz和真实空间中真实图像<span class="MathJax" id="MathJax-Element-69-Frame" tabindex="0" data-mathml="x" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xx之间的关系。由 E 的损失函数式(5)得到潜在向量<span class="MathJax" id="MathJax-Element-70-Frame" tabindex="0" data-mathml="z=&#x3BC;+r&#x2299;exp(&#x3B5;)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">z=μ+r⊙exp(ε)z=μ+r⊙exp(ε),其中<span class="MathJax" id="MathJax-Element-71-Frame" tabindex="0" data-mathml="&#xFF0C;r&#xFF5E;N(0,1)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">,r~N(0,1),r~N(0,1)是一个随机向量,⊙表示逐元素乘法。网络E将<span class="MathJax" id="MathJax-Element-72-Frame" tabindex="0" data-mathml="x" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xx映射得到<span class="MathJax" id="MathJax-Element-73-Frame" tabindex="0" data-mathml="z" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zz后,网络 G 获得生成样本<span class="MathJax" id="MathJax-Element-74-Frame" tabindex="0" data-mathml="x&#x2032;" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">x′x′,在<span class="MathJax" id="MathJax-Element-75-Frame" tabindex="0" data-mathml="x" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xx和<span class="MathJax" id="MathJax-Element-76-Frame" tabindex="0" data-mathml="x&#x2032;" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">x′x′之间添加成对特征匹配损失


[size=&quot;normal&quot;>x&#x2212;<mstyle]
LG=12(∥x−x′∥22+∥fD(x)−fD(x′)∥22+LG=12(‖x−x′‖22+‖fD(x)−fD(x′)‖22+






[size=&quot;normal&quot;>x<mo]
∥fC(x)−fC(x′)∥22)    (11)‖fC(x)−fC(x′)‖22)    (11)



其中,fD和 fC分别是网络D和C的最后一个全连接层输入,<span class="MathJax" id="MathJax-Element-79-Frame" tabindex="0" data-mathml="LG" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGLG衡量生成样本与输入训练样本的相似程度。


综上,所有优化目标相互补充,CVAE-GAN优化总目标为


L=LD+LC+λ1LKL+λ2LG+λ3LGD+λ4LGC    (12)L=LD+LC+λ1LKL+λ2LG+λ3LGD+λ4LGC    (12)



其中,λi为权重因子。此后,对 MMSN 入侵检测数据集执行min-max归一化


[size=&quot;normal&quot;>x=x&#x2212;xminxmax&#x2212;xmin&#x3000;&#x3000;&#x3000;&#x3000;<mo]
x=x−xminxmax−xmin    (13)x=x−xminxmax−xmin    (13)



将每个维度的特征值缩放至[0,1]区间内,再转换为二维灰度图像。由于转换后的灰度图像不便于观察图像生成质量,因此对少数类数据分别进行生成,输入 CVAE-GAN 中训练子网络,训练过程如算法2所示。


算法2 CVAE-GAN训练过程


给定批量大小m,类数目n,真实 MMSN 数据批量<span class="MathJax" id="MathJax-Element-82-Frame" tabindex="0" data-mathml="{xr,cr}&#x223C;Pr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">{xr,cr}∼Pr{xr,cr}∼Pr,真实MMSN样本类别<span class="MathJax" id="MathJax-Element-83-Frame" tabindex="0" data-mathml="cr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">crcr,随机噪声批量<span class="MathJax" id="MathJax-Element-84-Frame" tabindex="0" data-mathml="zp&#x223C;Pz" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zp∼Pzzp∼Pz,随机样本类别<span class="MathJax" id="MathJax-Element-85-Frame" tabindex="0" data-mathml="cp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cpcp;初始化网络E参数θE,网络G参数θG,网络D参数θD,网络C参数θC;


1) while θ G未收敛 do


2) 根据式(7)计算网络C的损失函数<span class="MathJax" id="MathJax-Element-86-Frame" tabindex="0" data-mathml="LC" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LCLC;


3) 网络E输入<span class="MathJax" id="MathJax-Element-87-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr和<span class="MathJax" id="MathJax-Element-88-Frame" tabindex="0" data-mathml="cr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">crcr,输出得到潜在向量<span class="MathJax" id="MathJax-Element-89-Frame" tabindex="0" data-mathml="z" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zz;


4) 根据式(8)计算网络E的损失函数<span class="MathJax" id="MathJax-Element-90-Frame" tabindex="0" data-mathml="LKL" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LKLLKL ;


5) 网络G输入<span class="MathJax" id="MathJax-Element-91-Frame" tabindex="0" data-mathml="z" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zz和<span class="MathJax" id="MathJax-Element-92-Frame" tabindex="0" data-mathml="cr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">crcr,输出得到生成样本<span class="MathJax" id="MathJax-Element-93-Frame" tabindex="0" data-mathml="xf" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xfxf;


6) 网络G输入<span class="MathJax" id="MathJax-Element-94-Frame" tabindex="0" data-mathml="zp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">zpzp和<span class="MathJax" id="MathJax-Element-95-Frame" tabindex="0" data-mathml="cp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cpcp,得到生成样本<span class="MathJax" id="MathJax-Element-96-Frame" tabindex="0" data-mathml="xp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xpxp;


7) 根据式(6)计算网络D的损失函数<span class="MathJax" id="MathJax-Element-97-Frame" tabindex="0" data-mathml="LD" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LDLD;


8) 计算<span class="MathJax" id="MathJax-Element-98-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr的特征中心 <span class="MathJax" id="MathJax-Element-99-Frame" tabindex="0" data-mathml="1m&#x2211;imfD(xr)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">1m∑imfD(xr)1m∑imfD(xr) 和<span class="MathJax" id="MathJax-Element-100-Frame" tabindex="0" data-mathml="xp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xpxp的特征中心 <span class="MathJax" id="MathJax-Element-101-Frame" tabindex="0" data-mathml="1m&#x2211;imfD(xp)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">1m∑imfD(xp)1m∑imfD(xp) ;


9) 根据式(9)计算<span class="MathJax" id="MathJax-Element-102-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr和<span class="MathJax" id="MathJax-Element-103-Frame" tabindex="0" data-mathml="xp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xpxp的平均特征匹配损失<span class="MathJax" id="MathJax-Element-104-Frame" tabindex="0" data-mathml="LGD" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGDLGD ;


10) 使用移动平均算法计算<span class="MathJax" id="MathJax-Element-105-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr的每个类<span class="MathJax" id="MathJax-Element-106-Frame" tabindex="0" data-mathml="ci" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">cici的特征中心 <span class="MathJax" id="MathJax-Element-107-Frame" tabindex="0" data-mathml="fCci(xr)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">fciC(xr)fCci(xr)和<span class="MathJax" id="MathJax-Element-108-Frame" tabindex="0" data-mathml="xp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xpxp的每个类的特征中心 <span class="MathJax" id="MathJax-Element-109-Frame" tabindex="0" data-mathml="fCci(xp)" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">fciC(xp)fCci(xp);


11) 根据式(10)计算<span class="MathJax" id="MathJax-Element-110-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr和<span class="MathJax" id="MathJax-Element-111-Frame" tabindex="0" data-mathml="xp" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xpxp的每个类的平均特征匹配损失<span class="MathJax" id="MathJax-Element-112-Frame" tabindex="0" data-mathml="LGC" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGCLGC ;


12) 根据式(11)计算<span class="MathJax" id="MathJax-Element-113-Frame" tabindex="0" data-mathml="xr" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xrxr和<span class="MathJax" id="MathJax-Element-114-Frame" tabindex="0" data-mathml="xf" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">xfxf的成对特征匹配损失<span class="MathJax" id="MathJax-Element-115-Frame" tabindex="0" data-mathml="LG" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LGLG;


13) 分别使用<span class="MathJax" id="MathJax-Element-116-Frame" tabindex="0" data-mathml="LC" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LCLC、<span class="MathJax" id="MathJax-Element-117-Frame" tabindex="0" data-mathml="LD" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LDLD、<span class="MathJax" id="MathJax-Element-118-Frame" tabindex="0" data-mathml="LG+LGD+LGC" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LG+LGD+LGCLG+LGD+LGC、<span class="MathJax" id="MathJax-Element-119-Frame" tabindex="0" data-mathml="LG+LKL" role="presentation" style="box-sizing: border-box; list-style: none; display: inline; line-height: normal; font-size-adjust: none; text-indent: 0px; text-align: left; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; text-wrap: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">LG+LKLLG+LKL 所传递的梯度信息更新网络参数θC、θD、θG、θE


14) end while


网络G包括一个全连接层及4个步长为2×2,卷积核为128、256、256和512的解卷积层,滤波器大小为5×5。在每层后应用批归一化,其他3个子网络也采用相同参数的卷积层结构。


观察生成结果,当训练至网络收敛后,固定生成器G的参数,从随机标准正态分布向量中采样作为输入,输出得到目标类别的生成样本。本文在样本生成完毕后,再次对所生成的少数类样本使用基于OPTICS聚类的算法去噪,通过所提取簇的可视化结果选择参数,去除生成过程中产生的偏离真实分布的样本,进一步提高少数类的生成质量。最后,将分别处理的少数类、多数类与未处理的其他类混合,得到平衡后的训练集。


2.4 分类器训练
本节使用平衡后的训练集训练分类器,实现对各类攻击的高效精准检测。由于本文所提系统和方法重点考虑数据集的平衡化处理,因此本文使用多种基础ML、DL分类器进行二分类和多分类实验,以验证该方法的性能。


3 仿真实验与结果分析3.1 数据集选取
由2.1节所述MMSN特点可知,真实MMSN入侵检测数据集数据具有数据量大、正常样本与攻击样本分布极端不平衡等特征。NSL-KDD 数据集数据构成如表1所示。分析其结构分布可知,该数据集具有类似的数据量大和分布极端不平衡等特征,符合 MMSN 数据集分布的核心特征,能够近似代表MMSN 入侵检测数据的分布。因此本文使用 NSL-KDD 数据集模拟真实 MMSN 环境下的入侵检测数据流分布进行仿真实验。


表1   NSL-KDD数据集数据构成


数据集
Normal
Probe
DoS
U2R
R2L

训练集67 34311 65645 92752995
测试集
9 711
2 421
7 458
200
2 754

新窗口打开| 下载CSV



NSL-KDD[[url=]28[/url]]数据集是在KDD CUP 99的基础上整理而来的,并在许多研究中被使用,可以作为一个有效的基准数据集进行评估[[url=]17[/url]]。该数据集每条样本包含 41 个维度特征和一个类型标签,数据集包含正常数据类型Normal和4种不同的攻击类型:Probe、DoS、U2R和R2L。本次实验中,KDDTrain+被用作训练集,KDDTest+被用作测试集。


3.2 实验评估指标
为了测试所提 MMSN 入侵检测数据集处理对分类器性能的改善,使用分别经由平衡化前后的数据集训练的 MMSN-IDS 的分类器对测试集进行检测,可得真阳性(TP, true positive)、真阴性(TN, true negative)、假阳性(FP, false positive)、假阴性(FN, false negative)的样本数目及表2所示的混淆矩阵。


表2   混淆矩阵


实际
预测

攻击数据
正常数据

攻击数据TPFN
正常数据
FP
TN

新窗口打开| 下载CSV



混淆矩阵是 MMSN-IDS 分类器对各类型数据分类能力最基本、最直观的衡量方法。在此基础上,使用准确率(Acc, accuracy)、精确率(P, precision)、召回率(R, recall)、假阳性率(FPR, false positive rate)、F1-score等常用指标进行评估


Acc=TP+TNTP+TN+FP+FN    (14)Acc=TP+TNTP+TN+FP+FN    (14)






P=TPTP+FP      (15)P=TPTP+FP      (15)






R=TPTP+FN      (16)R=TPTP+FN      (16)






FPR=FPFP+TN     (17)FPR=FPFP+TN     (17)






F1−score=2PRP+R    (18)F1-score=2PRP+R    (18)



以上指标中,准确率衡量分类器整体的攻击样本检测准确性;精确率、召回率和假阳性率则衡量部分结果中分类器对网络攻击预测结果正确的比重;F1-score 为精确率和召回率的调和平均数,兼顾两者性能,平衡精确率和召回率间的矛盾。


最后,精确率-召回率(P-R, precision-recall)曲线和受试者工作特征(ROC, receiver operating characteristic)曲线也被用于本文中的 MMSN-IDS分类器性能评估。


3.3 实验结果分析
对于 NSL-KDD 数据集,按照各类别在训练集中所占比例,将Normal、DoS类视为多数类, U2R、R2L视为少数类。对其字符串类型特“flag”“service”和“protocol_type”进行独热编码, NSL-KDD的41维特征被扩展为122维稀疏特征矩阵,并按照式(10)进行标准化,最后通过 PCA算法降维保留其包含主要特征分量的前49维。对降维后的训练集中的多数类使用 OPTICS 聚类的去噪处理,人工选择合理的参数ε、MinPts和Eps,再将约5%的异常值判定为噪声并从原始数据集中删除。


U2R 和 R2L 训练过程中的损失函数值分别如图4(a)和图4(b)所示。当少数类扩充时,对于U2R类,将潜在向量设置为256维,epoch=200,批处理大小为16。从图4(a)中可以看到,网络G的损失函数呈现微小幅度的下降趋势,网络D的损失函数呈现微小幅度的上升趋势,但是两者总体走势均在振荡中趋于平稳,并且在 epoch=180时得到拟合良好的生成器网络。对于 R2L 类,潜在向量被设置为 128 维,epoch=100,批处理大小为64,对图4(b)和生成样本进行类似的观察分析可知,在 epoch=80 时得到生成器网络的最佳参数。


图4

图4   少数类训练损失函数值




结合 MMSN 数据流特性,考虑到实际的MMSN入侵检测数据集不平衡性过大、少数类数目极少,将其扩展到与多数类相同数量的样本会产生大量冗余数据。因此,实验中分别将 U2R 和 R2L类的样本数量扩大到15 000,并采用基于OPTICS的去噪算法对生成样本进行处理,消除异常值,减小生成偏差。图5展示了少数类扩充前后的样本分布情况,可以看到 CVAE-GAN 模型充分学习少数类分布特征。图5(b)和图5(d)中扩充后的样本分布能够较好地拟合图5(a)和图5(c)中原始少数类样本的分布,说明生成样本覆盖整个数据分布,模型学习到了少数类数据的多样性和复杂性,缓解了GAN模型的模式崩溃缺陷。且不平衡程度越小,拟合效果越好,推知所提方法对真实MMSN入侵检测数据集具有较好的分布特征提取及模拟能力。表3展示了NSL-KDD数据集平衡前后数据分布。从表3可以看到,使用所提方法处理后,数据集的不平衡性大大减小。


表3   NSL-KDD数据集平衡前后数据分布


类别
平衡前
平衡前比例
平衡后
平衡后比例

Normal67 34353.46%64 07743.83%
Probe11 6569.25%11 6567.97%
DoS45 92736.46%43 61429.83%
U2R520.04%12 1138.28%
R2L
995
0.79%
14 747
10.09%

总计
125 973
100%
146 207
100%

新窗口打开| 下载CSV



图5

图5   少数类扩充前后的样本分布情况




使用平衡后数据集训练CNN分类器以进行多分类实验的仿真验证,并将得到的结果与原始数据集进行对比。图6给出了原始数据集和平衡化数据集的多分类混淆矩阵。混淆矩阵显示,平衡化前分类器对R2L类的预测中,72.08%的R2L类数据被误分类为Normal类,27.60%被误分类为Probe类,而平衡化后这2种误分类的比例分别下降到43.97%和2.58%,被错误分类为多数类的问题得到很大改善,相应地, R2L类的误分类概率和分类准确率也有所改善。


表4给出了3.2节中提到的评估指标的改善结果。从表4可以看到,使用原始数据集得到的分类结果较差,尤其是少数类的检测召回率极低。数据集平衡化后分类器的多分类准确率提高了4.48%,少数类尤其是R2L类在精确率、召回率和F1-score上都有较大幅度提升,其检测性能改善明显,而U2R类由于真实样本过少(52个),检测性能改善稍弱,对于 MMSN 入侵检测数据集,所提方法有效提高了分类器的性能。由于被错误分类为Normal类的攻击数据减少,Normal类的召回率有所下降,但精确率和F1-score却有所上升。图7给出了平衡化前后P-R曲线和ROC曲线,所使用的基础分类器的局限性限制了其检测精度,导致曲线下面积变化不明显,但P-R曲线中U2R类、R2L类和ROC曲线中 U2R 类曲线下面积的增加同样验证了本文所提方法的有效性。


使用ML分类器DT、RF、SVM、朴素贝叶斯(NB, naive Bayes)、K-近邻(KNN, K-nearest neighbors)和DL分类器MLP、CNN进行二分类实验,验证各分类器性能,结果如表5所示。分析可知,MLP分类器在各分类指标上均展现明显优势,综合性能最优。其次,CNN分类器准确率仅次于MLP,但优于其他ML分类器。该结果验证了1.1节中所提到的监督式DL分类器算法的优势。此外,所有分类器在经过平衡化处理后分类精度均显著提高,其中,NB分类器平衡化后分类准确率提高 12.64%,以上结果再次验证了本文所提方法的有效性。


图6

图6   平衡化前后数据集的多分类混淆矩阵




表4   平衡化前后多分类评估指标对比


评估指标
原始数据集
平衡化后

Normal
Probe
DoS
U2R
R2L
Normal
Probe
DoS
U2R
R2L

精确率0.719 40.618 20.954 70.640 00.150 00.781 60.760 10.899 00.517 20.827 1
召回率0.966 00.769 90.824 90.080 00.001 10.914 00.811 20.817 50.150 00.529 8
F1-score0.824 70.685 80.885 10.142 20.002 20.842 60.784 80.856 30.232 60.645 9
准确率
0.772 5
0.817 3

新窗口打开| 下载CSV



图7

图7   平衡化前后P-R和ROC曲线




表5   数据平衡化前后不同分类器二分类实验结果对比


分类器
平衡化前
平衡化后

精确率
召回率
F1-score
准确率
精确率
召回率
F1-score
准确率

DT0.714 40.951 70.814 20.812 90.733 5[size=&quot;normal&quot;>0<mstyle]0.96640.9664
0.834 00.834 3
RF0.642 00.958 40.768 90.751 80.776 10.919 00.841 50.850 9
SVM0.642 80.918 40.756 30.745 00.654 30.919 10.764 40.756 0
NB0.576 30.998 60.730 40.683 00.733 20.876 30.798 40.809 4
KNN0.663 10.959 60.784 30.772 60.767 00.951 00.849 10.854 4
MLP0.694 30.918 40.790 80.790 7[size=&quot;normal&quot;>0<mstyle]0.80090.8009
0.907 5[size=&quot;normal&quot;>0<mstyle]0.58090.5809
[size=&quot;normal&quot;>0<mstyle]0.96300.9630
CNN
0.710 5
0.923 1
0.802 9
0.804 8
0.792 6
0.904 1
0.844 7
0.856 8

新窗口打开| 下载CSV



4 结束语
本文研究了 MMSN 中的入侵检测机制,归纳和总结了该网络的特征和关键节点数据流的不平衡特性,并提出了一种具有针对性的MMSN-IDS。该系统重点考虑了实验数据集和真实世界 MMSN内的数据分布不平衡性,并提出了一种综合性的MMSN入侵检测数据集平衡化处理方法。所提方法使用 CVAE-GAN 模型作为数据生成模块,挖掘并学习少数类特征,实现高质量的模拟样本生成,以扩展不平衡数据集中的少数类。对于多数类,采用基于OPTICS聚类的去噪算法,删除多数类内的噪声样本,并降低类分布边缘的样本重叠程度。获得数据类型分布相对均衡的平衡化数据集,仿真实验结果充分验证了本文方法的有效性。本文所采用的基础分类器均具有一定的局限性,对分类的准确率难以进一步优化。后续将考虑运用集成学习方法,对多个基础分类器的检测结果加权投票,提高总体检测精度、降低误报率,以强化 MMSN-IDS 的攻击检测性能。




您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|超连云论坛 ( 苏ICP备2024117169号 )

GMT+8, 2025-4-9 18:31 , Processed in 0.163750 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表