当前位置:网站首页>TorchDrug教程
TorchDrug教程
2022-07-04 16:54:00 【发呆的比目鱼】
TorchDrug
基于张量的图
图表
图是 TorchDrug 中使用的基本数据结构。它们可以被视为张量框架中图形处理库(例如NetworkX)的泛化,同时享受 GPU 加速和自动微分。
import torchdrug as td
from torchdrug import data
edge_list = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]
graph = data.Graph(edge_list, num_node=6)
graph.visualize()
分子
药物发现中图的一个特定实例是一个分子,它可能具有额外的化学约束和特征。例如,我们可以从SMILES字符串构造一个分子。SMILES 是一种使用线性字符串描述复杂分子结构的语言。
mol = data.Molecule.from_smiles("C1=CC=CC=C1")
mol.visualize()
print(mol.node_feature.shape)
print(mol.edge_feature.shape)
图操作
一组任意图也可以批量处理,以最大限度地利用硬件。它们也可以使用 cpu()和cuda()方法在 CPU 和 GPU 之间传输。
smiles_list = ["CCSCCSP(=S)(OC)OC", "CCOC(=O)N",
"N(Nc1ccccc1)c2ccccc2", "NC(=O)c1cccnc1"]
mols = data.PackedMolecule.from_smiles(smiles_list)
mols.visualize()
mols = mols.cuda()
print(mols)
就像原始的 PyTorch 张量一样,图支持广泛的索引操作。典型用法包括应用节点屏蔽、边缘屏蔽或图形屏蔽。以下示例显示如何选择包含至少一个碳的边。更多图操作请看注释。
node_in, node_out, bond_type = mols.edge_list.t()
edge_mask = (mols.atom_type[node_in] == td.CARBON) | \
(mols.atom_type[node_out] == td.CARBON)
mols = mols.edge_mask(edge_mask)
mols.visualize()
边栏推荐
- Interpretation of SIGMOD '22 hiengine paper
- General environmental instructions for the project
- 用于图数据库的开源 PostgreSQL 扩展 AGE被宣布为 Apache 软件基金会顶级项目
- Unity makes revolving door, sliding door, cabinet door drawer, click the effect of automatic door opening and closing, and automatically play the sound effect (with editor extension code)
- 1、 Introduction to C language
- People in the workplace with a miserable expression
- TCP两次挥手,你见过吗?那四次握手呢?
- Pytoch deep learning environment construction
- Make a grenade with 3DMAX
- Machine learning concept drift detection method (Apria)
猜你喜欢
Unity 制作旋转门 推拉门 柜门 抽屉 点击自动开门效果 开关门自动播放音效 (附带编辑器扩展代码)
2022 national CMMI certification subsidy policy | Changxu consulting
力扣刷题日记/day8/7.1
Just today, four experts from HSBC gathered to discuss the problems of bank core system transformation, migration and reconstruction
删除二叉搜索树中的节点附图详解
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
90后开始攒钱植发,又一个IPO来了
"In Vietnam, money is like lying on the street"
力扣刷题日记/day3/2022.6.25
随机推荐
Analysis of I2C adapter driver of s5pv210 chip (i2c-s3c2410. C)
力扣刷题日记/day7/2022.6.29
How to download files using WGet and curl
Achieve animation effect through event binding
庆贺!科蓝SUNDB与中创软件完成七大产品的兼容性适配
股价大跌、市值缩水,奈雪推出虚拟股票,深陷擦边球争议
【每日一题】871. 最低加油次数
项目通用环境使用说明
线上MySQL的自增id用尽怎么办?
表情包坑惨职场人
The block:usdd has strong growth momentum
Li Kou brush question diary /day6/6.28
celebrate! Kelan sundb and Zhongchuang software complete the compatibility adaptation of seven products
2022年全国CMMI认证补贴政策|昌旭咨询
Open source PostgreSQL extension age for graph database was announced as the top-level project of Apache Software Foundation
【209】go语言的学习思想
Grain Mall (I)
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
ITSS运维能力成熟度分级详解|一文搞清ITSS证书
力扣刷题日记/day4/6.26