[{"data":1,"prerenderedAt":288},["ShallowReactive",2],{"content-query-adFv8zURyy":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":282,"_id":283,"_source":284,"_file":285,"_stem":286,"_extension":287},"/technology-blogs/zh/2893","zh",false,"","MindSpore AI科学计算系列 | 周期性图Transformer提升MindSpore模型对晶体性质的预测","作者：于璠 来源：知乎","2023-11-28","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2023/12/01/c5e2179857e241e6827cff15c7abcd68.png","technology-blogs",{"type":14,"children":15,"toc":277},"root",[16,24,43,51,56,61,71,76,81,86,91,100,105,110,115,120,130,135,140,147,152,157,162,169,174,179,186,191,201,206,215,220,225,230,235,247,257,267],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"mindspore-ai科学计算系列-周期性图transformer提升mindspore模型对晶体性质的预测",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28,30,36,38],{"type":23,"value":29},"**作者：**",{"type":17,"tag":31,"props":32,"children":33},"strong",{},[34],{"type":23,"value":35},"于璠",{"type":23,"value":37}," ",{"type":17,"tag":31,"props":39,"children":40},{},[41],{"type":23,"value":42},"来源：知乎",{"type":17,"tag":25,"props":44,"children":45},{},[46],{"type":17,"tag":31,"props":47,"children":48},{},[49],{"type":23,"value":50},"背景",{"type":17,"tag":25,"props":52,"children":53},{},[54],{"type":23,"value":55},"晶体材料是一类由3D空间中原子的周期重复形成的大型化合物家族，是许多实际工业应用的基础，如半导体电子学、太阳能电池和化学电池[1]。材料科学通过预测材料性质（例如形成能）和设计具有目标性质的新材料来满足各行各业的巨大需求，但其进展受限于昂贵的实验或耗时的材料模拟。AI方法的成功，使人们尝试在晶体材料上应用这些AI模型。然而与分子不同，晶体材料中的原子排列具有复杂的重复单元和原子的周期排列，开发有效的AI模型需要明确地捕捉这些结构中的对称性。",{"type":17,"tag":25,"props":57,"children":58},{},[59],{"type":23,"value":60},"我们通过晶格矢量L=(L1, L2, L3)，和元胞内原子(Ai, Pi)来表示一种晶体，其中L是3D空间中的晶格重复周期，元胞是晶体的最小重复单元，Ai是其中第i个原子的类型，Pi是其坐标位置。在将晶体结构表示为图结构时，需要具备周期不变性，即学习到的图表示对于最小可重复单元的规模扩大、周期边界变化保持不变。",{"type":17,"tag":25,"props":62,"children":63},{},[64,66],{"type":23,"value":65},"**1、**",{"type":17,"tag":31,"props":67,"children":68},{},[69],{"type":23,"value":70},"CGCNN",{"type":17,"tag":25,"props":72,"children":73},{},[74],{"type":23,"value":75},"较早在晶体图表示中引入周期性的是CGCNN[2]。其构建图的方式如图1所示：",{"type":17,"tag":25,"props":77,"children":78},{},[79],{"type":23,"value":80},"1）图中的节点数等于晶体元胞中的原子个数（元包边界处原子按所属元胞数平分）；",{"type":17,"tag":25,"props":82,"children":83},{},[84],{"type":23,"value":85},"2）周期性重复的原子在图中对应同一个节点；",{"type":17,"tag":25,"props":87,"children":88},{},[89],{"type":23,"value":90},"3）节点间的连接由原子与截断半径内所有原子的连接组成。因为一个原子可以和其周围多个元胞中相同原子相连，而这些原子在晶体图中由同一个节点表示，节点之间可以存在多条不同的边。",{"type":17,"tag":25,"props":92,"children":93},{},[94],{"type":17,"tag":95,"props":96,"children":99},"img",{"alt":97,"src":98},"image.png","https://fileserver.developer.huaweicloud.com/FileServer/getFile/cmtybbs/e64/154/b38/90a1d5d431e64154b387b3660e356ff5.20231201030907.81015815554873140392329861868780:50541130065739:2400:30AA56F7CF4CEF16C99179AD7FCB24D2926CF10CEB89524F3AD98AA2AF722AD6.png",[],{"type":17,"tag":25,"props":101,"children":102},{},[103],{"type":23,"value":104},"图 1. CGCNN构建图表示的方式[2]",{"type":17,"tag":25,"props":106,"children":107},{},[108],{"type":23,"value":109},"这样做的优点是当元胞选取的边界不同时，也能得到同样的晶体图，保证了周期不变性。CGCNN原论文中也存在不足点：",{"type":17,"tag":25,"props":111,"children":112},{},[113],{"type":23,"value":114},"1）没有显式表示周期性信息，微观结构相同，但重复周期不同也可能表示不同晶体；",{"type":17,"tag":25,"props":116,"children":117},{},[118],{"type":23,"value":119},"2）具体实现时对每个原子采用了最近邻n个原子构造连接，当有相同距离的不同原子时，有可能违背周期不变性。",{"type":17,"tag":25,"props":121,"children":122},{},[123,125],{"type":23,"value":124},"**2、**",{"type":17,"tag":31,"props":126,"children":127},{},[128],{"type":23,"value":129},"Matformer",{"type":17,"tag":25,"props":131,"children":132},{},[133],{"type":23,"value":134},"针对这些不足，2022年发表的论文Matformer [3]进行了改进。论文中显式将周期性加入晶体图表示中，并采用attention结构进行图消息传播，在Materials Project、JARVIS等多个数据集上预测晶体属性，得到了不错的结果。",{"type":17,"tag":25,"props":136,"children":137},{},[138],{"type":23,"value":139},"其首先采用和CGCNN类似的方法构建多边图，但将最近邻n的连边方式替换为小于最小距离r则存在边，能够保证周期不变性。图2 a)展示了不使用多边图，当周期边界发生变化时，图表示发生变化的情况。",{"type":17,"tag":25,"props":141,"children":142},{},[143],{"type":17,"tag":95,"props":144,"children":146},{"alt":97,"src":145},"https://fileserver.developer.huaweicloud.com/FileServer/getFile/cmtybbs/e64/154/b38/90a1d5d431e64154b387b3660e356ff5.20231201030927.49648121115066013927629801968514:50541130065739:2400:6ED8931D55D250DB297B1C09A6C6A3AF63FC6B5391DB8ADA4143B441375D2CAF.png",[],{"type":17,"tag":25,"props":148,"children":149},{},[150],{"type":23,"value":151},"图 2. a)改变周期边界时满足和不满足周期不变性的图构建示例，b)显式加入周期表示的图构建[3]",{"type":17,"tag":25,"props":153,"children":154},{},[155],{"type":23,"value":156},"然后将晶格矢量显式地以自连边的方式加入图表示中。具体地，如图2 b)所示，将原子与它在3个晶格方向上的邻近复制进行连接和编码。因为使用角度表示空间信息会带来更多的复杂度，额外使用晶格表面的3个对角线隐式的表示晶格矢量的角度关系。",{"type":17,"tag":25,"props":158,"children":159},{},[160],{"type":23,"value":161},"模型的结构如图3所示。原子序号代表的节点信息和原子间距离代表的边信息经过编码后进入多层Matformer Layer。每层Matformer Layer中基于attention架构，针对每个节点将与之相连的节点及边的信息进行汇聚，并以此对该节点进行更新。对于多边图，每条边对应到一个attention head，图中h表示边序号。在生成attention中的K和V时，将边的特征和节点特征进行了拼接。并且在Q和K点乘后，用sigmoid替代了常用的softmax来计算权重，这样可以考虑到节点不同度（连接数）的影响，并且减少了相邻节点间消息的汇聚及广播，提升了计算效率。消融实验也表明sigmoid能得到更好的测试精度。",{"type":17,"tag":25,"props":163,"children":164},{},[165],{"type":17,"tag":95,"props":166,"children":168},{"alt":97,"src":167},"https://fileserver.developer.huaweicloud.com/FileServer/getFile/cmtybbs/e64/154/b38/90a1d5d431e64154b387b3660e356ff5.20231201030943.76950497685699128599652019698633:50541130065739:2400:0B991CCD43BF3BE49CC699465A7B1ABC75A4D749D6AB8641D20F644764E1CEB7.png",[],{"type":17,"tag":25,"props":170,"children":171},{},[172],{"type":23,"value":173},"图 3. a)Matformer的整体网络架构，b)Matformer Layer的网络结构，c)Sigmoid替换为Softmax的消融实验[3]",{"type":17,"tag":25,"props":175,"children":176},{},[177],{"type":23,"value":178},"模型在Materials Project、JARVIS数据集上，对多种属性预测的表现均达到领先。这得益于其显式周期性的引入，以及针对多边图的attention结构的设计。在计算效率上，Matformer比精度次优的ALIGNN也高出很多。预测精度和计算效率对比如图4所示。",{"type":17,"tag":25,"props":180,"children":181},{},[182],{"type":17,"tag":95,"props":183,"children":185},{"alt":97,"src":184},"https://fileserver.developer.huaweicloud.com/FileServer/getFile/cmtybbs/e64/154/b38/90a1d5d431e64154b387b3660e356ff5.20231201031001.39081441042360351555471772445970:50541130065739:2400:86DEC8B82CECD01D2CAB26B5513EB3446C31B86E1043C75012AB6EE378397D76.png",[],{"type":17,"tag":25,"props":187,"children":188},{},[189],{"type":23,"value":190},"图4. Matformer与ALIGNN预测精度和计算效率对比",{"type":17,"tag":25,"props":192,"children":193},{},[194,196],{"type":23,"value":195},"**3、**",{"type":17,"tag":31,"props":197,"children":198},{},[199],{"type":23,"value":200},"感想",{"type":17,"tag":25,"props":202,"children":203},{},[204],{"type":23,"value":205},"通过本文的分析可以看出，加入先验物理知识，例如周期不变性及周期重复特征，对提升模型对材料性质的预测能起到很大的帮助。同时，针对晶体多边图的attention结构的设计在较好地捕捉晶体结构特征的同时，也兼顾了计算效率的优化。当前昇思MindSpore AI框架结合自身优势，基于已有能力开展周期性图Transformer相关工作，从而提升晶体性质预测和计算效率，预计不久将与大家见面。",{"type":17,"tag":207,"props":208,"children":210},"h2",{"id":209},"参考文献",[211],{"type":17,"tag":31,"props":212,"children":213},{},[214],{"type":23,"value":209},{"type":17,"tag":25,"props":216,"children":217},{},[218],{"type":23,"value":219},"[1]Keith T Butler, Daniel W Davies, Hugh Cartwright, Olexandr Isayev, and Aron Walsh. 2018. Machine learning for molecular and materials science. Nature 559, 7715 (2018), 547–555.",{"type":17,"tag":25,"props":221,"children":222},{},[223],{"type":23,"value":224},"[2]Tian Xie and Jeffrey C Grossman. 2018. Crystal graph convolutional neural networks for an accurate and interpretable prediction of material properties. Physical Review Letters 120, 14 (2018), 145301.",{"type":17,"tag":25,"props":226,"children":227},{},[228],{"type":23,"value":229},"[3]Keqiang Yan, Yi Liu, Yuchao Lin, and Shuiwang Ji. 2022. Periodic Graph Transformers for Crystal Material Property Prediction. In The 36th Annual Conference on Neural Information Processing Systems. 15066–15080.",{"type":17,"tag":25,"props":231,"children":232},{},[233],{"type":23,"value":234},"往期回顾",{"type":17,"tag":25,"props":236,"children":237},{},[238],{"type":17,"tag":239,"props":240,"children":244},"a",{"href":241,"rel":242},"http://mp.weixin.qq.com/s?__biz=MzkxMTM2MjMzNg==&mid=2247611648&idx=1&sn=e911c86334147c2a3166b88d33b4d953&chksm=c11e254ff669ac596ce34dac6cb14ef9e0ab951ef0ef5bba8a354510e158dbc63264b58b5149&scene=21#wechat_redirect",[243],"nofollow",[245],{"type":23,"value":246},"MindSpore AI科学计算系列 | 初探海洋大模型AI-GOMS，打开大模型在海洋方面的大门",{"type":17,"tag":25,"props":248,"children":249},{},[250],{"type":17,"tag":239,"props":251,"children":254},{"href":252,"rel":253},"http://mp.weixin.qq.com/s?__biz=MzkxMTM2MjMzNg==&mid=2247611392&idx=1&sn=389807811fd28aef1d4d28477386bf70&chksm=c11e244ff669ad59788563652e2ceb065fcbd47d5bf171be264da2f4c17615e743fa268c487e&scene=21#wechat_redirect",[243],[255],{"type":23,"value":256},"MindSpore AI科学计算系列 | “没有最快，只有更快”，快速傅里叶变换详解",{"type":17,"tag":25,"props":258,"children":259},{},[260],{"type":17,"tag":239,"props":261,"children":264},{"href":262,"rel":263},"http://mp.weixin.qq.com/s?__biz=MzkxMTM2MjMzNg==&mid=2247610343&idx=1&sn=439ab653c8b9a1c43522cb1ff4edb324&chksm=c11e3fa8f669b6beebd68b7298d7c3d48abd229a4fb0b7b6fd628539c5d1e81cbb08578ad1d4&scene=21#wechat_redirect",[243],[265],{"type":23,"value":266},"MindSpore AI科学计算系列 | 有效改善预报模糊问题，生成式模型在短临降水预报中大放异彩",{"type":17,"tag":25,"props":268,"children":269},{},[270],{"type":17,"tag":239,"props":271,"children":274},{"href":272,"rel":273},"http://mp.weixin.qq.com/s?__biz=MzkxMTM2MjMzNg==&mid=2247610058&idx=1&sn=7358eefefaf4e48be10e16b2b24a3170&chksm=c11e3e85f669b793d55eea2a57f2caa44aad8fc88d2c8ba0ef2e1f277d2f8f60f6a9c1d58562&scene=21#wechat_redirect",[243],[275],{"type":23,"value":276},"MindSpore AI科学计算系列 | 基于深度学习模型来替代传统DFT模型以及DeephE3模型的分析综述",{"title":7,"searchDepth":278,"depth":278,"links":279},4,[280],{"id":209,"depth":281,"text":209},2,"markdown","content:technology-blogs:zh:2893.md","content","technology-blogs/zh/2893.md","technology-blogs/zh/2893","md",1776506123860]