【PyTorch】教程:对抗学习实例生成

news2025/2/23 6:30:09

ADVERSARIAL EXAMPLE GENERATION

研究推动 ML 模型变得更快、更准、更高效。设计和模型的安全性和鲁棒性经常被忽视,尤其是面对那些想愚弄模型故意对抗时。

本教程将提供您对 ML 模型的安全漏洞的认识,并将深入了解对抗性机器学习这一热门话题。在图像中添加难以察觉的扰动会导致模型性能的显著不同,鉴于这是一个教程,我们将通过图像分类器的示例来探讨这个主题。具体来说,我们将使用第一种也是最流行的攻击方法之一,快速梯度符号攻击( FGSM )来欺骗 MNIST 分类器。

Threat Model (攻击模型)

在论文中,有许多类型的对抗攻击,每种攻击都有不同的目标和攻击者的知识假设。然而,总的来说,首要目标是向输入数据添加最小数量的扰动,以导致期望的错误分类。攻击者的知识有几种假设,其中两种是: white-box (白盒)和 black-box黑盒);白盒攻击假定攻击者具有对模型的完整知识和访问权限,包括体系结构、输入、输出和权重。黑盒攻击假设攻击者只能访问模型的输入和输出,并且对底层架构或权重一无所知。还有几种类型的目标,包括 misclassification错误分类)和 source/target misclassification 源/目标错误分类错误分类的目标意味着对手只希望输出分类错误,而不在乎新的分类是什么。源/目标错误分类意味着对手希望更改最初属于特定源类别的图像,从而将其分类为特定目标类别。

Fast Gradient Sign Attack

FGSM 攻击是白盒攻击,目标是错误分类。

迄今为止最早也是最流行的的对抗攻击是 Fast Gradient Sign Attack, FGSM (Explaining and Harnessing Adversarial Examples),这种攻击非常强大, 也很直观。它旨在利用神经网络的学习方式,即梯度来攻击神经网络。这个想法很简单,而不是通过基于反向传播梯度调整权重来最小化损失,而是基于相同的反向传播梯度来调整输入数据以最大化损失。换句话说,攻击使用输入数据的损失梯度,然后调整输入数据以最大化损失。

在这里插入图片描述

从图中可以看出, x x x 是被正确分类为 panda 的原始图像, y y y x x x 的正确标签, θ \theta θ 代表的是模型参数,$ J(\theta, x, y)$ 是训练网络的 loss 。攻击反向传播梯度到输入数据计算 ∇ x J ( θ , x , y ) \nabla_x J(\theta, x, y) xJ(θ,x,y) , 然后利用很小的步长 ( ϵ \epsilon ϵ 或 0.007 ) 在某个方向上最大化损失(例如: s i g n ( ∇ x J ( θ , x , y ) ) sign(\nabla_x J(\theta, x, y)) sign(xJ(θ,x,y)) ),最后的扰动图像 x ′ x' x 最后被错误分类为 gibbon, 实际上图像还是 panda

import torch
import torch.nn as nn 
import torch.nn.functional as F 
import torch.optim as optim 
from torchvision import datasets, transforms 
import numpy as np 
import matplotlib.pyplot as plt 

from six.moves import urllib 
opener = urllib.request.build_opener() 
opener.addheaders = [('User-agent', 'Mozilla/5.0')] 
urllib.request.install_opener(opener) 

Implementation

本节中,我们将讨论教程的输入参数,定义攻击下的模型,以及相关的测试

Inputs

三个输入:

  • epsilons: epsilon 列表值,保持 0 在列表中非常重要,代表着原始模型的性能。 epsilon 越大代表着攻击越大。
  • pretrained_model: 预训练模型,训练模型的代码在 这里. 也可以直接下载 预训练模型. 因为 google drive 无法下载,所以还可以在 CSDN资源 下载
  • use_cuda: 使用 GPU;

Model Under Attack

定义了模型和 DataLoader,初始化模型和加载权重。

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, 3, 1)
        self.conv2 = nn.Conv2d(32, 64, 3, 1)
        self.dropout1 = nn.Dropout(0.25)
        self.dropout2 = nn.Dropout(0.5)
        self.fc1 = nn.Linear(9216, 128)
        self.fc2 = nn.Linear(128, 10)

    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = F.max_pool2d(x, 2)
        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output


epsilons = [0, .05, .1, .15, .2, .25, .3]
pretrained_model = "lenet_mnist_model.pt"
use_cuda = True

# MNIST Test dataset and dataloader declaration
test_loader = torch.utils.data.DataLoader(
    datasets.MNIST('../../../datasets', train=False, download=True, transform=transforms.Compose([
        transforms.ToTensor(),
    ])),
    batch_size=1, shuffle=True)

print("CUDA Available: ", torch.cuda.is_available())
device = torch.device('cuda' if (use_cuda and torch.cuda.is_available()) else 'cpu')

# init network
model = Net().to(device)

# load the pretrained model 
model.load_state_dict(torch.load(pretrained_model, map_location='cpu'))

# set the model in evaluation mode. In this case this is for the Dropout layers
model.eval()
CUDA Available:  True
Net(
  (conv1): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1))
  (conv2): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1))
  (dropout1): Dropout(p=0.25, inplace=False)
  (dropout2): Dropout(p=0.5, inplace=False)
  (fc1): Linear(in_features=9216, out_features=128, bias=True)
  (fc2): Linear(in_features=128, out_features=10, bias=True)
)

FGSM Attack (FGSM 攻击)

我们现在定义一个函数创建一个对抗实例,通过对原始输入进行干扰。 fgsm_attack 函数有3个输入,原始输入图像 x x x,像素方向扰动量 ϵ \epsilon ϵ ,梯度损失,(例如 ∇ x J ( θ , x , y ) \nabla_x J(\mathbf{\theta}, \mathbf{x}, y) xJ(θ,x,y)

创建干扰图像

p e r t u r b e d i m a g e = i m a g e + e p s i l o n ∗ s i g n ( d a t a g r a d ) = x + ϵ ∗ s i g n ( ∇ x J ( θ , x , y ) ) perturbed_image=image+epsilon∗sign(data_grad)=x+ϵ∗sign(∇x J(θ,x,y)) perturbedimage=image+epsilonsign(datagrad)=x+ϵsign(xJ(θ,x,y))

最后,为了保持原始图像的数据范围,干扰图像被缩放到 [0, 1]

# FGSM attack code
def fgsm_attack(image, epsilon, data_grad):
    # collect the element-wise sign of the data gradient
    sign_data_grad = data_grad.sign()
    
    # create the perturbed image by adjusting each pixel of the input image 
    perturbed_image = image + epsilon * sign_data_grad 
    
    # adding clipping to maintain [0, 1] range 
    perturbed_image = torch.clamp(perturbed_image, 0, 1)
    
    # return the perturbed image 
    return perturbed_image

Testing Function (测试函数)

def test(model, device, test_loader, epsilon):
    # accuracy counter
    correct = 0
    adv_examples = []
    
    # loop over all examples in test set 
    for data, target in test_loader:
        data, target = data.to(device), target.to(device)
        
        # Set requires_grad attribute of tensor. Important for Attack
        data.requires_grad = True
        
        # 
        output = model(data)
        init_pred = output.max(1, keepdim=True)[1]
        
        # if the initial prediction is wrong, don't botter attacking, just move on
        if init_pred.item() != target.item():
            continue 
        
        # calculate the loss
        loss = F.nll_loss(output, target)
        
        # zero all existing grad
        model.zero_grad()

        # calculate gradients of model in backward loss 
        loss.backward()
        
        # collect datagrad
        data_grad = data.grad.data 
        
        # call FGSM attack
        perturbed_data = fgsm_attack(data, epsilon, data_grad)
        
        # reclassify the perturbed image 
        output = model(perturbed_data)
        
        # check for success 
        final_pred = output.max(1, keepdim=True)[1]
        
        # 
        if final_pred.item() == target.item():
            correct += 1
            
            # special case for saving 0 epsilon examples
            if (epsilon == 0) and (len(adv_examples) < 5):
                adv_ex = perturbed_data.squeeze().detach().cpu().numpy()
                adv_examples.append((init_pred.item(), final_pred.item(), adv_ex))
        else:
            # Save some adv examples for visualization later
            if len(adv_examples) < 5:
                adv_ex = perturbed_data.squeeze().detach().cpu().numpy()
                adv_examples.append( (init_pred.item(), final_pred.item(), adv_ex) )

    # Calculate final accuracy for this epsilon
    final_acc = correct/float(len(test_loader))
    print("Epsilon: {}\tTest Accuracy = {} / {} = {}".format(epsilon, correct, 
        len(test_loader), final_acc))

    # Return the accuracy and an adversarial example
    return final_acc, adv_examples

Run Attack (执行攻击)

实现的最后一步是执行攻击,我们针对每个 epsilon 执行全部的 test step,并且保存最终的准确率和一些成功的对抗实例。 ϵ = 0 \epsilon=0 ϵ=0 不执行攻击

accuracies = []
examples = []

# Run test for each epsilon
for eps in epsilons:
    acc, ex = test(model, device, test_loader, eps)
    accuracies.append(acc)
    examples.append(ex)
Epsilon: 0	Test Accuracy = 9906 / 10000 = 0.9906
Epsilon: 0.05	Test Accuracy = 9517 / 10000 = 0.9517
Epsilon: 0.1	Test Accuracy = 8070 / 10000 = 0.807
Epsilon: 0.15	Test Accuracy = 4242 / 10000 = 0.4242
Epsilon: 0.2	Test Accuracy = 1780 / 10000 = 0.178
Epsilon: 0.25	Test Accuracy = 1292 / 10000 = 0.1292
Epsilon: 0.3	Test Accuracy = 1180 / 10000 = 0.118

Accuracy vs Epsilon (正确率 VS epsilon)

ϵ \epsilon ϵ 增大时,我们期望正确率下降,因为大的 ϵ \epsilon ϵ 我们在方向上有大的变换可以最大化 loss. 他们的变换不是线性的,一开始下降的慢,中间下降的快,最后下降的慢。

plt.figure(figsize=(5, 5))
plt.plot(epsilons, accuracies, "*-")
plt.yticks(np.arange(0, 1.1, step=0.1))
plt.xticks(np.arange(0, .35, step=0.05))
plt.title("Accuracy vs Epsilon")
plt.xlabel("Epsilon")
plt.ylabel("Accuracy")
plt.show()

在这里插入图片描述

Sample Adversarial Examples (对抗实例)

# Plot several examples of adversarial samples at each epsilon
cnt = 0
plt.figure(figsize=(8,10))
for i in range(len(epsilons)):
    for j in range(len(examples[i])):
        cnt += 1
        plt.subplot(len(epsilons),len(examples[0]),cnt)
        plt.xticks([], [])
        plt.yticks([], [])
        if j == 0:
            plt.ylabel("Eps: {}".format(epsilons[i]), fontsize=14)
        orig,adv,ex = examples[i][j]
        plt.title("{} -> {}".format(orig, adv))
        plt.imshow(ex, cmap="gray")
plt.tight_layout()
plt.show()

在这里插入图片描述

完整代码

import torch
import torch.nn as nn 
import torch.nn.functional as F 
import torch.optim as optim 
from torchvision import datasets, transforms 
import numpy as np 
import matplotlib.pyplot as plt 

from six.moves import urllib 
opener = urllib.request.build_opener() 
opener.addheaders = [('User-agent', 'Mozilla/5.0')] 
urllib.request.install_opener(opener) 

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 32, 3, 1)
        self.conv2 = nn.Conv2d(32, 64, 3, 1)
        self.dropout1 = nn.Dropout(0.25)
        self.dropout2 = nn.Dropout(0.5)
        self.fc1 = nn.Linear(9216, 128)
        self.fc2 = nn.Linear(128, 10)

    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = F.max_pool2d(x, 2)
        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output


epsilons = [0, .05, .1, .15, .2, .25, .3]
pretrained_model = "lenet_mnist_model.pt"
use_cuda = True

# MNIST Test dataset and dataloader declaration
test_loader = torch.utils.data.DataLoader(
    datasets.MNIST('../../../datasets', train=False, download=True, transform=transforms.Compose([
        transforms.ToTensor(),
    ])),
    batch_size=1, shuffle=True)

print("CUDA Available: ", torch.cuda.is_available())
device = torch.device('cuda' if (use_cuda and torch.cuda.is_available()) else 'cpu')

# init network
model = Net().to(device)

# load the pretrained model 
model.load_state_dict(torch.load(pretrained_model, map_location='cpu'))

# set the model in evaluation mode. In this case this is for the Dropout layers
model.eval()

# FGSM attack code
def fgsm_attack(image, epsilon, data_grad):
    # collect the element-wise sign of the data gradient
    sign_data_grad = data_grad.sign()
    
    # create the perturbed image by adjusting each pixel of the input image 
    perturbed_image = image + epsilon * sign_data_grad 
    
    # adding clipping to maintain [0, 1] range 
    perturbed_image = torch.clamp(perturbed_image, 0, 1)
    
    # return the perturbed image 
    return perturbed_image


def test(model, device, test_loader, epsilon):
    # accuracy counter
    correct = 0
    adv_examples = []

    # loop over all examples in test set
    for data, target in test_loader:
        data, target = data.to(device), target.to(device)

        # Set requires_grad attribute of tensor. Important for Attack
        data.requires_grad = True

        #
        output = model(data)
        init_pred = output.max(1, keepdim=True)[1]

        # if the initial prediction is wrong, don't botter attacking, just move on
        if init_pred.item() != target.item():
            continue

        # calculate the loss
        loss = F.nll_loss(output, target)

        # zero all existing grad
        model.zero_grad()

        # calculate gradients of model in backward loss
        loss.backward()

        # collect datagrad
        data_grad = data.grad.data

        # call FGSM attack
        perturbed_data = fgsm_attack(data, epsilon, data_grad)

        # reclassify the perturbed image
        output = model(perturbed_data)

        # check for success
        final_pred = output.max(1, keepdim=True)[1]

        #
        if final_pred.item() == target.item():
            correct += 1

            # special case for saving 0 epsilon examples
            if (epsilon == 0) and (len(adv_examples) < 5):
                adv_ex = perturbed_data.squeeze().detach().cpu().numpy()
                adv_examples.append(
                    (init_pred.item(), final_pred.item(), adv_ex))
        else:
            # Save some adv examples for visualization later
            if len(adv_examples) < 5:
                adv_ex = perturbed_data.squeeze().detach().cpu().numpy()
                adv_examples.append(
                    (init_pred.item(), final_pred.item(), adv_ex))

    # Calculate final accuracy for this epsilon
    final_acc = correct/float(len(test_loader))
    print("Epsilon: {}\tTest Accuracy = {} / {} = {}".format(epsilon, correct,
                                                             len(test_loader), final_acc))

    # Return the accuracy and an adversarial example
    return final_acc, adv_examples


accuracies = []
examples = []

# Run test for each epsilon
for eps in epsilons:
    acc, ex = test(model, device, test_loader, eps)
    accuracies.append(acc)
    examples.append(ex)

plt.figure(figsize=(5, 5))
plt.plot(epsilons, accuracies, "*-")
plt.yticks(np.arange(0, 1.1, step=0.1))
plt.xticks(np.arange(0, .35, step=0.05))
plt.title("Accuracy vs Epsilon")
plt.xlabel("Epsilon")
plt.ylabel("Accuracy")
plt.show()


# Plot several examples of adversarial samples at each epsilon
cnt = 0
plt.figure(figsize=(8, 10))
for i in range(len(epsilons)):
    for j in range(len(examples[i])):
        cnt += 1
        plt.subplot(len(epsilons), len(examples[0]), cnt)
        plt.xticks([], [])
        plt.yticks([], [])
        if j == 0:
            plt.ylabel("Eps: {}".format(epsilons[i]), fontsize=14)
        orig, adv, ex = examples[i][j]
        plt.title("{} -> {}".format(orig, adv))
        plt.imshow(ex, cmap="gray")
plt.tight_layout()
plt.show()

【参考】

ADVERSARIAL EXAMPLE GENERATION

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/336422.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java程序设计-ssm企业财务管理系统设计与实现

摘要系统设计系统实现开发环境&#xff1a;摘要 对于企业集来说,财务管理的地位很重要。随着计算机和网络在企业中的广泛应用&#xff0c;企业发展速度在不断加快&#xff0c;在这种市场竞争冲击下企业财务管理系统必须优先发展&#xff0c;这样才能保证在竞争中处于优势地位。…

from文件突然全部变为类cs右击无法显示设计界面

右击也不显示查看设计器 工程文件 .csproj中将 <Compile Include"OperatorWindows\Connection.cs" /> <Compile Include"OperatorWindows\Connection.Designer.cs"> <DependentUpon>Connection.cs</DependentUpon> &…

CV——day74 读论文:关注前景的anchor-free交通场景探测器

FII-CenterNet&#xff1a;关注前景的anchor-free交通场景探测器FII-CenterNetI. INTRODUCTIONII. RELATED WORKC. Detectors Exploiting Segmentation InformationIII. FII-CENTERNET APPROACHA. 前景区域建议网络(Foreground Region Proposal Network)1) 上分支提出前景区域2…

linux称手的终端管理器Zsh(Z shell)-图文安装超详细

linux默认的shell太low了&#xff0c;iTerm2在macOS系统简直堪称终端管理神器&#xff0c;有一款可以平替iTem2的linux开源软件 Zsh&#xff08;Z shell&#xff09; &#xff0c;Zsh 是一个为交互使用而设计的 shell 一&#xff1a;安装Zsh 1.yum安装zsh yum install zsh安装…

频谱分析仪测量噪声系数方法介绍

用频谱仪测量噪声系数&#xff1a;测量框图为&#xff1a;基于噪声系数的定义得到的一个测量公式为&#xff1a;NFPNOUT-(-174dBm/Hz20lg(BW)Gain)(1)公式中&#xff0c;PNOUT是已测的总共输出噪声功率&#xff0c;-174dBm/Hz是290oK&#xff08;室温&#xff09;时环境噪声的功…

视频号小店新订单如何实时同步企业微信

随着直播带货的火热&#xff0c;视频号小店也为商家提供商品信息服务、商品交易&#xff0c;支持商家在视频号运营电商&#xff0c;许多企业也将产品的零售路径渗透至视频号小店中了。如果我们希望在视频号小店接收到订单后&#xff0c;能尽快及时发货&#xff0c;给用户较好的…

filter属性详解

filter属性详解 filter 属性定义了元素(通常是<img>)的可视效果(例如&#xff1a;模糊与饱和度)。 filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url();下面运用…

【金三银四系列】Spring面试题-上(2023版)

Spring面试专题 1.Spring应该很熟悉吧&#xff1f;来介绍下你的Spring的理解 有些同学可能会抢答&#xff0c;不熟悉!!! 好了&#xff0c;不开玩笑&#xff0c;面对这个问题我们应该怎么来回答呢&#xff1f;我们给大家梳理这个几个维度来回答 1.1 Spring的发展历程 先介绍…

由 GPT 驱动的沙盒,尽情发挥想象力! #NovelAI

一个由 GPT 驱动的沙盒&#xff0c;供用户尽情发挥想象力的空间&#xff0c;会获得怎样的体验&#xff1f;NovelAI NovelAI 是一项用于 AI 辅助创作、讲故事、虚拟陪伴的工具。NovelAI 的人工智能算法会根据用户的方式创建类似人类的写作&#xff0c;使任何人&#xff0c;无论能…

《爆肝整理》保姆级系列教程python接口自动化(十一)--发送post【data】(详解

简介  前面登录的是传 json 参数&#xff0c;由于其登录机制的改变没办法演示&#xff0c;然而在工作中有些登录不是传 json 的&#xff0c;如 jenkins 的登录&#xff0c;这里小编就以jenkins 登录为案例&#xff0c;传 data 参数&#xff0c;给各位童鞋详细演练一下。 一、…

【操作系统】操作系统IO和虚拟文件系统VFS

1.什么是操作系统的IO 输入&#xff08;input&#xff09;和输出&#xff08;output&#xff09;&#xff0c;就是对磁盘的读&#xff08;read&#xff09;和写&#xff08;write&#xff09;。 I/O模式可以划分为本地IO模型&#xff08;内存、磁盘&#xff09;和网络IO模型。…

测试的阶段性小小总结

转眼入职2年之余&#xff0c;毕业后就投入测试行业。在日常的工作中也有自己的一些思考和总结。2021到2023是多变的两年&#xff0c;加入教培行业&#xff0c;受双减政策影响&#xff0c;注定艰难。参与了各种类型的测试项目&#xff0c;不断在探索和前行&#xff0c;万变不离其…

C++ —— 多态

目录 1.多态的概念 2.多态的定义及实现 2.1构成多态的两个硬性条件 2.2虚函数的重写 2.3override和final 3.抽象类 3.1接口继承和实现继承 4.多态原理 4.1虚函数表 4.2原理 4.3静态绑定和动态绑定 5.单继承和多继承体系的虚函数表 5.1单继承体系的虚函数表 5.2多继…

【MyBatis】第七篇:动态sql

mybatis中的动态sql&#xff0c;其实就是在mybatis中映射配置文件中通过if等判断语句写sql。现在聊一下&#xff0c;常用的的判断语句。 前面准备&#xff1a; CREATE TABLE student (sid int DEFAULT NULL,sname varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general…

2023年深圳/东莞/惠州CPDA数据分析师认证报名入口

CPDA数据分析师认证是中国大数据领域有一定权威度的中高端人才认证&#xff0c;它不仅是中国较早大数据专业技术人才认证、更是中国大数据时代先行者&#xff0c;具有广泛的社会认知度和权威性。 无论是地方政府引进人才、公务员报考、各大企业选聘人才&#xff0c;还是招投标加…

计算机网络-传输层

文章目录前言概述用户数据报协议 UDP(User Datagram Protocol)传输控制协议 TCP(Transmission Control Protocol)TCP 的流量控制拥塞控制方法TCP 的运输连接管理TCP 的有限状态机总结前言 本博客仅做学习笔记&#xff0c;如有侵权&#xff0c;联系后即刻更改 科普&#xff1a…

LeetCode经典问题总结笔记—一文搞懂滑动窗口和哈希表结合使用之3. 无重复字符的最长子串问题(第一篇)

今日主要总结一下可以使用滑动窗口和哈希表结合使用解决的一道题目&#xff0c;3. 无重复字符的最长子串 题目&#xff1a;3. 无重复字符的最长子串 Leetcode题目地址 题目描述&#xff1a; 给定一个字符串 s &#xff0c;请你找出其中不含有重复字符的 最长子串 的长度。 示…

华尔街分析师:斗鱼2023财年前景暗淡,但盈利能力有望提升

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 华尔街预计斗鱼2023财年收入前景悲观 根据S&P Capital IQ的一致性数据&#xff0c;华尔街卖方分析师预计&#xff0c;斗鱼&#xff08;DOYU&#xff09;的收入将从2022财年的71.93亿元下降到2023财年的67.53亿元&#x…

react -- Context

使用Context简单传参例子 解决父子组件多层嵌套传参&#xff0c;中间不用通过props传值 import React, { useContext } from "react"; // 参数对象 const param { title: "星期四" }; // 创建一个 Context 对象 // const MyContext React.createContex…

基于matlab使用机器学习和深度学习进行雷达目标分类

一、前言此示例展示了如何使用机器学习和深度学习方法对雷达回波进行分类。机器学习方法使用小波散射特征提取与支持向量机相结合。此外&#xff0c;还说明了两种深度学习方法&#xff1a;使用SqueezeNet的迁移学习和长短期记忆&#xff08;LSTM&#xff09;递归神经网络。请注…