当前位置:网站首页>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()
边栏推荐
- 爬虫初级学习
- Introduction of time related knowledge in kernel
- [cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
- Make a grenade with 3DMAX
- 力扣刷题日记/day3/2022.6.25
- 力扣刷题日记/day7/6.30
- 网上开户安全吗?是真的吗?
- 被忽视的问题:测试环境配置管理
- The block:usdd has strong growth momentum
- Device interface analysis of the adapter of I2C subsystem (I2C dev.c file analysis)
猜你喜欢
Open source PostgreSQL extension age for graph database was announced as the top-level project of Apache Software Foundation
谷粒商城(一)
"In Vietnam, money is like lying on the street"
力扣刷题日记/day1/2022.6.23
vbs或vbe如何修改图标
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
With the stock price plummeting and the market value shrinking, Naixue launched a virtual stock, which was deeply in dispute
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
基于NCF的多模块协同实例
力扣刷题日记/day7/2022.6.29
随机推荐
网上开户安全吗?是真的吗?
[210] usage of PHP delimiter
力扣刷题日记/day7/6.30
Introduction of time related knowledge in kernel
2022年DCMM认证全国各地补贴政策汇总
力扣刷题日记/day2/2022.6.24
[HCIA continuous update] network management and operation and maintenance
SIGMOD’22 HiEngine论文解读
输入的查询SQL语句,是如何执行的?
How to download files using WGet and curl
Flask lightweight web framework
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
DB engines database ranking in July 2022: Microsoft SQL Server rose sharply, Oracle fell sharply
力扣刷题日记/day5/2022.6.27
78岁华科教授冲击IPO,丰年资本有望斩获数十倍回报
Li Kou brush question diary /day8/7.1
蓝桥:合根植物
Android uses sqliteopenhelper to flash back
Redis master-slave replication
LD_ LIBRARY_ Path environment variable setting