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

边栏推荐
- 线上MySQL的自增id用尽怎么办?
- MySQL common add, delete, modify and query operations (crud)
- 谷粒商城(一)
- 90后开始攒钱植发,又一个IPO来了
- uni-app与uviewUI实现仿小米商城app(附源码)
- 用于图数据库的开源 PostgreSQL 扩展 AGE被宣布为 Apache 软件基金会顶级项目
- mysql5.7安装教程图文详解
- File processing examples of fopen, FREAD, fwrite, fseek
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- Redis主从复制
猜你喜欢

Just today, four experts from HSBC gathered to discuss the problems of bank core system transformation, migration and reconstruction

How to test MDM products

能源行业的数字化“新”运维

Weima, which is going to be listed, still can't give Baidu confidence

Open source PostgreSQL extension age for graph database was announced as the top-level project of Apache Software Foundation

Imitation of numpy 2

提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像

Machine learning concept drift detection method (Apria)

With the stock price plummeting and the market value shrinking, Naixue launched a virtual stock, which was deeply in dispute

Load test practice of pingcode performance test
随机推荐
Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
Mysql5.7 installation tutorial graphic explanation
Is it safe to open an account online? is that true?
Clever use of curl command
With an estimated value of 90billion, the IPO of super chip is coming
[cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
谷粒商城(一)
【210】PHP 定界符的用法
Halcon template matching
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
【Go语言刷题篇】Go完结篇|函数、结构体、接口、错误入门学习
力扣刷题日记/day7/6.30
[daily question] 871 Minimum refueling times
The top half and bottom half of the interrupt are introduced and the implementation method (tasklet and work queue)
Tutorial on the use of Huawei cloud modelarts (with detailed illustrations)
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
力扣刷題日記/day6/6.28
怎么开户才是安全的,