【稀疏矩阵】使用torch.sparse模块

news2024/9/20 20:30:49

文章目录

  • 稀疏矩阵的格式
    • coo
    • csr
    • csc
  • Construction of Sparse COO tensors
  • Construction of CSR tensors
  • Linear Algebra operations(稀疏与稠密之间混合运算)
  • Tensor methods and sparse(与稀疏有关的tensor成员函数)
    • coo张量可用的tensor成员函数(经实测,csr也有一些可以用,比如dim())
  • Torch functions specific to sparse Tensors(与稀疏有关的torch函数)
  • 支持稀疏张量的常规torch函数
  • 支持稀疏张量的一元函数


稀疏矩阵的格式

目前,torch.sparse和scipy.sparse模块比较支持的主流的稀疏矩阵格式有coo格式、csr格式和csc格式,这三种格式中可供使用的API也最多。

coo

将矩阵中非零元素的坐标和值分开存储在3个数组中,3个数组长度必须相同,表示有n个非零元素。

在这里插入图片描述

csr

Index PointersIndicesData3个数组存储。

  • Index Pointers:第 i个元素记录这个矩阵的第 i行的第1个非零值在 Data数组的起始位置,第 i+1个元素记录这个矩阵的第 i行的最后一个非零值在 Data数组的终止位置(不包含右边界)。因此,这个矩阵的行数等于 len(Index Pointers)-1,第 i行非零值的个数等于 Index Pointers[i+1]-Index Pointers[i]
  • Indices:第 i个元素记录这个矩阵的第 i个非零值的列坐标。
  • Data:第 i个元素记录这个矩阵的第 i个非零值的具体数值,排列顺序严格按照行优先,列次先

在这里插入图片描述

csc

与csr唯一的不同在于列优先,其他规则一模一样。

在这里插入图片描述

Construction of Sparse COO tensors

  1. 常规构建
>>> i = [[0, 1, 1],
         [2, 0, 2]]
>>> v =  [3, 4, 5]
>>> s = torch.sparse_coo_tensor(i, v, (2, 3))
>>> s
tensor(indices=tensor([[0, 1, 1],
                       [2, 0, 2]]),
       values=tensor([3, 4, 5]),
       size=(2, 3), nnz=3, layout=torch.sparse_coo)
>>> s.to_dense()
tensor([[0, 0, 3],
        [4, 0, 5]])

torch中,稀疏矩阵的存储方式记录在 tensor.layout中,可以通过检查 torch.layout == torch.sparse_coo来判断是否是coo张量。此外,稠密张量的 layout等于 strided

  1. 稠密混合的coo张量
>>> i = [[0, 1, 1],
         [2, 0, 2]]
>>> v =  [[3, 4], [5, 6], [7, 8]]
>>> s = torch.sparse_coo_tensor(i, v, (2, 3, 2))
>>> s
tensor(indices=tensor([[0, 1, 1],
                       [2, 0, 2]]),
       values=tensor([[3, 4],
                      [5, 6],
                      [7, 8]]),
       size=(2, 3, 2), nnz=3, layout=torch.sparse_coo)

此方案与常规的coo构建方式不同,values中每个元素可以是一个向量,表示对应坐标的稠密张量,因此,创建出的coo张量也多出了一个维度。

  1. 带有重复坐标的coo张量
>>> i = [[1, 1]]
>>> v =  [3, 4]
>>> s=torch.sparse_coo_tensor(i, v, (3,))
>>> s
tensor(indices=tensor([[1, 1]]),
       values=tensor(  [3, 4]),
       size=(3,), nnz=2, layout=torch.sparse_coo)
>>> s.to_dense()
tensor([0, 7, 0])

如果输入的坐标有重复,则创建出的coo张量会自动把坐标重复的元素值相加。此外,可以通过成员函数 .coalesce()把重复坐标的元素值相加,将这个coo转换成一个不重复的张量;也可以通过 .is_coalesced()检查这个coo是否存在重复的坐标。

Construction of CSR tensors

按照 Index PointersIndicesData三个数组的定义构建即可。

>>> crow_indices = torch.tensor([0, 2, 4])
>>> col_indices = torch.tensor([0, 1, 0, 1])
>>> values = torch.tensor([1, 2, 3, 4])
>>> csr = torch.sparse_csr_tensor(crow_indices, col_indices, values, dtype=torch.float64)
>>> csr
tensor(crow_indices=tensor([0, 2, 4]),
       col_indices=tensor([0, 1, 0, 1]),
       values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4,
       dtype=torch.float64)
>>> csr.to_dense()
tensor([[1., 2.],
        [3., 4.]], dtype=torch.float64)

Linear Algebra operations(稀疏与稠密之间混合运算)

M表示2-D张量,V表示1-D张量,f表示标量,*表示逐元素乘法,@表示矩阵乘法。M[SparseSemiStructured]表示一种半结构化的稀疏矩阵,此处不再展开,可以自行去torch官网察看。

PyTorch operationSparse gradLayout signature
torch.mv()noM[sparse_coo] @ V[strided] -> V[strided]
torch.mv()noM[sparse_csr] @ V[strided] -> V[strided]
torch.matmul()noM[sparse_coo] @ M[strided] -> M[strided]
torch.matmul()noM[sparse_csr] @ M[strided] -> M[strided]
torch.matmul()noM[SparseSemiStructured] @ M[strided] -> M[strided]
torch.matmul()noM[strided] @ M[SparseSemiStructured] -> M[strided]
torch.mm()noM[strided] @ M[SparseSemiStructured] -> M[strided]
torch.mm()noM[sparse_coo] @ M[strided] -> M[strided]
torch.mm()noM[SparseSemiStructured] @ M[strided] -> M[strided]
torch.sparse.mm()yesM[sparse_coo] @ M[strided] -> M[strided]
torch.smm()noM[sparse_coo] @ M[strided] -> M[sparse_coo]
torch.hspmm()noM[sparse_coo] @ M[strided] -> M[hybrid sparse_coo]
torch.bmm()noT[sparse_coo] @ T[strided] -> T[strided]
torch.addmm()nof * M[strided] + f * (M[sparse_coo] @ M[strided]) -> M[strided]
torch.addmm()nof * M[strided] + f * (M[SparseSemiStructured] @ M[strided]) -> M[strided]
torch.addmm()nof * M[strided] + f * (M[strided] @ M[SparseSemiStructured]) -> M[strided]
torch.sparse.addmm()yesf * M[strided] + f * (M[sparse_coo] @ M[strided]) -> M[strided]
torch.sspaddmm()nof * M[sparse_coo] + f * (M[sparse_coo] @ M[strided]) -> M[sparse_coo]
torch.lobpcg()noGENEIG(M[sparse_coo]) -> M[strided], M[strided]
torch.pca_lowrank()yesPCA(M[sparse_coo]) -> M[strided], M[strided], M[strided]
torch.svd_lowrank()yesSVD(M[sparse_coo]) -> M[strided], M[strided], M[strided]

以上API中,如果 Layout signature中提供了 @或者 *操作符,就不需要记住API,直接通过操作符即可隐式调用对应的API。如:

>>> a = torch.tensor([[0, 0, 1, 0], [1, 2, 0, 0], [0, 0, 0, 0]], dtype=torch.float64)
>>> sp = a.to_sparse_csr()
>>> vec = torch.randn(4, 1, dtype=torch.float64)
>>> sp.matmul(vec)
tensor([[ 0.4788],
        [-3.2338],
        [ 0.0000]], dtype=torch.float64)
>>> sp @ vec
tensor([[ 0.4788],
        [-3.2338],
        [ 0.0000]], dtype=torch.float64)

需要注意的是,使用操作符在稀疏张量和稠密张量之间乘法运算时,返回的都是稠密张量。如果想要返回稀疏张量,需要显式使用torch.smm()

torch同样支持稀疏与稀疏之间的运算,但要求输入的稀疏张量必须具有相同的稀疏结构,否则会报错,返回的稀疏张量的稀疏结构也与输入相同。

乘法运算:

>>> a = torch.tensor([[0, 0, 1, 0], [1, 2, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0]], dtype=torch.float64)
>>> b = torch.tensor([[0, 0, 2, 0], [3, 1, 0, 0], [0, 0, 4, 0], [1, 0, 0, 1]], dtype=torch.float64)
>>> sp1 = a.to_sparse_coo()
>>> sp2 = b.to_sparse_coo()
>>> sp1 @ sp2
tensor(indices=tensor([[0, 1, 1, 1, 2, 2, 3],
                       [2, 0, 1, 2, 0, 1, 2]]),
       values=tensor([4., 6., 2., 2., 3., 1., 2.]),
       size=(4, 4), nnz=7, dtype=torch.float64, layout=torch.sparse_coo)

加法运算

>>> a = torch.tensor([[0, 0, 1, 0], [1, 2, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0]], dtype=torch.float64)
>>> b = torch.tensor([[0, 0, 2, 0], [3, 1, 0, 0], [0, 0, 4, 0], [1, 0, 0, 1]], dtype=torch.float64)
>>> sp1 = a.to_sparse_coo()
>>> sp2 = b.to_sparse_coo()
>>> sp3 = b.to_sparse_csr()
>>> sp1 + sp2
tensor(indices=tensor([[0, 1, 1, 2, 2, 3, 3],
                       [2, 0, 1, 1, 2, 0, 3]]),
       values=tensor([3., 4., 3., 1., 4., 2., 1.]),
       size=(4, 4), nnz=7, dtype=torch.float64, layout=torch.sparse_coo)
>>> sp1 + sp3
UserWarning: Sparse CSR tensor support is in beta state. If you miss a functionality in the sparse tensor support, please submit a feature request to https://github.com/pytorch/pytorch/issues. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\SparseCsrTensorImpl.cpp:55.)
  sp3 = b.to_sparse_csr()
Traceback (most recent call last):
  File "C:\Users\Xu Han\Desktop\pycharm-projects\MD_notes\main.py", line 18, in <module>
    print(sp1 + sp3)
RuntimeError: memory format option is only supported by strided tensors

Tensor methods and sparse(与稀疏有关的tensor成员函数)

PyTorch operationreturn
Tensor.is_sparseIsTrue if the Tensor uses sparse COO storage layout, False otherwise.
Tensor.is_sparse_csrIsTrue if the Tensor uses sparse CSR storage layout, False otherwise.
Tensor.dense_dimReturn the number of dense dimensions in a sparse tensorself.
Tensor.sparse_dimReturn the number of sparse dimensions in a sparse tensorself.

这里打断一下表格,讲解一下dense_dim和sparse_dim的含义。上文中,我们曾构建过稠密混合的coo张量,如下:

>>> i = [[0, 1, 1],
         [2, 0, 2]]
>>> v =  [[3, 4], [5, 6], [7, 8]]
>>> s = torch.sparse_coo_tensor(i, v, (2, 3, 2))
>>> s
tensor(indices=tensor([[0, 1, 1],
                       [2, 0, 2]]),
       values=tensor([[3, 4],
                      [5, 6],
                      [7, 8]]),
       size=(2, 3, 2), nnz=3, layout=torch.sparse_coo)

那么,对于这个tensor,它的dense_dim为1,sparse_dim为2。

此外,在进行稀疏与稀疏之间的数学运算时,一定要保证稀疏张量的sparse_dim等于2.

继续表格。

PyTorch operationreturn
Tensor.sparse_maskReturns a new sparse tensor with values from a strided tensorself filtered by the indices of the sparse tensor mask.
Tensor.to_sparseReturns a sparse copy of the tensor.
Tensor.to_sparse_cooConvert a tensor to coordinate format.
Tensor.to_sparse_csrConvert a tensor to compressed row storage format (CSR).
Tensor.to_sparse_cscConvert a tensor to compressed column storage (CSC) format.
Tensor.to_sparse_bsrConvert a tensor to a block sparse row (BSR) storage format of given blocksize.
Tensor.to_sparse_bscConvert a tensor to a block sparse column (BSC) storage format of given blocksize.
Tensor.to_denseCreates a strided copy ofself if self is not a strided tensor, otherwise returns self.
Tensor.valuesReturn the values tensor of a sparse COO tensor.

以下是仅限coo张量的成员:

PyTorch operationreturn
Tensor.coalesceReturns a coalesced copy ofself if self is an uncoalesced tensor.
Tensor.sparse_resize_Resizesself sparse tensor to the desired size and the number of sparse and dense dimensions.
Tensor.sparse_resize_and_clear_Removes all specified elements from a sparse tensorself and resizes self to the desired size and the number of sparse and dense dimensions.
Tensor.is_coalescedReturnsTrue if self is a sparse COO tensor that is coalesced, False otherwise.
Tensor.indicesReturn the indices tensor of a sparse COO tensor.

以下是仅限csr和bsr张量的成员:

PyTorch operationreturn
Tensor.crow_indicesReturns the tensor containing the compressed row indices of theself tensor when self is a sparse CSR tensor of layout sparse_csr.
Tensor.col_indicesReturns the tensor containing the column indices of theself tensor when self is a sparse CSR tensor of layout sparse_csr.

以下是仅限csc和bsc张量的成员:

PyTorch operationreturn
Tensor.row_indices
Tensor.ccol_indices

coo张量可用的tensor成员函数(经实测,csr也有一些可以用,比如dim())

add() add_() addmm() addmm_() any() asin() asin_() arcsin() arcsin_() bmm() clone() deg2rad() deg2rad_() detach() detach_() dim() div() div_() floor_divide() floor_divide_() get_device() index_select() isnan() log1p() log1p_() mm() mul() mul_() mv() narrow_copy() neg() neg_() negative() negative_() numel() rad2deg() rad2deg_() resize_as_() size() pow() sqrt() square() smm() sspaddmm() sub() sub_() t() t_() transpose() transpose_() zero_()

Torch functions specific to sparse Tensors(与稀疏有关的torch函数)

PyTorch operationreturn
sparse_coo_tensorConstructs a sparse tensor in COO(rdinate) format with specified values at the givenindices.
sparse_csr_tensorConstructs a sparse tensor in CSR (Compressed Sparse Row) with specified values at the givencrow_indices and col_indices.
sparse_csc_tensorConstructs a sparse tensor in CSC (Compressed Sparse Column) with specified values at the givenccol_indices and row_indices.
sparse_bsr_tensorConstructs a sparse tensor in BSR (Block Compressed Sparse Row)) with specified 2-dimensional blocks at the givencrow_indices and col_indices.
sparse_bsc_tensorConstructs a sparse tensor in BSC (Block Compressed Sparse Column)) with specified 2-dimensional blocks at the givenccol_indices and row_indices.
sparse_compressed_tensorConstructs a sparse tensor in Compressed Sparse format - CSR, CSC, BSR, or BSC - with specified values at the givencompressed_indices and plain_indices.
sparse.sumReturn the sum of each row of the given sparse tensor.
sparse.addmmThis function does exact same thing as torch.addmm() in the forward, except that it supports backward for sparse COO matrixmat1.
sparse.sampled_addmmPerforms a matrix multiplication of the dense matricesmat1 and mat2 at the locations specified by the sparsity pattern of input.
sparse.mmPerforms a matrix multiplication of the sparse matrixmat1
sspaddmmMatrix multiplies a sparse tensormat1 with a dense tensor mat2, then adds the sparse tensor input to the result.
hspmmPerforms a matrix multiplication of a sparse COO matrixmat1 and a strided matrix mat2.
smmPerforms a matrix multiplication of the sparse matrixinput with the dense matrix mat.
sparse.softmaxApplies a softmax function.
sparse.log_softmaxApplies a softmax function followed by logarithm.
sparse.spdiagsCreates a sparse 2D tensor by placing the values from rows ofdiagonals along specified diagonals of the output

支持稀疏张量的常规torch函数

cat() dstack() empty() empty_like() hstack() index_select() is_complex() is_floating_point() is_nonzero() is_same_size() is_signed() is_tensor() lobpcg() mm() native_norm() pca_lowrank() select() stack() svd_lowrank() unsqueeze() vstack() zeros() zeros_like()

支持稀疏张量的一元函数

The following operators currently support sparse COO/CSR/CSC/BSR tensor inputs.

abs() asin() asinh() atan() atanh() ceil() conj_physical() floor() log1p() neg() round() sin() sinh() sign() sgn() signbit() tan() tanh() trunc() expm1() sqrt() angle() isinf() isposinf() isneginf() isnan() erf() erfinv()

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

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

相关文章

【软件逆向】第38课,软件逆向安全工程师之静态补丁,每天5分钟学习逆向吧!

关于x64dbg补丁工具的使用&#xff0c;以下是一些基本的指南和步骤&#xff1a; x64dbg的安装与配置&#xff1a;首先&#xff0c;您需要从x64dbg的官方网站下载并安装x64dbg。界面介绍&#xff1a;x64dbg的主要界面包括反汇编窗口、寄存器窗口、数据窗口和堆栈窗口。反汇编窗…

正运动邀您共聚2024 CIOE中国光博会!

■展会名称&#xff1a; 第25届中国国际光电博览会&#xff08;以下简称&#xff1a;CIOE中国光博会&#xff09; ■展会日期 2024年9月11日–13日 ■展馆地点 中国深圳国际会展中心&#xff08;新馆&#xff09;■展位号6A52-10 9月11至13日&#xff0c;深圳国际会展中心…

lnmp - tp6.0的安装和简单使用

概述 使用了很长时间的Mac M2芯片的电脑在之前使用虚拟机之前总有一些bug不是那么好用&#xff0c;周末之余重新安装了一下centos虚拟机&#xff0c;搭建了lnmp环境&#xff0c;打算自己挤时间&#xff0c;做一点应用&#xff0c;作为一次新的小小的尝试。 安装&更新 ce…

HTML5好看的花店商城源码3

文章目录 1.设计来源1.1 主界面1.2 登录界面1.3 注册界面1.4 商品列表界面1.5 商品详细界面1.6 购物车界面1.7 团队介绍界面1.8 关于我们界面1.9 其他界面效果汇总 2.效果和源码2.1 动态效果2.2 源代码 源码下载万套模板&#xff0c;程序开发&#xff0c;在线开发&#xff0c;在…

设计模式 —— 单例模式

文章目录 一、单例模式1.1 单例模式定义1.2 单例模式的优点1.3 单例模式的缺点1.4 单例模式的使用场景 二、普通案例2.1 饿汉式单例模式(Eager Initialization Singleton)2.2 懒汉式单例模式(Lazy Initialization Singleton) 参考资料 本文源代码地址为 java-demos/singeleton-…

西柚云 Rstudio Server 使用教程

在生物信息学的研究中&#xff0c;R语言与RStudio的搭配如同汽车与引擎&#xff0c;是科研工作的强力组合。不过&#xff0c;除了在个人电脑上传统使用的方式&#xff0c;还有没有更简便、更高效的选择呢&#xff1f; RStudio Server Cloud —— 云端的RStudio体验 快速切换多…

【408DS算法题】036基础-14年真题_求二叉树的WPL

Index 真题题目分析实现总结 真题题目 二叉树的带权路径长度(WPL)是二叉树中所有叶结点的带权路径长度之和。给定一棵二叉树T ,采用二叉链表存储&#xff0c; 结点结构如下&#xff1a; 其中叶结点的weight域保存该结点的非负权值。设root为指向T的根结点的指针&#xff0c; 请…

贪心算法求无序数组最大递增序列

给定一个无序的数组&#xff0c;获取其最大的递增序列。下面使用贪心算法实现&#xff1a; 1、算法实现 void max_seq(int* arr,int len) {/// 标记递增序列的开始位置int start 0;/// 记录最大的递增序列数int max 0;int i 1;for( ; i<len; i){/// 如果当前元素大于…

【计算机组成原理】你知道什么是8421码、什么是余3码什么又是2421码吗?今天这篇文章带你认识计算机中的BCD码

BCD码 导读一、编码1.1 什么是编码&#xff1f;1.2 编码机制ASCII码非ASCII编码Unicode 二、 BCD码2.1 8421码小结 2.2 余3码2.3 2421码2.4 总结 结语 导读 大家好&#xff0c;很高兴又和大家见面啦&#xff01;&#xff01;&#xff01; 在上一篇内容中我们介绍了不同的进位…

github中action作用和讲解

1&#xff0c;简介 GitHub Actions 是 GitHub 的一个自动化功能&#xff0c;它允许你在 GitHub 仓库中自动执行软件开发工作流程。你可以使用 GitHub Actions 来执行各种任务&#xff0c;比如&#xff1a; 自动测试&#xff1a;每当代码被推送到仓库时&#xff0c;自动运行测试…

学生公寓单相费控电表的规格如何选择

石家庄光大远通电气有限公司学生公寓单相费控电表功能支持时间管理控制。L1、L2、L3可分别设置为工作日和节假日模式&#xff0c;每天多可设置8个时间段&#xff0c;每个时间段可分别设置为合闸状态或夜间模式&#xff0c;合闸时间段内电表保持合闸&#xff0c;夜间时间段内&am…

手机玩机常识-----小米系列机型 Android 15 更新计划 那些机型将会更新安卓15

小米机型是很多米粉最喜欢把玩的&#xff0c;其中解锁bl root 刷写twrp以及刷第三方系统资源相对其他品牌机型来说比较丰富。目前安卓15快要更新到很多机型。我们来了解下小米系列机型的更新计划是咋样的 小米会定期更新有关 Redmi红米 设备的支持日期的数据&#xff0c;包括可…

如何使用Spoon连接data-integration-server并在服务器上执行转换

1.建立连接 2.新建转换或任务 3.右键[子服务器]&#xff0c;新建一个服务器连接(data-integration-server服务器的连接信息) 4.右键[Run configurations],新建一个执行连接,勾选相应的选项即可: 5.选择服务器运行即可! 6.最后&#xff0c;你可以通过服务器端的WEB查看执行日志…

Kafka【八】如何保证消息发送的可靠性、重复性、有序性

【1】消息发送的可靠性保证 对于生产者发送的数据&#xff0c;我们有的时候是不关心数据是否已经发送成功的&#xff0c;我们只要发送就可以了。在这种场景中&#xff0c;消息可能会因为某些故障或问题导致丢失&#xff0c;我们将这种情况称之为消息不可靠。虽然消息数据可能会…

zoom缩放导致下拉框定位偏移问题

因为浏览器升级修改了zoom导致 https://developer.chrome.google.cn/release-notes/128?hlzh_tw 可根据zoom值计算相差偏移量 const isChromeHighVersion () > {const ua navigator.userAgent.toLowerCase();const chromeIndex ua.indexOf(chrome);if (chromeIndex >…

跑步戴的耳机哪个品牌的好?精选五款热门品牌骨传导耳机分享

近年来&#xff0c;骨传导耳机逐渐成为了人们喜爱的耳机之一。相比于传统的耳机&#xff0c;骨传导耳机不需要使用耳塞&#xff0c;就可以让用户在运动时更加自由自在&#xff0c;不受耳机带来的束缚感。然而&#xff0c;市面上的骨传导耳机品牌和型号众多&#xff0c;质量参差…

如何把大的txt文件拆分为小的文件?

命令&#xff1a;split 1. 功能&#xff1a;这个是一个Linux 命令&#xff0c;功能是一个大文件分割成多个较小的文件。 可以使用该命令的系统&#xff1a;在Linux 终端&#xff0c;或者是windows git bash 端口。 官方说明&#xff1a;在Linux 终端&#xff0c;或者是…

【生成模型系列(中级)】词向量维度选择的奥秘——从理论到实验的揭秘【通俗理解,代码模拟】

【通俗理解】词向量维度选择的奥秘——从理论到实验的揭秘 关键词提炼 #词向量 #维度选择 #最小熵原理 #Johnson-Lindenstrauss引理 #注意力机制 #图网络 第一节&#xff1a;词向量维度选择的类比与核心概念【尽可能通俗】 1.1 词向量维度选择的类比 词向量维度选择就像为一…

Git 使用指南 --- 版本管理

序言 Git 是一个开源的 分布式版本控制系统&#xff0c;可以有效、高速地处理从很小到非常大的项目版本管理。对一个程序员来说&#xff0c;掌握 Git 的使用是必要的。  在这个系列中&#xff0c;将详细的介绍 Git 的使用和原理&#xff0c;话不多说&#xff0c;让我们开始吧。…

C# 加解密之DES

说完了对称加密中的AES&#xff0c;这一篇再来介绍下DES。加解密原理什么的就不介绍了&#xff0c;大家可以自行百度&#xff08;主要我也不太明白&#xff0c;也不需要太明白&#xff09;&#xff0c;大致说一下两者的区别吧&#xff01; 首先肯定是加密算法的不同&#xff0…