当前位置:网站首页>Torchdrug tutorial
Torchdrug tutorial
2022-07-04 18:53:00 【Stunned flounder (】
TorchDrug
Tensor based graph
Chart
The picture is TorchDrug The basic data structure used in . They can be regarded as graphic processing libraries in the tensor framework ( for example NetworkX) Generalization , At the same time enjoy GPU Acceleration and automatic differentiation .
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()
molecular
A specific example of the graph in drug discovery is a molecule , It may have additional chemical constraints and characteristics . for example , We can SMILES String constructs a molecule .SMILES Is a language that uses linear strings to describe complex molecular structures .
mol = data.Molecule.from_smiles("C1=CC=CC=C1")
mol.visualize()
print(mol.node_feature.shape)
print(mol.edge_feature.shape)
Figure operation
A group of arbitrary graphs can also be processed in batch , To maximize the use of hardware . They can also be used cpu() and cuda() Method in CPU and GPU Transferred between .
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)
It's like the original PyTorch Tensors are the same , Graph supports a wide range of indexing operations . Typical uses include application node masking 、 Edge shielding or graphic shielding . The following example shows how to select an edge that contains at least one carbon . See notes for more graphic operations .
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()
边栏推荐
猜你喜欢
How is the entered query SQL statement executed?
Load test practice of pingcode performance test
Li Kou brush question diary /day7/6.30
I wrote a learning and practice tutorial for beginners!
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
基于C语言的菜鸟驿站管理系统
Scala基础教程--17--集合
Blue bridge: sympodial plant
Principle and application of ThreadLocal
2022 ByteDance daily practice experience (Tiktok)
随机推荐
Li Kou brush question diary /day3/2022.6.25
[HCIA continuous update] WAN technology
Is it safe to open an account online? is that true?
How to open an account is safe,
Lua EmmyLua 注解详解
Li Kou brush question diary /day6/6.28
Stars open stores, return, return, return
Android uses sqliteopenhelper to flash back
Mxnet implementation of googlenet (parallel connection network)
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
Li Kou brush question diary /day8/7.1
Scala基础教程--15--递归
I wrote a learning and practice tutorial for beginners!
【210】PHP 定界符的用法
"In Vietnam, money is like lying on the street"
力扣刷题日记/day7/2022.6.29
Just today, four experts from HSBC gathered to discuss the problems of bank core system transformation, migration and reconstruction
uni-app与uviewUI实现仿小米商城app(附源码)
General environmental instructions for the project
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation