当前位置:网站首页>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()

边栏推荐
- Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
- 估值900亿,超级芯片IPO来了
- 蓝桥:合根植物
- [cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
- Russia arena data releases PostgreSQL based products
- How to open an account is safe,
- 线上MySQL的自增id用尽怎么办?
- 激进技术派 vs 项目保守派的微服务架构之争
- Implementation of shell script replacement function
- Stars open stores, return, return, return
猜你喜欢

The block:usdd has strong growth momentum

爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用

How to improve development quality

Grain Mall (I)

MySQL common add, delete, modify and query operations (crud)

Journal des problèmes de brosse à boutons de force / day6 / 6.28

力扣刷题日记/day6/6.28
![[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors](/img/7a/16b481753d7d57f50dc8787eec8a1a.png)
[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors

NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读

股价大跌、市值缩水,奈雪推出虚拟股票,深陷擦边球争议
随机推荐
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
Make a grenade with 3DMAX
How is the entered query SQL statement executed?
TCP waves twice, have you seen it? What about four handshakes?
Wireshark抓包TLS协议栏显示版本不一致问题
LD_ LIBRARY_ Path environment variable setting
要上市的威马,依然给不了百度信心
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
MySQL常用增删改查操作(CRUD)
[HCIA continuous update] network management and operation and maintenance
输入的查询SQL语句,是如何执行的?
股价大跌、市值缩水,奈雪推出虚拟股票,深陷擦边球争议
力扣刷题日记/day2/2022.6.24
Summary of subsidy policies across the country for dcmm certification in 2022
Machine learning concept drift detection method (Apria)
Imitation of numpy 2
2022 national CMMI certification subsidy policy | Changxu consulting
Russia arena data releases PostgreSQL based products
能源行业的数字化“新”运维
fopen、fread、fwrite、fseek 的文件处理示例