当前位置:网站首页>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()
边栏推荐
- Self reflection of a small VC after two years of entrepreneurship
- ITSS运维能力成熟度分级详解|一文搞清ITSS证书
- I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
- Large scale service exception log retrieval
- 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)
- 输入的查询SQL语句,是如何执行的?
- Reptile elementary learning
- Grain Mall (I)
- 【云端心声 建议征集】云商店焕新升级:提有效建议,赢海量码豆、华为AI音箱2!
- DB engines database ranking in July 2022: Microsoft SQL Server rose sharply, Oracle fell sharply
猜你喜欢
Digital "new" operation and maintenance of energy industry
Neglected problem: test environment configuration management
DB engines database ranking in July 2022: Microsoft SQL Server rose sharply, Oracle fell sharply
TCP waves twice, have you seen it? What about four handshakes?
Li Kou brush question diary /day8/7.1
12 - explore the underlying principles of IOS | runtime [isa details, class structure, method cache | t]
Halcon template matching
上市公司改名,科学还是玄学?
被忽视的问题:测试环境配置管理
明星开店,退,退,退
随机推荐
怎么开户才是安全的,
How to download files using WGet and curl
表情包坑惨职场人
Microservice architecture debate between radical technologists vs Project conservatives
Li Kou brush question diary /day7/2022.6.29
Summary of subsidy policies across the country for dcmm certification in 2022
【Hot100】32. Longest valid bracket
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)
Is it safe to open an account online? is that true?
比李嘉诚还有钱的币圈大佬,刚在沙特买了楼
Performance test of Gatling
大厂面试总结大全二
如何提高开发质量
The block:usdd has strong growth momentum
Clever use of curl command
【Go语言刷题篇】Go完结篇|函数、结构体、接口、错误入门学习
Android uses sqliteopenhelper to flash back
Interview summary of large factory Daquan II
Make a grenade with 3DMAX
[210] usage of PHP delimiter