[{"data":1,"prerenderedAt":413},["ShallowReactive",2],{"content-query-HEescFfkIZ":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":407,"_id":408,"_source":409,"_file":410,"_stem":411,"_extension":412},"/technology-blogs/zh/3212","zh",false,"","谱神经算子Spectral Neural Operator在MindSpore Flow开源","作者：于璠 来源：知乎","2024-06-28","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/a9d48d2d5b8b4cab863857f6db243e3c.png","technology-blogs","大V博文",{"type":15,"children":16,"toc":402},"root",[17,25,44,52,57,62,70,78,92,97,102,116,121,129,134,139,144,158,163,170,175,183,191,196,210,215,222,227,241,246,255,260,267,272,279,284,289,296,301,309,317,322,327,336,341,354,366,378,390],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"谱神经算子spectral-neural-operator在mindspore-flow开源",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29,31,37,39],{"type":24,"value":30},"**作者：**",{"type":18,"tag":32,"props":33,"children":34},"strong",{},[35],{"type":24,"value":36},"于璠",{"type":24,"value":38}," ",{"type":18,"tag":32,"props":40,"children":41},{},[42],{"type":24,"value":43},"来源：知乎",{"type":18,"tag":26,"props":45,"children":46},{},[47],{"type":18,"tag":32,"props":48,"children":49},{},[50],{"type":24,"value":51},"背景",{"type":18,"tag":26,"props":53,"children":54},{},[55],{"type":24,"value":56},"近日，谱神经算子(Spectral Neural Operator，SNO)及其在Burgers 1D/Navier-Stokes 2D/Navier-Stokes 3D问题上的应用案例在MindSpore Flow开源。",{"type":18,"tag":26,"props":58,"children":59},{},[60],{"type":24,"value":61},"谱神经算子(Spectral Neural Operator，SNO)是利用多项式将计算变换到频谱空间(Chebyshev,Legendre等)的类似FNO的架构。与FNO相比，SNO的特点是由混淆误差引起的系统偏差较小。其中最重要的好处之一是SNO的基的选择更为宽泛，因此可以在其中找到一组最方便表示的多项式。例如，针对问题的对称性或针对时间间隔来选取适应的基。此外，当输入定义在在非结构化网格上时，基于正交多项式的神经算子相比其他算子更有竞争力。",{"type":18,"tag":26,"props":63,"children":64},{},[65],{"type":18,"tag":32,"props":66,"children":67},{},[68],{"type":24,"value":69},"01",{"type":18,"tag":26,"props":71,"children":72},{},[73],{"type":18,"tag":32,"props":74,"children":75},{},[76],{"type":24,"value":77},"SNO原理",{"type":18,"tag":26,"props":79,"children":80},{},[81,86,87],{"type":18,"tag":32,"props":82,"children":83},{},[84],{"type":24,"value":85},"1.1",{"type":24,"value":38},{"type":18,"tag":32,"props":88,"children":89},{},[90],{"type":24,"value":91},"神经算子",{"type":18,"tag":26,"props":93,"children":94},{},[95],{"type":24,"value":96},"近年来，随着神经网络的迅猛发展，为科学计算提供了新的范式。经典的神经网络是在有限维度的空间进行映射，只能学习与特定离散化相关的解。与经典神经网络不同，傅里叶神经算子(Fourier Neural Operator，FNO)是一种能够学习无限维函数空间映射的新型深度学习架构。该架构可直接学习从任意函数参数到解的映射，用于解决一类偏微分方程的求解问题，具有更强的泛化能力。",{"type":18,"tag":26,"props":98,"children":99},{},[100],{"type":24,"value":101},"同时FNO也存在一定缺点，例如：变换到傅里叶空间后的线性截断引发混淆误差(aliasing errors)，傅里叶变换涉及到的复数运算较为消耗计算资源等。",{"type":18,"tag":26,"props":103,"children":104},{},[105,110,111],{"type":18,"tag":32,"props":106,"children":107},{},[108],{"type":24,"value":109},"1.2",{"type":24,"value":38},{"type":18,"tag":32,"props":112,"children":113},{},[114],{"type":24,"value":115},"谱神经算子",{"type":18,"tag":26,"props":117,"children":118},{},[119],{"type":24,"value":120},"SNO给出的方案是通过多项式逼近(切比雪夫Chebyshev，勒让德Legendre等)代替傅里叶变换，只需要使用基本的线性变换，而不涉及复杂的傅里叶变换计算，不涉及复数计算。其具体架构如图1所示。",{"type":18,"tag":26,"props":122,"children":123},{},[124],{"type":18,"tag":125,"props":126,"children":128},"img",{"alt":7,"src":127},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/64c7e45b2b6f426286b7306c8a3350f6.png",[],{"type":18,"tag":26,"props":130,"children":131},{},[132],{"type":24,"value":133},"图1. SNO架构",{"type":18,"tag":26,"props":135,"children":136},{},[137],{"type":24,"value":138},"图中以二维物理场时序预测问题为例。首先，为了计算频谱卷积的正向和逆多项式变换矩阵，应在相应的Gauss正交节点（Chebyshev网格等）对输入进行插值。然后，通过卷积编码器将插值后的输入提升到更高维度。编码后的结果用来作为一系列SNO层的输入，每个层对其截断的频谱表示进行线性卷积。接着，SNO层的输出通过卷积解码器投影回目标维度，最后插值回原始节点。",{"type":18,"tag":26,"props":140,"children":141},{},[142],{"type":24,"value":143},"在SNO层将会执行以下操作：首先应用多项式变换A(Chebyshev，Legendre等)，将物理场从物理空间映射到谱空间；而后，L层执行多项式低阶模态上的线性卷积操作和高阶模态上的过滤操作；接下来应用逆变换 S=A^{-1}(从谱空间映射回物理空间)。最后，输出结果与输入层的直接线性卷积W进行加和，并应用非线性激活层完成一个SNO层的计算。",{"type":18,"tag":26,"props":145,"children":146},{},[147,152,153],{"type":18,"tag":32,"props":148,"children":149},{},[150],{"type":24,"value":151},"1.3",{"type":24,"value":38},{"type":18,"tag":32,"props":154,"children":155},{},[156],{"type":24,"value":157},"U-SNO",{"type":18,"tag":26,"props":159,"children":160},{},[161],{"type":24,"value":162},"特别地，在二维应用案例中，在嵌套的SNO层中加入若干层U-SNO层能够取得更好的效果。其中，U-SNO层与SNO的架构相似，区别在于U-SNO层使用UNet2D替代直接线性卷积W。如图2所示。",{"type":18,"tag":26,"props":164,"children":165},{},[166],{"type":18,"tag":125,"props":167,"children":169},{"alt":7,"src":168},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/fb956026e4a8424ba8b4596d1f49f934.png",[],{"type":18,"tag":26,"props":171,"children":172},{},[173],{"type":24,"value":174},"图2. U-SNO架构",{"type":18,"tag":26,"props":176,"children":177},{},[178],{"type":18,"tag":32,"props":179,"children":180},{},[181],{"type":24,"value":182},"02",{"type":18,"tag":26,"props":184,"children":185},{},[186],{"type":18,"tag":32,"props":187,"children":188},{},[189],{"type":24,"value":190},"模型表现",{"type":18,"tag":26,"props":192,"children":193},{},[194],{"type":24,"value":195},"目前，SNO cell已在MindSpore Flow开源。同时，Burgers 1D/Navier-Stokes 2D/Navier-Stokes 3D问题上的应用案例也已经同步开放。",{"type":18,"tag":26,"props":197,"children":198},{},[199,204,205],{"type":18,"tag":32,"props":200,"children":201},{},[202],{"type":24,"value":203},"2.1",{"type":24,"value":38},{"type":18,"tag":32,"props":206,"children":207},{},[208],{"type":24,"value":209},"求解方程",{"type":18,"tag":26,"props":211,"children":212},{},[213],{"type":24,"value":214},"在二维线性方程场景，和包括双曲型、抛物线型和椭圆型在内的三类非线性方程的场景下，SNO相比FNO均表现出超过1.5倍的精度改进，同时，性能损失均在10%以内，如图3所示：",{"type":18,"tag":26,"props":216,"children":217},{},[218],{"type":18,"tag":125,"props":219,"children":221},{"alt":7,"src":220},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/05fec29df8dc4483a977be7de2a350af.png",[],{"type":18,"tag":26,"props":223,"children":224},{},[225],{"type":24,"value":226},"图3. 求解方程效果对比",{"type":18,"tag":26,"props":228,"children":229},{},[230,235,236],{"type":18,"tag":32,"props":231,"children":232},{},[233],{"type":24,"value":234},"2.2",{"type":24,"value":38},{"type":18,"tag":32,"props":237,"children":238},{},[239],{"type":24,"value":240},"应用案例",{"type":18,"tag":26,"props":242,"children":243},{},[244],{"type":24,"value":245},"本次MindSpore Flow开源的三个案例数据集均根据Zongyi Li的文章产生。在Burgers1D案例中，基于周期性边界，生成满足如下分布的初始条件u_0(x)：",{"type":18,"tag":26,"props":247,"children":248},{},[249,253],{"type":18,"tag":125,"props":250,"children":252},{"alt":7,"src":251},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/c6c3a92f921c4f5580afb3f4638e7965.png",[],{"type":24,"value":254}," 选取粘度系数v=0.1，并使用分步法求解方程，其中热方程部分在傅里叶空间中精确求解，然后使用前向欧拉方法求解非线性部分。",{"type":18,"tag":26,"props":256,"children":257},{},[258],{"type":24,"value":259},"在Navier-Stokes2D和3D案例中，基于周期性边界，生成满足如下分布的初始条件w_0(x)：",{"type":18,"tag":26,"props":261,"children":262},{},[263],{"type":18,"tag":125,"props":264,"children":266},{"alt":7,"src":265},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/da3769db72d541bf935ae6962673530d.png",[],{"type":18,"tag":26,"props":268,"children":269},{},[270],{"type":24,"value":271},"外力项设置为：",{"type":18,"tag":26,"props":273,"children":274},{},[275],{"type":18,"tag":125,"props":276,"children":278},{"alt":7,"src":277},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/1eb31f6da91c49bb96dbc4788230776e.png",[],{"type":18,"tag":26,"props":280,"children":281},{},[282],{"type":24,"value":283},"采用Crank-Nicolson方法生成数据，时间步长设置为1e-4，最终数据以每t=1个时间单位记录解。所有数据均在256×256的网格上生成，并被下采样至64×64网格。选取粘度系数v=1e−5。",{"type":18,"tag":26,"props":285,"children":286},{},[287],{"type":24,"value":288},"测试结果统计如图。其中，二维案例下SNO精度稍有提升，性能提升明显；一维和三维案例SNO表现不及FNO。",{"type":18,"tag":26,"props":290,"children":291},{},[292],{"type":18,"tag":125,"props":293,"children":295},{"alt":7,"src":294},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/07/05/534f8a43d661456b886be3765096dd9d.png",[],{"type":18,"tag":26,"props":297,"children":298},{},[299],{"type":24,"value":300},"图4. 应用案例效果对比",{"type":18,"tag":26,"props":302,"children":303},{},[304],{"type":18,"tag":32,"props":305,"children":306},{},[307],{"type":24,"value":308},"03",{"type":18,"tag":26,"props":310,"children":311},{},[312],{"type":18,"tag":32,"props":313,"children":314},{},[315],{"type":24,"value":316},"结论",{"type":18,"tag":26,"props":318,"children":319},{},[320],{"type":24,"value":321},"谱神经算子SNO利用多项式逼近代替了FNO中的傅里叶变换，仅通过基本的线性计算即可完成从物理场到谱空间的映射。其正交基的选择更为宽泛，可以根据实际问题针对性选取。在验证案例中，SNO尤其适用于二维Navier-Stokes方程的物理场预测问题。",{"type":18,"tag":26,"props":323,"children":324},{},[325],{"type":24,"value":326},"SNO cell和相关应用案例已在MindSpore Flow开源，欢迎开发者们使用。",{"type":18,"tag":328,"props":329,"children":331},"h2",{"id":330},"参考文献",[332],{"type":18,"tag":32,"props":333,"children":334},{},[335],{"type":24,"value":330},{"type":18,"tag":26,"props":337,"children":338},{},[339],{"type":24,"value":340},"[1] Fanaskov V S, Oseledets I V. Spectral neural operators[C]//Doklady Mathematics. Moscow: Pleiades Publishing, 2023,",{"type":18,"tag":26,"props":342,"children":343},{},[344,346],{"type":24,"value":345},"108(Suppl 2): S226-S232. ",{"type":18,"tag":347,"props":348,"children":352},"a",{"href":349,"rel":350},"https://arxiv.org/abs/2205.10573",[351],"nofollow",[353],{"type":24,"value":349},{"type":18,"tag":26,"props":355,"children":356},{},[357,359],{"type":24,"value":358},"[2] SNO cell: ",{"type":18,"tag":347,"props":360,"children":363},{"href":361,"rel":362},"https://gitee.com/mindspore/mindscience/blob/master/MindFlow/mindflow/cell/neural%5C_operators/sno.py",[351],[364],{"type":24,"value":365},"https://gitee.com/mindspore/mindscience/blob/master/MindFlow/mindflow/cell/neural\\_operators/sno.py",{"type":18,"tag":26,"props":367,"children":368},{},[369,371],{"type":24,"value":370},"[3] SNO Burgers1D application: ",{"type":18,"tag":347,"props":372,"children":375},{"href":373,"rel":374},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data%5C_driven/burgers/sno1d",[351],[376],{"type":24,"value":377},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data\\_driven/burgers/sno1d",{"type":18,"tag":26,"props":379,"children":380},{},[381,383],{"type":24,"value":382},"[4] SNO Navier-Stokes2D application: ",{"type":18,"tag":347,"props":384,"children":387},{"href":385,"rel":386},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data%5C_driven/navier%5C_stokes/sno2d",[351],[388],{"type":24,"value":389},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data\\_driven/navier\\_stokes/sno2d",{"type":18,"tag":26,"props":391,"children":392},{},[393,395],{"type":24,"value":394},"[5] SNO Navier-Stokes3D application: ",{"type":18,"tag":347,"props":396,"children":399},{"href":397,"rel":398},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data%5C_driven/navier%5C_stokes/sno3d",[351],[400],{"type":24,"value":401},"https://gitee.com/mindspore/mindscience/tree/master/MindFlow/applications/data\\_driven/navier\\_stokes/sno3d",{"title":7,"searchDepth":403,"depth":403,"links":404},4,[405],{"id":330,"depth":406,"text":330},2,"markdown","content:technology-blogs:zh:3212.md","content","technology-blogs/zh/3212.md","technology-blogs/zh/3212","md",1776506127216]